import { AES, mode, pad, enc } from "crypto-js"; import { WORKORDEREVALUATION } from "./enum.workorderEvaluation.js"; import { reqDelWorkOrder, reqUrge, reqEvaluate, reqDirectStartOrder, } from "../request/api.js"; //aes加密 export function encryptByEnAES(data = '') { let Key = "dsadmin"; let tmpAES = AES.encrypt(data, Key, { mode: mode.CBC, padding: pad.Pkcs7, }); return tmpAES.toString(); } //aes解密 export function encryptByDeAES(data = '') { let Key = "dsadmin"; let tmpDeAES = AES.decrypt(data, Key, { mode: mode.CBC, padding: pad.Pkcs7, }); return tmpDeAES.toString(enc.Utf8); } // 简单的模拟枚举 export function createEnum(arr = []) { let obj = {} arr.forEach(v => { obj[obj[v.name] = v.value] = v.name; }) return Object.freeze(obj); }; // 获取页面栈,默认0是当前页面栈 export function getCurrentPagesSeimin(num = 0) { let routes = getCurrentPages(); // 获取当前打开过的页面路由数组 let curRoute = routes[routes.length - 1 - num].route // 获取当前页面路由,也就是最后一个打开的页面路由 return curRoute; }; //评价 export function showAppraise(id, callBack) { this.$refs.seiminModel.show({ skin: 'evaluate', content: "工单已完成,请对本次服务做出评价!", btns: [{ click: () => { console.log('取消'); this.$refs.seiminModel.close(); } }, { click: () => { console.log('确定'); let serviceEvaluationId; this.$refs.seiminModel.close(); uni.showLoading({ title: '加载中', mask: true, }) //算出评级 switch (this.$refs.seiminModel.stars.indexOf('pda-haoping1')) { case -1: //五星 serviceEvaluationId = WORKORDEREVALUATION['非常好评']; break; case 1: //一星 serviceEvaluationId = WORKORDEREVALUATION['极差']; break; case 2: //二星 serviceEvaluationId = WORKORDEREVALUATION['差']; break; case 3: //三星 serviceEvaluationId = WORKORDEREVALUATION['一般']; break; case 4: //四星 serviceEvaluationId = WORKORDEREVALUATION['好评']; break; } let postData = { serviceEvaluation: { id: serviceEvaluationId }, remark: this.$refs.seiminModel.evaluateTextArea, }; reqEvaluate(id, postData).then(res => { uni.hideLoading(); if (res.status == 200) { this.$refs.seiminModel.show({ skin: 'toast', icon: 'success', content: '评价成功', btns: [{ click: () => { callBack && callBack(); } }] }) } else { this.$refs.seiminModel.show({ skin: 'toast', icon: 'error', content: '评价失败', }) } }) } } ] }); }; //撤销 export function openRecallModal(id, callBack) { this.$refs.seiminModel.show({ icon: "warn", content: "您确认要撤销工单吗?撤销工单我们会通知服务台、支助人员不再执行此工单,请谨慎操作,如确认撤销请点击确认。", btns: [{ click: () => { console.log('取消'); this.$refs.seiminModel.close(); } }, { click: () => { console.log('确定'); this.$refs.seiminModel.close(); uni.showLoading({ title: '加载中', mask: true, }) reqDelWorkOrder(id).then(res => { uni.hideLoading(); if (res.status == 200) { this.$refs.seiminModel.show({ skin: 'toast', icon: 'success', content: '撤销成功', btns: [{ click: () => { callBack && callBack(); } }] }) } else { this.$refs.seiminModel.show({ skin: 'toast', icon: 'error', content: '撤销失败', }) } }) } } ] }); }; //立即执行 export function openExecModal(id, callBack) { this.$refs.seiminModel.show({ icon: 'warn', content: '您确认要立即执行该工单吗?', btns: [{ click: () => { console.log('取消'); this.$refs.seiminModel.close(); } }, { click: () => { console.log('确认'); this.$refs.seiminModel.close(); uni.showLoading({ title: '加载中', mask: true, }) reqDirectStartOrder(id).then(res => { uni.hideLoading(); if (res.status == 200) { this.$refs.seiminModel.show({ skin: 'toast', icon: 'success', content: '立即执行成功', btns: [{ click: () => { callBack && callBack(); } }] }) } else { this.$refs.seiminModel.show({ skin: 'toast', icon: 'error', content: '立即执行失败', }) } }) } }, ] }) }; //加急 export function showJiaji(id, callBack) { this.$refs.seiminModel.urgentTextArea = ''; this.$refs.seiminModel.show({ title: '', skin: 'urgent', content: "请填写加急原因,填写后我们会根据您的诉求优先处理", btns: [{ click: () => { console.log('取消'); this.$refs.seiminModel.close(); } }, { click: () => { console.log('确定', this.$refs.seiminModel.urgentTextArea); const urgentTextArea = this.$refs.seiminModel.urgentTextArea; if (urgentTextArea.trim() === '') { uni.showToast({ icon: 'none', title: '请填写加急原因', }) return; } this.$refs.seiminModel.close(); uni.showLoading({ title: '加载中', mask: true, }) let postData = { urgentDetails: { workerOrder: id, checkStatus: { id: this.checkStatus[1] }, urgentReason: urgentTextArea, }, }; reqUrge(postData).then(res => { uni.hideLoading(); if (res.status == 200) { this.$refs.seiminModel.show({ skin: 'toast', icon: 'success', content: '您的加急申请已成功,调度人员会紧急处理!', btns: [{ click: () => { callBack && callBack(); } }] }) } else { this.$refs.seiminModel.show({ skin: 'toast', icon: 'error', content: '加急失败', }) } }) } } ] }); };