123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- const util = require('../../../utils/util.js');
- const api = require('../../../config/api.js');
- //获取应用实例
- const app = getApp();
- Page({
- data: {
- consultList: [],
- questionList: [],
- imgList: [],
- remark: '',
- detail: '',
- satisfy: '',
- bookTradeNo: '',
- type: '',
- isFinished: false,
- tradeOrder: {
- itemName: '',
- serviceNumber: '',
- beginDate: '',
- serviceTime: '',
- workerName: ''
- },
- code: '',
- loginShow: false,
- },
- onLoad: function (options) {
- console.log("options", options);
- if (options) {
- this.setData({
- bookTradeNo: options.id,
- // type:options.type
- });
- this.getOrderDetail();
- }
- // 获取题目
- // this.getConsoultType();
- // let that=this;
- // wx.login({
- // success(res) {
- // console.log(res);
- // let params = {
- // code: res.code,
- // bookTradeNo:that.data.bookTradeNo
- // };
- // if (res.code) {
- // that.setData({
- // code: res.code
- // });
- // util.request(api.loginCusUnionId, params, 'POST').then(response => {
- // if (response.errno === 0) {
- // console.log(response);
- // if(response.data.tradeOrder==null||response.data.tradeOrder==''){
- // wx.showToast({
- // title: '您还没有购买过任何商品,如有疑问,欢迎咨询4009218787',
- // icon: 'none',
- // duration: 2000
- // });
- // }else{
- // that.setData({
- // tradeOrder:response.data.tradeOrder
- // });
- // that.getConsoultType();
- // }
- // } else {
- // wx.login({
- // success(res) {
- // console.log(res);
- // if (res.code) {
- // that.setData({
- // code: res.code
- // });
- // }
- // }});
- // that.setData({
- // loginShow: true
- // });
- // }
- // });
- // } else {
- // console.log('登录失败!' + res.errMsg)
- // }
- // }
- // });
- },
- getOrderDetail(){
- util.request(api.getTradeOrderList, { bookDetailId: this.data.bookTradeNo}, 'GET').then(res => {
- if (res.errno === 0) {
- console.log(res);
- this.setData({
- tradeOrder:res.data
- });
- // 获取题目
- 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;
- });
- 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 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;
- this.setData({
- satisfy: result
- });
- },
- remarkInput(e) {
- this.setData({
- remark: e.detail.value
- });
- },
- detailInput(e) {
- this.setData({
- detail: e.detail.value
- });
- },
- previewImg(e) {
- let img = e.currentTarget.dataset.img;
- let imgs = this.data.imgList
- wx.previewImage({
- current: img, // 当前显示图片的http链接
- urls: imgs // 需要预览的图片http链接列表
- })
- },
- delImg(e) {
- let imgs = this.data.imgList;
- let index = e.currentTarget.dataset.index;
- imgs.splice(index, 1);
- this.setData({
- imgList: imgs
- })
- },
- uploadImg() {
- if (this.data.imgList.length >= 9) {
- wx.showToast({
- title: '最多上传9张图片',
- icon: 'none',
- duration: 2000
- });
- return false;
- }
- let that = this;
- let count = 9 - that.data.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 = that.data.imgList;
- if (imgs.length >= 9) {
- that.setData({
- imgList: imgs
- });
- 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
- });
- } else {
- console.log('上传失败')
- }
- }
- })
- }
- }
- wx.hideLoading();
- }
- });
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function (options) {
- // wx.hideHomeButton({
- // success(){
- // }
- // });
- },
- 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);
- },
- 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 params = {
- bookTime: this.data.tradeOrder.beginDate + ' ' + this.data.tradeOrder.serviceTime,
- bookTradeNo: this.data.tradeOrder.bookTradeNo,
- cusTel: this.data.tradeOrder.cusPhone,
- degree: this.data.satisfy,
- type: this.data.tradeOrder.goodsType,
- worderNo: this.data.tradeOrder.workerNo,
- workerName: this.data.tradeOrder.workerName,
- }
- if (this.data.satisfy == 2) {
- let isEmpty = this.data.questionList.some(item => { return item.consultId == undefined || item.consultId == '' });
- if (isEmpty) {
- wx.showToast({
- title: '请填写完整',
- icon: 'none',
- duration: 2000
- });
- return false;
- } else if (this.data.detail == '') {
- wx.showToast({
- title: '请输入具体问题描述',
- icon: 'none',
- duration: 2000
- });
- return false;
- } else {
- let title = [];
- let titleId = [];
- let consultId = [];
- let consultName = [];
- this.data.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 = this.data.detail;
- params.imgSrc = this.data.imgList.join(',');
- }
- } else if (this.data.satisfy == 3) {
- if (this.data.remark == '') {
- wx.showToast({
- title: '请填写建议',
- icon: 'none',
- duration: 2000
- });
- return false;
- } else {
- params.question = this.data.remark;
- }
- }
- wx.showLoading({
- title: '加载中...',
- });
- util.request(api.saveVisit, params, '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() {
- },
- })
|