var formatNumber = function(n){ n = n.toString() return n[1] ? n : '0' + n } var regYear = getRegExp("(y+)", "i"); var orderStatus = function(status){ // 0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单 if(status==5){ return '取消待审'; }else 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 == 8) { return '已完成'; } } var redPacketStatus = function(status){ // // 1随机红包 2等额红包 if(status==1){ return '随机红包'; }else if(status==2){ return '等额红包'; } } var dateFormat = function(timestamp,format){ if (!format) { format = "yyyy-MM-dd hh:mm:ss"; } if(timestamp == undefined|| timestamp ==null){ return ""; } timestamp = parseInt(timestamp); var realDate = getDate(timestamp); function timeFormat(num) { return num < 10 ? '0' + num : num; } var date = [ ["M+", timeFormat(realDate.getMonth() + 1)], ["d+", timeFormat(realDate.getDate())], ["h+", timeFormat(realDate.getHours())], ["m+", timeFormat(realDate.getMinutes())], ["s+", timeFormat(realDate.getSeconds())], ["q+", Math.floor((realDate.getMonth() + 3) / 3)], ["S+", realDate.getMilliseconds()], ]; var reg1 = regYear.exec(format); // console.log(reg1[0]); if (reg1) { format = format.replace(reg1[1], (realDate.getFullYear() + '').substring(4 - reg1[1].length)); } for (var i=0;i