|
@@ -2,19 +2,61 @@ const app = getApp()
|
|
import WxValidate from '../../../utils/wxValidate';
|
|
import WxValidate from '../../../utils/wxValidate';
|
|
Page({
|
|
Page({
|
|
data: {
|
|
data: {
|
|
- frameStyle: { useTop: true, name: '课程信息', leftArrow: true, useBar: false },
|
|
|
|
|
|
+ frameStyle: { useTop: true, name: '信息维护', leftArrow: true, useBar: false },
|
|
|
|
+ // 教练和学校的关系
|
|
|
|
+ schoolInfo: {},
|
|
form: {},
|
|
form: {},
|
|
|
|
+ statusList: []
|
|
},
|
|
},
|
|
initValidate() {
|
|
initValidate() {
|
|
- const rules = { salary: { required: false } }
|
|
|
|
|
|
+ const rules = { title: { required: true }, start_date: { required: true }, start_time: { required: true }, end_date: { required: true }, end_time: { required: true }, brief: { required: true }, money: { required: true }, limit: { required: true }, refund_date: { required: false }, refund_time: { required: false } }
|
|
// 验证字段的提示信息,若不传则调用默认的信息
|
|
// 验证字段的提示信息,若不传则调用默认的信息
|
|
- const messages = { salary: { required: '请输入提现金额' } };
|
|
|
|
|
|
+ const messages = { title: { required: '课程标题' }, start_date: { required: '课程开始日期' }, start_time: { required: '课程开始时间' }, end_date: { required: '课程结束日期' }, end_time: { required: '课程结束时间' }, brief: { required: '请输入课程简介' }, money: { required: '报名费用' }, limit: { required: '人数限制' }, refund_date: { required: '退款期限日期' }, refund_time: { required: '退款期限时间' } };
|
|
this.WxValidate = new WxValidate(rules, messages)
|
|
this.WxValidate = new WxValidate(rules, messages)
|
|
},
|
|
},
|
|
// 返回
|
|
// 返回
|
|
back: function () {
|
|
back: function () {
|
|
wx.navigateBack({ delta: 1 })
|
|
wx.navigateBack({ delta: 1 })
|
|
},
|
|
},
|
|
|
|
+ // 课程开始日期
|
|
|
|
+ startdChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ 'form.start_date': e.detail.value })
|
|
|
|
+ },
|
|
|
|
+ // 课程开始时间
|
|
|
|
+ starttChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ 'form.start_time': e.detail.value })
|
|
|
|
+ },
|
|
|
|
+ // 课程结束日期
|
|
|
|
+ enddChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ 'form.end_date': e.detail.value })
|
|
|
|
+ },
|
|
|
|
+ // 课程结束时间
|
|
|
|
+ endtChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ 'form.end_time': e.detail.value })
|
|
|
|
+ },
|
|
|
|
+ // 退款期限日期
|
|
|
|
+ refunddChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ 'form.refund_date': e.detail.value })
|
|
|
|
+ },
|
|
|
|
+ // 退款期限时间
|
|
|
|
+ refundtChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ 'form.refund_time': e.detail.value })
|
|
|
|
+ },
|
|
|
|
+ // 选择状态
|
|
|
|
+ statusChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ let data = that.data.statusList[e.detail.value];
|
|
|
|
+ if (data) {
|
|
|
|
+ that.setData({ 'form.status': data.value })
|
|
|
|
+ that.setData({ 'form.zhStatus': data.label })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
//提交
|
|
//提交
|
|
onSubmit: async function (e) {
|
|
onSubmit: async function (e) {
|
|
const that = this;
|
|
const that = this;
|
|
@@ -24,10 +66,14 @@ Page({
|
|
wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
return false
|
|
return false
|
|
} else {
|
|
} else {
|
|
- console.log(params);
|
|
|
|
- // const arr = await app.$post(`/billApply`, params)
|
|
|
|
- // if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
|
|
|
|
- // else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
|
|
|
+ params.time_start = params.start_date + '-' + params.start_time;
|
|
|
|
+ params.time_end = params.end_date + '-' + params.end_time;
|
|
|
|
+ params.refund_hour = params.refund_date + '-' + params.refund_time;
|
|
|
|
+ let arr;
|
|
|
|
+ if (params._id) { arr = await app.$post(`/lesson/${params._id}`, params) }
|
|
|
|
+ else { arr = await app.$post(`/lesson`, params) }
|
|
|
|
+ if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
|
|
|
|
+ else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
}
|
|
}
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
@@ -43,31 +89,49 @@ Page({
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
await that.watchLogin();
|
|
await that.watchLogin();
|
|
},
|
|
},
|
|
- // 查询其他信息
|
|
|
|
- searchOther: function () {
|
|
|
|
- const that = this;
|
|
|
|
- let arr;
|
|
|
|
- },
|
|
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
watchLogin: async function () {
|
|
watchLogin: async function () {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ let statusList = that.data.statusList;
|
|
wx.getStorage({
|
|
wx.getStorage({
|
|
key: 'user',
|
|
key: 'user',
|
|
success: async res => {
|
|
success: async res => {
|
|
let data = res.data;
|
|
let data = res.data;
|
|
- // 教练与学校的关系
|
|
|
|
- // const school = await app.$get(`/rcs`, { coach_id: form.coach_id });
|
|
|
|
- // if (school.errcode == '0' && school.total > 0) { form.school_id = school.data[0].school_id }
|
|
|
|
- // let form = { coach_id: data.info.id };
|
|
|
|
|
|
+ let arr;
|
|
|
|
+ // 教练与学校关系
|
|
|
|
+ arr = await app.$get(`/rcs`, { coach_id: data.info._id });
|
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ schoolInfo: arr.data[0] });
|
|
|
|
+ let form = { school_id: that.data.schoolInfo.school_id, type: '1' };
|
|
|
|
+ if (that.data.id) {
|
|
|
|
+ arr = await app.$get(`/lesson/${that.data.id}`);
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ arr.data.start_date = arr.data.time_start.slice(0, 10);
|
|
|
|
+ arr.data.start_time = arr.data.time_start.slice(11, arr.data.time_start.length);
|
|
|
|
+ arr.data.end_date = arr.data.time_end.slice(0, 10);
|
|
|
|
+ arr.data.end_time = arr.data.time_end.slice(11, arr.data.time_end.length);
|
|
|
|
+ arr.data.refund_date = arr.data.refund_hour.slice(0, 10);
|
|
|
|
+ arr.data.refund_time = arr.data.refund_hour.slice(11, arr.data.refund_hour.length);
|
|
|
|
+ // 查询状态
|
|
|
|
+ let status = statusList.find(i => i.value = arr.data.status);
|
|
|
|
+ if (status) arr.data.zhStatus = status.label;
|
|
|
|
+ form = arr.data;
|
|
|
|
|
|
- // else { wx.showToast({ title: `缺少必要信息`, icon: 'error', duration: 2000 }) };
|
|
|
|
- // that.setData({ form })
|
|
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ that.setData({ form: form })
|
|
},
|
|
},
|
|
fail: async res => {
|
|
fail: async res => {
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ // 查询其他信息
|
|
|
|
+ searchOther: async function () {
|
|
|
|
+ const that = this;
|
|
|
|
+ let arr;
|
|
|
|
+ arr = await app.$get(`/dict`, { code: 'lesson_status' });
|
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list })
|
|
|
|
+ },
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
*/
|