info.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. * 生命周期函数--监听页面加载
  49. */
  50. onLoad: function (options) {
  51. const that = this;
  52. that.setData({ match_id: options.id || '' });
  53. // 计算高度
  54. that.searchHeight()
  55. // 监听用户是否登录
  56. that.watchLogin();
  57. },
  58. // 监听用户是否登录
  59. watchLogin: function () {
  60. var that = this;
  61. wx.getStorage({
  62. key: 'token',
  63. success: async res => {
  64. let arr;
  65. // 查询比赛信息
  66. arr = await app.$get(`/courtAdmin/api/match/${that.data.match_id}`)
  67. if (arr.errcode == '0') {
  68. let status = match_status.find((i) => i.label == arr.data.status);
  69. if (status) arr.data.status_name = status.value;
  70. that.setData({ matchInfo: arr.data })
  71. }
  72. arr = await app.$get(`/courtAdmin/api/matchteam`, { match_id: that.data.match_id });
  73. if (arr.errcode == '0') that.setData({ matchteamList: arr.data })
  74. arr = await app.$get(`/courtAdmin/api/schedule`, { match_id: that.data.match_id });
  75. if (arr.errcode == '0') that.setData({ scheduleList: arr.data })
  76. },
  77. fail: res => {
  78. return wx.redirectTo({ url: '/pages/index/index', })
  79. }
  80. })
  81. },
  82. // 计算高度
  83. searchHeight: function () {
  84. let frameStyle = this.data.frameStyle;
  85. let client = app.globalData.client;
  86. let infoHeight = client.windowHeight;
  87. // 是否去掉状态栏
  88. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  89. // 是否减去底部菜单
  90. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  91. if (infoHeight) this.setData({ infoHeight: infoHeight })
  92. },
  93. /**
  94. * 生命周期函数--监听页面初次渲染完成
  95. */
  96. onReady: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面显示
  100. */
  101. onShow: function () {
  102. },
  103. /**
  104. * 生命周期函数--监听页面隐藏
  105. */
  106. onHide: function () {
  107. },
  108. /**
  109. * 生命周期函数--监听页面卸载
  110. */
  111. onUnload: function () {
  112. },
  113. /**
  114. * 页面相关事件处理函数--监听用户下拉动作
  115. */
  116. onPullDownRefresh: function () {
  117. },
  118. /**
  119. * 页面上拉触底事件的处理函数
  120. */
  121. onReachBottom: function () {
  122. },
  123. /**
  124. * 用户点击右上角分享
  125. */
  126. onShareAppMessage: function () {
  127. }
  128. })