index.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. const moment = require("../../utils/moment.min")
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. frameStyle: { useTop: true, name: '解散申请', leftArrow: true, useBar: false },
  11. ids: '',
  12. apply_time: '',
  13. // 主体高度
  14. infoHeight: '',
  15. form: {},
  16. },
  17. back: function () {
  18. wx.navigateBack({ url: '/pages/me/index' })
  19. },
  20. //提交
  21. formSubmit: function (e) {
  22. const params = e.detail.value;
  23. var apply_time = this.data.apply_time;
  24. var form = {
  25. "team_id": params.team_id,
  26. "team_name": params.team_name,
  27. "create_user": params.create_user,
  28. "create_id": params.create_id,
  29. "apply_time": apply_time,
  30. "resaon": params.resaon
  31. }
  32. if (!this.WxValidate.checkForm(params)) {
  33. const error = this.WxValidate.errorList[0];
  34. wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
  35. return false
  36. } else {
  37. wx.request({
  38. url: `${app.globalData.publicUrl}/courtAdmin/api/dismissapply`,
  39. method: 'post',
  40. data: form,
  41. success(res) {
  42. if (res.data.errcode == 0) {
  43. wx.showToast({ title: `解散审核提交成功`, icon: 'success', duration: 2000 })
  44. wx.navigateTo({ url: '/pages/me/index' })
  45. } else {
  46. wx.showToast({
  47. title: res.data.errmsg,
  48. icon: 'none',
  49. duration: 2000
  50. })
  51. }
  52. }
  53. })
  54. }
  55. },
  56. /**
  57. * 生命周期函数--监听页面加载
  58. */
  59. onLoad: function (options) {
  60. this.setData({ids: options.id,});
  61. //获取当前时间
  62. let apply_time = moment().format('YYYY-MM-DD HH:mm:ss');
  63. this.setData({apply_time: apply_time,});
  64. // 计算高度
  65. this.searchHeight();
  66. // 监听用户是否登录
  67. this.watchLogin();
  68. //验证规则函数
  69. this.initValidate()
  70. },
  71. initValidate() {
  72. const rules = { team_id: { required: true }, team_name: { required: true, }, create_user: { required: true }, create_id: { required: true, }, resaon: { required: true, } }
  73. // 验证字段的提示信息,若不传则调用默认的信息
  74. const messages = { team_id: { required: '请输入团队id', }, team_name: { required: '请输入团队名称', }, create_user: { required: '请输入团队创建人', }, create_id: { required: '请输入团队创建人id', }, resaon: { required: '请输入解散团队原因', } };
  75. this.WxValidate = new WxValidate(rules, messages)
  76. },
  77. // 监听用户是否登录
  78. watchLogin: function () {
  79. wx.getStorage({
  80. key: 'token',
  81. success: res => {
  82. var that = this;
  83. wx.request({
  84. url: `${app.globalData.publicUrl}/courtAdmin/api/team/` + that.data.ids,
  85. method: 'get',
  86. data: '',
  87. success(res) {
  88. if (res.data.errcode == 0) {
  89. let datas = res.data.data
  90. that.setData({ form: datas,});
  91. } else {
  92. wx.showToast({
  93. title: res.data.errmsg,
  94. icon: 'none',
  95. duration: 2000
  96. })
  97. }
  98. }
  99. })
  100. },
  101. fail: res => {
  102. return wx.redirectTo({ url: '/pages/login/index', })
  103. }
  104. })
  105. },
  106. // 计算高度
  107. searchHeight: function () {
  108. let frameStyle = this.data.frameStyle;
  109. let client = app.globalData.client;
  110. let infoHeight = client.windowHeight;
  111. // 是否去掉状态栏
  112. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  113. // 是否减去底部菜单
  114. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  115. if (infoHeight) this.setData({ infoHeight: infoHeight })
  116. },
  117. /**
  118. * 生命周期函数--监听页面初次渲染完成
  119. */
  120. onReady: function () {
  121. },
  122. /**
  123. * 生命周期函数--监听页面显示
  124. */
  125. onShow: function () {
  126. },
  127. /**
  128. * 生命周期函数--监听页面隐藏
  129. */
  130. onHide: function () {
  131. },
  132. /**
  133. * 生命周期函数--监听页面卸载
  134. */
  135. onUnload: function () {
  136. },
  137. /**
  138. * 页面相关事件处理函数--监听用户下拉动作
  139. */
  140. onPullDownRefresh: function () {
  141. },
  142. /**
  143. * 页面上拉触底事件的处理函数
  144. */
  145. onReachBottom: function () {
  146. },
  147. /**
  148. * 用户点击右上角分享
  149. */
  150. onShareAppMessage: function () {
  151. }
  152. })