formatFuc.wxs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. //时间格式化
  2. var formatTime = function (date) {
  3. var date = getDate(date)
  4. var year = date.getFullYear()
  5. var month = date.getMonth() + 1
  6. var day = date.getDate()
  7. var hour = date.getHours()
  8. var minute = date.getMinutes()
  9. var second = date.getSeconds()
  10. return [year, month, day].map(formatNumber).join('-')
  11. }
  12. var formatNumber = function (n) {
  13. n = n.toString()
  14. return n[1] ? n : '0' + n
  15. }
  16. // + ' ' + [hour, minute, second].map(formatNumber).join(':')
  17. //年月日时分
  18. var formatDate = function (date) {
  19. if(date==null||date=='') return " "
  20. var date = getDate(date)
  21. var year = date.getFullYear()
  22. var month = date.getMonth() + 1
  23. var day = date.getDate()
  24. var hour = date.getHours()
  25. var minute = date.getMinutes()
  26. var second = date.getSeconds()
  27. return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute].map(formatNumber).join(':')
  28. }
  29. //时分格式化
  30. var formatDateSF = function (date) {
  31. var date = getDate(date)
  32. var year = date.getFullYear()
  33. var month = date.getMonth() + 1
  34. var day = date.getDate()
  35. var hour = date.getHours()
  36. var minute = date.getMinutes()
  37. var second = date.getSeconds()
  38. return [hour, minute].map(formatNumber).join(':')
  39. }
  40. var numToReg = function (val) {
  41. return val.replace(getRegExp('[0-9]', 'g'), '*')
  42. }
  43. //截取返回时间到分钟
  44. var sliceFun = function (val) {
  45. return val.slice(0, 5)
  46. }
  47. //正则-逗号
  48. var regD = function (val) {
  49. return val.replace(getRegExp('[,]', 'g'), ' ')
  50. }
  51. var interceptStart = function (text) {
  52. var str = text.substr(1, 3).replace(str, "**");
  53. return str
  54. }
  55. function defineIndexOf(str, val) {
  56. return str.indexOf(val);
  57. }
  58. function includeItem(arr, week, val) {
  59. // let arrItem=arr.filter(item=>{return item.week==week});
  60. // let isInclude=arrItem.some(item=>{return item.time==val});
  61. // return isInclude;
  62. var length = arr.length;
  63. var timeList = [];
  64. for (var i = 0; i < length; i++) {
  65. if (arr[i].week == week) {
  66. timeList.push(arr[i]);
  67. }
  68. }
  69. var len2 = timeList.length;
  70. var isInclude = false;
  71. for (var j = 0; j < len2; j++) {
  72. if (timeList[j].time == val) {
  73. isInclude = true;
  74. break;
  75. }
  76. }
  77. return isInclude;
  78. }
  79. function serviceModel(type) {
  80. var modelText = '';
  81. switch (type) {
  82. case '1':
  83. modelText = '钟点工';
  84. break;
  85. case '2':
  86. modelText = '白班保姆';
  87. break;
  88. case '3':
  89. modelText = '住家保姆';
  90. break;
  91. case '4':
  92. modelText = '月嫂';
  93. break;
  94. case '5':
  95. modelText = '代班保姆-钟点工';
  96. break;
  97. case '6':
  98. modelText = '代班保姆-保姆';
  99. break;
  100. default:
  101. modelText = '';
  102. }
  103. return modelText;
  104. }
  105. function sliceStr(str,start,end){
  106. var result=str.substring(start,end);
  107. result=result.replace(getRegExp('-','g'),'.');
  108. return result;
  109. }
  110. function statusText(type) {
  111. var status = '';
  112. switch (type) {
  113. case 0:
  114. status = '未支付';
  115. break;
  116. case 1:
  117. status = '已支付';
  118. break;
  119. case 2:
  120. status = '已取消';
  121. break;
  122. case 3:
  123. status = '已退款';
  124. break;
  125. case 4:
  126. status = '待退款';
  127. break;
  128. default:
  129. status = '';
  130. }
  131. return status;
  132. }
  133. function specialStatusText(type) {
  134. var status = '';
  135. // 2 已生成待同意 3 已同意待发放(不需收集信息) ,4 不同意发放结束 5已同意待发放(已收集具体信息) 6 发放成功 7取消发放,8 发放失败 9 发放中
  136. switch (type) {
  137. case 2:
  138. status = '已生成待同意';
  139. break;
  140. case 3:
  141. status = '已同意待发放(不需收集信息)';
  142. break;
  143. case 4:
  144. status = '不同意';
  145. break;
  146. case 5:
  147. status = '已同意待发放(已收集具体信息)';
  148. break;
  149. case 6:
  150. status = '发放成功';
  151. break;
  152. case 7:
  153. status = '取消发放';
  154. break;
  155. case 8:
  156. status = '发放失败';
  157. break;
  158. case 9:
  159. status = '发放中';
  160. break;
  161. default:
  162. status = '';
  163. }
  164. return status;
  165. }
  166. function filterSource(source) {
  167. var result='';
  168. var sourceList= [
  169. { label: "400进线", value: "IB" },
  170. { label: "日常回访", value: "OB" },
  171. { label: "XP反馈", value: "XP" },
  172. { label: "在线chat", value: "IM" },
  173. { label: "钉钉反馈", value: "DD" },
  174. { label: "APP差评", value: "HMAPP" },
  175. { label: "企微反馈", value: "CP" },
  176. { label: "勤鸽XP", value: "QG" },
  177. { label: "阿姨自主报备", value: "SS" },
  178. { label: "保姆工具", value: "APP" },
  179. { label: "公众号", value: "WX" },
  180. { label: "其他", value: "OT" },
  181. { label: "回访话务", value: "CallRecord" },
  182. { label: "客户中心", value: "Customer" }
  183. ];
  184. for(var i=0;i<sourceList.length;i++){
  185. if(sourceList[i].value==source){
  186. result=sourceList[i].label;
  187. break;
  188. }
  189. }
  190. // var list = sourceList.filter(item => { return item.value == source });
  191. // if (list.length > 0){
  192. // return list[0].label;
  193. // }
  194. return result;
  195. }
  196. function isSelectResult(arr,item){
  197. return arr.indexOf(item)>-1;
  198. }
  199. function goodsTypeText(goodsType) {
  200. if (goodsType == '0') {
  201. return '服务类商品'
  202. } else if (goodsType == '1') {
  203. return '保险'
  204. } else if (goodsType == '2') {
  205. return '中介'
  206. } else if (goodsType == '3') {
  207. return '买约分离次卡'
  208. } else if (goodsType == '4') {
  209. return '补差价商品'
  210. } else if (goodsType == '5') {
  211. return '中介代金券'
  212. } else if (goodsType == '6') {
  213. return '实物商品'
  214. } else if (goodsType == '7') {
  215. return '补差'
  216. }
  217. }
  218. function orderStatusText(status) {
  219. //订单状态 101 未付款 102已取消 103系统取消 201 已付款 202订单取消,退款中 203已退款 204 已超时团购 301服务中 401服务已完成 402系统完成服务
  220. if (status == '101') {
  221. return '未付款'
  222. } else if (status == '102') {
  223. return '已取消'
  224. } else if (status == '103') {
  225. return '系统取消'
  226. } else if (status == '201') {
  227. return '已付款'
  228. } else if (status == '202') {
  229. return '订单取消,退款中'
  230. } else if (status == '203') {
  231. return '已退款'
  232. } else if (status == '204') {
  233. return '已超时团购'
  234. } else if (status == '301') {
  235. return '服务中'
  236. } else if (status == '401') {
  237. return '服务已完成'
  238. } else if (status == '402') {
  239. return '系统完成服务'
  240. }
  241. }
  242. function payTypeText(payType) {
  243. if (payType == 'WX') {
  244. return '微信'
  245. } else if (payType == 'ZFB') {
  246. return '支付宝'
  247. } else if (payType == 'ZZ') {
  248. return '对公转账'
  249. } else if (payType == 'DOUYIN') {
  250. return '抖音'
  251. }
  252. }
  253. function serviceOrderStatusText(status) {
  254. //工单状态 0-未预约,7匹配中,1-待履约,2-服务中,3-服务已提供,4-服务已完成,5-取消 未付款,6-退款
  255. if (status == 0) {
  256. return '未付款'
  257. } else if (status == 1) {
  258. return '待履约'
  259. } else if (status == 2) {
  260. return '服务中'
  261. } else if (status == 3) {
  262. return '服务已提供'
  263. } else if (status == 4) {
  264. return '服务已完成'
  265. } else if (status == 5) {
  266. return '取消/未付款'
  267. } else if (status == 6) {
  268. return '退款'
  269. } else if (status == 7) {
  270. return '匹配中'
  271. }
  272. }
  273. module.exports = {
  274. formatTime: formatTime,
  275. formatNumber: formatNumber,
  276. formatDate: formatDate,
  277. sliceFun: sliceFun,
  278. numToReg: numToReg,
  279. regD: regD,
  280. defineIndexOf: defineIndexOf,
  281. includeItem: includeItem,
  282. serviceModel:serviceModel,
  283. sliceStr:sliceStr,
  284. statusText:statusText,
  285. specialStatusText:specialStatusText,
  286. filterSource:filterSource,
  287. isSelectResult:isSelectResult,
  288. goodsTypeText:goodsTypeText,
  289. orderStatusText:orderStatusText,
  290. payTypeText:payTypeText,
  291. serviceOrderStatusText:serviceOrderStatusText
  292. }