123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497 |
- const util = require('../../../utils/util.js');
- const api = require('../../../config/api.js');
- //获取应用实例
- const app = getApp();
- Page({
- data: {
- bookServantList:[],
- consultList: [],
- questionList: [],
- imgList: [],
- remark: '',
- detail: '',
- satisfy: '',
- bookTradeNo: '',
- type: '',
- isFinished: false,
- tradeOrder: {
- itemName: '',
- serviceNumber: '',
- beginDate: '',
- serviceTime: '',
- workerName: ''
- },
- code: '',
- loginShow: false,
- isCanSumit: false,
- qrImg:''//加企微二维码
- },
- onLoad: function (options) {
- console.log("options", options);
- if (options) {
- this.setData({
- bookTradeNo: options.id ? options.id : '',
- // type:options.type
- });
- }
-
- if(options.scene!=undefined && options.scene!=''){
- let scene = decodeURIComponent(options.scene);
- this.setData({
- bookTradeNo: scene.split(",")[1],
- // type:options.type
- });
- }
- this.getOrderDetail();
- },
- getOrderDetail() {
- util.request(api.getTradeOrderList, {
- bookDetailId: this.data.bookTradeNo
- }, 'GET').then(res => {
- if (res.errno === 0) {
- 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,
- bookServantList:svlist,
- isCanSumit: true,
- qrImg:res.data.qrUrl
- });
- // 获取题目
- this.getConsoultType();
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none',
- duration: 2000
- });
- }
- }).catch((err) => {
- console.log(err)
- });
- },
- getConsoultType() {
- util.request(api.getConsoultType, {
- type: this.data.tradeOrder.goodsType
- }, 'GET').then(res => {
- if (res.errno === 0) {
- console.log(res);
- let list = res.data[0].children;
- list.forEach(item => {
- item.checked = false;
- });
- let dd= this.data.bookServantList;
- dd.forEach(s=>{
- s.consultList=JSON.parse(JSON.stringify(list));;
- })
- this.setData({
- consultList: list,
- });
-
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none',
- duration: 2000
- });
- }
- }).catch((err) => {
- console.log(err)
- });
- },
- questionClick(e) {
- let checked = e.currentTarget.dataset.checked;
- 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 bkindex=e.currentTarget.dataset.bkindex;
- let dd=this.data.bookServantList[bkindex];
- dd.satisfy=result;
- this.setData({
- // satisfy: result,
- bookServantList:this.data.bookServantList
- });
- },
- remarkInput(e) {
- 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) {
- 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 bkindex = e.currentTarget.dataset.bkindex;
- wx.previewImage({
- current: img, // 当前显示图片的http链接
- urls: this.data.bookServantList[bkindex].imgList // 需要预览的图片http链接列表
- })
- },
- delImg(e) {
- // 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({
- bookServantList: dd
- })
- },
- 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',
- duration: 2000
- });
- return false;
- }
- let that = this;
- let count = 9 - imgList.length;
- wx.chooseImage({
- count: count,
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success: function (res) {
- console.log(res);
- let tempFilePaths = res.tempFilePaths;
- // for(let i=0;i<tempFilePaths.length;i++){
- // if(imgs.length>=9){
- // that.setData({
- // imgList:imgs
- // });
- // return false;
- // }else{
- // imgs.push(tempFilePaths[i]);
- // }
- // }
- // that.setData({
- // imgList:imgs
- // });
- // console.log(that.data.imgList);
- wx.showLoading({
- title: '上传中...',
- });
- for (let i = 0; i < tempFilePaths.length; i++) {
- let imgs = imgList;
- if (imgs.length >= 9) {
- that.setData({
- // imgList: imgs
- bookServantList:dd
- });
- return false;
- } else {
- wx.uploadFile({
- url: api.StorageUpload,
- filePath: tempFilePaths[i],
- name: 'file',
- success(res) {
- console.log(res);
- let data = JSON.parse(res.data);
- if (data.errno == 0) {
- imgs.push(data.data.url);
- that.setData({
- // imgList: imgs
- bookServantList:dd
- });
- } else {
- console.log('上传失败')
- }
- }
- })
- }
- }
- wx.hideLoading();
- }
- });
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function (options) {
- // this.getOrderDetail();
- // wx.hideHomeButton({
- // success(){
- // }
- // });
- },
- answerClick(e) {
- let index1 = e.currentTarget.dataset.index1;
- let answer = e.currentTarget.dataset.answer;
- 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) {
- let answer = e.currentTarget.dataset.answer;
- this.setData({
- isUnMask: answer
- });
- },
- getPhoneNumber(e) {
- console.log(e.detail);
- let params = {
- // type:'保洁',
- code: this.data.code,
- encryptedData: e.detail.encryptedData,
- iv: e.detail.iv,
- bookTradeNo: this.data.bookTradeNo
- // loginType: '',
- // openId: "",
- // sessionKey: "",
- // tel: "",
- // unionId: "",
- // userPassword: ""
- };
- util.request(api.loginCusTel, params, 'POST').then(res => {
- if (res.errno === 0) {
- console.log(res);
- this.setData({
- loginShow: false
- });
- if (res.data.tradeOrder == null || res.data.tradeOrder == '') {
- wx.showToast({
- title: '您还没有购买过任何商品,如有疑问,欢迎咨询4009218787',
- icon: 'none',
- duration: 2000
- });
- } else {
- this.setData({
- tradeOrder: res.data.tradeOrder
- });
- this.getConsoultType();
- }
- } else {
- this.setData({
- loginShow: true
- });
- wx.showToast({
- title: res.errmsg,
- icon: 'none',
- duration: 2000
- });
- let that = this;
- wx.login({
- success(res) {
- console.log(res);
- if (res.code) {
- that.setData({
- code: res.code
- });
- }
- }
- });
- }
- })
- },
- sumitRevisit() {
- 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: sv.satisfy,
- type: this.data.tradeOrder.goodsType,
- worderNo: sv.workerNo,
- workerName: sv.workerName,
- }
- 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) {
- wx.showToast({
- title: '请填写完整',
- icon: 'none',
- duration: 2000
- });
- return false;
- } else if (sv.detail == '') {
- wx.showToast({
- title: '请输入具体问题描述',
- icon: 'none',
- duration: 2000
- });
- return false;
- } else {
- let title = [];
- let titleId = [];
- let consultId = [];
- let consultName = [];
- sv.questionList.forEach(item => {
- title.push(item.name);
- titleId.push(item.id);
- consultId.push(item.consultId);
- consultName.push(item.consultName);
- });
- params.title = title.join(',');
- params.titleId = titleId.join(',');
- params.consultId = consultId.join(',');
- params.consultName = consultName.join(',');
- params.question = sv.detail;
- params.imgSrc = sv.imgList.join(',');
- }
- } else if (sv.satisfy == 3) {
- if (sv.remark == '') {
- wx.showToast({
- title: '请填写建议',
- icon: 'none',
- duration: 2000
- });
- return false;
- } else {
- params.question = sv.remark;
- }
- }
- req.push(params);
- }
- wx.showLoading({
- title: '加载中...',
- });
- util.request(api.saveVisitBatch, req, 'POST').then(res => {
- wx.hideLoading();
- if (res.errno === 0) {
- console.log(res);
- wx.showToast({
- title: '提交成功',
- icon: 'success',
- duration: 2000
- });
- this.setData({
- isFinished: true
- });
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none',
- duration: 2000
- });
- }
- }).catch((err) => {
- wx.hideLoading();
- });
- },
- goDetail() {
- wx.navigateTo({
- url: '/pages/qwOrderDetail/qwOrderDetail?payId=' + this.data.tradeOrder.payId
- });
- },
- onOverlayHide() {
- },
- })
|