shteam.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 = {};
  89. const arr = await app.$get(`/newCourt/api/teamApply`, { ...info });
  90. if (arr.errcode == '0') {
  91. for (const val of arr.data) {
  92. const match = await app.$get(`/newCourt/api/match/${val.match_id}`);
  93. if (match.errcode == '0') { val.match_name = match.data.name }
  94. }
  95. that.setData({ list: arr.data })
  96. } else {
  97. wx.showToast({ title: `${arr.errmsg}`, icon: 'fail', duration: 2000 });
  98. }
  99. },
  100. fail: res => {
  101. wx.redirectTo({ url: '/pages/index/index', })
  102. }
  103. })
  104. },
  105. /**
  106. * 生命周期函数--监听页面初次渲染完成
  107. */
  108. onReady: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面显示
  112. */
  113. onShow: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面隐藏
  117. */
  118. onHide: function () {
  119. },
  120. /**
  121. * 生命周期函数--监听页面卸载
  122. */
  123. onUnload: function () {
  124. },
  125. /**
  126. * 页面相关事件处理函数--监听用户下拉动作
  127. */
  128. onPullDownRefresh: function () {
  129. },
  130. /**
  131. * 页面上拉触底事件的处理函数
  132. */
  133. onReachBottom: function () {
  134. },
  135. /**
  136. * 用户点击右上角分享
  137. */
  138. onShareAppMessage: function () {
  139. }
  140. })