index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. toClose: function () {
  45. const that = this;
  46. that.setData({ dialog: { title: '详细信息', show: false, type: '1' } })
  47. },
  48. /**
  49. * 生命周期函数--监听页面加载
  50. */
  51. onLoad: function (options) {
  52. const that = this;
  53. that.watchLogin();
  54. },
  55. // 监听用户是否登录
  56. watchLogin: async function () {
  57. const that = this;
  58. wx.getStorage({
  59. key: 'user',
  60. success: async res => {
  61. const arr = await app.$get(`/newCourt/api/enroll/`, { openid: res.data.openid });
  62. if (arr.errcode == '0') {
  63. for (const val of arr.data) {
  64. // 赛事信息
  65. const match = await app.$get(`/newCourt/api/match/${val.match_id}`);
  66. if (match.errcode = '0') { val.match_name = match.data.name };
  67. }
  68. that.setData({ list: arr.data })
  69. }
  70. },
  71. fail: res => {
  72. wx.redirectTo({ url: '/pages/index/index', })
  73. }
  74. })
  75. },
  76. /**
  77. * 生命周期函数--监听页面初次渲染完成
  78. */
  79. onReady: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面显示
  83. */
  84. onShow: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面隐藏
  88. */
  89. onHide: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面卸载
  93. */
  94. onUnload: function () {
  95. },
  96. /**
  97. * 页面相关事件处理函数--监听用户下拉动作
  98. */
  99. onPullDownRefresh: function () {
  100. },
  101. /**
  102. * 页面上拉触底事件的处理函数
  103. */
  104. onReachBottom: function () {
  105. },
  106. /**
  107. * 用户点击右上角分享
  108. */
  109. onShareAppMessage: function () {
  110. }
  111. })