Authored by Feng

merge

... ... @@ -87,9 +87,29 @@ exports.special = (req, res) => {
pageFooter: true
};
saleModel.getSpecialDate().then((result) => {
saleModel.getSpecialData().then((result) => {
res.render('special', Object.assign(renderData, result));
}).catch((err) => {
saleLogger(err, res);
});
};
/**
* 折扣专场专题详情
*/
exports.specialDetail = (req, res) => {
let headerData = headerModel.setNavHeader('折扣专场');
let renderData = {
module: 'product',
page: 'sale',
pageHeader: headerData,
pageFooter: true
};
saleModel.getSpecialDetailData().then((result) => {
res.render('special-detail', Object.assign(renderData, result));
}).catch((err) => {
saleLogger(err, res);
});
};
... ...
... ... @@ -7,14 +7,33 @@
const library = '../../../library';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const _ = require('lodash');
const camelCase = require(`${library}/camel-case`);
const api = new API();
/**
* 折扣专场跳转链接处理
*/
const processSpecial = (list) => {
const formatData = [];
list = list || [];
list = camelCase(list);
_.forEach(list, (data) => {
data.specialUrl = `/product/specialDetail?id=${data.id}`;
formatData.push(data);
});
return formatData;
};
/**
* 获取首页数据
* @param {[object]} params
* @return {[object]}
*/
exports.getSaleDate = (params) => {
exports.getSaleData = (params) => {
return api.get('', sign.apiSign(Object.assign({
method: 'app.search.sales'
... ... @@ -26,7 +45,8 @@ exports.getSaleDate = (params) => {
* @param {[object]} params
* @return {[object]}
*/
exports.getSpecialDate = (params) => {
exports.getSpecialData = (params) => {
const specialData = {};
return api.get('', sign.apiSign(Object.assign({
method: 'app.activity.get',
... ... @@ -34,7 +54,10 @@ exports.getSpecialDate = (params) => {
plateform: 2
}, params))).then((result) => {
if (result && result.code === 200) {
return result;
specialData.data = processSpecial(result.data);
return specialData;
// return camelCase(result);
} else {
return Promise.reject('error');
}
... ... @@ -42,3 +65,22 @@ exports.getSpecialDate = (params) => {
};
/**
* 获取折扣专场专题详情数据
* @param {[object]} params
* @return {[object]}
*/
exports.getSpecialDetailData = (params) => {
return api.get('', sign.apiSign(Object.assign({
method: 'app.activity.get',
sort: 2,
plateform: 2
}, params))).then((result) => {
if (result && result.code === 200) {
return camelCase(result.data);
} else {
return Promise.reject('error');
}
});
};
... ...
... ... @@ -20,6 +20,6 @@ router.get('/detail/:id/:gid', detail.index);
router.get('/sale', sale.index);
router.get('/special', sale.special);
router.get('/specialDetail', sale.specialDetail);
module.exports = router;
... ...
<div class="sale-channel-page yoho-page">
<div class="banner">
<img src="{{image src 640 250}}"/>
<span class="activity-time"><i class="iconfont time-ico">&#xe603;</i>{{time}}</span>
</div>
</div>
\ No newline at end of file
... ...
{{# data}}
<div class="sale-special-page yoho-page">
<ul class="special-list">
{{#each data}}
<li>
<a href="">
<img class="lazy" data-original="{{image cover_url 640 250}}" />
<a href="{{specialUrl}}">
<img class="lazy" data-original="{{image coverUrl 640 250}}" />
<p class="special-cont">
<span class="special-title">{{title}}</span>
<span class="special-time"></span>
<span class="special-time {{#if warnColor}}red-color{{/if}}">{{leftTime}}</span>
</p>
</a>
</li>
{{/each}}
</ul>
</div>
{{/ data}}
\ No newline at end of file
</div>
\ No newline at end of file
... ...
... ... @@ -10,12 +10,34 @@
margin-bottom: 30px;
}
img {
width: 100%;
height: 250px;
}
.special-cont {
height: 77px;
line-height: 77px;
border-bottom: 1px solid #e0e0e0;
padding-left: 20px;
padding: 0 20px;
box-sizing: border-box;
}
.special-title {
width: 450px;
height: 77px;
float: left;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.special-time {
float: right;
}
.red-color {
color: #d0021b;
}
}
}
\ No newline at end of file
}
... ...