...
|
...
|
@@ -31,56 +31,56 @@ Page({ |
|
|
// checked_student: [],
|
|
|
},
|
|
|
chooseChildren(e) {
|
|
|
console.log(e,e.detail);
|
|
|
// console.log(e,e.detail);
|
|
|
// const current = e.currentTarget.dataset.index;
|
|
|
const that = this;
|
|
|
var index_arr = e.detail.value;
|
|
|
console.log(index_arr)
|
|
|
// console.log(index_arr)
|
|
|
//新建数组全部设置为没被选中
|
|
|
var new_arr = [];
|
|
|
console.log('选择时学员', that.data.student_list);
|
|
|
// console.log('选择时学员', that.data.student_list);
|
|
|
that.data.student_list.forEach((item) => {
|
|
|
new_arr.push({ ...item, checked: false })
|
|
|
});//给每一项添加checked属性
|
|
|
console.log('new_arr',new_arr);
|
|
|
// console.log('new_arr',new_arr);
|
|
|
var new_itmes = new_arr;
|
|
|
console.log('new_itmes', new_itmes);
|
|
|
// console.log('new_itmes', new_itmes);
|
|
|
if(that.data.student_num >=2) { //两个学员预约时
|
|
|
console.log('两个学员');
|
|
|
// console.log('两个学员');
|
|
|
if (index_arr.length > 2) {
|
|
|
//取出倒数两个值
|
|
|
var key1 = index_arr[index_arr.length - 1];
|
|
|
var key2 = index_arr[index_arr.length - 2];
|
|
|
// var key3 = skin[skin.length - 3];
|
|
|
// console.log(key1, key2, key3);
|
|
|
console.log(key1, key2);
|
|
|
console.log(new_itmes[key1]['checked'],new_itmes[key1].id,new_itmes[key2].id);
|
|
|
// console.log(key1, key2);
|
|
|
// console.log(new_itmes[key1]['checked'],new_itmes[key1].id,new_itmes[key2].id);
|
|
|
//设置最后两个值为选中状态
|
|
|
new_itmes[key1]['checked'] = true
|
|
|
new_itmes[key2]['checked'] = true
|
|
|
// new_itmes[key3 - 1]['checked'] = 'true'
|
|
|
//删除被选中的第一个值
|
|
|
index_arr.splice(0, 1);
|
|
|
console.log('skin',index_arr);
|
|
|
// console.log('skin',index_arr);
|
|
|
const id_arr = [];
|
|
|
id_arr.push(new_itmes[key1].id,new_itmes[key2].id);
|
|
|
that.setData({student_id: id_arr.join(','),is_choose_student:true});
|
|
|
console.log('student_id', that.data.student_id);
|
|
|
// console.log('student_id', that.data.student_id);
|
|
|
} else {
|
|
|
//被选中少于两个,直接设置被选中
|
|
|
const checked_student = [];
|
|
|
for (var i = 0; i < index_arr.length; i++) {
|
|
|
var key = index_arr[i]
|
|
|
console.log('key', key);
|
|
|
// console.log('key', key);
|
|
|
new_itmes[key]['checked'] = true;
|
|
|
}
|
|
|
console.log('选一个时候new_itmes', new_itmes);
|
|
|
// console.log('选一个时候new_itmes', new_itmes);
|
|
|
new_itmes.forEach((item) => {
|
|
|
if(item.checked) {
|
|
|
checked_student.push(item)
|
|
|
}
|
|
|
});
|
|
|
console.log('选择学员length', checked_student,checked_student.length);
|
|
|
// console.log('选择学员length', checked_student,checked_student.length);
|
|
|
if(checked_student.length>=2) {
|
|
|
const arr = [];
|
|
|
new_itmes.forEach((item) => {
|
...
|
...
|
@@ -93,7 +93,7 @@ Page({ |
|
|
wx.showToast({title:'请选择两个学员!',icon:'none'});
|
|
|
that.setData({student_id: new_itmes[key].id,is_choose_student:true});
|
|
|
}
|
|
|
console.log('student_id', that.data.student_id);
|
|
|
// console.log('student_id', that.data.student_id);
|
|
|
}
|
|
|
//存入
|
|
|
that.setData({
|
...
|
...
|
@@ -102,26 +102,26 @@ Page({ |
|
|
student_list: new_itmes,
|
|
|
})
|
|
|
}else if(that.data.student_num <2){ //一个学员预约时
|
|
|
console.log('一个学员');
|
|
|
// console.log('一个学员');
|
|
|
if (index_arr.length > 1) {
|
|
|
//取出倒数一个值
|
|
|
var key1 = index_arr[index_arr.length - 1];
|
|
|
// var key2 = skin[skin.length - 2];
|
|
|
// var key3 = skin[skin.length - 3];
|
|
|
// console.log(key1, key2, key3);
|
|
|
console.log(key1);
|
|
|
console.log(new_itmes[key1]['checked'],new_itmes[key1].id);
|
|
|
// console.log(key1);
|
|
|
// console.log(new_itmes[key1]['checked'],new_itmes[key1].id);
|
|
|
//设置最后一个值为选中状态
|
|
|
new_itmes[key1]['checked'] = true
|
|
|
// new_itmes[key2]['checked'] = true
|
|
|
// new_itmes[key3 - 1]['checked'] = 'true'
|
|
|
//删除被选中的第一个值
|
|
|
index_arr.splice(0, 1);
|
|
|
console.log('skin',index_arr);
|
|
|
// console.log('skin',index_arr);
|
|
|
that.setData({student_id: new_itmes[key1].id,is_choose_student:true});
|
|
|
console.log('student_id', that.data.student_id);
|
|
|
// console.log('student_id', that.data.student_id);
|
|
|
} else {
|
|
|
console.log('111');
|
|
|
// console.log('111');
|
|
|
//被选中少于1个,直接设置被选中
|
|
|
// new_itmes.forEach((item,index) => {
|
|
|
// if(item.id === that.data.student_id) {
|
...
|
...
|
@@ -129,15 +129,15 @@ Page({ |
|
|
// }
|
|
|
// });
|
|
|
for (var i = 0; i < index_arr.length; i++) {
|
|
|
console.log('222',index_arr,i);
|
|
|
// console.log('222',index_arr,i);
|
|
|
var key = index_arr[i]
|
|
|
console.log('key', key);
|
|
|
// console.log('key', key);
|
|
|
new_itmes[key]['checked'] = true
|
|
|
that.setData({student_id: new_itmes[key].id,is_choose_student:true});
|
|
|
}
|
|
|
index_arr = []
|
|
|
console.log('333');
|
|
|
console.log('student_id', that.data.student_id);
|
|
|
// console.log('333');
|
|
|
// console.log('student_id', that.data.student_id);
|
|
|
}
|
|
|
//存入
|
|
|
that.setData({
|
...
|
...
|
@@ -150,13 +150,13 @@ Page({ |
|
|
},
|
|
|
//提交预约
|
|
|
formSubmit(e) {
|
|
|
console.log('预约学生人数',this.data.student_num,e.detail);
|
|
|
// console.log('预约学生人数',this.data.student_num,e.detail);
|
|
|
if(this.data.student_list.length === 0) {
|
|
|
wx.showToast({title: '请添加学员!',icon:'none'})
|
|
|
}else if(!this.data.is_choose_student) {
|
|
|
wx.showToast({title: '请选择学员!',icon:'none'})
|
|
|
}else if(this.data.student_num>=2 && ('' + this.data.student_id).indexOf(',') === -1) {
|
|
|
console.log('检验student_id',('' + this.data.student_id).indexOf(','));
|
|
|
// console.log('检验student_id',('' + this.data.student_id).indexOf(','));
|
|
|
wx.showToast({title:'请选择两个学员!',icon:'none'})
|
|
|
} else {
|
|
|
// this.setData({'modal_data.is_showModal': true})
|
...
|
...
|
@@ -173,7 +173,7 @@ Page({ |
|
|
students: this.data.student_id,
|
|
|
};
|
|
|
app.post(url,params,header).then((res) => {
|
|
|
console.log('提交预约信息',res);
|
|
|
// console.log('提交预约信息',res);
|
|
|
if(res.data.card_modal === 1) {
|
|
|
this.setData({'modal_data.is_showModal': true});
|
|
|
}else if(res.data.reservation_modal === 1) {
|
...
|
...
|
@@ -217,115 +217,70 @@ Page({ |
|
|
reservation_id: this.data.reservation_id,
|
|
|
};
|
|
|
app.post(url,params,header).then((res) => {
|
|
|
console.log('预约信息',res);
|
|
|
// console.log('预约信息',res);
|
|
|
var arr = [];
|
|
|
for (let i in res.list) {
|
|
|
arr.push(res.list[i]); //属性
|
|
|
//arr.push(obj[i]); //值
|
|
|
}//对象转数组
|
|
|
console.log('arr',arr);
|
|
|
// console.log('arr',arr);
|
|
|
var new_arr = [];
|
|
|
arr.forEach((item) => {
|
|
|
new_arr.push({ ...item, checked: false })
|
|
|
});//给每一项添加checked属性
|
|
|
console.log(new_arr);
|
|
|
// console.log(new_arr);
|
|
|
this.setData({
|
|
|
student_list: new_arr,
|
|
|
new_arr:new_arr,
|
|
|
session_info: res.session_info,
|
|
|
})
|
|
|
console.log('student_list', this.data.student_list);
|
|
|
// console.log('student_list', this.data.student_list);
|
|
|
})
|
|
|
},
|
|
|
//获取学员列表
|
|
|
getStudentList() {
|
|
|
const self = this;
|
|
|
console.log('预约学生人数',this.data.student_num);
|
|
|
// console.log('预约学生人数',this.data.student_num);
|
|
|
self.setData({is_choose_student: true});
|
|
|
console.log('返回时的学生列表预约信息自带的学员', self.data.student_list);
|
|
|
// console.log('返回时的学生列表预约信息自带的学员', self.data.student_list);
|
|
|
const buy_arr = [];
|
|
|
self.data.student_list.forEach((item) => {
|
|
|
buy_arr.push({ ...item, checked: false })
|
|
|
});//给每一项添加checked属性
|
|
|
console.log('buy_arr', buy_arr);
|
|
|
// console.log('buy_arr', buy_arr);
|
|
|
this.setData({
|
|
|
student_list: buy_arr,
|
|
|
// new_arr:buy_arr,
|
|
|
// session_info: res.session_info,
|
|
|
})
|
|
|
this.refreshBuyState();
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('预约学生人数',this.data.student_num);
|
|
|
// self.setData({is_choose_student: true})
|
|
|
// console.log('返回时的学生列表预约信息自带的学员', self.data.student_list);
|
|
|
// let url = '/user/Student/student_list';
|
|
|
// let header = {
|
|
|
// "XX-token": wx.getStorageSync('token')
|
|
|
// };
|
|
|
// let params = {
|
|
|
// page: 2,
|
|
|
// };
|
|
|
// app.post(url,params,header).then((res) => {
|
|
|
// console.log('学员列表',res);
|
|
|
//
|
|
|
// var arr = [];
|
|
|
// for (let i in res.list) {
|
|
|
// arr.push(res.list[i]); //属性
|
|
|
// //arr.push(obj[i]); //值
|
|
|
// }//对象转数组
|
|
|
// console.log('arr',arr);
|
|
|
// var new_arr = [];
|
|
|
// arr.forEach((item) => {
|
|
|
// new_arr.push({ ...item, checked: false })
|
|
|
// });//给每一项添加checked属性
|
|
|
// console.log('new_arr',new_arr);
|
|
|
// this.setData({
|
|
|
// student_list: new_arr,
|
|
|
// new_arr:new_arr,
|
|
|
// // session_info: res.session_info,
|
|
|
// })
|
|
|
// console.log('student_list', this.data.student_list);
|
|
|
// this.refreshBuyState();
|
|
|
|
|
|
// res.list.forEach((item) => {
|
|
|
// if(item.time !== '') {
|
|
|
// self.data.student_list.forEach((item) => {
|
|
|
// new_arr.push({ ...item, checked: false })
|
|
|
// });//给每一项添加checked属性
|
|
|
|
|
|
// }
|
|
|
// })
|
|
|
// this.setData({student_list: res.list})
|
|
|
// })
|
|
|
},
|
|
|
//更新购买状态
|
|
|
refreshBuyState() {
|
|
|
console.log('更新购买状态---学生id--人数',this.data.student_num,this.data.is_buy,this.data.choose_student_id);
|
|
|
// console.log('更新购买状态---学生id--人数',this.data.student_num,this.data.is_buy,this.data.choose_student_id);
|
|
|
if(this.data.is_buy) {
|
|
|
if(this.data.student_num<2) {
|
|
|
this.data.student_list.forEach((item) => {
|
|
|
item.checked = false;
|
|
|
if (item.id === this.data.choose_student_id) {
|
|
|
console.log('item.id', item.id);
|
|
|
// console.log('item.id', item.id);
|
|
|
item.checked = true;
|
|
|
}
|
|
|
});
|
|
|
this.setData({student_list:this.data.student_list,is_choose_student:true})
|
|
|
console.log('student_list',this.data.student_list);
|
|
|
// console.log('student_list',this.data.student_list);
|
|
|
}else if(this.data.student_num>=2) {
|
|
|
console.log('购买完进入两个学员student_list',this.data.student_list);
|
|
|
// console.log('购买完进入两个学员student_list',this.data.student_list);
|
|
|
this.data.student_list.forEach((item) => {
|
|
|
item.checked = false;
|
|
|
if (item.id === this.data.choose_student_id) {
|
|
|
console.log('item.id', item.id);
|
|
|
// console.log('item.id', item.id);
|
|
|
item.checked = true;
|
|
|
// total_student_num.push(item)
|
|
|
}
|
|
|
});
|
|
|
this.setData({student_list:this.data.student_list,is_choose_student:true,});
|
|
|
console.log('student_list',this.data.student_list);
|
|
|
// console.log('student_list',this.data.student_list);
|
|
|
}
|
|
|
}
|
|
|
},
|
...
|
...
|
@@ -334,8 +289,8 @@ Page({ |
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
const self =this;
|
|
|
console.log('load');
|
|
|
console.log(options);
|
|
|
// console.log('load');
|
|
|
// console.log(options);
|
|
|
self.setData({
|
|
|
experiment_id: +options.experiment_id?+options.experiment_id:'',
|
|
|
session_id: +options.session_id?+options.session_id:'',
|
...
|
...
|
@@ -356,7 +311,7 @@ Page({ |
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function() {
|
|
|
console.log('show');
|
|
|
// console.log('show');
|
|
|
const self = this;
|
|
|
self.setData({is_choose_student: false});
|
|
|
self.getStudentList();
|
...
|
...
|
|