shteam.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. const app = getApp()
  2. import { examine_status } from '../../utils/dict';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. frameStyle: { useTop: true, name: '组队信息审核', leftArrow: true, useBar: false },
  9. //查询条件
  10. searchInfo: {},
  11. list: [],
  12. dialog: { title: '详细信息', show: false, type: '1' },
  13. info: {},
  14. statusList: examine_status
  15. },
  16. // 跳转菜单
  17. back(e) {
  18. wx.navigateBack({ delta: 1 })
  19. },
  20. search: function (e) {
  21. const that = this;
  22. that.setData({ 'searchInfo.teammate_name': e.detail.value });
  23. that.watchLogin()
  24. },
  25. // 查看
  26. toView: async function (e) {
  27. const that = this;
  28. const { item } = e.currentTarget.dataset;
  29. const arr = await app.$get(`/newCourt/api/teamApply/${item._id}`);
  30. if (arr.errcode == '0') {
  31. // 赛事信息
  32. const match = await app.$get(`/newCourt/api/match/${item.match_id}`);
  33. if (match.errcode == '0') {
  34. arr.data.match_name = match.data.name;
  35. // 赛事组别
  36. const group = match.data.grouping.find((i) => i._id == item.grouping_id);
  37. if (group) { arr.data.grouping_name = group.name }
  38. };
  39. // 组内项目
  40. const project = await app.$get(`/newCourt/api/matchProject/${item.project_id}`)
  41. if (project.errcode == '0') { arr.data.project_name = project.data.name; }
  42. that.setData({ info: arr.data })
  43. that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
  44. }
  45. },
  46. // 审核
  47. toCheck: async function (e) {
  48. const that = this;
  49. let { item } = e.currentTarget.dataset;
  50. const arr = await app.$get(`/newCourt/api/teamApply/${item._id}`);
  51. if (arr.errcode == '0') {
  52. that.setData({ info: arr.data })
  53. that.setData({ dialog: { title: '信息审核', show: true, type: '2' } })
  54. }
  55. },
  56. // 选择状态
  57. statusChange: function (e) {
  58. const that = this;
  59. let data = that.data.statusList[e.detail.value];
  60. if (data) { that.setData({ 'info.status': data.value }) }
  61. },
  62. onSubmit: async function (e) {
  63. const that = this;
  64. const params = e.detail.value;
  65. const info = that.data.info;
  66. const arr = await app.$post(`/newCourt/api/teamApply/${info._id}`, params);
  67. if (arr.errcode == '0') {
  68. wx.showToast({ title: `审核信息成功`, icon: 'success', duration: 2000 });
  69. that.watchLogin();
  70. that.toClose()
  71. } else {
  72. wx.showToast({ title: `${arr.errmsg}`, icon: 'fail', duration: 2000 });
  73. }
  74. },
  75. // 关闭弹框
  76. toClose: function () {
  77. const that = this;
  78. that.setData({ dialog: { title: '详细信息', show: false, type: '1' } })
  79. },
  80. /**
  81. * 生命周期函数--监听页面加载
  82. */
  83. onLoad: function (options) {
  84. const that = this;
  85. that.watchLogin();
  86. },
  87. // 监听用户是否登录
  88. watchLogin: async function () {
  89. const that = this;
  90. let searchInfo = that.data.searchInfo;
  91. wx.getStorage({
  92. key: 'user',
  93. success: async res => {
  94. let info = { skip: 0, limit: 1000 };
  95. if (searchInfo.teammate_name) info.teammate_name = searchInfo.teammate_name;
  96. const match = await app.$get(`/newCourt/api/match`, { ...info });
  97. if (match.errcode == '0') {
  98. const arr = await app.$get(`/newCourt/api/teamApply`, { ...info });
  99. if (arr.errcode == '0') {
  100. let test1 = []
  101. for (const val of arr.data) {
  102. let matchInfo = match.data.find((i) => i._id == val.match_id)
  103. if (matchInfo) val.match_name = matchInfo.name;
  104. }
  105. for (const val of test1) {
  106. console.log(val);
  107. }
  108. that.setData({ list: arr.data })
  109. } else {
  110. wx.showToast({ title: `${arr.errmsg}`, icon: 'fail', duration: 2000 });
  111. }
  112. }
  113. },
  114. fail: res => {
  115. wx.redirectTo({ url: '/pages/index/index', })
  116. }
  117. })
  118. },
  119. /**
  120. * 生命周期函数--监听页面初次渲染完成
  121. */
  122. onReady: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面显示
  126. */
  127. onShow: function () {
  128. },
  129. /**
  130. * 生命周期函数--监听页面隐藏
  131. */
  132. onHide: function () {
  133. },
  134. /**
  135. * 生命周期函数--监听页面卸载
  136. */
  137. onUnload: function () {
  138. },
  139. /**
  140. * 页面相关事件处理函数--监听用户下拉动作
  141. */
  142. onPullDownRefresh: function () {
  143. },
  144. /**
  145. * 页面上拉触底事件的处理函数
  146. */
  147. onReachBottom: function () {
  148. },
  149. /**
  150. * 用户点击右上角分享
  151. */
  152. onShareAppMessage: function () {
  153. }
  154. })