12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- const app = getApp();
- Page({
- data: {
- frameStyle: { useTop: true, name: '详细信息', leftArrow: true, useBar: false },
- id: '',
- info: {},
- statusList: []
- },
- // 返回
- back: function () { wx.navigateBack({ delta: 1 }) },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: async function (options) {
- const that = this;
- await that.setData({ id: options.id || null })
- // 查询其他信息
- await that.searchOther();
- // 监听用户是否登录
- await that.watchLogin();
- },
- searchOther: async function () {
- const that = this;
- let arr;
- arr = await app.$get(`/dict`, { code: "schedule_status" });
- if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
- },
- // 监听用户是否登录
- watchLogin: async function () {
- const that = this;
- wx.getStorage({
- key: 'user',
- success: async res => {
- if (that.data.id) {
- const arr = await app.$get(`/eliminate/${that.data.id}`, {}, 'race');
- if (arr.errcode == '0') {
- arr.data.zhStatus = that.searchStatus(arr.data.status);
- if (arr.data.player_one == arr.data.winner) arr.data.winner_name = arr.data.player_one_name;
- else arr.data.winner_name = arr.data.player_two_name;
- that.setData({ info: arr.data })
- } else {
- wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
- }
- }
- },
- fail: async res => {
- wx.redirectTo({ url: '/pages/index/index' })
- }
- })
- },
- // 查询状态
- searchStatus: function (e) {
- const that = this;
- let data = that.data.statusList.find(i => i.value == e);
- if (data) return data.label;
- else return '暂无';
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () { },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|