info.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp();
  4. import { match_status } from '../../utils/dict';
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. frameStyle: { useTop: true, name: '比赛信息', leftArrow: true, useBar: false },
  11. // 主体高度
  12. infoHeight: '',
  13. bg_img: '/image/yun.jpg',
  14. // 比赛信息
  15. match_id: '',
  16. matchInfo: {},
  17. // 参赛队伍
  18. matchteamList: [],
  19. // 状态
  20. statusList: match_status,
  21. // 选项卡
  22. tabs: {
  23. active: 'b',
  24. list: [{ title: '赛制信息', name: 'a' }, { title: '参赛队伍', name: 'b' }, { title: '赛程列表', name: 'c' }, { title: '队伍榜单', name: 'd' }],
  25. },
  26. // ids: '',
  27. // // 选项卡
  28. // tabs: {
  29. // active: 'd',
  30. // list: [
  31. // { title: '赛制信息', name: 'a' },
  32. // { title: '参赛队伍', name: 'b' },
  33. // { title: '赛程列表', name: 'c' },
  34. // { title: '队伍榜单', name: 'd' },
  35. // ],
  36. // },
  37. // teamlist: [],
  38. // ranks: [],
  39. // listbang: [
  40. // {
  41. // pm: '1',
  42. // team_name: '测试团队',
  43. // sf: '1/0',
  44. // jf: '234'
  45. // },
  46. // {
  47. // pm: '1',
  48. // team_name: '测试团队',
  49. // sf: '1/0',
  50. // jf: '234'
  51. // },
  52. // {
  53. // pm: '1',
  54. // team_name: '测试团队',
  55. // sf: '1/0',
  56. // jf: '234'
  57. // },
  58. // {
  59. // pm: '1',
  60. // team_name: '测试团队',
  61. // sf: '1/0',
  62. // jf: '234'
  63. // },
  64. // ],
  65. // schedule: [],
  66. },
  67. back: function () {
  68. wx.navigateBack({ url: '/pages/me/index' })
  69. },
  70. // 选项卡
  71. tabsChange: function (e) {
  72. const that = this;
  73. that.setData({ 'tabs.active': e.detail.name })
  74. },
  75. /**
  76. * 生命周期函数--监听页面加载
  77. */
  78. onLoad: function (options) {
  79. const that = this;
  80. that.setData({ match_id: options.id || '629eb5de78fa03648c0535d9' });
  81. // 计算高度
  82. that.searchHeight()
  83. // 监听用户是否登录
  84. that.watchLogin();
  85. },
  86. // 监听用户是否登录
  87. watchLogin: function () {
  88. var that = this;
  89. wx.getStorage({
  90. key: 'token',
  91. success: async res => {
  92. let arr;
  93. // 查询比赛信息
  94. arr = await app.$get(`/courtAdmin/api/match/${that.data.match_id}`)
  95. if (arr.errcode == '0') {
  96. let status = match_status.find((i) => i.label == arr.data.status);
  97. if (status) arr.data.status_name = status.value;
  98. that.setData({ matchInfo: arr.data })
  99. }
  100. arr = await app.$get(`/courtAdmin/api/matchteam`, { match_id: that.data.match_id });
  101. if (arr.errcode == '0') that.setData({ matchteamList: arr.data })
  102. // wx.request({
  103. // url: `${app.globalData.publicUrl}/courtAdmin/api/match/${this.data.ids}`, //接口地址
  104. // method: 'get',
  105. // // data: {},
  106. // success(res) {
  107. // if (res.data.errcode == 0) {
  108. // let datas = res.data.data
  109. // that.setData({
  110. // teamlist: datas,
  111. // });
  112. // // 查询参赛队伍数据
  113. // that.ranks();
  114. // // 查询赛程列表数据
  115. // that.course();
  116. // } else {
  117. // wx.showToast({
  118. // title: res.data.errmsg,
  119. // icon: 'none',
  120. // duration: 2000
  121. // })
  122. // }
  123. // }
  124. // })
  125. },
  126. fail: res => {
  127. return wx.redirectTo({ url: '/pages/index/index', })
  128. }
  129. })
  130. },
  131. // 计算高度
  132. searchHeight: function () {
  133. let frameStyle = this.data.frameStyle;
  134. let client = app.globalData.client;
  135. let infoHeight = client.windowHeight;
  136. // 是否去掉状态栏
  137. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  138. // 是否减去底部菜单
  139. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  140. if (infoHeight) this.setData({ infoHeight: infoHeight })
  141. },
  142. /**
  143. * 生命周期函数--监听页面初次渲染完成
  144. */
  145. onReady: function () {
  146. },
  147. /**
  148. * 生命周期函数--监听页面显示
  149. */
  150. onShow: function () {
  151. },
  152. /**
  153. * 生命周期函数--监听页面隐藏
  154. */
  155. onHide: function () {
  156. },
  157. /**
  158. * 生命周期函数--监听页面卸载
  159. */
  160. onUnload: function () {
  161. },
  162. /**
  163. * 页面相关事件处理函数--监听用户下拉动作
  164. */
  165. onPullDownRefresh: function () {
  166. },
  167. /**
  168. * 页面上拉触底事件的处理函数
  169. */
  170. onReachBottom: function () {
  171. },
  172. /**
  173. * 用户点击右上角分享
  174. */
  175. onShareAppMessage: function () {
  176. }
  177. })