info.js 4.2 KB

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