shteam.js 4.8 KB

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