util.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. Date.prototype.format = function(formatStr)
  2. {
  3. var str = formatStr;
  4. var Week = ['日','一','二','三','四','五','六'];
  5. str=str.replace(/yyyy|YYYY/,this.getFullYear());
  6. str=str.replace(/yy|YY/,(this.getYear() % 100)>9?(this.getYear() % 100).toString():'0' + (this.getYear() % 100));
  7. str=str.replace(/MM/,this.getMonth()>8?(this.getMonth()+1).toString():'0' + (this.getMonth()+1));
  8. str=str.replace(/M/g,this.getMonth()+1);
  9. str=str.replace(/w|W/g,Week[this.getDay()]);
  10. str=str.replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0' + this.getDate());
  11. str=str.replace(/d|D/g,this.getDate());
  12. str=str.replace(/hh|HH/,this.getHours()>9?this.getHours().toString():'0' + this.getHours());
  13. str=str.replace(/h|H/g,this.getHours());
  14. str=str.replace(/mm/,this.getMinutes()>9?this.getMinutes().toString():'0' + this.getMinutes());
  15. str=str.replace(/m/g,this.getMinutes());
  16. str=str.replace(/ss|SS/,this.getSeconds()>9?this.getSeconds().toString():'0' + this.getSeconds());
  17. str=str.replace(/s|S/g,this.getSeconds());
  18. return str;
  19. }
  20. //获取链接上的参数
  21. function getRequest() {
  22. var url = location.search; //获取url中"?"符后的字串
  23. var theRequest = new Object();
  24. if (url.indexOf("?") != -1) {
  25. var str = url.substr(1);
  26. strs = str.split("&");
  27. for(var i = 0; i < strs.length; i ++) {
  28. theRequest[strs[i].split("=")[0]]=(strs[i].split("=")[1]);
  29. }
  30. }
  31. return theRequest;
  32. }
  33. //根据选择的tab获得开始和结束时间
  34. function getStartEndDate(index){
  35. var now = new Date(),
  36. sDate = new Date();
  37. var endDate = now.format('yyyy-MM-dd'),
  38. startDate = '';
  39. switch (index){
  40. case '0':
  41. startDate = '';
  42. endDate = '';
  43. break;
  44. case '1': //近一周
  45. sDate.setDate(now.getDate() - 7);
  46. startDate = sDate.format('yyyy-MM-dd');
  47. break;
  48. case '2': //近一个月
  49. sDate.setMonth(now.getMonth() -1);
  50. startDate = sDate.format('yyyy-MM-dd');
  51. break;
  52. case '3': //近半年
  53. sDate.setMonth(now.getMonth() - 6);
  54. startDate = sDate.format('yyyy-MM-dd');
  55. break;
  56. case '4': //近一年
  57. sDate.setFullYear(now.getFullYear() - 1);
  58. startDate = sDate.format('yyyy-MM-dd');
  59. break;
  60. }
  61. return {endDate: endDate, startDate: startDate};
  62. }
  63. //获得状态值
  64. //续方各状态返回值
  65. //(-3 支付过期 -2 患者自己取消 )续方取消,
  66. //-1 审核不通过 ,
  67. //(0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中,
  68. //20药师审核中,
  69. //21.药师审核失败,
  70. //30 开方中/药师审核成功,
  71. //31.开方失败,
  72. //(40开方完成/待支付 ,41 支付失败 )待支付,
  73. // 50 支付成功/待配药,
  74. //(60配药成功/待配送)等待领药,
  75. //(61配送失败62分配健管师 65配送中,69配送到服务站)配送中,
  76. //(100配送到患者手中/已完成)已完成
  77. //根据状态获得相关信息
  78. function getStatusName(status){
  79. var name = "";
  80. status = status + '';
  81. switch (status){
  82. case '-3':
  83. name = '支付过期';
  84. break;
  85. case '-2':
  86. name = '患者自己取消';
  87. break;
  88. case '-1':
  89. name = '审核不通过';
  90. break;
  91. case '0':
  92. case '2':
  93. case '3':
  94. case '4':
  95. case '10':
  96. name = '审核中';
  97. break;
  98. case '20':
  99. name = '药师审核中';
  100. break;
  101. case '21':
  102. name = '药师审核失败';
  103. break;
  104. case '30':
  105. name = '开方中';
  106. break;
  107. case '31':
  108. name = '开方失败';
  109. break;
  110. case '40':
  111. name = '待支付';
  112. break;
  113. case '41':
  114. name = '支付失败';
  115. break;
  116. case '50':
  117. name = '配药中';
  118. break;
  119. case '60':
  120. name = '等待领药';
  121. break;
  122. case '61':
  123. case '62':
  124. case '65':
  125. case '69':
  126. name = '配送中';
  127. break;
  128. case '100':
  129. name = '已完成';
  130. break;
  131. default:
  132. break;
  133. }
  134. return name;
  135. }
  136. function getExpressName(type){
  137. switch(type){
  138. case 1:
  139. return '自取';
  140. break;
  141. case 2:
  142. return '快递配送';
  143. break;
  144. case 3:
  145. return '健管师配送';
  146. break;
  147. }
  148. }