排队支付小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.0 KiB

  1. var formatNumber = function(n){
  2. n = n.toString()
  3. return n[1] ? n : '0' + n
  4. }
  5. var regYear = getRegExp("(y+)", "i");
  6. var orderStatus = function(status){
  7. // 0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单
  8. if(status==5){
  9. return '取消待审';
  10. }else if(status==0){
  11. return '待上门';
  12. }else if(status==1){
  13. return '待揽收';
  14. }else if(status==2){
  15. return '待支付';
  16. }else if(status==3){
  17. return '待评价';
  18. }else if(status==4){
  19. return '已取消';
  20. }
  21. else if (status == 8) {
  22. return '已完成';
  23. }
  24. }
  25. var redPacketStatus = function(status){
  26. // // 1随机红包 2等额红包
  27. if(status==1){
  28. return '随机红包';
  29. }else if(status==2){
  30. return '等额红包';
  31. }
  32. }
  33. var dateFormat = function(timestamp,format){
  34. if (!format) {
  35. format = "yyyy-MM-dd hh:mm:ss";
  36. }
  37. if(timestamp == undefined|| timestamp ==null){
  38. return "";
  39. }
  40. timestamp = parseInt(timestamp);
  41. var realDate = getDate(timestamp);
  42. function timeFormat(num) {
  43. return num < 10 ? '0' + num : num;
  44. }
  45. var date = [
  46. ["M+", timeFormat(realDate.getMonth() + 1)],
  47. ["d+", timeFormat(realDate.getDate())],
  48. ["h+", timeFormat(realDate.getHours())],
  49. ["m+", timeFormat(realDate.getMinutes())],
  50. ["s+", timeFormat(realDate.getSeconds())],
  51. ["q+", Math.floor((realDate.getMonth() + 3) / 3)],
  52. ["S+", realDate.getMilliseconds()],
  53. ];
  54. var reg1 = regYear.exec(format);
  55. // console.log(reg1[0]);
  56. if (reg1) {
  57. format = format.replace(reg1[1], (realDate.getFullYear() + '').substring(4 - reg1[1].length));
  58. }
  59. for (var i=0;i<date.length;i++) {
  60. var k = date[i][0];
  61. var v = date[i][1];
  62. var reg2 = getRegExp("(" + k + ")").exec(format);
  63. if (reg2) {
  64. format = format.replace(reg2[1], reg2[1].length == 1
  65. ? v : ("00" + v).substring(("" + v).length));
  66. }
  67. }
  68. return format;
  69. }
  70. module.exports = {
  71. dateFormat: dateFormat,
  72. orderStatus:orderStatus,
  73. redPacketStatus:redPacketStatus
  74. };