diff --git a/packageA/pages/goodsInfo/goodsInfo.wxml b/packageA/pages/goodsInfo/goodsInfo.wxml
index d3d587e..231982d 100644
--- a/packageA/pages/goodsInfo/goodsInfo.wxml
+++ b/packageA/pages/goodsInfo/goodsInfo.wxml
@@ -215,7 +215,7 @@
备注:{{filters.show_default(item.remark, '无')}}
- 有效期:{{filters.showStartAndEndDate(item)}}
+ 有效期:{{filters.showStartAndEndDate(item, data.validDays)}}
@@ -232,7 +232,7 @@
备注:{{filters.show_default(item.remark, '无')}}
- 有效期:{{filters.showStartAndEndDate(item)}}
+ 有效期:{{filters.showStartAndEndDate(item,data.validDays)}}
diff --git a/utils/filter.wxs b/utils/filter.wxs
index 5825dc6..c9c4bf0 100644
--- a/utils/filter.wxs
+++ b/utils/filter.wxs
@@ -219,22 +219,50 @@ var filters = {
},
// 显示开始和结束日期
- showStartAndEndDate: function(o) {
+ showStartAndEndDate: function(o, val) {
+
var dateType = o.date_type;
var currentDate = getDate().getTime();
var startDate, endDate, days, begin_days;
-
+
+
if(dateType === 0) {
- days = (o.effective_days === 0 ? o.effective_days : (o.effective_days - 1)) * 24 * 60 * 60 * 1000;
- endDate = filters.format_time2(currentDate + days);
- currentDate = filters.format_time2(currentDate);
- return currentDate + '至' + endDate;
+
+ if(o.effective_days !== 0) {
+ days = (o.effective_days - 1) * 24 * 60 * 60 * 1000;
+ endDate = filters.format_time2(currentDate + days);
+ currentDate = filters.format_time2(currentDate);
+ return currentDate + '至' + endDate;
+ } else {
+ if(val) {
+ days = (val - 1) * 24 * 60 * 60 * 1000;
+ endDate = filters.format_time2(currentDate + days);
+ currentDate = filters.format_time2(currentDate);
+ return currentDate + '至' + endDate;
+ } else {
+ currentDate = filters.format_time2(currentDate);
+ return currentDate + '至不限';
+ }
+ }
+
};
if(dateType === 1) {
- return o.begin_date + '至' + o.effective_date;
+ if(o.begin_date && o.effective_date) {
+ return o.begin_date + '至' + o.effective_date;
+ };
+ if(o.begin_date && !o.effective_date) {
+ return o.begin_date + '至不限';
+ };
+ if(!o.begin_date && o.effective_date) {
+ return currentDate + '至不限';
+ };
+ if(!o.begin_date && !o.effective_date) {
+ return currentDate + '至不限';
+ };
};
+
if(dateType === 2) {
// N天后开始
begin_days = o.begin_days * 24 * 60 * 60 * 1000;
@@ -243,10 +271,8 @@ var filters = {
startDate = filters.format_time2(currentDate + begin_days);
endDate = filters.format_time2(getDate(startDate).getTime() + days);
return startDate + '至' + endDate;
- }
+ };
- // console.log('999***', currentDate);
- // return currentDate.toLocaleDateString();
},