Sfoglia il codice sorgente

1:付款截止时间的过滤器的调整

yujia 8 anni fa
parent
commit
df626f3118

+ 19 - 6
src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_order_ctrl.js

@@ -717,7 +717,7 @@ define(['app/app'], function (app) {
 	/**
 	 * 与现在的时间对比,距离多少天多少小时
 	 */
-	app.register.filter('restTime', function () {
+	app.register.filter('restTime', ['NumberService', function (NumberService) {
 		var day = 0, hours = 0;
 		return function (time) {
 			if(!time) {
@@ -725,12 +725,25 @@ define(['app/app'], function (app) {
 			}
 			var nowTime = new Date();
 			var s1 = time - nowTime.getTime();
-			var totalHours = s1/(1000*60*60);//算多少个小时
-			day = parseInt(totalHours) / 24;
-			hours = parseInt(totalHours) % 24;
-			return "还剩 " + parseInt(day) + "天" + parseInt(hours) + "小时";
+			if(parseInt(s1) <= 0) {
+				return "到期未付款";
+			}else {
+				var totalHours = Math.ceil(s1/(1000*60*60));//算多少个小时
+				day = parseInt(totalHours) / 24;
+				hours = parseInt(totalHours) % 24;
+				var str = "还剩";
+				if(parseInt(day) > 0) {
+					str = str + parseInt(day) + "天";
+				}
+				if(parseInt(hours) > 0) {
+					str = str + parseInt(hours) + "小时";
+				}
+				return str;
+			}
+
+
 		}
-	});
+	}]);
 
 	/**
 	 * totalHours传入小时,被减去minuesTime转换成天数