Showing
2 changed files
with
1 additions
and
57 deletions
@@ -15,7 +15,7 @@ let channel = { | @@ -15,7 +15,7 @@ let channel = { | ||
15 | cache: true, | 15 | cache: true, |
16 | code: 200 | 16 | code: 200 |
17 | }).then(result => { | 17 | }).then(result => { |
18 | - return processResources(result.data); | 18 | + return result.data ? processResources(result.data) : []; |
19 | }); | 19 | }); |
20 | }, | 20 | }, |
21 | getSidebarData() { | 21 | getSidebarData() { |
utils/beautify/time.js
deleted
100644 → 0
1 | -/** | ||
2 | - * 需要格式化的时间格式 | ||
3 | - */ | ||
4 | - | ||
5 | -'use strict'; | ||
6 | - | ||
7 | -const helpers = global.yoho.helpers; | ||
8 | - | ||
9 | -const timeFormat = { | ||
10 | - y: '剩{y}年{M}月{d}天', | ||
11 | - M: '剩{M}月{d}天', | ||
12 | - d: '剩{d}天', | ||
13 | - h: '剩{h}小时', | ||
14 | - m: '剩{m}分钟', | ||
15 | - s: '剩{s}秒', | ||
16 | - dh: '剩{d}天{h}小时', | ||
17 | - dhms: '剩{d}天{h}小时{m}分钟{s}秒', | ||
18 | - hms: '剩{h}小时{m}分钟{s}秒', | ||
19 | - ms: '剩{m}分钟{s}秒' | ||
20 | -}; | ||
21 | - | ||
22 | -const anHour = 3600; | ||
23 | -const aDay = anHour * 24; | ||
24 | -const aMonth = aDay * 30; | ||
25 | -const aYear = aMonth * 12; | ||
26 | - | ||
27 | -/** | ||
28 | - * 折扣专场专题列表过期时间处理 单位:s | ||
29 | - * @param {[string]} time | ||
30 | - * @return {[object]} | ||
31 | - */ | ||
32 | -const processTime = (time) => { | ||
33 | - let data = {}; | ||
34 | - let type = ''; | ||
35 | - | ||
36 | - if (time < anHour) { | ||
37 | - data.warnColor = true; | ||
38 | - data.time = '低于1小时'; | ||
39 | - } else { | ||
40 | - if (time > aYear) { | ||
41 | - type = 'y'; | ||
42 | - } else if (time > aMonth) { | ||
43 | - type = 'M'; | ||
44 | - } else if (time > aDay) { | ||
45 | - type = 'dh'; | ||
46 | - } else { | ||
47 | - type = 'h'; | ||
48 | - } | ||
49 | - | ||
50 | - data.time = helpers.dateDiffFormat(timeFormat[type], time, 's'); | ||
51 | - } | ||
52 | - | ||
53 | - return data; | ||
54 | -}; | ||
55 | - | ||
56 | -module.exports = processTime; |
-
Please register or login to post a comment