index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '团队审核', leftArrow: true, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. // 选项卡
  13. tabs: {
  14. active: 'a',
  15. list: [
  16. { title: '系统团队', name: 'a' },
  17. { title: '解散团队', name: 'b' },
  18. { title: '参赛团队', name: 'c' },
  19. ],
  20. },
  21. // 全部团队
  22. aList: [],
  23. // 解散团队
  24. bList: [],
  25. // 弹框
  26. dialog: { title: '信息审核', show: false, type: '1' },
  27. form: {},
  28. statusList: [{ label: '待审核', value: '0' }, { label: '审核通过', value: '1' }, { label: '审核拒绝', value: '-1' }]
  29. },
  30. initValidate() {
  31. const rules = { status: { required: true } }
  32. // 验证字段的提示信息,若不传则调用默认的信息
  33. const messages = { status: { required: '请选择状态', } };
  34. this.WxValidate = new WxValidate(rules, messages)
  35. },
  36. back: function () {
  37. wx.navigateBack({ url: '/pages/administration/index' })
  38. },
  39. // 选项卡
  40. tabsChange: function (e) {
  41. const that = this;
  42. that.setData({ 'tabs.active': e.detail.name })
  43. },
  44. // 系统团队查看详情
  45. toView: function (e) {
  46. let { id } = e.currentTarget.dataset;
  47. wx.navigateTo({ url: `/pages/teamInfo/info?id=${id}` })
  48. },
  49. // 系统团队信息审核
  50. toCheck: async function (e) {
  51. const that = this;
  52. let { id, type } = e.currentTarget.dataset;
  53. let arr;
  54. if (type == 'a') arr = await app.$get(`/courtAdmin/api/team/${id}`);
  55. else if (type == 'b') arr = await app.$get(`/courtAdmin/api/dismissapply/${id}`);
  56. if (arr.errcode == '0') {
  57. let data = { tabs_type: type, ...arr.data };
  58. that.setData({ form: data })
  59. that.setData({ dialog: { title: '信息审核', show: true, type: '1' } })
  60. }
  61. },
  62. // 选择状态
  63. statusChange: function (e) {
  64. const that = this;
  65. const { value } = e.detail;
  66. that.setData({ 'form.status': value })
  67. },
  68. // 提交审核
  69. aSubmit: async function (e) {
  70. const that = this;
  71. const data = that.data.form;
  72. const params = e.detail.value;
  73. if (!this.WxValidate.checkForm(params)) {
  74. const error = this.WxValidate.errorList[0];
  75. wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
  76. return false
  77. } else {
  78. let arr;
  79. if (data.tabs_type == 'a') arr = await app.$post(`/courtAdmin/api/team/${data.id}`, params);
  80. else if (data.tabs_type == 'b') {
  81. arr = await app.$post(`/courtAdmin/api/dismissapply/${data.id}`, params);
  82. if (arr.errcode == '0' && data.status == '1') arr = await app.$delete(`/courtAdmin/api/team/${data.team_id}`);
  83. }
  84. if (arr.errcode == '0') { wx.showToast({ title: `审核信息成功`, icon: 'error', duration: 2000 }); that.toClose(); }
  85. else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
  86. }
  87. },
  88. // 关闭弹框
  89. toClose: function () {
  90. const that = this;
  91. that.setData({ dialog: { title: '信息审核', show: false, type: '1' } })
  92. that.watchLogin();
  93. },
  94. /**
  95. * 生命周期函数--监听页面加载
  96. */
  97. onLoad: function (options) {
  98. //验证规则函数
  99. this.initValidate();
  100. // 计算高度
  101. this.searchHeight();
  102. // 监听用户是否登录
  103. this.watchLogin();
  104. },
  105. // 监听用户是否登录
  106. watchLogin: function () {
  107. const that = this;
  108. wx.getStorage({
  109. key: 'token',
  110. success: async res => {
  111. let arr;
  112. // 系统团队
  113. arr = await app.$get(`/courtAdmin/api/team`);
  114. if (arr.errcode == '0') that.setData({ aList: arr.data });
  115. // 解散团队
  116. arr = await app.$get(`/courtAdmin/api/dismissapply`);
  117. if (arr.errcode == '0') that.setData({ bList: arr.data });
  118. },
  119. fail: res => {
  120. wx.redirectTo({ url: '/pages/index/index', })
  121. }
  122. })
  123. },
  124. // 计算高度
  125. searchHeight: function () {
  126. let frameStyle = this.data.frameStyle;
  127. let client = app.globalData.client;
  128. let infoHeight = client.windowHeight;
  129. // 是否去掉状态栏
  130. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  131. // 是否减去底部菜单
  132. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  133. if (infoHeight) this.setData({ infoHeight: infoHeight })
  134. },
  135. /**
  136. * 生命周期函数--监听页面初次渲染完成
  137. */
  138. onReady: function () {
  139. },
  140. /**
  141. * 生命周期函数--监听页面显示
  142. */
  143. onShow: function () {
  144. },
  145. /**
  146. * 生命周期函数--监听页面隐藏
  147. */
  148. onHide: function () {
  149. },
  150. /**
  151. * 生命周期函数--监听页面卸载
  152. */
  153. onUnload: function () {
  154. },
  155. /**
  156. * 页面相关事件处理函数--监听用户下拉动作
  157. */
  158. onPullDownRefresh: function () {
  159. },
  160. /**
  161. * 页面上拉触底事件的处理函数
  162. */
  163. onReachBottom: function () {
  164. },
  165. /**
  166. * 用户点击右上角分享
  167. */
  168. onShareAppMessage: function () {
  169. }
  170. })