|
@@ -7,7 +7,8 @@ const app = getApp();
|
|
|
|
|
|
|
|
|
Page({
|
|
|
- data: {
|
|
|
+ data: {
|
|
|
+ bookServantList:[],
|
|
|
consultList: [],
|
|
|
questionList: [],
|
|
|
imgList: [],
|
|
@@ -46,15 +47,26 @@ Page({
|
|
|
// type:options.type
|
|
|
});
|
|
|
}
|
|
|
+ this.getOrderDetail();
|
|
|
},
|
|
|
getOrderDetail() {
|
|
|
util.request(api.getTradeOrderList, {
|
|
|
bookDetailId: this.data.bookTradeNo
|
|
|
}, 'GET').then(res => {
|
|
|
if (res.errno === 0) {
|
|
|
- console.log(res);
|
|
|
+ console.log(res);
|
|
|
+ let svlist=res.data.bookServantList;
|
|
|
+ svlist.forEach(s=>{
|
|
|
+ s.consultList= [];
|
|
|
+ s.questionList= [];
|
|
|
+ s.imgList= [];
|
|
|
+ s.satisfy= '';
|
|
|
+ s.detail='';
|
|
|
+ s.remark='';
|
|
|
+ })
|
|
|
this.setData({
|
|
|
- tradeOrder: res.data,
|
|
|
+ tradeOrder: res.data,
|
|
|
+ bookServantList:svlist,
|
|
|
isCanSumit: true,
|
|
|
qrImg:res.data.qrUrl
|
|
|
});
|
|
@@ -82,9 +94,15 @@ Page({
|
|
|
item.checked = false;
|
|
|
});
|
|
|
|
|
|
+ let dd= this.data.bookServantList;
|
|
|
+ dd.forEach(s=>{
|
|
|
+ s.consultList=JSON.parse(JSON.stringify(list));;
|
|
|
+ })
|
|
|
+
|
|
|
this.setData({
|
|
|
- consultList: list
|
|
|
- });
|
|
|
+ consultList: list,
|
|
|
+ });
|
|
|
+
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
title: res.errmsg,
|
|
@@ -98,52 +116,88 @@ Page({
|
|
|
},
|
|
|
questionClick(e) {
|
|
|
let checked = e.currentTarget.dataset.checked;
|
|
|
- let index = e.currentTarget.dataset.index;
|
|
|
- let item = `consultList[${index}].checked`;
|
|
|
- this.setData({
|
|
|
- [item]: !checked
|
|
|
- });
|
|
|
- let current = this.data.consultList.filter(item => {
|
|
|
- return item.checked
|
|
|
- });
|
|
|
- this.setData({
|
|
|
- questionList: current
|
|
|
- });
|
|
|
+ let index = e.currentTarget.dataset.index;
|
|
|
+
|
|
|
+ let bkindex = e.currentTarget.dataset.bkindex;
|
|
|
+ let dd=this.data.bookServantList;
|
|
|
+ dd[bkindex].consultList[index].checked=!checked;
|
|
|
+
|
|
|
+ let current = dd[bkindex].consultList.filter((item) => {
|
|
|
+ return item.checked;
|
|
|
+ });
|
|
|
+ dd[bkindex].questionList=current;
|
|
|
+ this.setData({
|
|
|
+ bookServantList: dd
|
|
|
+ });
|
|
|
+
|
|
|
+ // let item = `consultList[${index}].checked`;
|
|
|
+ // this.setData({
|
|
|
+ // [item]: !checked
|
|
|
+ // });
|
|
|
+ // let current = this.data.consultList.filter(item => {
|
|
|
+ // return item.checked
|
|
|
+ // });
|
|
|
+ // this.setData({
|
|
|
+ // questionList: current
|
|
|
+ // });
|
|
|
},
|
|
|
selectSatisfy(e) {
|
|
|
- let result = e.currentTarget.dataset.satisfy;
|
|
|
+ let result = e.currentTarget.dataset.satisfy;
|
|
|
+ let bkindex=e.currentTarget.dataset.bkindex;
|
|
|
+ let dd=this.data.bookServantList[bkindex];
|
|
|
+ dd.satisfy=result;
|
|
|
this.setData({
|
|
|
- satisfy: result
|
|
|
+ // satisfy: result,
|
|
|
+ bookServantList:this.data.bookServantList
|
|
|
});
|
|
|
},
|
|
|
remarkInput(e) {
|
|
|
- this.setData({
|
|
|
- remark: e.detail.value
|
|
|
- });
|
|
|
+ console.log(e);
|
|
|
+ let dd=this.data.bookServantList;
|
|
|
+ dd[e.currentTarget.dataset.idx].remark=e.detail.value;
|
|
|
+ this.setData({
|
|
|
+ bookServantList:dd
|
|
|
+ });
|
|
|
+ // this.setData({
|
|
|
+ // remark: e.detail.value
|
|
|
+ // });
|
|
|
},
|
|
|
detailInput(e) {
|
|
|
- this.setData({
|
|
|
- detail: e.detail.value
|
|
|
- });
|
|
|
+
|
|
|
+ console.log(e);
|
|
|
+ let dd=this.data.bookServantList;
|
|
|
+ dd[e.currentTarget.dataset.idx].detail=e.detail.value;
|
|
|
+ this.setData({
|
|
|
+ bookServantList:dd
|
|
|
+ });
|
|
|
+
|
|
|
+ // this.setData({
|
|
|
+ // detail: e.detail.value
|
|
|
+ // });
|
|
|
},
|
|
|
previewImg(e) {
|
|
|
let img = e.currentTarget.dataset.img;
|
|
|
- let imgs = this.data.imgList
|
|
|
+ let bkindex = e.currentTarget.dataset.bkindex;
|
|
|
wx.previewImage({
|
|
|
current: img, // 当前显示图片的http链接
|
|
|
- urls: imgs // 需要预览的图片http链接列表
|
|
|
+ urls: this.data.bookServantList[bkindex].imgList // 需要预览的图片http链接列表
|
|
|
})
|
|
|
},
|
|
|
delImg(e) {
|
|
|
- let imgs = this.data.imgList;
|
|
|
- let index = e.currentTarget.dataset.index;
|
|
|
- imgs.splice(index, 1);
|
|
|
+ // let imgs = e.currentTarget.dataset.imglist;
|
|
|
+ let index = e.currentTarget.dataset.index;
|
|
|
+ let bkindex=e.currentTarget.dataset.bkindex;
|
|
|
+ let dd=this.data.bookServantList;
|
|
|
+ dd[bkindex].imgList.splice(index, 1);
|
|
|
this.setData({
|
|
|
- imgList: imgs
|
|
|
+ bookServantList: dd
|
|
|
})
|
|
|
},
|
|
|
- uploadImg() {
|
|
|
- if (this.data.imgList.length >= 9) {
|
|
|
+ uploadImg(e) {
|
|
|
+ let bkindex=e.currentTarget.dataset.bkindex;
|
|
|
+ let dd=this.data.bookServantList;
|
|
|
+ let imgList= dd[bkindex].imgList;
|
|
|
+ if (imgList >= 9) {
|
|
|
wx.showToast({
|
|
|
title: '最多上传9张图片',
|
|
|
icon: 'none',
|
|
@@ -152,7 +206,7 @@ Page({
|
|
|
return false;
|
|
|
}
|
|
|
let that = this;
|
|
|
- let count = 9 - that.data.imgList.length;
|
|
|
+ let count = 9 - imgList.length;
|
|
|
wx.chooseImage({
|
|
|
count: count,
|
|
|
sizeType: ['original', 'compressed'],
|
|
@@ -181,10 +235,11 @@ Page({
|
|
|
title: '上传中...',
|
|
|
});
|
|
|
for (let i = 0; i < tempFilePaths.length; i++) {
|
|
|
- let imgs = that.data.imgList;
|
|
|
+ let imgs = imgList;
|
|
|
if (imgs.length >= 9) {
|
|
|
that.setData({
|
|
|
- imgList: imgs
|
|
|
+ // imgList: imgs
|
|
|
+ bookServantList:dd
|
|
|
});
|
|
|
return false;
|
|
|
} else {
|
|
@@ -200,7 +255,8 @@ Page({
|
|
|
|
|
|
imgs.push(data.data.url);
|
|
|
that.setData({
|
|
|
- imgList: imgs
|
|
|
+ // imgList: imgs
|
|
|
+ bookServantList:dd
|
|
|
});
|
|
|
} else {
|
|
|
console.log('上传失败')
|
|
@@ -220,7 +276,7 @@ Page({
|
|
|
*/
|
|
|
onShow: function (options) {
|
|
|
|
|
|
- this.getOrderDetail();
|
|
|
+ // this.getOrderDetail();
|
|
|
// wx.hideHomeButton({
|
|
|
// success(){
|
|
|
|
|
@@ -230,14 +286,23 @@ Page({
|
|
|
answerClick(e) {
|
|
|
let index1 = e.currentTarget.dataset.index1;
|
|
|
let answer = e.currentTarget.dataset.answer;
|
|
|
- let id = e.currentTarget.dataset.id;
|
|
|
- let obj1 = `questionList[${index1}].consultId`;
|
|
|
- let obj2 = `questionList[${index1}].consultName`;
|
|
|
- this.setData({
|
|
|
- [obj1]: id,
|
|
|
- [obj2]: answer
|
|
|
- });
|
|
|
- console.log(this.data.questionList);
|
|
|
+ let id = e.currentTarget.dataset.id;
|
|
|
+ let bkindex=e.currentTarget.dataset.bkindex;
|
|
|
+
|
|
|
+ let dd=this.data.bookServantList;
|
|
|
+ dd[bkindex].questionList[index1].consultId=id;
|
|
|
+ dd[bkindex].questionList[index1].consultName=answer;
|
|
|
+ this.setData({
|
|
|
+ bookServantList:dd
|
|
|
+ });
|
|
|
+
|
|
|
+ // let obj1 = `questionList[${index1}].consultId`;
|
|
|
+ // let obj2 = `questionList[${index1}].consultName`;
|
|
|
+ // this.setData({
|
|
|
+ // [obj1]: id,
|
|
|
+ // [obj2]: answer
|
|
|
+ // });
|
|
|
+ // console.log(this.data.questionList);
|
|
|
|
|
|
},
|
|
|
maskClick(e) {
|
|
@@ -313,19 +378,33 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
sumitRevisit() {
|
|
|
- let params = {
|
|
|
-
|
|
|
- bookTime: this.data.tradeOrder.beginDate + ' ' + this.data.tradeOrder.serviceTime,
|
|
|
+ let req=[];
|
|
|
+ let that =this;
|
|
|
+ // this.bookServantList.forEach(sv=>{
|
|
|
+ for(let k=0;k<this.data.bookServantList.length;k++){
|
|
|
+ let sv=this.data.bookServantList[k];
|
|
|
+
|
|
|
+ let params = {
|
|
|
+ detailServantId:sv.detailServantId,
|
|
|
+ bookTime: sv.bookTime,
|
|
|
bookTradeNo: this.data.tradeOrder.bookTradeNo,
|
|
|
cusTel: this.data.tradeOrder.cusPhone,
|
|
|
- degree: this.data.satisfy,
|
|
|
+ degree: sv.satisfy,
|
|
|
type: this.data.tradeOrder.goodsType,
|
|
|
- worderNo: this.data.tradeOrder.workerNo,
|
|
|
- workerName: this.data.tradeOrder.workerName,
|
|
|
+ worderNo: sv.workerNo,
|
|
|
+ workerName: sv.workerName,
|
|
|
|
|
|
- }
|
|
|
- if (this.data.satisfy == 2) {
|
|
|
- let isEmpty = this.data.questionList.some(item => {
|
|
|
+ }
|
|
|
+ if(sv.satisfy==''){
|
|
|
+ wx.showToast({
|
|
|
+ title: '辛苦您为每位服务者进行评价~',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (sv.satisfy == 2) {
|
|
|
+ let isEmpty = sv.questionList.some(item => {
|
|
|
return item.consultId == undefined || item.consultId == ''
|
|
|
});
|
|
|
if (isEmpty) {
|
|
@@ -335,7 +414,7 @@ Page({
|
|
|
duration: 2000
|
|
|
});
|
|
|
return false;
|
|
|
- } else if (this.data.detail == '') {
|
|
|
+ } else if (sv.detail == '') {
|
|
|
wx.showToast({
|
|
|
title: '请输入具体问题描述',
|
|
|
icon: 'none',
|
|
@@ -347,7 +426,7 @@ Page({
|
|
|
let titleId = [];
|
|
|
let consultId = [];
|
|
|
let consultName = [];
|
|
|
- this.data.questionList.forEach(item => {
|
|
|
+ sv.questionList.forEach(item => {
|
|
|
|
|
|
title.push(item.name);
|
|
|
titleId.push(item.id);
|
|
@@ -359,33 +438,29 @@ Page({
|
|
|
params.titleId = titleId.join(',');
|
|
|
params.consultId = consultId.join(',');
|
|
|
params.consultName = consultName.join(',');
|
|
|
- params.question = this.data.detail;
|
|
|
- params.imgSrc = this.data.imgList.join(',');
|
|
|
+ params.question = sv.detail;
|
|
|
+ params.imgSrc = sv.imgList.join(',');
|
|
|
|
|
|
}
|
|
|
- } else if (this.data.satisfy == 3) {
|
|
|
- if (this.data.remark == '') {
|
|
|
+ } else if (sv.satisfy == 3) {
|
|
|
+ if (sv.remark == '') {
|
|
|
wx.showToast({
|
|
|
title: '请填写建议',
|
|
|
icon: 'none',
|
|
|
duration: 2000
|
|
|
});
|
|
|
return false;
|
|
|
- } else {
|
|
|
-
|
|
|
- params.question = this.data.remark;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ params.question = sv.remark;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ req.push(params);
|
|
|
+ }
|
|
|
|
|
|
wx.showLoading({
|
|
|
title: '加载中...',
|
|
|
});
|
|
|
- util.request(api.saveVisit, params, 'POST').then(res => {
|
|
|
+ util.request(api.saveVisitBatch, req, 'POST').then(res => {
|
|
|
wx.hideLoading();
|
|
|
if (res.errno === 0) {
|
|
|
console.log(res);
|