index.js 5.6 KB

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