|
@@ -33,6 +33,13 @@ Page({
|
|
// 赛制储存信息
|
|
// 赛制储存信息
|
|
szList: [],
|
|
szList: [],
|
|
},
|
|
},
|
|
|
|
+ //验证是否输入
|
|
|
|
+ initValidate() {
|
|
|
|
+ const rules = { name: { required: true }, match_time: { required: true, }, single_time: { required: true }, address: { required: true, }, format: { required: true } }
|
|
|
|
+ // 验证字段的提示信息,若不传则调用默认的信息
|
|
|
|
+ const messages = { name: { required: '请输入比赛名称', }, match_time: { required: '请输入时间', }, single_time: { required: '请输入单场时间', }, address: { required: '请输入地点', }, format: { required: '请选择赛制', } };
|
|
|
|
+ this.WxValidate = new WxValidate(rules, messages)
|
|
|
|
+ },
|
|
//当用户点击确定时,执行的事件
|
|
//当用户点击确定时,执行的事件
|
|
bindCatePickerChange: function (e) {
|
|
bindCatePickerChange: function (e) {
|
|
var cid = this.data.cateArray[e.detail.value].id;
|
|
var cid = this.data.cateArray[e.detail.value].id;
|
|
@@ -100,25 +107,12 @@ Page({
|
|
//提交
|
|
//提交
|
|
formSubmit: function (e) {
|
|
formSubmit: function (e) {
|
|
const value = e.detail.value;
|
|
const value = e.detail.value;
|
|
- var cateIndex =this.data.cateIndex
|
|
|
|
- var id = this.ids;
|
|
|
|
- var name = value.name;
|
|
|
|
- var match_time = this.data.starttime + ' - ' + this.data.endtime;
|
|
|
|
- var single_time = this.data.timedate + ' ' + this.data.time;
|
|
|
|
- var address = value.address;
|
|
|
|
- var format = this.data.szList;
|
|
|
|
- // var match_team = this.form.match_team;
|
|
|
|
- const params = {
|
|
|
|
- "id": id,
|
|
|
|
- "name": name,
|
|
|
|
- "match_time": match_time,
|
|
|
|
- "single_time": single_time,
|
|
|
|
- "address": address,
|
|
|
|
- "format": format,
|
|
|
|
- "match_team": [],
|
|
|
|
- "status": cateIndex
|
|
|
|
- };
|
|
|
|
- if (!this.WxValidate.checkForm(params)) {
|
|
|
|
|
|
+ value.match_time = this.data.starttime + ' - ' + this.data.endtime;
|
|
|
|
+ value.single_time = this.data.timedate + ' ' + this.data.time;
|
|
|
|
+ value.format = this.data.szList;
|
|
|
|
+ value.status = this.data.cateIndex;
|
|
|
|
+ var id = this.data.ids;
|
|
|
|
+ if (!this.WxValidate.checkForm(value)) {
|
|
const error = this.WxValidate.errorList[0];
|
|
const error = this.WxValidate.errorList[0];
|
|
wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
return false
|
|
return false
|
|
@@ -127,20 +121,12 @@ Page({
|
|
key: 'token',
|
|
key: 'token',
|
|
success: function (res) {
|
|
success: function (res) {
|
|
wx.request({
|
|
wx.request({
|
|
- url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`, //接口地址
|
|
|
|
|
|
+ url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`,
|
|
method: 'post',
|
|
method: 'post',
|
|
- data: params,
|
|
|
|
|
|
+ data: value,
|
|
success(res) {
|
|
success(res) {
|
|
- if (res.data.errcode == 0) {
|
|
|
|
- wx.showToast({ title: `修改比赛成功`, icon: 'success', duration: 2000 }) //创建成功提示
|
|
|
|
- // wx.navigateTo({ url: '/pages/administration/index' })// 跳转页面
|
|
|
|
- } else {
|
|
|
|
- wx.showToast({
|
|
|
|
- title: res.data.errmsg,
|
|
|
|
- icon: 'none',
|
|
|
|
- duration: 2000
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ console.log(res.data.data);
|
|
|
|
+ wx.showToast({ title: `修改比赛成功`, icon: 'success', duration: 2000 })
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -154,65 +140,42 @@ Page({
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
- this.ids = options.id;
|
|
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ ids: options.id })
|
|
//选择器
|
|
//选择器
|
|
- var cindex = this.data.cateIndex
|
|
|
|
- type = this.data.cateArray[cindex].id
|
|
|
|
|
|
+ var cindex = that.data.cateIndex
|
|
|
|
+ type = that.data.cateArray[cindex].id
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
- this.watchLogin();
|
|
|
|
|
|
+ that.watchLogin();
|
|
//验证规则函数
|
|
//验证规则函数
|
|
- this.initValidate()
|
|
|
|
|
|
+ that.initValidate()
|
|
// 计算高度
|
|
// 计算高度
|
|
- this.searchHeight()
|
|
|
|
- const that = this;
|
|
|
|
|
|
+ that.searchHeight()
|
|
// 初始化数据
|
|
// 初始化数据
|
|
that.search();
|
|
that.search();
|
|
},
|
|
},
|
|
- //验证是否输入
|
|
|
|
- initValidate() {
|
|
|
|
- const rules = { name: { required: true }, match_time: { required: true, }, single_time: { required: true }, address: { required: true, }, format: { required: true } }
|
|
|
|
- // 验证字段的提示信息,若不传则调用默认的信息
|
|
|
|
- const messages = { name: { required: '请输入比赛名称', }, match_time: { required: '请输入时间', }, single_time: { required: '请输入单场时间', }, address: { required: '请输入地点', }, format: { required: '请选择赛制', } };
|
|
|
|
- this.WxValidate = new WxValidate(rules, messages)
|
|
|
|
- },
|
|
|
|
|
|
+
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
watchLogin: function () {
|
|
watchLogin: function () {
|
|
|
|
+ var that = this;
|
|
|
|
+ var id = that.data.ids;
|
|
wx.getStorage({
|
|
wx.getStorage({
|
|
key: 'token',
|
|
key: 'token',
|
|
success: res => {
|
|
success: res => {
|
|
- var that = this;
|
|
|
|
- var id = that.ids;
|
|
|
|
wx.request({
|
|
wx.request({
|
|
- url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`, //接口地址
|
|
|
|
|
|
+ url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`,
|
|
method: 'get',
|
|
method: 'get',
|
|
- // data: {},
|
|
|
|
|
|
+ data: {},
|
|
success(res) {
|
|
success(res) {
|
|
- if (res.data.errcode == 0) {
|
|
|
|
- let datas = res.data.data
|
|
|
|
- let timer = res.data.data.single_time
|
|
|
|
- let date = res.data.data.match_time
|
|
|
|
- let status = res.data.data.status
|
|
|
|
- let szList = res.data.data.format
|
|
|
|
- let timedate = timer.substring(0, 10)
|
|
|
|
- let time = timer.substring(11, 16)
|
|
|
|
- let starttime = date.substring(0, 10)
|
|
|
|
- let endtime = date.substring(16, 28)
|
|
|
|
- that.setData({
|
|
|
|
- form: datas,
|
|
|
|
- timedate: timedate,
|
|
|
|
- time: time,
|
|
|
|
- starttime: starttime,
|
|
|
|
- endtime: endtime,
|
|
|
|
- cateIndex: status,
|
|
|
|
- szList: szList
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- wx.showToast({
|
|
|
|
- title: res.data.errmsg,
|
|
|
|
- icon: 'none',
|
|
|
|
- duration: 2000
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ that.setData({
|
|
|
|
+ form: res.data.data,
|
|
|
|
+ timedate: res.data.data.single_time.substring(0, 10),
|
|
|
|
+ time: res.data.data.single_time.substring(11, 16),
|
|
|
|
+ starttime: res.data.data.match_time.substring(0, 10),
|
|
|
|
+ endtime: res.data.data.match_time.substring(13, 28),
|
|
|
|
+ cateIndex: res.data.data.status,
|
|
|
|
+ szList: res.data.data.format
|
|
|
|
+ });
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -237,7 +200,7 @@ Page({
|
|
// 是否减去底部菜单
|
|
// 是否减去底部菜单
|
|
if (frameStyle.useBar) infoHeight = infoHeight - 50;
|
|
if (frameStyle.useBar) infoHeight = infoHeight - 50;
|
|
if (infoHeight) this.setData({ infoHeight: infoHeight })
|
|
if (infoHeight) this.setData({ infoHeight: infoHeight })
|
|
-},
|
|
|
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|