Authored by ccbikai

SALE 折扣专场资源位处理

... ... @@ -128,7 +128,9 @@ let discount = (req, res, next) => {
let params = _processPublicData(req, '折扣专场', 'discount');
saleModel.getDiscountData(params.channel).then((result) => {
res.render('sale/discount', Object.assign(params.renderData, result));
res.render('sale/discount', Object.assign(params.renderData, {
data: result
}));
}).catch(next);
};
... ... @@ -143,7 +145,7 @@ let discountDetail = (req, res, next) => {
let id = req.query.id;
let params = _processPublicData(req, '', 'discount-detail');
saleModel.getDiscountDetailData(id, params.channel).then((result) => {
saleModel.getDiscountDetailData(id, req.yoho.channel).then((result) => {
params.renderData.pageHeader.navTitle = result.title;
res.render('sale/discount-detail', Object.assign(params.renderData, result));
}).catch(next);
... ...
... ... @@ -49,7 +49,7 @@ const contentCode = contentCodeConfig.sale;
* @param {[array]} list
* @return {[array]}
*/
const _processDiscount = (list, channel) => {
const _processDiscount = (list) => {
const formatData = [];
let flag = true;
... ... @@ -63,7 +63,6 @@ const _processDiscount = (list, channel) => {
_.forEach(list, (data) => {
if (flag === true) {
data.specialUrl = `/product/sale/discount/detail?id=${data.id}&channel=${channel}`;
Object.assign(data, processTime(data.leftTime));
}
... ... @@ -84,7 +83,7 @@ const _discount = (params) => {
return api.get('', Object.assign({
method: 'app.activity.get',
sort: 2,
plateform: 3
plateform: 2
}, params));
};
... ... @@ -300,14 +299,13 @@ const getBreakCodeData = (params) => {
* @return {[object]}
*/
const getDiscountData = (yhChannel) => {
const discountData = {};
return _discount({
yh_channel: channelType[yhChannel] || '1'
}).then((result) => {
if (result && result.code === 200) {
discountData.data = _processDiscount(result.data, yhChannel);
return discountData;
return {
list: _processDiscount(result.data)
};
} else {
logger.error('折扣专场专题列表返回 code 不是 200');
return {};
... ...
... ... @@ -2,17 +2,17 @@
{{#if ../discountActivity}}
{{> common/floor-header-more}}
{{/if}}
<ul class="special-list">
{{#each list}}
<ul class="discount-list">
{{#list}}
<li>
<a href="{{specialUrl}}">
<a href="/product/sale/discount/detail?id={{id}}">
<img class="lazy" data-original="{{image coverUrl 640 250}}" />
<p class="special-cont">
<span class="special-title">{{title}}</span>
<span class="special-time {{#if warnColor}}red-color{{/if}}">{{time}}</span>
<p class="discount-cont">
<span class="discount-title">{{title}}</span>
<span class="discount-time {{#if warnColor}}red-color{{/if}}">{{time}}</span>
</p>
</a>
</li>
{{/each}}
{{/list}}
</ul>
{{/data}}
... ...
.discount-list {
li {
margin-bottom: 30px;
background: #fff;
}
img {
width: 100%;
height: 250px;
}
.discount-cont {
box-sizing: border-box;
padding: 0 20px;
height: 77px;
border-bottom: 1px solid #e0e0e0;
line-height: 77px;
}
.discount-title {
float: left;
overflow: hidden;
width: 450px;
height: 77px;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 24px;
}
.discount-time {
float: right;
font-size: 22px;
}
.red-color {
color: #d0021b;
}
}
... ...
... ... @@ -21,6 +21,7 @@
@import "notice";
@import "fresh-only";
@import "coupon";
@import "discount-list";
.mobile-container {
margin-left: auto;
... ...
... ... @@ -2,43 +2,4 @@
overflow: hidden;
height: auto;
background: #f0f0f0;
.special-list {
li {
margin-bottom: 30px;
background: #fff;
}
img {
width: 100%;
height: 250px;
}
.special-cont {
box-sizing: border-box;
padding: 0 20px;
height: 77px;
border-bottom: 1px solid #e0e0e0;
line-height: 77px;
}
.special-title {
float: left;
overflow: hidden;
width: 450px;
height: 77px;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 24px;
}
.special-time {
float: right;
font-size: 22px;
}
.red-color {
color: #d0021b;
}
}
}
... ...
const _ = require('lodash');
const processTime = require('./time-process');
const camelCase = global.yoho.camelCase;
/**
... ... @@ -33,6 +34,7 @@ module.exports = (list) => {
}
}
// OUTLETS
if (floor.titleImage && floor.data) {
if (floor.data.image) {
floor.data.bigImage = {
... ... @@ -47,6 +49,13 @@ module.exports = (list) => {
};
}
// 折扣专场
if (floor.discountActivity && floor.data && floor.data.list.length) {
_.map(floor.data.list, (item) => {
Object.assign(item, processTime(item.leftTime));
});
}
formatData.push(floor);
});
... ...