Commit f23c46b899da16c143e8cf43540f70f529845e42

Authored by 后端研发-苏泰源
1 parent 53f42910

服务卡详情有效期修改

packageA/pages/goodsInfo/goodsInfo.wxml
@@ -215,7 +215,7 @@ @@ -215,7 +215,7 @@
215 <view class="flex ai_c jc_sb fs24 c-6"> 215 <view class="flex ai_c jc_sb fs24 c-6">
216 <view class="ellipsis-1">备注:{{filters.show_default(item.remark, '无')}}</view> 216 <view class="ellipsis-1">备注:{{filters.show_default(item.remark, '无')}}</view>
217 <!-- 指定开始日期和结束日期 --> 217 <!-- 指定开始日期和结束日期 -->
218 - <view class="pdl30 shrink0">有效期:{{filters.showStartAndEndDate(item)}}</view> 218 + <view class="pdl30 shrink0">有效期:{{filters.showStartAndEndDate(item, data.validDays)}}</view>
219 </view> 219 </view>
220 </view> 220 </view>
221 </block> 221 </block>
@@ -232,7 +232,7 @@ @@ -232,7 +232,7 @@
232 </view> 232 </view>
233 <view class="flex ai_c jc_sb fs24 c-6 pdt10"> 233 <view class="flex ai_c jc_sb fs24 c-6 pdt10">
234 <view class="ellipsis-1">备注:{{filters.show_default(item.remark, '无')}}</view> 234 <view class="ellipsis-1">备注:{{filters.show_default(item.remark, '无')}}</view>
235 - <view class="pdl30 shrink0">有效期:{{filters.showStartAndEndDate(item)}}</view> 235 + <view class="pdl30 shrink0">有效期:{{filters.showStartAndEndDate(item,data.validDays)}}</view>
236 </view> 236 </view>
237 </view> 237 </view>
238 </block> 238 </block>
utils/filter.wxs
@@ -219,22 +219,50 @@ var filters = { @@ -219,22 +219,50 @@ var filters = {
219 }, 219 },
220 220
221 // 显示开始和结束日期 221 // 显示开始和结束日期
222 - showStartAndEndDate: function(o) { 222 + showStartAndEndDate: function(o, val) {
  223 +
223 var dateType = o.date_type; 224 var dateType = o.date_type;
224 var currentDate = getDate().getTime(); 225 var currentDate = getDate().getTime();
225 var startDate, endDate, days, begin_days; 226 var startDate, endDate, days, begin_days;
226 - 227 +
  228 +
227 if(dateType === 0) { 229 if(dateType === 0) {
228 - days = (o.effective_days === 0 ? o.effective_days : (o.effective_days - 1)) * 24 * 60 * 60 * 1000;  
229 - endDate = filters.format_time2(currentDate + days);  
230 - currentDate = filters.format_time2(currentDate);  
231 - return currentDate + '至' + endDate; 230 +
  231 + if(o.effective_days !== 0) {
  232 + days = (o.effective_days - 1) * 24 * 60 * 60 * 1000;
  233 + endDate = filters.format_time2(currentDate + days);
  234 + currentDate = filters.format_time2(currentDate);
  235 + return currentDate + '至' + endDate;
  236 + } else {
  237 + if(val) {
  238 + days = (val - 1) * 24 * 60 * 60 * 1000;
  239 + endDate = filters.format_time2(currentDate + days);
  240 + currentDate = filters.format_time2(currentDate);
  241 + return currentDate + '至' + endDate;
  242 + } else {
  243 + currentDate = filters.format_time2(currentDate);
  244 + return currentDate + '至不限';
  245 + }
  246 + }
  247 +
232 }; 248 };
233 249
234 if(dateType === 1) { 250 if(dateType === 1) {
235 - return o.begin_date + '至' + o.effective_date; 251 + if(o.begin_date && o.effective_date) {
  252 + return o.begin_date + '至' + o.effective_date;
  253 + };
  254 + if(o.begin_date && !o.effective_date) {
  255 + return o.begin_date + '至不限';
  256 + };
  257 + if(!o.begin_date && o.effective_date) {
  258 + return currentDate + '至不限';
  259 + };
  260 + if(!o.begin_date && !o.effective_date) {
  261 + return currentDate + '至不限';
  262 + };
236 }; 263 };
237 264
  265 +
238 if(dateType === 2) { 266 if(dateType === 2) {
239 // N天后开始 267 // N天后开始
240 begin_days = o.begin_days * 24 * 60 * 60 * 1000; 268 begin_days = o.begin_days * 24 * 60 * 60 * 1000;
@@ -243,10 +271,8 @@ var filters = { @@ -243,10 +271,8 @@ var filters = {
243 startDate = filters.format_time2(currentDate + begin_days); 271 startDate = filters.format_time2(currentDate + begin_days);
244 endDate = filters.format_time2(getDate(startDate).getTime() + days); 272 endDate = filters.format_time2(getDate(startDate).getTime() + days);
245 return startDate + '至' + endDate; 273 return startDate + '至' + endDate;
246 - } 274 + };
247 275
248 - // console.log('999***', currentDate);  
249 - // return currentDate.toLocaleDateString();  
250 }, 276 },
251 277
252 278