info.js 4.0 KB

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