|
@@ -3,18 +3,9 @@ Page({
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '比赛管理', leftArrow: false, useBar: true },
|
|
|
user: {},
|
|
|
- typeList: [
|
|
|
- { label: '其他', value: '0' },
|
|
|
- { label: '羽毛球', value: '1' },
|
|
|
- { label: '篮球', value: '2' },
|
|
|
- { label: '足球', value: '3' },
|
|
|
- ],
|
|
|
- statusList: [
|
|
|
- { label: '计划中', value: '0' },
|
|
|
- { label: '报名中', value: '1' },
|
|
|
- { label: '进行中', value: '2' },
|
|
|
- { label: '已结束', value: '3' },
|
|
|
- ],
|
|
|
+ searchInfo: {},
|
|
|
+ statusList: [],
|
|
|
+ typeList: [],
|
|
|
list: [],
|
|
|
total: 0,
|
|
|
page: 0,
|
|
@@ -37,12 +28,16 @@ Page({
|
|
|
const that = this;
|
|
|
let data = that.data.typeList[e.detail.value];
|
|
|
if (data) that.setData({ 'searchInfo.type': data.value })
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] })
|
|
|
+ that.watchLogin();
|
|
|
},
|
|
|
// 状态选择
|
|
|
statusChange: function (e) {
|
|
|
const that = this;
|
|
|
let data = that.data.statusList[e.detail.value];
|
|
|
that.setData({ 'searchInfo.status': data.value });
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] })
|
|
|
+ that.watchLogin();
|
|
|
},
|
|
|
// 分页
|
|
|
toPage: function () {
|
|
@@ -70,18 +65,47 @@ Page({
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
- onShow: function () {
|
|
|
+ onShow: async function () {
|
|
|
const that = this;
|
|
|
+ // 查询其他信息
|
|
|
+ await that.searchOther();
|
|
|
// 监听用户是否登录
|
|
|
- that.watchLogin();
|
|
|
+ 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 });
|
|
|
+ // 赛事类别
|
|
|
+ arr = await app.$get(`/dict`, { code: "match_type" });
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ typeList: arr.data[0].list });
|
|
|
},
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: async function () {
|
|
|
const that = this;
|
|
|
+ const searchInfo = that.data.searchInfo;
|
|
|
+ const statusList = that.data.statusList;
|
|
|
+ const typeList = that.data.typeList;
|
|
|
wx.getStorage({
|
|
|
key: 'user',
|
|
|
success: async res => {
|
|
|
that.setData({ user: res.data })
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit };
|
|
|
+ if (searchInfo.status) info.status = searchInfo.status;
|
|
|
+ if (searchInfo.type) info.type = searchInfo.type;
|
|
|
+ const arr = await app.$get(`/match`, { ...info }, 'race');
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ for (const val of arr.data) {
|
|
|
+ let status = statusList.find(i => i.value == val.status)
|
|
|
+ if (status) val.zhStatus = status.label;
|
|
|
+ let type = typeList.find(i => i.value == val.type)
|
|
|
+ if (type) val.zhType = type.label;
|
|
|
+ }
|
|
|
+ that.setData({ list: [...that.data.list, ...arr.data] });
|
|
|
+ that.setData({ total: arr.total });
|
|
|
+ }
|
|
|
},
|
|
|
fail: async res => {
|
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
@@ -95,7 +119,8 @@ Page({
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function () {
|
|
|
-
|
|
|
+ const that = this;
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] })
|
|
|
},
|
|
|
|
|
|
/**
|