|
@@ -0,0 +1,113 @@
|
|
|
+const app = getApp();
|
|
|
+Page({
|
|
|
+ data: {
|
|
|
+ frameStyle: { useTop: true, name: '赛事信息', leftArrow: true, useBar: false },
|
|
|
+ fileUrl: app.globalData.fileUrl,
|
|
|
+ id: '',
|
|
|
+ info: {},
|
|
|
+ user: {},
|
|
|
+ // 选项卡
|
|
|
+ tabs: {
|
|
|
+ active: 'a',
|
|
|
+ menu: [
|
|
|
+ { title: '规程', active: 'a' },
|
|
|
+ { title: '选手', active: 'b' },
|
|
|
+ { title: '秩序册', active: 'c' },
|
|
|
+ { title: '赛况', active: 'd' },
|
|
|
+ { title: '成绩册', active: 'e' },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ // 状态
|
|
|
+ statusList: []
|
|
|
+ },
|
|
|
+ // 返回
|
|
|
+ back: function () { wx.navigateBack({ delta: 1 }) },
|
|
|
+ // 选项卡
|
|
|
+ tabsChange: function (e) {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ 'tabs.active': e.detail.active });
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad: function (options) {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ id: options.id || '' });
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
+ */
|
|
|
+ onReady: function () { },
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ onShow: async function () {
|
|
|
+ const that = this;
|
|
|
+ // 查询其他信息
|
|
|
+ await that.searchOther();
|
|
|
+ // 监听用户是否登录
|
|
|
+ await that.watchLogin();
|
|
|
+ },
|
|
|
+ searchOther: async function () {
|
|
|
+ const that = this;
|
|
|
+ let arr;
|
|
|
+ // 状态
|
|
|
+ arr = await app.$get(`/dict`, { code: "match_status" });
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) { that.setData({ statusList: arr.data[0].list }); }
|
|
|
+ },
|
|
|
+ // 监听用户是否登录
|
|
|
+ watchLogin: async function () {
|
|
|
+ const that = this;
|
|
|
+ const statusList = that.data.statusList;
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'user',
|
|
|
+ success: async res => {
|
|
|
+ that.setData({ user: res.data })
|
|
|
+ let arr;
|
|
|
+ // 比赛信息
|
|
|
+ arr = await app.$get(`/match/${that.data.id}`, {}, 'race');
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ let status = statusList.find(i => i.value == arr.data.status)
|
|
|
+ if (status) arr.data.zhStatus = status.label;
|
|
|
+ let regular = arr.data.regular.replace(/\<img/gi, '<img style="width:100%;height:auto;margin: 5px 0"');
|
|
|
+ if (regular) arr.data.zhRegular = regular;
|
|
|
+ that.setData({ info: arr.data })
|
|
|
+ } else { wx.showToast({ title: `${res.errmsg}`, icon: 'fail', duration: 2000 }); }
|
|
|
+ },
|
|
|
+ fail: async res => {
|
|
|
+ wx.redirectTo({ url: '/pages/index/index' })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
+ */
|
|
|
+ onHide: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
+ */
|
|
|
+ onUnload: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户点击右上角分享
|
|
|
+ */
|
|
|
+ onShareAppMessage: function () {
|
|
|
+
|
|
|
+ }
|
|
|
+})
|