|
@@ -3,22 +3,26 @@ import WxValidate from '../../../utils/wxValidate';
|
|
|
Page({
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '小组赛管理', leftArrow: true, useBar: false },
|
|
|
- dialog: { title: '赛程上分', show: false, type: '1' },
|
|
|
- form: {},
|
|
|
- //查询
|
|
|
- searchInfo: {},
|
|
|
+ // 用户信息
|
|
|
+ raceuser: {},
|
|
|
// 赛事列表
|
|
|
matchList: [],
|
|
|
// 组别列表
|
|
|
groupList: [],
|
|
|
// 组内项目列表
|
|
|
projectList: [],
|
|
|
+ // 赛程状态
|
|
|
+ statusList: [],
|
|
|
list: [],
|
|
|
total: 0,
|
|
|
page: 0,
|
|
|
skip: 0,
|
|
|
limit: 5,
|
|
|
- statusList: []
|
|
|
+ dialog: { title: '赛程上分', show: false, type: '1' },
|
|
|
+ //查询
|
|
|
+ searchInfo: {},
|
|
|
+ // 上分
|
|
|
+ form: {},
|
|
|
},
|
|
|
initValidate() {
|
|
|
const rules = { player_one_score: { required: true }, player_two_score: { required: true } }
|
|
@@ -27,7 +31,7 @@ Page({
|
|
|
this.WxValidate = new WxValidate(rules, messages)
|
|
|
},
|
|
|
// 返回
|
|
|
- back: function () { wx.navigateBack({ delta: 1 }) },
|
|
|
+ back: function () { wx.navigateBack({ delta: 1 }); wx.removeStorage({ key: 'searchInfo' }) },
|
|
|
// 详细信息
|
|
|
toCommon: function (e) {
|
|
|
const that = this;
|
|
@@ -40,13 +44,6 @@ Page({
|
|
|
const that = this;
|
|
|
that.setData({ dialog: { title: '选择赛事', show: true, type: '2' } })
|
|
|
},
|
|
|
- // 赛程上分
|
|
|
- toScore: function (e) {
|
|
|
- const that = this;
|
|
|
- const { item } = e.currentTarget.dataset;
|
|
|
- that.setData({ form: item })
|
|
|
- that.setData({ dialog: { title: '赛程上分', show: true, type: '1' } })
|
|
|
- },
|
|
|
// 选择赛事
|
|
|
matchChange: async function (e) {
|
|
|
const that = this;
|
|
@@ -75,33 +72,84 @@ Page({
|
|
|
that.setData({ 'searchInfo.project_id': data._id, 'searchInfo.project_name': data.name });
|
|
|
}
|
|
|
},
|
|
|
+ // 提交查询
|
|
|
toSubmit: function (e) {
|
|
|
const that = this
|
|
|
- const params = e.detail.value;
|
|
|
- if (params) { that.setData({ skip: 0, page: 0, list: [] }); that.toClose(); that.watchLogin(); }
|
|
|
+ let searchInfo = that.data.searchInfo;
|
|
|
+ if (searchInfo) {
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] });
|
|
|
+ wx.setStorage({ key: "searchInfo", data: searchInfo });
|
|
|
+ that.search();
|
|
|
+ that.toClose();
|
|
|
+ }
|
|
|
else { wx.showToast({ title: '请选择数据', icon: 'error', duration: 2000 }) }
|
|
|
},
|
|
|
- // 提交保存
|
|
|
+ // 查询
|
|
|
+ search: async function () {
|
|
|
+ const that = this;
|
|
|
+ let raceuser = that.data.raceuser;
|
|
|
+ let statusList = that.data.statusList;
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'searchInfo',
|
|
|
+ success: async res => {
|
|
|
+ if (res.data.group_id && res.data.match_id && res.data.project_id) {
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit, referee_id: raceuser._id, group_id: res.data.group_id, match_id: res.data.match_id, project_id: res.data.project_id }
|
|
|
+ let arr = await app.$get(`/msgs`, { ...info }, 'race');
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ let list = [...that.data.list, ...arr.data];
|
|
|
+ for (const val of list) {
|
|
|
+ let status = statusList.find(i => i.value == val.status)
|
|
|
+ if (status) val.zhStatus = status.label;
|
|
|
+ }
|
|
|
+ that.setData({ list })
|
|
|
+ that.setData({ total: arr.total })
|
|
|
+ } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 分页
|
|
|
+ toPage: function () {
|
|
|
+ const that = this;
|
|
|
+ let list = that.data.list;
|
|
|
+ let limit = that.data.limit;
|
|
|
+ if (that.data.total > list.length) {
|
|
|
+ wx.showLoading({ title: '加载中', mask: true })
|
|
|
+ let page = that.data.page + 1;
|
|
|
+ that.setData({ page: page })
|
|
|
+ let skip = page * limit;
|
|
|
+ that.setData({ skip: skip })
|
|
|
+ that.search();
|
|
|
+ wx.hideLoading()
|
|
|
+ } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
|
|
|
+ },
|
|
|
+ // 赛程上分
|
|
|
+ toScore: function (e) {
|
|
|
+ const that = this;
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
+ that.setData({ form: item })
|
|
|
+ that.setData({ dialog: { title: '赛程上分', show: true, type: '1' } })
|
|
|
+ },
|
|
|
+ // 提交上分
|
|
|
onSubmit: async function (e) {
|
|
|
const that = this;
|
|
|
const params = e.detail.value;
|
|
|
- const form = that.data.form;
|
|
|
if (!this.WxValidate.checkForm(params)) {
|
|
|
const error = this.WxValidate.errorList[0];
|
|
|
wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
return false
|
|
|
} else {
|
|
|
- let arr = await app.$post(`/msgs/${form.id}`, params, 'race');
|
|
|
+ let arr = await app.$post(`/msgs/${params.id}`, params, 'race');
|
|
|
if (arr.errcode == '0') {
|
|
|
wx.showToast({ title: `上分成功`, icon: 'success', duration: 2000 });
|
|
|
that.setData({ skip: 0, page: 0, list: [], form: {} })
|
|
|
- that.watchLogin();
|
|
|
+ that.search();
|
|
|
that.toClose();
|
|
|
}
|
|
|
else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
}
|
|
|
},
|
|
|
- // 删除
|
|
|
+ // 交换场地
|
|
|
toChange: function (e) {
|
|
|
const that = this;
|
|
|
const { item } = e.currentTarget.dataset;
|
|
@@ -114,28 +162,13 @@ Page({
|
|
|
if (arr.errcode == '0') {
|
|
|
wx.showToast({ title: `交换场地成功`, icon: 'success', duration: 2000 });
|
|
|
that.setData({ skip: 0, page: 0, list: [] })
|
|
|
- that.watchLogin();
|
|
|
+ that.search();
|
|
|
}
|
|
|
else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- // 分页
|
|
|
- toPage: function () {
|
|
|
- const that = this;
|
|
|
- let list = that.data.list;
|
|
|
- let limit = that.data.limit;
|
|
|
- if (that.data.total > list.length) {
|
|
|
- wx.showLoading({ title: '加载中', mask: true })
|
|
|
- let page = that.data.page + 1;
|
|
|
- that.setData({ page: page })
|
|
|
- let skip = page * limit;
|
|
|
- that.setData({ skip: skip })
|
|
|
- that.watchLogin();
|
|
|
- wx.hideLoading()
|
|
|
- } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
|
|
|
- },
|
|
|
// 关闭弹框
|
|
|
toClose: function () {
|
|
|
const that = this;
|
|
@@ -170,25 +203,13 @@ Page({
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: async function () {
|
|
|
const that = this;
|
|
|
- let searchInfo = that.data.searchInfo;
|
|
|
wx.getStorage({
|
|
|
key: 'raceuser',
|
|
|
success: async res => {
|
|
|
- let match = await app.$get(`/match`, {}, 'race');
|
|
|
+ that.setData({ raceuser: res.data })
|
|
|
+ let match = await app.$get(`/match`, { belong_id: res.data.parent_id }, 'race');
|
|
|
if (match.errcode == '0') { that.setData({ matchList: match.data }) }
|
|
|
- if (searchInfo.group_id && searchInfo.match_id && searchInfo.project_id) {
|
|
|
- let info = { skip: that.data.skip, limit: that.data.limit, referee_id: res.data._id, group_id: searchInfo.group_id, match_id: searchInfo.match_id, project_id: searchInfo.project_id }
|
|
|
- let arr = await app.$get(`/msgs`, { ...info }, 'race');
|
|
|
- if (arr.errcode == '0') {
|
|
|
- let list = [...that.data.list, ...arr.data]
|
|
|
- for (const val of list) {
|
|
|
- let status = that.data.statusList.find(i => i.value == val.status)
|
|
|
- if (status) val.zhStatus = status.label;
|
|
|
- }
|
|
|
- that.setData({ list })
|
|
|
- that.setData({ total: arr.total })
|
|
|
- } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
- }
|
|
|
+ that.search();
|
|
|
},
|
|
|
fail: async res => {
|
|
|
wx.redirectTo({ url: '/pages/index/index' })
|