// index.js // 获取应用实例 const app = getApp(); const util = require('../../../utils/jmsUtil.js'); const api = require('../../../api/jms.js'); import moment from 'moment' Page({ data: { id:'', fines:'', memo:'', resultList:[], scrollShow:false, result:[], serviceId:'', keywords:'', wholeList:[], orderInfo:{ consignee:'', mobile:'', address:'', bookDate:'', time:'', workerName:'', workerId:'' , workerTel:'' }, selectValue:'', selectVisible:false, selectKey:'', timeList:[], currentDate:new Date().getTime(), max:5, uploadShow:true, isFinish:false, feedbackInfo:{ noticeType:'', sendTime:'', }, fileList: [], pictures:[], }, // 事件处理函数 onLoad(options) { if(options.id){ this.setData({ id:options.id }); } this.getResultList(); }, onshow(){ }, finesInput(e){ this.setData({ fines:e.detail.value }); }, bindMemo(e){ this.setData({ memo:e.detail.value }); }, getResultList(){ util.request(api.TicketResult, { }, 'GET').then(res=>{ if (res.errno == 0) { this.setData({ resultList:res.data }); }else{ wx.showToast({ title: res.errmsg, icon:'none' }) } }); }, inputClue(e){ let obj=e.currentTarget.dataset.obj; let item=`clueInfo.${obj}`; this.setData({ [item]:e.detail.value }); // console.log(this.data.clueInfo); }, selectClue(e){ let obj=e.currentTarget.dataset.obj; this.setData({ selectKey:obj, selectVisible:true }); console.log(this.data.selectKey); }, onPickerConfirm(e){ console.log(e); let obj={ label:e.detail.value.text, value:e.detail.value.value } this.setData({ 'orderInfo.changeReason':obj, selectVisible:false }); }, onPickerCancel(){ this.setData({ selectVisible:true }); }, selectDate(){ this.setData({ scrollShow:true }); }, hidePicker(){ this.setData({ dateTimeVisible:false }); }, onDateTimeConfirm(e){ console.log(e); this.setData({ currentDate:e.detail, 'orderInfo.bookDate':util.formetdate(new Date(e.detail)), dateTimeVisible:false }); }, onPickerConfirm(e){ console.log(e); this.setData({ 'orderInfo.time':e.detail.value, selectVisible:false }); }, onPickerCancel(){ this.setData({ selectVisible:false }); }, inputAddress(e){ this.setData({ address:e.detail.value }); }, deleteImage (event) { const { fileList = [] } = this.data; fileList.splice(event.detail.index, 1) this.setData({ fileList: fileList }) let urls=[]; fileList.forEach(function(e){ urls.push(e.url); }) this.setData({ "pictures": urls }) }, afterRead(event) { console.log(event); const { file } = event.detail let that = this; const uploadTask = wx.uploadFile({ url: api.StorageUpload, filePath: file.url, name: 'file', header: { 'X-JZ-Admin-Token': wx.getStorageSync('token')}, success: function (res) { console.log(res); var _res = JSON.parse(res.data); if (_res.errno === 0) { var url = _res.data.fileUrl; that.data.pictures.push(url) const { fileList = [] } = that.data; fileList.push({ ...file, url: url }); that.setData({ fileList: fileList }) } }, fail: function (e) { wx.showModal({ title: '错误', content: '上传失败', showCancel: false }) }, }) }, workerTap(e){ let id=e.currentTarget.dataset.id; let name=e.currentTarget.dataset.name; let current=[]; if(this.data.result.indexOf(id)>=0){ current=this.data.result; current.splice(this.data.result.indexOf(id),1); }else{ current=this.data.result; current.push(id); } this.setData({ result:current }); let resultName=[]; current.forEach(item=>{ let matchRes=this.data.resultList.filter(obj=>{return obj.id==item}); resultName.push(matchRes[0].name) }); this.setData({ resultName:resultName }); }, resultCancel(){ this.setData({ result:[], resultName:[], scrollShow:false, }) }, resultConf(){ this.setData({ scrollShow:false, }) }, confTap(){ if(this.data.result.length==0){ wx.showToast({ title: '请选择处理结果', icon:'none' }); return false; } if(this.data.memo==''){ wx.showToast({ title: '请输入处理备注', icon:'none' }); return false; } wx.showLoading({ title: '加载中', }) let params={ id:this.data.id, result:this.data.result, memo:this.data.memo, fines:Number(this.data.fines), fileUrl:this.data.pictures } util.request(api.HandleTicket, params , 'POST').then(res=>{ wx.hideLoading(); if (res.errno == 0) { wx.showModal({ title: '提示', content: '操作成功', showCancel:false, complete: (res) => { if (res.cancel) { } if (res.confirm) { wx.navigateBack({ delta:1 }); } } }) }else{ wx.showToast({ title: res.errmsg, icon:'none' }) } }).catch(err=>{ wx.hideLoading(); }); }, })