|
@@ -4,19 +4,19 @@ Page({
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '信息维护', leftArrow: true, useBar: false },
|
|
|
form: {},
|
|
|
+ // 比赛列表
|
|
|
+ matchList: [],
|
|
|
+ // 赛事分组
|
|
|
+ groupList: [],
|
|
|
//项目类别
|
|
|
typeList: [],
|
|
|
- //性别
|
|
|
+ //性别限制
|
|
|
genderList: [],
|
|
|
- // 比赛
|
|
|
- matchList: [],
|
|
|
- // 赛事分组
|
|
|
- groupList: []
|
|
|
},
|
|
|
initValidate() {
|
|
|
- const rules = { name: { required: true }, type: { required: true }, match_id: { required: false }, group_id: { required: true }, age: { required: false }, gender: { required: false }, num: { required: false }, explain: { required: false } }
|
|
|
+ const rules = { match_id: { required: false }, group_id: { required: true }, name: { required: true }, type: { required: true }, age: { required: false }, gender: { required: true }, num: { required: true }, explain: { required: false } }
|
|
|
// 验证字段的提示信息,若不传则调用默认的信息
|
|
|
- const messages = { name: { required: '项目名称' }, match_id: { required: '比赛赛事' }, group_id: { required: '赛事分组' }, type: { required: '项目类别' }, age: { required: '人数限制' }, gender: { required: '性别限制' }, num: { required: '人数限制' }, explain: { required: '说明' } };
|
|
|
+ const messages = { match_id: { required: '比赛赛事' }, group_id: { required: '赛事分组' }, name: { required: '项目名称' }, type: { required: '项目类别' }, age: { required: '人数限制' }, gender: { required: '性别限制' }, num: { required: '人数限制' }, explain: { required: '说明' } };
|
|
|
this.WxValidate = new WxValidate(rules, messages)
|
|
|
},
|
|
|
// 返回
|
|
@@ -28,8 +28,7 @@ Page({
|
|
|
const that = this;
|
|
|
let data = that.data.genderList[e.detail.value];
|
|
|
if (data) {
|
|
|
- that.setData({ 'form.gender': data.value });
|
|
|
- that.setData({ 'form.zhGender': data.label });
|
|
|
+ that.setData({ 'form.gender': data.value, 'form.zhGender': data.label });
|
|
|
}
|
|
|
},
|
|
|
// 项目类别
|
|
@@ -37,8 +36,7 @@ Page({
|
|
|
const that = this;
|
|
|
let data = that.data.typeList[e.detail.value];
|
|
|
if (data) {
|
|
|
- that.setData({ 'form.type': data.value })
|
|
|
- that.setData({ 'form.zhType': data.label })
|
|
|
+ that.setData({ 'form.type': data.value, 'form.zhType': data.label })
|
|
|
}
|
|
|
},
|
|
|
// 比赛名称
|
|
@@ -46,8 +44,7 @@ Page({
|
|
|
const that = this;
|
|
|
let data = that.data.matchList[e.detail.value];
|
|
|
if (data) {
|
|
|
- that.setData({ 'form.match_id': data._id })
|
|
|
- that.setData({ 'form.match_name': data.name })
|
|
|
+ that.setData({ 'form.match_id': data._id, 'form.match_name': data.name })
|
|
|
}
|
|
|
},
|
|
|
// 赛事分组
|
|
@@ -55,8 +52,7 @@ Page({
|
|
|
const that = this;
|
|
|
let data = that.data.groupList[e.detail.value];
|
|
|
if (data) {
|
|
|
- that.setData({ 'form.group_id': data._id })
|
|
|
- that.setData({ 'form.group_name': data.name })
|
|
|
+ that.setData({ 'form.group_id': data._id, 'form.group_name': data.name })
|
|
|
}
|
|
|
},
|
|
|
//提交
|
|
@@ -91,10 +87,10 @@ Page({
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: async function () {
|
|
|
const that = this;
|
|
|
- let genderList = that.data.genderList;
|
|
|
- let typeList = that.data.typeList;
|
|
|
let matchList = that.data.matchList;
|
|
|
let groupList = that.data.groupList;
|
|
|
+ let typeList = that.data.typeList;
|
|
|
+ let genderList = that.data.genderList;
|
|
|
wx.getStorage({
|
|
|
key: 'user',
|
|
|
success: async res => {
|
|
@@ -110,7 +106,7 @@ Page({
|
|
|
// 项目类别
|
|
|
let type = typeList.find(i => i.value == arr.data.type);
|
|
|
if (type) arr.data.zhType = type.label;
|
|
|
- // 性别
|
|
|
+ // 性别限制
|
|
|
let gender = genderList.find(i => i.value == arr.data.gender);
|
|
|
if (gender) arr.data.zhGender = gender.label;
|
|
|
that.setData({ form: arr.data })
|