index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import { match_status } from '../../utils/dict';
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. frameStyle: { useTop: true, name: '赛事信息', leftArrow: true, useBar: false },
  9. fileUrl: app.globalData.fileUrl,
  10. user: {},
  11. id: '',
  12. info: {},
  13. // 选项卡
  14. tabs: {
  15. active: 'a',
  16. list: [
  17. { title: '规程', name: 'a' },
  18. { title: '选手', name: 'b' },
  19. { title: '秩序册', name: 'c' },
  20. { title: '赛况', name: 'd' },
  21. { title: '成绩册', name: 'e' },
  22. ],
  23. },
  24. // 选手
  25. bActive: '0',
  26. groupList: []
  27. },
  28. // 跳转菜单
  29. back(e) {
  30. wx.navigateBack({ delta: 1 })
  31. },
  32. // 选项卡
  33. tabsChange: function (e) {
  34. const that = this;
  35. const { name } = e.detail;
  36. if (name == 'c' || name == "d" || name == "e") {
  37. wx.showToast({ title: `暂无发布`, icon: 'error', duration: 2000 });
  38. } else {
  39. that.setData({ 'tabs.active': e.detail.name });
  40. }
  41. },
  42. // 更多
  43. toCommon: function (e) {
  44. const { route } = e.currentTarget.dataset;
  45. wx.redirectTo({ url: `/pages/${route}/index` })
  46. },
  47. // 报名
  48. toSign: function (e) {
  49. const { item } = e.currentTarget.dataset;
  50. wx.navigateTo({ url: `/pages/matchInfo/sign?id=${item._id}` })
  51. },
  52. // 选择手风琴
  53. bChange: function (e) {
  54. const that = this;
  55. that.setData({ bActive: e.detail })
  56. },
  57. /**
  58. * 生命周期函数--监听页面加载
  59. */
  60. onLoad: function (options) {
  61. const that = this;
  62. that.setData({ id: options.id || '62e388d4fd61d871861b80af' });
  63. // 监听用户是否登录
  64. that.watchLogin();
  65. },
  66. watchLogin: function () {
  67. const that = this;
  68. wx.getStorage({
  69. key: 'user',
  70. success: async (res) => {
  71. that.setData({ user: res.data })
  72. if (that.data.id) {
  73. let arr;
  74. arr = await app.$get(`/newCourt/api/match/${that.data.id}`);
  75. if (arr.errcode == '0') {
  76. arr.data.statusZh = that.getStatusZh(arr.data.status);
  77. that.setData({ info: arr.data })
  78. } else { wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 }); }
  79. arr = await app.$get(`/newCourt/api/view/groupProjectUser?match_id=${that.data.id}`);
  80. if (arr.errcode == '0') { that.setData({ groupList: arr.data }) }
  81. }
  82. },
  83. fail: async (res) => {
  84. wx.redirectTo({ url: '/pages/index/index' });
  85. },
  86. });
  87. },
  88. getStatusZh(status) {
  89. let word = "未知"
  90. let data = match_status.find((i) => i.label == status);
  91. if (data) word = data.value;
  92. return word;
  93. },
  94. /**
  95. * 生命周期函数--监听页面初次渲染完成
  96. */
  97. onReady: function () {
  98. },
  99. /**
  100. * 生命周期函数--监听页面显示
  101. */
  102. onShow: function () {
  103. },
  104. /**
  105. * 生命周期函数--监听页面隐藏
  106. */
  107. onHide: function () {
  108. },
  109. /**
  110. * 生命周期函数--监听页面卸载
  111. */
  112. onUnload: function () {
  113. },
  114. /**
  115. * 页面相关事件处理函数--监听用户下拉动作
  116. */
  117. onPullDownRefresh: function () {
  118. },
  119. /**
  120. * 页面上拉触底事件的处理函数
  121. */
  122. onReachBottom: function () {
  123. },
  124. /**
  125. * 用户点击右上角分享
  126. */
  127. onShareAppMessage: function () {
  128. }
  129. })