index.js 6.4 KB

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