Authored by biao

Merge branch 'develop' of http://git.yoho.cn/fe/yohobuywap-node into develop

... ... @@ -63,11 +63,12 @@ exports.index = (req, res) => {
* @param {[object]} res
* @return {[type]}
*/
exports.breakCode = (req, res) => {
exports.breakingYards = (req, res) => {
let headerData = headerModel.setNavHeader('断码区');
let renderData = {
module: 'product',
page: 'break-code',
title: '断码区',
pageHeader: headerData,
pageFooter: true
};
... ... @@ -87,17 +88,17 @@ exports.breakCode = (req, res) => {
* @param {[object]} res
* @return {[type]}
*/
exports.special = (req, res) => {
exports.discount = (req, res) => {
let headerData = headerModel.setNavHeader('折扣专场');
let renderData = {
module: 'product',
page: 'special',
page: 'discount',
pageHeader: headerData,
pageFooter: true
};
saleModel.getSpecialData().then((result) => {
res.render('sale/special', Object.assign(renderData, result));
saleModel.getDiscountData().then((result) => {
res.render('sale/discount', Object.assign(renderData, result));
}).catch((err) => {
saleLogger(err, res);
});
... ... @@ -110,19 +111,19 @@ exports.special = (req, res) => {
* @param {[object]} res
* @return {[type]}
*/
exports.specialDetail = (req, res) => {
exports.discountDetail = (req, res) => {
let headerData = headerModel.setNavHeader();
let id = req.query.id;
let renderData = {
module: 'product',
page: 'special-detail',
page: 'discount-detail',
pageFooter: true
};
saleModel.getSpecialDetailData(id).then((result) => {
saleModel.getDiscountDetailData(id).then((result) => {
headerData.navTitle = result.title;
renderData.pageHeader = headerData;
res.render('sale/special-detail', Object.assign(renderData, result));
res.render('sale/discount-detail', Object.assign(renderData, result));
}).catch((err) => {
saleLogger(err, res);
});
... ... @@ -139,6 +140,7 @@ exports.vip = (req, res) => {
let renderData = {
module: 'product',
page: 'vip',
title: '会员专享',
pageHeader: headerData,
pageFooter: true
};
... ...
... ... @@ -75,7 +75,7 @@ const processTime = (time) => {
* @param {[array]} list
* @return {[array]}
*/
const processSpecial = (list) => {
const processDiscount = (list) => {
const formatData = [];
let flag = true;
... ... @@ -88,7 +88,7 @@ const processSpecial = (list) => {
_.forEach(list, (data) => {
if (flag === true) {
data.specialUrl = `/product/specialDetail?id=${data.id}`;
data.specialUrl = `/product/sale/discount/detail?id=${data.id}`;
_.merge(data, processTime(data.leftTime));
}
... ... @@ -103,13 +103,13 @@ const processSpecial = (list) => {
* @param {[object]} params
* @return {[array]}
*/
const special = (params) => {
const discount = (params) => {
params = params || {};
return api.get('', sign.apiSign(Object.assign({
method: 'app.activity.get',
sort: 2,
plateform: 3
plateform: 2
}, params)));
};
... ... @@ -307,13 +307,13 @@ exports.getBreakCodeData = (params) => {
* @param {[object]} params
* @return {[object]}
*/
exports.getSpecialData = (params) => {
const specialData = {};
exports.getDiscountData = (params) => {
const discountData = {};
return special(params).then((result) => {
return discount(params).then((result) => {
if (result && result.code === 200) {
specialData.data = processSpecial(result.data);
return specialData;
discountData.data = processDiscount(result.data);
return discountData;
} else {
logger.error('折扣专场专题列表返回 code 不是 200');
return {};
... ... @@ -327,16 +327,16 @@ exports.getSpecialData = (params) => {
* @param {[string]} id
* @return {[object]}
*/
exports.getSpecialDetailData = (id) => {
exports.getDiscountDetailData = (id) => {
let res = {};
let param = {
id: id
};
return special(param).then((result) => {
return discount(param).then((result) => {
if (result && result.code === 200) {
res = processSpecial(result.data);
console.log(res);
res = processDiscount(result.data);
return {
title: res[0].title,
activity: {
... ...
... ... @@ -22,10 +22,10 @@ router.get(/\/pro_([\d]+)_([\d]+)\/(.*)/, detail.index);
router.get('/detail/intro/:productskn', detail.intro);
router.get('/detail/preference/:productskn/:yhchannel/:brandId', detail.preference);
router.get('/sale', sale.index);
router.get('/sale/special', sale.special);
router.get('/sale/special/detail', sale.specialDetail);
router.get('/sale/breakCode', sale.breakCode);
router.get('/sale/index', sale.index);
router.get('/sale/discount', sale.discount);
router.get('/sale/discount/detail', sale.discountDetail);
router.get('/sale/breakingYards', sale.breakingYards);
router.get('/sale/vip', sale.vip);
router.get('/sale/search', sale.search);
... ...
<div class="sale-channel-page goods-page yoho-page">
<div class="discount-detail-page goods-page yoho-page">
{{> product/sale/banner}}
... ...
<div class="sale-special-page yoho-page">
<div class="discount-page yoho-page">
<ul class="special-list">
{{#each data}}
<li>
... ...
... ... @@ -30,7 +30,7 @@ exports.setNavHeader = (title, navBack, backUrl, navBtn) => {
return _.merge({
navTitle: '',
backUrl: true,
navBack: true,
navBack: 'history.go(-1);',
navBtn: true,
boys: true
}, header);
... ...
... ... @@ -9,46 +9,53 @@ var $ = require('yoho-jquery'),
var $activityTime = $('.activity-time'),
endTime = $activityTime.data('time-ms');
var anHour = 3600000,
aMinute = 60000,
aSecond = 1000;
var params = {
anHour: 3600000, // 1小时=?毫秒
aMinute: 60000, // 1分钟=?毫秒
aSecond: 1000, // 1秒=?毫秒
timeDom: $activityTime, // 时间对象数组
endTime: [endTime] // 时间差数组
};
require('./sale/search');
lazyLoad($('img.lazy'));
// 倒计时
function getRTime() {
function getRTime(conf) {
var showTime = '',
d = 0,
h = 0,
m = 0,
s = 0;
endTime = endTime - 1000;
if (endTime > 1000) {
d = Math.floor(endTime / anHour / 24);
h = Math.floor(endTime / anHour % 24);
m = Math.floor(endTime / aMinute % 60);
s = Math.floor(endTime / aSecond % 60);
showTime += d > 0 ? d + '天' : '';
showTime += h > 0 ? h + '小时' : '';
showTime += m > 0 ? m + '分钟' : '';
showTime += s > 0 ? s + '秒' : '';
if (showTime.length !== '') {
showTime = '剩' + showTime;
conf.timeDom.each(function(key, item) {
showTime = '';
conf.endTime[key] = conf.endTime[key] - 1000;
if (conf.endTime[key] > 1000) {
d = Math.floor(conf.endTime[key] / conf.anHour / 24);
h = Math.floor(conf.endTime[key] / conf.anHour % 24);
m = Math.floor(conf.endTime[key] / conf.aMinute % 60);
s = Math.floor(conf.endTime[key] / conf.aSecond % 60);
showTime += d > 0 ? d + '天' : '';
showTime += h > 0 ? h + '小时' : '';
showTime += m > 0 ? m + '分钟' : '';
showTime += s > 0 ? s + '秒' : '';
if (showTime.length !== '') {
showTime = '剩' + showTime;
}
$(item).find('span').html(showTime);
$(item).fadeIn();
} else {
$(item).hide();
}
$activityTime.find('span').html(showTime);
$activityTime.attr('data-time-ms', endTime);
} else {
$activityTime.hide();
}
});
}
setInterval(getRTime, 1000);
setInterval(function() {
getRTime(params);
}, 1000);
... ...
.sale-channel-page {
.discount-detail-page {
.banner {
position: relative;
overflow: hidden;
... ... @@ -18,6 +18,7 @@
text-align: right;
font-size: 22px;
line-height: 50px;
display: none;
.time-ico {
margin-right: 15px;
... ...
.sale-special-page {
.discount-page {
overflow: hidden;
height: auto;
background: #f0f0f0;
... ...
@import "break-code";
@import "goods-list";
@import "sale";
@import "special";
@import "special-detail";
@import "discount";
@import "discount-detail";
... ...