123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- const app = getApp()
- Page({
- data: {
- id: "",
- info: {},
- user: {},
- statusList: [],
- list: []
- },
- // 报名
- async toAdd() {
- const that = this;
- if (that.data.user._id) wx.navigateTo({ url: '/pagesMatch/enroll/index?match=' + that.data.info._id }); else wx.navigateTo({ url: '/pagesCommon/login/index' })
- },
- // 排名
- toRank() {
- const that = this;
- wx.navigateTo({ url: '/pagesMy/ranking/index?id=' + that.data.info._id })
- },
- // 赛程信息
- toCourse(e) {
- const that = this;
- wx.navigateTo({ url: '/pagesMy/course/index?id=' + that.data.info._id })
- },
- // 参赛团队
- toTeam(e) {
- const that = this;
- wx.navigateTo({ url: '/pagesMatch/team/index?id=' + that.data.info._id })
- },
- // 字典
- getDict(value, model) {
- const that = this;
- if (model == 'status') {
- if (value) {
- let data = that.data.statusList.find(i => i.value == value)
- if (data) return data.label
- else return '暂无'
- }
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- async onLoad(options) {
- const that = this;
- that.setData({ id: options.id });
- },
- /**
- * 生命周期函数--监听页面显示
- */
- async onShow() {
- const that = this;
- wx.showLoading({ title: '加载中', mask: true })
- await that.searchUser()
- await that.searchOther()
- await that.search()
- wx.hideLoading()
- },
- async searchUser() {
- const that = this;
- wx.getStorage({
- key: 'user',
- async success(res) {
- that.setData({ user: res.data })
- }, fail(err) {
- // console.log(err);
- }
- })
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let res;
- res = await app.$api('dictData', 'GET', { type: 'match_status', is_use: '0' })
- if (res.errcode == '0') that.setData({ statusList: res.data })
- },
- // 查询通知
- async search() {
- const that = this;
- let res = await app.$api(`match/${that.data.id}`, 'GET', {})
- if (res.errcode == '0') {
- res.data.status_name = that.getDict(res.data.status, 'status')
- if (res.data.information) res.data.information = res.data.information.replace(/\<img/gi,
- '<img class="rich-img"');
- that.setData({ info: res.data })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|