//时间格式化 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 { 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 }