123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- //时间格式化
- var formatTime = function (date) {
- var date = getDate(date)
- var year = date.getFullYear()
- var month = date.getMonth() + 1
- var day = date.getDate()
- var hour = date.getHours()
- var minute = date.getMinutes()
- var second = date.getSeconds()
- return [year, month, day].map(formatNumber).join('-')
- }
- var formatNumber = function (n) {
- n = n.toString()
- return n[1] ? n : '0' + n
- }
- // + ' ' + [hour, minute, second].map(formatNumber).join(':')
- //年月日时分
- var formatDate = function (date) {
- if(date==null||date=='') return " "
- var date = getDate(date)
- var year = date.getFullYear()
- var month = date.getMonth() + 1
- var day = date.getDate()
- var hour = date.getHours()
- var minute = date.getMinutes()
- var second = date.getSeconds()
- return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute].map(formatNumber).join(':')
- }
-
- //时分格式化
- var formatDateSF = function (date) {
- var date = getDate(date)
- var year = date.getFullYear()
- var month = date.getMonth() + 1
- var day = date.getDate()
- var hour = date.getHours()
- var minute = date.getMinutes()
- var second = date.getSeconds()
- return [hour, minute].map(formatNumber).join(':')
- }
- var numToReg = function (val) {
- return val.replace(getRegExp('[0-9]', 'g'), '*')
- }
- //截取返回时间到分钟
- var sliceFun = function (val) {
- return val.slice(0, 5)
- }
- //正则-逗号
- var regD = function (val) {
- return val.replace(getRegExp('[,]', 'g'), ' ')
- }
- var interceptStart = function (text) {
- var str = text.substr(1, 3).replace(str, "**");
- return str
- }
- function defineIndexOf(str, val) {
- return str.indexOf(val);
- }
- function includeItem(arr, week, val) {
- // let arrItem=arr.filter(item=>{return item.week==week});
- // let isInclude=arrItem.some(item=>{return item.time==val});
- // return isInclude;
- var length = arr.length;
- var timeList = [];
- for (var i = 0; i < length; i++) {
- if (arr[i].week == week) {
- timeList.push(arr[i]);
- }
- }
- var len2 = timeList.length;
- var isInclude = false;
- for (var j = 0; j < len2; j++) {
- if (timeList[j].time == val) {
- isInclude = true;
- break;
- }
- }
- return isInclude;
- }
- function serviceModel(type) {
- var modelText = '';
- switch (type) {
- case '1':
- modelText = '钟点工';
- break;
- case '2':
- modelText = '白班保姆';
- break;
- case '3':
- modelText = '住家保姆';
- break;
- case '4':
- modelText = '月嫂';
- break;
- case '5':
- modelText = '代班保姆-钟点工';
- break;
- case '6':
- modelText = '代班保姆-保姆';
- break;
- default:
- modelText = '';
- }
- return modelText;
- }
- function sliceStr(str,start,end){
- var result=str.substring(start,end);
- result=result.replace(getRegExp('-','g'),'.');
- return result;
- }
- function statusText(type) {
- var status = '';
- switch (type) {
- case 0:
- status = '未支付';
- break;
- case 1:
- status = '已支付';
- break;
- case 2:
- status = '已取消';
- break;
- case 3:
- status = '已退款';
- break;
- case 4:
- status = '待退款';
- break;
-
- default:
- status = '';
- }
- return status;
- }
- function specialStatusText(type) {
- var status = '';
- // 2 已生成待同意 3 已同意待发放(不需收集信息) ,4 不同意发放结束 5已同意待发放(已收集具体信息) 6 发放成功 7取消发放,8 发放失败 9 发放中
- switch (type) {
- case 2:
- status = '已生成待同意';
- break;
- case 3:
- status = '已同意待发放(不需收集信息)';
- break;
- case 4:
- status = '不同意';
- break;
- case 5:
- status = '已同意待发放(已收集具体信息)';
- break;
- case 6:
- status = '发放成功';
- break;
- case 7:
- status = '取消发放';
- break;
- case 8:
- status = '发放失败';
- break;
- case 9:
- status = '发放中';
- break;
- default:
- status = '';
- }
- return status;
- }
- function filterSource(source) {
- var result='';
- var sourceList= [
- { label: "400进线", value: "IB" },
- { label: "日常回访", value: "OB" },
- { label: "XP反馈", value: "XP" },
- { label: "在线chat", value: "IM" },
- { label: "钉钉反馈", value: "DD" },
- { label: "APP差评", value: "HMAPP" },
- { label: "企微反馈", value: "CP" },
- { label: "勤鸽XP", value: "QG" },
- { label: "阿姨自主报备", value: "SS" },
- { label: "保姆工具", value: "APP" },
- { label: "公众号", value: "WX" },
- { label: "其他", value: "OT" },
- { label: "回访话务", value: "CallRecord" },
- { label: "客户中心", value: "Customer" }
- ];
- for(var i=0;i<sourceList.length;i++){
- if(sourceList[i].value==source){
- result=sourceList[i].label;
- break;
- }
- }
- // var list = sourceList.filter(item => { return item.value == source });
- // if (list.length > 0){
- // return list[0].label;
- // }
- return result;
- }
- function isSelectResult(arr,item){
- return arr.indexOf(item)>-1;
- }
- function goodsTypeText(goodsType) {
- if (goodsType == '0') {
- return '服务类商品'
- } else if (goodsType == '1') {
- return '保险'
- } else if (goodsType == '2') {
- return '中介'
- } else if (goodsType == '3') {
- return '买约分离次卡'
- } else if (goodsType == '4') {
- return '补差价商品'
- } else if (goodsType == '5') {
- return '中介代金券'
- } else if (goodsType == '6') {
- return '实物商品'
- } else if (goodsType == '7') {
- return '补差'
- }
- }
- function orderStatusText(status) {
- //订单状态 101 未付款 102已取消 103系统取消 201 已付款 202订单取消,退款中 203已退款 204 已超时团购 301服务中 401服务已完成 402系统完成服务
- if (status == '101') {
- return '未付款'
- } else if (status == '102') {
- return '已取消'
- } else if (status == '103') {
- return '系统取消'
- } else if (status == '201') {
- return '已付款'
- } else if (status == '202') {
- return '订单取消,退款中'
- } else if (status == '203') {
- return '已退款'
- } else if (status == '204') {
- return '已超时团购'
- } else if (status == '301') {
- return '服务中'
- } else if (status == '401') {
- return '服务已完成'
- } else if (status == '402') {
- return '系统完成服务'
- }
- }
- function payTypeText(payType) {
- if (payType == 'WX') {
- return '微信'
- } else if (payType == 'ZFB') {
- return '支付宝'
- } else if (payType == 'ZZ') {
- return '对公转账'
- } else if (payType == 'DOUYIN') {
- return '抖音'
- }
- }
- function serviceOrderStatusText(status) {
- //工单状态 0-未预约,7匹配中,1-待履约,2-服务中,3-服务已提供,4-服务已完成,5-取消 未付款,6-退款
- if (status == 0) {
- return '未付款'
- } else if (status == 1) {
- return '待履约'
- } else if (status == 2) {
- return '服务中'
- } else if (status == 3) {
- return '服务已提供'
- } else if (status == 4) {
- return '服务已完成'
- } else if (status == 5) {
- return '取消/未付款'
- } else if (status == 6) {
- return '退款'
- } else if (status == 7) {
- return '匹配中'
- }
- }
- module.exports = {
- formatTime: formatTime,
- formatNumber: formatNumber,
- formatDate: formatDate,
- sliceFun: sliceFun,
- numToReg: numToReg,
- regD: regD,
- defineIndexOf: defineIndexOf,
- includeItem: includeItem,
- serviceModel:serviceModel,
- sliceStr:sliceStr,
- statusText:statusText,
- specialStatusText:specialStatusText,
- filterSource:filterSource,
- isSelectResult:isSelectResult,
- goodsTypeText:goodsTypeText,
- orderStatusText:orderStatusText,
- payTypeText:payTypeText,
- serviceOrderStatusText:serviceOrderStatusText
- }
|