Showing
6 changed files
with
103 additions
and
13 deletions
@@ -87,9 +87,29 @@ exports.special = (req, res) => { | @@ -87,9 +87,29 @@ exports.special = (req, res) => { | ||
87 | pageFooter: true | 87 | pageFooter: true |
88 | }; | 88 | }; |
89 | 89 | ||
90 | - saleModel.getSpecialDate().then((result) => { | 90 | + saleModel.getSpecialData().then((result) => { |
91 | res.render('special', Object.assign(renderData, result)); | 91 | res.render('special', Object.assign(renderData, result)); |
92 | }).catch((err) => { | 92 | }).catch((err) => { |
93 | saleLogger(err, res); | 93 | saleLogger(err, res); |
94 | }); | 94 | }); |
95 | }; | 95 | }; |
96 | + | ||
97 | + | ||
98 | +/** | ||
99 | + * 折扣专场专题详情 | ||
100 | + */ | ||
101 | +exports.specialDetail = (req, res) => { | ||
102 | + let headerData = headerModel.setNavHeader('折扣专场'); | ||
103 | + let renderData = { | ||
104 | + module: 'product', | ||
105 | + page: 'sale', | ||
106 | + pageHeader: headerData, | ||
107 | + pageFooter: true | ||
108 | + }; | ||
109 | + | ||
110 | + saleModel.getSpecialDetailData().then((result) => { | ||
111 | + res.render('special-detail', Object.assign(renderData, result)); | ||
112 | + }).catch((err) => { | ||
113 | + saleLogger(err, res); | ||
114 | + }); | ||
115 | +}; |
@@ -7,14 +7,33 @@ | @@ -7,14 +7,33 @@ | ||
7 | const library = '../../../library'; | 7 | const library = '../../../library'; |
8 | const API = require(`${library}/api`).API; | 8 | const API = require(`${library}/api`).API; |
9 | const sign = require(`${library}/sign`); | 9 | const sign = require(`${library}/sign`); |
10 | +const _ = require('lodash'); | ||
11 | +const camelCase = require(`${library}/camel-case`); | ||
10 | const api = new API(); | 12 | const api = new API(); |
11 | 13 | ||
12 | /** | 14 | /** |
15 | + * 折扣专场跳转链接处理 | ||
16 | + */ | ||
17 | +const processSpecial = (list) => { | ||
18 | + const formatData = []; | ||
19 | + | ||
20 | + list = list || []; | ||
21 | + list = camelCase(list); | ||
22 | + | ||
23 | + _.forEach(list, (data) => { | ||
24 | + data.specialUrl = `/product/specialDetail?id=${data.id}`; | ||
25 | + formatData.push(data); | ||
26 | + }); | ||
27 | + | ||
28 | + return formatData; | ||
29 | +}; | ||
30 | + | ||
31 | +/** | ||
13 | * 获取首页数据 | 32 | * 获取首页数据 |
14 | * @param {[object]} params | 33 | * @param {[object]} params |
15 | * @return {[object]} | 34 | * @return {[object]} |
16 | */ | 35 | */ |
17 | -exports.getSaleDate = (params) => { | 36 | +exports.getSaleData = (params) => { |
18 | 37 | ||
19 | return api.get('', sign.apiSign(Object.assign({ | 38 | return api.get('', sign.apiSign(Object.assign({ |
20 | method: 'app.search.sales' | 39 | method: 'app.search.sales' |
@@ -26,7 +45,8 @@ exports.getSaleDate = (params) => { | @@ -26,7 +45,8 @@ exports.getSaleDate = (params) => { | ||
26 | * @param {[object]} params | 45 | * @param {[object]} params |
27 | * @return {[object]} | 46 | * @return {[object]} |
28 | */ | 47 | */ |
29 | -exports.getSpecialDate = (params) => { | 48 | +exports.getSpecialData = (params) => { |
49 | + const specialData = {}; | ||
30 | 50 | ||
31 | return api.get('', sign.apiSign(Object.assign({ | 51 | return api.get('', sign.apiSign(Object.assign({ |
32 | method: 'app.activity.get', | 52 | method: 'app.activity.get', |
@@ -34,7 +54,10 @@ exports.getSpecialDate = (params) => { | @@ -34,7 +54,10 @@ exports.getSpecialDate = (params) => { | ||
34 | plateform: 2 | 54 | plateform: 2 |
35 | }, params))).then((result) => { | 55 | }, params))).then((result) => { |
36 | if (result && result.code === 200) { | 56 | if (result && result.code === 200) { |
37 | - return result; | 57 | + specialData.data = processSpecial(result.data); |
58 | + return specialData; | ||
59 | + | ||
60 | + // return camelCase(result); | ||
38 | } else { | 61 | } else { |
39 | return Promise.reject('error'); | 62 | return Promise.reject('error'); |
40 | } | 63 | } |
@@ -42,3 +65,22 @@ exports.getSpecialDate = (params) => { | @@ -42,3 +65,22 @@ exports.getSpecialDate = (params) => { | ||
42 | }; | 65 | }; |
43 | 66 | ||
44 | 67 | ||
68 | +/** | ||
69 | + * 获取折扣专场专题详情数据 | ||
70 | + * @param {[object]} params | ||
71 | + * @return {[object]} | ||
72 | + */ | ||
73 | +exports.getSpecialDetailData = (params) => { | ||
74 | + return api.get('', sign.apiSign(Object.assign({ | ||
75 | + method: 'app.activity.get', | ||
76 | + sort: 2, | ||
77 | + plateform: 2 | ||
78 | + }, params))).then((result) => { | ||
79 | + if (result && result.code === 200) { | ||
80 | + return camelCase(result.data); | ||
81 | + } else { | ||
82 | + return Promise.reject('error'); | ||
83 | + } | ||
84 | + }); | ||
85 | +}; | ||
86 | + |
@@ -20,6 +20,6 @@ router.get('/detail/:id/:gid', detail.index); | @@ -20,6 +20,6 @@ router.get('/detail/:id/:gid', detail.index); | ||
20 | 20 | ||
21 | router.get('/sale', sale.index); | 21 | router.get('/sale', sale.index); |
22 | router.get('/special', sale.special); | 22 | router.get('/special', sale.special); |
23 | - | 23 | +router.get('/specialDetail', sale.specialDetail); |
24 | 24 | ||
25 | module.exports = router; | 25 | module.exports = router; |
apps/product/views/action/special-detail.hbs
0 → 100644
1 | -{{# data}} | ||
2 | <div class="sale-special-page yoho-page"> | 1 | <div class="sale-special-page yoho-page"> |
3 | <ul class="special-list"> | 2 | <ul class="special-list"> |
3 | + {{#each data}} | ||
4 | <li> | 4 | <li> |
5 | - <a href=""> | ||
6 | - <img class="lazy" data-original="{{image cover_url 640 250}}" /> | 5 | + <a href="{{specialUrl}}"> |
6 | + <img class="lazy" data-original="{{image coverUrl 640 250}}" /> | ||
7 | <p class="special-cont"> | 7 | <p class="special-cont"> |
8 | <span class="special-title">{{title}}</span> | 8 | <span class="special-title">{{title}}</span> |
9 | - <span class="special-time"></span> | 9 | + <span class="special-time {{#if warnColor}}red-color{{/if}}">{{leftTime}}</span> |
10 | </p> | 10 | </p> |
11 | </a> | 11 | </a> |
12 | </li> | 12 | </li> |
13 | + {{/each}} | ||
13 | </ul> | 14 | </ul> |
14 | -</div> | ||
15 | -{{/ data}} | ||
15 | +</div> |
@@ -10,12 +10,34 @@ | @@ -10,12 +10,34 @@ | ||
10 | margin-bottom: 30px; | 10 | margin-bottom: 30px; |
11 | } | 11 | } |
12 | 12 | ||
13 | + img { | ||
14 | + width: 100%; | ||
15 | + height: 250px; | ||
16 | + } | ||
17 | + | ||
13 | .special-cont { | 18 | .special-cont { |
14 | height: 77px; | 19 | height: 77px; |
15 | line-height: 77px; | 20 | line-height: 77px; |
16 | border-bottom: 1px solid #e0e0e0; | 21 | border-bottom: 1px solid #e0e0e0; |
17 | - padding-left: 20px; | 22 | + padding: 0 20px; |
18 | box-sizing: border-box; | 23 | box-sizing: border-box; |
19 | } | 24 | } |
25 | + | ||
26 | + .special-title { | ||
27 | + width: 450px; | ||
28 | + height: 77px; | ||
29 | + float: left; | ||
30 | + text-overflow: ellipsis; | ||
31 | + overflow: hidden; | ||
32 | + white-space: nowrap; | ||
33 | + } | ||
34 | + | ||
35 | + .special-time { | ||
36 | + float: right; | ||
37 | + } | ||
38 | + | ||
39 | + .red-color { | ||
40 | + color: #d0021b; | ||
41 | + } | ||
20 | } | 42 | } |
21 | -} | ||
43 | +} |
-
Please register or login to post a comment