|
@@ -1,3 +1,4 @@
|
|
|
+import { race_status } from "../../utils/dict";
|
|
|
const app = getApp()
|
|
|
Page({
|
|
|
|
|
@@ -10,6 +11,8 @@ Page({
|
|
|
list: [],
|
|
|
dialog: { title: '详细信息', show: false, type: '1' },
|
|
|
info: {},
|
|
|
+ form: {},
|
|
|
+ statusList: race_status
|
|
|
},
|
|
|
// 跳转菜单
|
|
|
back(e) {
|
|
@@ -22,10 +25,61 @@ Page({
|
|
|
that.setData({ info: item })
|
|
|
that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
|
|
|
},
|
|
|
+ // 更换场地
|
|
|
+ toChange: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '您是否确定要更换场地吗?',
|
|
|
+ async success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ const arr = await app.$post(`/newCourt/api/race/${item._id}`, { is_change: '1' });
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ wx.showToast({ title: `更换场地完成`, icon: 'error', duration: 2000 })
|
|
|
+ that.watchLogin()
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ // 赛事管理
|
|
|
+ toScore: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
+ const arr = await app.$get(`/newCourt/api/race/${item._id}`);
|
|
|
+ if (arr.errcode == '0') { that.setData({ form: arr.data }) }
|
|
|
+ that.setData({ dialog: { title: '赛事管理', show: true, type: '2' } });
|
|
|
+ },
|
|
|
+ // 选择比赛状态
|
|
|
+ statusChange: function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.statusList[e.detail.value];
|
|
|
+ if (data) { that.setData({ 'form.status': data.value }) }
|
|
|
+ },
|
|
|
+ // 提交保存
|
|
|
+ onSubmit: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ const params = e.detail.value;
|
|
|
+ const arr = await app.$post(`/newCourt/api/race/${params._id}`, params);
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ wx.showToast({ title: `上分成功`, icon: 'error', duration: 2000 })
|
|
|
+ that.toClose()
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 关闭弹框
|
|
|
toClose: function () {
|
|
|
const that = this;
|
|
|
+ that.setData({ info: {} })
|
|
|
+ that.setData({ form: {} })
|
|
|
that.setData({ dialog: { title: '详细信息', show: false, type: '1' } })
|
|
|
+ that.watchLogin();
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|