const app = getApp(); import { match_status } from '../../utils/dict'; Page({ /** * 页面的初始数据 */ data: { frameStyle: { useTop: true, name: '比赛信息', leftArrow: true, useBar: false }, // 主体高度 infoHeight: '', bg_img: '/image/yun.jpg', bg_img1: '/image/me_2.png', // 比赛信息 match_id: '', matchInfo: {}, // 参赛队伍 matchteamList: [], // 赛程列表 scheduleList: [], // 榜单 rankingList: [ { pm: '1', logo: [{ url: '/image/team_1.jpg' }], team_name: '测试战队', sheng: '10', fu: '10', jf: '111' } ], // 状态 statusList: match_status, // 选项卡 tabs: { active: 'a', list: [{ title: '赛制信息', name: 'a' }, { title: '参赛队伍', name: 'b' }, { title: '赛程列表', name: 'c' }, { title: '队伍榜单', name: 'd' }], }, }, back: function () { wx.navigateBack({ url: '/pages/me/index' }) }, // 选项卡 tabsChange: function (e) { const that = this; that.setData({ 'tabs.active': e.detail.name }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { const that = this; that.setData({ match_id: options.id || '' }); // 计算高度 that.searchHeight() // 监听用户是否登录 that.watchLogin(); }, // 监听用户是否登录 watchLogin: function () { var that = this; wx.getStorage({ key: 'token', success: async res => { let arr; // 查询比赛信息 arr = await app.$get(`/courtAdmin/api/match/${that.data.match_id}`) if (arr.errcode == '0') { console.log(match_status); console.log(arr); let status = match_status.find((i) => i.label == arr.data.status); if (status) arr.data.status_name = status.value; that.setData({ matchInfo: arr.data }) } arr = await app.$get(`/courtAdmin/api/matchteam`, { match_id: that.data.match_id }); if (arr.errcode == '0') that.setData({ matchteamList: arr.data }) arr = await app.$get(`/courtAdmin/api/schedule`, { match_id: that.data.match_id }); if (arr.errcode == '0') that.setData({ scheduleList: arr.data }) }, fail: res => { return wx.redirectTo({ url: '/pages/index/index', }) } }) }, // 计算高度 searchHeight: function () { let frameStyle = this.data.frameStyle; let client = app.globalData.client; let infoHeight = client.windowHeight; // 是否去掉状态栏 if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2); // 是否减去底部菜单 if (frameStyle.useBar) infoHeight = infoHeight - 50; if (infoHeight) this.setData({ infoHeight: infoHeight }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })