|
@@ -101,7 +101,7 @@ Page({
|
|
|
// 监听用户是否登录
|
|
|
this.watchLogin();
|
|
|
//验证规则函数
|
|
|
- // this.initValidate();
|
|
|
+ this.initValidate();
|
|
|
},
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: function () {
|
|
@@ -136,17 +136,16 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
//验证必填项
|
|
|
- // initValidate() {
|
|
|
- // const rules = { phone: { required: true}, }
|
|
|
- // // 验证字段的提示信息,若不传则调用默认的信息
|
|
|
- // const messages = { phone: { required: '请输入手机号' }, };
|
|
|
- // this.WxValidate = new WxValidate(rules, messages)
|
|
|
- // },
|
|
|
+ initValidate() {
|
|
|
+ const rules = { match_name: { required: true }, }
|
|
|
+ // 验证字段的提示信息,若不传则调用默认的信息
|
|
|
+ const messages = { match_name: { required: '请输入比赛名称' }, };
|
|
|
+ this.WxValidate = new WxValidate(rules, messages)
|
|
|
+ },
|
|
|
//提交
|
|
|
formSubmit: function (e) {
|
|
|
var match_time = this.data.date + ' ' + this.data.time;
|
|
|
const value = e.detail.value;
|
|
|
- // console.log(value);
|
|
|
value.match_id = this.data.id;
|
|
|
value.red_id = this.data.red._id;
|
|
|
value.red_name = this.data.red.team_name;
|
|
@@ -158,38 +157,34 @@ Page({
|
|
|
value.blue_members = this.data.blue.members;
|
|
|
value.match_time = match_time;
|
|
|
console.log(value);
|
|
|
- // if (!this.WxValidate.checkForm(value)) {
|
|
|
- // const error = this.WxValidate.errorList[0];
|
|
|
- // wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
- // return false
|
|
|
- // } else {
|
|
|
- wx.getStorage({
|
|
|
- key: 'token',
|
|
|
- success: function (res) {
|
|
|
- wx.request({
|
|
|
- url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`, //接口地址
|
|
|
- method: "post",
|
|
|
- data: value,
|
|
|
- header: {},
|
|
|
- success: res => {
|
|
|
- if (res.data.errcode == 0) {
|
|
|
- wx.showToast({
|
|
|
- title: '保存成功',
|
|
|
- icon: 'success',
|
|
|
- duration: 2000//延迟两秒
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.showToast({
|
|
|
- title: '保存失败',
|
|
|
- icon: 'success',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- // }
|
|
|
+ if (!this.WxValidate.checkForm(value)) {
|
|
|
+ const error = this.WxValidate.errorList[0];
|
|
|
+ wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ wx.request({
|
|
|
+ url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`, //接口地址
|
|
|
+ method: "post",
|
|
|
+ data: value,
|
|
|
+ header: {},
|
|
|
+ success: res => {
|
|
|
+ console.log(res);
|
|
|
+ if (res.data.errcode == 0) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '保存成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 2000//延迟两秒
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: '保存失败',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
// 计算高度
|
|
|
searchHeight: function () {
|