info.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. const app = getApp();
  2. import { match_status } from '../../utils/dict';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. frameStyle: { useTop: true, name: '比赛信息', leftArrow: true, useBar: false },
  9. // 主体高度
  10. infoHeight: '',
  11. bg_img: '/image/yun.jpg',
  12. bg_img1: '/image/me_2.png',
  13. // 比赛信息
  14. match_id: '',
  15. matchInfo: {},
  16. // 参赛队伍
  17. matchteamList: [],
  18. // 赛程列表
  19. scheduleList: [],
  20. // 榜单
  21. rankingList: [],
  22. // 状态
  23. statusList: match_status,
  24. // 选项卡
  25. tabs: {
  26. active: 'b',
  27. list: [{ title: '参赛队伍', name: 'b' }, { title: '赛程列表', name: 'c' }, { title: '队伍榜单', name: 'd' }],
  28. },
  29. },
  30. back: function () {
  31. wx.navigateBack({ url: '/pages/me/index' })
  32. },
  33. // 选项卡
  34. tabsChange: function (e) {
  35. const that = this;
  36. that.setData({ 'tabs.active': e.detail.name })
  37. },
  38. // 赛程信息
  39. toSchedule: function (e) {
  40. let { id } = e.currentTarget.dataset;
  41. wx.navigateTo({ url: `/pages/match/schedule?id=${id}` })
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad: function (options) {
  47. const that = this;
  48. that.setData({ match_id: options.id || '62a2eb5378ee7c27422d9e51' });
  49. // 计算高度
  50. that.searchHeight()
  51. // 监听用户是否登录
  52. that.watchLogin();
  53. },
  54. // 监听用户是否登录
  55. watchLogin: function () {
  56. var that = this;
  57. wx.getStorage({
  58. key: 'token',
  59. success: async res => {
  60. let arr;
  61. // 查询比赛信息
  62. arr = await app.$get(`/courtAdmin/api/match/${that.data.match_id}`)
  63. if (arr.errcode == '0') {
  64. let status = match_status.find((i) => i.label == arr.data.status);
  65. if (status) arr.data.status_name = status.value;
  66. that.setData({ matchInfo: arr.data })
  67. }
  68. arr = await app.$get(`/courtAdmin/api/matchteam`, { match_id: that.data.match_id });
  69. if (arr.errcode == '0') that.setData({ matchteamList: arr.data })
  70. arr = await app.$get(`/courtAdmin/api/schedule`, { match_id: that.data.match_id });
  71. if (arr.errcode == '0') that.setData({ scheduleList: arr.data })
  72. arr = await app.$get(`/courtAdmin/api/statistics/match`, { match_id: that.data.match_id });
  73. if (arr.errcode == '0') that.setData({ rankingList: arr.data })
  74. },
  75. fail: res => {
  76. return wx.redirectTo({ url: '/pages/index/index', })
  77. }
  78. })
  79. },
  80. // 计算高度
  81. searchHeight: function () {
  82. let frameStyle = this.data.frameStyle;
  83. let client = app.globalData.client;
  84. let infoHeight = client.windowHeight;
  85. // 是否去掉状态栏
  86. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  87. // 是否减去底部菜单
  88. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  89. if (infoHeight) this.setData({ infoHeight: infoHeight })
  90. },
  91. /**
  92. * 生命周期函数--监听页面初次渲染完成
  93. */
  94. onReady: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面显示
  98. */
  99. onShow: function () {
  100. },
  101. /**
  102. * 生命周期函数--监听页面隐藏
  103. */
  104. onHide: function () {
  105. },
  106. /**
  107. * 生命周期函数--监听页面卸载
  108. */
  109. onUnload: function () {
  110. },
  111. /**
  112. * 页面相关事件处理函数--监听用户下拉动作
  113. */
  114. onPullDownRefresh: function () {
  115. },
  116. /**
  117. * 页面上拉触底事件的处理函数
  118. */
  119. onReachBottom: function () {
  120. },
  121. /**
  122. * 用户点击右上角分享
  123. */
  124. onShareAppMessage: function () {
  125. }
  126. })