|
@@ -8,14 +8,16 @@ Page({
|
|
|
form: { logo: [] },
|
|
|
// 状态列表
|
|
|
statusList: [],
|
|
|
+ // 类别列表
|
|
|
+ typeList: []
|
|
|
},
|
|
|
initValidate() {
|
|
|
const rules = {
|
|
|
- logo: { required: true }, name: { required: true }, start_time: { required: true }, end_time: { required: true }, address: { required: true }, sign_time: { required: true }, contact: { required: true }, status: { required: true }
|
|
|
+ belong_id: { required: false }, logo: { required: true }, name: { required: true }, start_time: { required: true }, end_time: { required: true }, address: { required: true }, sign_time: { required: true }, contact: { required: true }, status: { required: true }
|
|
|
}
|
|
|
// 验证字段的提示信息,若不传则调用默认的信息
|
|
|
const messages = {
|
|
|
- logo: { required: 'logo' }, name: { required: '比赛名称' }, start_time: { required: '比赛开始时间' }, end_time: { required: '比赛结束时间' }, address: { required: '比赛地点' }, sign_time: { required: '报名截止时间' }, contact: { required: '联系方式' }, status: { required: '比赛状态' },
|
|
|
+ belong_id: { required: '属于id' }, logo: { required: 'logo' }, name: { required: '比赛名称' }, start_time: { required: '比赛开始时间' }, end_time: { required: '比赛结束时间' }, address: { required: '比赛地点' }, sign_time: { required: '报名截止时间' }, contact: { required: '联系方式' }, status: { required: '比赛状态' },
|
|
|
};
|
|
|
this.WxValidate = new WxValidate(rules, messages)
|
|
|
},
|
|
@@ -38,7 +40,7 @@ Page({
|
|
|
// 确认选择
|
|
|
datetimeChange: function (e) {
|
|
|
const that = this;
|
|
|
- that.setData({ [`form.${e.detail.fieldValue}`]: e.detail.datetime });
|
|
|
+ that.setData({ [`form.${e.detail.name}`]: e.detail.datetime });
|
|
|
},
|
|
|
// 选择状态
|
|
|
statusChange: function (e) {
|
|
@@ -46,7 +48,16 @@ Page({
|
|
|
let data = that.data.statusList[e.detail.value];
|
|
|
if (data) {
|
|
|
that.setData({ 'form.status': data.value });
|
|
|
- that.setData({ 'form.zhstatus': data.label });
|
|
|
+ that.setData({ 'form.zhStatus': data.label });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 赛事类别
|
|
|
+ typeChange: function (e) {
|
|
|
+ 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 });
|
|
|
}
|
|
|
},
|
|
|
//赛事规程
|
|
@@ -58,11 +69,9 @@ Page({
|
|
|
toSubmit: async function (e) {
|
|
|
const that = this;
|
|
|
const form = that.data.form;
|
|
|
- const params = e.detail.value;
|
|
|
- params.start_time = form.start_time;
|
|
|
- params.end_time = form.end_time;
|
|
|
- params.sign_time = form.sign_time;
|
|
|
- params.logo = form.logo;
|
|
|
+ let params = e.detail.value;
|
|
|
+ const { start_time, end_time, sign_time, logo, regular } = form
|
|
|
+ params = { ...params, start_time, end_time, sign_time, logo, regular }
|
|
|
if (!this.WxValidate.checkForm(params)) {
|
|
|
const error = this.WxValidate.errorList[0];
|
|
|
wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
@@ -78,13 +87,23 @@ Page({
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: function (options) {
|
|
|
+ onLoad: async function (options) {
|
|
|
const that = this;
|
|
|
that.setData({ id: options.id || '' })
|
|
|
//验证规则函数
|
|
|
that.initValidate();
|
|
|
+ // 查询其他信息
|
|
|
+ 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 () {
|
|
@@ -92,14 +111,15 @@ Page({
|
|
|
wx.getStorage({
|
|
|
key: 'user',
|
|
|
success: async res => {
|
|
|
- const aee = await app.$get(`/dict`, { code: "match_status" });
|
|
|
- if (aee.errcode == '0' && aee.total > 0) that.setData({ statusList: aee.data[0].list });
|
|
|
if (that.data.id) {
|
|
|
- const arr = await app.$get(`/match/${that.data.id}`, 'race');
|
|
|
+ const arr = await app.$get(`/match/${that.data.id}`, {}, 'race');
|
|
|
if (arr.errcode == '0') {
|
|
|
// 比赛状态
|
|
|
- let status = statusList.find(i => i.value == arr.data.status)
|
|
|
+ let status = that.data.statusList.find(i => i.value == arr.data.status)
|
|
|
if (status) arr.data.zhStatus = status.label;
|
|
|
+ // 赛事类别
|
|
|
+ let type = that.data.typeList.find(i => i.value == arr.data.type)
|
|
|
+ if (type) arr.data.zhtype = type.label;
|
|
|
that.setData({ form: arr.data });
|
|
|
}
|
|
|
}
|