index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. const app = getApp()
  2. import { examine_status } from '../../utils/dict';
  3. import WxValidate from '../../utils/wxValidate';
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '我的报名', leftArrow: true, useBar: false },
  10. searchInfo: {},
  11. list: [],
  12. dialog: { title: '详细信息', show: false, type: '1' },
  13. info: {},
  14. },
  15. // 跳转菜单
  16. back(e) {
  17. wx.navigateBack({ delta: 1 })
  18. },
  19. // 查询
  20. search: function (e) { console.log('查询'); },
  21. // 查看
  22. toView: async function (e) {
  23. const that = this;
  24. const { item } = e.currentTarget.dataset;
  25. const arr = await app.$get(`/newCourt/api/enroll/${item._id}`);
  26. if (arr.errcode == '0') {
  27. // 用户信息
  28. const user = await app.$get(`/newCourt/api/user/${arr.data.openid}`);
  29. if (user.errcode = '0') { arr.data.user_name = user.data.name };
  30. // 赛事信息
  31. const match = await app.$get(`/newCourt/api/match/${arr.data.match_id}`);
  32. if (match.errcode = '0') { arr.data.match_name = match.data.name };
  33. // 赛事组别
  34. let group = match.data.grouping.find((i) => i._id == arr.data.grouping_id);
  35. if (group) { arr.data.grouping_name = group.name; arr.data.project_type = group.type }
  36. // 赛事项目
  37. const project = await app.$get(`/newCourt/api/matchProject/${arr.data.project_id}`)
  38. if (project.errcode = '0') { arr.data.project_name = project.data.name };
  39. that.setData({ info: arr.data })
  40. that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
  41. }
  42. },
  43. // 组队申请
  44. toTeam: function (e) {
  45. const { item } = e.currentTarget.dataset;
  46. wx.navigateTo({ url: `/pages/usermyteam/add?id=${item._id}` })
  47. },
  48. // 关闭弹框
  49. toClose: function () {
  50. const that = this;
  51. that.setData({ dialog: { title: '详细信息', show: false, type: '1' } })
  52. },
  53. /**
  54. * 生命周期函数--监听页面加载
  55. */
  56. onLoad: function (options) {
  57. const that = this;
  58. that.watchLogin();
  59. },
  60. // 监听用户是否登录
  61. watchLogin: async function () {
  62. const that = this;
  63. wx.getStorage({
  64. key: 'user',
  65. success: async res => {
  66. const arr = await app.$get(`/newCourt/api/enroll/`, { openid: res.data.openid });
  67. if (arr.errcode == '0') {
  68. for (const val of arr.data) {
  69. // 赛事信息
  70. const match = await app.$get(`/newCourt/api/match/${val.match_id}`);
  71. if (match.errcode = '0') { val.match_name = match.data.name };
  72. }
  73. that.setData({ list: arr.data })
  74. }
  75. },
  76. fail: res => {
  77. wx.redirectTo({ url: '/pages/index/index', })
  78. }
  79. })
  80. },
  81. /**
  82. * 生命周期函数--监听页面初次渲染完成
  83. */
  84. onReady: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面显示
  88. */
  89. onShow: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面隐藏
  93. */
  94. onHide: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面卸载
  98. */
  99. onUnload: function () {
  100. },
  101. /**
  102. * 页面相关事件处理函数--监听用户下拉动作
  103. */
  104. onPullDownRefresh: function () {
  105. },
  106. /**
  107. * 页面上拉触底事件的处理函数
  108. */
  109. onReachBottom: function () {
  110. },
  111. /**
  112. * 用户点击右上角分享
  113. */
  114. onShareAppMessage: function () {
  115. }
  116. })