|
@@ -1,5 +1,6 @@
|
|
|
const app = getApp()
|
|
|
import { examine_status } from '../../utils/dict';
|
|
|
+import WxValidate from '../../utils/wxValidate';
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -12,7 +13,15 @@ Page({
|
|
|
list: [],
|
|
|
dialog: { title: '详细信息', show: false, type: '1' },
|
|
|
info: {},
|
|
|
- statusList: examine_status
|
|
|
+ statusList: examine_status,
|
|
|
+ projectList: [],
|
|
|
+ form: {}
|
|
|
+ },
|
|
|
+ initValidate() {
|
|
|
+ const rules = { grouping_id: { required: true }, project_id: { required: true } }
|
|
|
+ // 验证字段的提示信息,若不传则调用默认的信息
|
|
|
+ const messages = { grouping_id: { required: '请选择赛事分组' }, project_id: { required: '请选择组内项目' } };
|
|
|
+ this.WxValidate = new WxValidate(rules, messages)
|
|
|
},
|
|
|
// 跳转菜单
|
|
|
back(e) {
|
|
@@ -44,10 +53,55 @@ Page({
|
|
|
let { id } = e.currentTarget.dataset;
|
|
|
const arr = await app.$get(`/newCourt/api/enroll/${id}`);
|
|
|
if (arr.errcode == '0') {
|
|
|
- that.setData({ info: arr.data })
|
|
|
+ const ass = await app.$get(`/newCourt/api/match/${arr.data.match_id}`);
|
|
|
+ if (ass.errcode == '0') {
|
|
|
+ that.setData({ info: ass.data })
|
|
|
+ let data = { openid: ass.data.openid, match_id: ass.data._id, match_name: ass.data.name }
|
|
|
+ that.setData({ form: data })
|
|
|
+ }
|
|
|
that.setData({ dialog: { title: '信息审核', show: true, type: '2' } })
|
|
|
}
|
|
|
},
|
|
|
+ // 赛事分组
|
|
|
+ groupingChange: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.info.grouping[e.detail.value];
|
|
|
+ that.setData({ 'form.grouping_id': data._id });
|
|
|
+ that.setData({ 'form.grouping_name': data.name });
|
|
|
+ let project = [];
|
|
|
+ for (const val of data.project) {
|
|
|
+ const arr = await app.$get(`/newCourt/api/matchProject/${val}`);
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ project.push(arr.data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ that.setData({ projectList: project });
|
|
|
+ },
|
|
|
+ // 选择组内项目
|
|
|
+ projectChange: function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.projectList[e.detail.value];
|
|
|
+ that.setData({ 'form.project_id': data._id });
|
|
|
+ that.setData({ 'form.project_name': data.name });
|
|
|
+ },
|
|
|
+ onSubmit: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ const params = e.detail.value;
|
|
|
+ if (!this.WxValidate.checkForm(params)) {
|
|
|
+ const error = this.WxValidate.errorList[0];
|
|
|
+ wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ const arr = await app.$post(`/newCourt/api/enroll`, params);
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ wx.showToast({ title: `报名成功`, icon: 'success', duration: 2000 });
|
|
|
+ that.setData({ dialog: { title: '信息审核', show: false, type: '2' } })
|
|
|
+ that.watchLogin();
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
// 关闭弹框
|
|
|
toClose: function () {
|
|
|
const that = this;
|
|
@@ -58,6 +112,8 @@ Page({
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
const that = this;
|
|
|
+ //验证规则函数
|
|
|
+ that.initValidate();
|
|
|
that.watchLogin();
|
|
|
},
|
|
|
// 监听用户是否登录
|