Authored by 王水玲

sale bug 修改

... ... @@ -27,25 +27,42 @@ const saleLogger = (err, res) => {
res.send('error');
};
/**
* sale 首页 资源位获取
* 公共数据处理
* @param {[object]} req
* @param {[object]} res
* @param {[string]} title 标题
* @param {[string]} page js文件page名称
* @return {[type]}
*/
exports.index = (req, res) => {
const processPublicData = (req, title, page) => {
let data = {};
let channel = req.query.channel || req.cookies._Channel || 'boys';
let headerData = headerModel.setNavHeader('SALE');
let renderData = {
let headerData = headerModel.setNavHeader(title, channel);
return data = {
channel: channel,
renderData: {
module: 'product',
page: 'sale',
title: 'SALE',
page: page,
title: title,
pageHeader: headerData,
pageFooter: true
}
};
};
/**
* sale 首页 资源位获取
* @param {[object]} req
* @param {[object]} res
* @return {[type]}
*/
exports.index = (req, res) => {
let params = processPublicData(req, 'SALE', 'sale');
saleModel.getSaleData(channel).then((result) => {
res.render('sale/index', Object.assign(renderData, queryParam, {
saleModel.getSaleData(params.channel).then((result) => {
res.render('sale/index', Object.assign(params.renderData, queryParam, {
content: result,
floorHeader: {
title: {
... ... @@ -65,20 +82,12 @@ exports.index = (req, res) => {
* @return {[type]}
*/
exports.breakingYards = (req, res) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
let headerData = headerModel.setNavHeader('断码区');
let renderData = {
module: 'product',
page: 'break-code',
title: '断码区',
pageHeader: headerData,
pageFooter: true
};
let params = processPublicData(req, '断码区', 'break-code');
saleModel.getBreakCodeData({
yhChannel: channel
yhChannel: params.channel
}).then((result) => {
res.render('sale/break-code', Object.assign(renderData, result));
res.render('sale/break-code', Object.assign(params.renderData, result));
}).catch((err) => {
saleLogger(err, res);
});
... ... @@ -91,16 +100,10 @@ exports.breakingYards = (req, res) => {
* @return {[type]}
*/
exports.discount = (req, res) => {
let headerData = headerModel.setNavHeader('折扣专场');
let renderData = {
module: 'product',
page: 'discount',
pageHeader: headerData,
pageFooter: true
};
let params = processPublicData(req, '折扣专场', 'discount');
saleModel.getDiscountData().then((result) => {
res.render('sale/discount', Object.assign(renderData, result));
saleModel.getDiscountData(params.channel).then((result) => {
res.render('sale/discount', Object.assign(params.renderData, result));
}).catch((err) => {
saleLogger(err, res);
});
... ... @@ -114,18 +117,12 @@ exports.discount = (req, res) => {
* @return {[type]}
*/
exports.discountDetail = (req, res) => {
let headerData = headerModel.setNavHeader();
let id = req.query.id;
let renderData = {
module: 'product',
page: 'discount-detail',
pageFooter: true
};
let params = processPublicData(req, '', 'discount-detail');
saleModel.getDiscountDetailData(id).then((result) => {
headerData.navTitle = result.title;
renderData.pageHeader = headerData;
res.render('sale/discount-detail', Object.assign(renderData, result));
params.renderData.pageHeader.navTitle = result.title;
res.render('sale/discount-detail', Object.assign(params.renderData, result));
}).catch((err) => {
saleLogger(err, res);
});
... ... @@ -138,18 +135,10 @@ exports.discountDetail = (req, res) => {
* @return {[type]}
*/
exports.vip = (req, res) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
let headerData = headerModel.setNavHeader('会员专享');
let renderData = {
module: 'product',
page: 'vip',
title: '会员专享',
pageHeader: headerData,
pageFooter: true
};
let params = processPublicData(req, '会员专享', 'vip');
saleModel.getVipData(channel).then((result) => {
res.render('sale/vip', Object.assign(renderData, {
saleModel.getVipData(params.channel).then((result) => {
res.render('sale/vip', Object.assign(params.renderData, {
content: result
}));
}).catch((err) => {
... ...
... ... @@ -17,7 +17,7 @@ const productProcess = require(`${utils}/product-process`);
const _ = require('lodash');
const api = new API();
const serviceAPI = new ServiceAPI();
const anHour = 3600000;
const anHour = 3600;
const aDay = anHour * 24;
/**
... ... @@ -90,7 +90,7 @@ const processTime = (time) => {
type = 'h';
}
data.time = helpers.dateDiffFormat(timeFormat[type], time, 'ms');
data.time = helpers.dateDiffFormat(timeFormat[type], time, 's');
}
return data;
... ... @@ -101,7 +101,7 @@ const processTime = (time) => {
* @param {[array]} list
* @return {[array]}
*/
const processDiscount = (list) => {
const processDiscount = (list, channel) => {
const formatData = [];
let flag = true;
... ... @@ -114,7 +114,7 @@ const processDiscount = (list) => {
_.forEach(list, (data) => {
if (flag === true) {
data.specialUrl = `/product/sale/discount/detail?id=${data.id}`;
data.specialUrl = `/sale/discount/detail?id=${data.id}&channel=${channel}`;
_.merge(data, processTime(data.leftTime));
}
... ... @@ -331,9 +331,9 @@ exports.getBreakCodeData = (params) => {
exports.getDiscountData = (params) => {
const discountData = {};
return discount(params).then((result) => {
return discount().then((result) => {
if (result && result.code === 200) {
discountData.data = processDiscount(result.data);
discountData.data = processDiscount(result.data, params);
return discountData;
} else {
logger.error('折扣专场专题列表返回 code 不是 200');
... ...
... ... @@ -8,16 +8,17 @@
const _ = require('lodash');
const getChannle = () => ('kids');
// const getChannle = () => ('kids');
/**
* 设置头部
* @param {String} title 标题
* @param {Boolen} channel 频道
* @param {Boolen} backUrl 返回的url
* @param {Boolen} navBtn 是否显示导航
* @param {Boolen} navBack 是否显示返回箭头
*/
exports.setNavHeader = (title, navBack, backUrl, navBtn) => {
exports.setNavHeader = (title, channel, navBack, backUrl, navBtn) => {
let header = {
navTitle: title,
backUrl: backUrl,
... ... @@ -25,14 +26,18 @@ exports.setNavHeader = (title, navBack, backUrl, navBtn) => {
navBtn: navBtn
};
header[getChannle()] = true;
header[channel] = true;
return _.merge({
navTitle: '',
backUrl: true,
navBack: '',
navBtn: true,
navBtn: {
indexUrl: '/?go=1',
categoryUrl: '/cate',
shoppingCartUrl: '/cart/index/index',
mineUrl: '/home'
},
boys: true
}, header);
};
\ No newline at end of file
... ...
... ... @@ -18,7 +18,7 @@ var $mobileWrap = $('.mobile-wrap'),
swiperClass,
isen = true;
require('../common');
require('../common/common');
fastclick.attach(document.body);
lazyLoad($('img.lazy'));
... ...
... ... @@ -16,7 +16,7 @@ var $search = $searchBox.children('input[type="text"]'),
$cancelSearch = $box.children('.no-search'),
$searchIcon = $searchBox.children('.search-icon');
require('../common');
require('../common/common');
$search.on('focus', function() {
$box.addClass('action');
... ...
... ... @@ -64,7 +64,7 @@ var swipers = [],
goodsType = ['coat', 'trouser', 'shoes', 'other'];
require('../common/suspend-cart'); // 悬浮购物车
require('../common');
require('../common/common');
ellipsis.init();
... ...
... ... @@ -10,9 +10,9 @@ var $activityTime = $('.activity-time'),
endTime = $activityTime.data('time-ms');
var params = {
anHour: 3600000, // 1小时=?毫秒
aMinute: 60000, // 1分钟=?毫秒
aSecond: 1000, // 1秒=?毫秒
anHour: 3600, // 1小时=?秒
aMinute: 60, // 1分钟=?秒
aSecond: 1, // 1秒=?秒
timeDom: $activityTime, // 时间对象数组
endTime: [endTime] // 时间差数组
};
... ... @@ -31,9 +31,9 @@ function getRTime(conf) {
conf.timeDom.each(function(key, item) {
showTime = '';
conf.endTime[key] = conf.endTime[key] - 1000;
conf.endTime[key] = conf.endTime[key] - conf.aSecond;
if (conf.endTime[key] > 1000) {
if (conf.endTime[key] > conf.aSecond) {
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);
... ...
... ... @@ -6,4 +6,6 @@
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
require('../common/common');
lazyLoad($('img.lazy'));
... ...
... ... @@ -7,6 +7,7 @@
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper');
require('../common/common');
require('./sale/search');
if ($('.swiper-container .swiper-slide').length > 1) {
... ...
... ... @@ -62,7 +62,7 @@ var $listNav = $('#list-nav'),
searching;
require('../../common/suspend-cart'); // 悬浮购物车
require('../../common');
require('../../common/common');
ellipsis.init();
... ...
... ... @@ -68,7 +68,7 @@ a {
.iconfont {
text-decoration: none;
font-style: normal;
font-size: 32px;
font-size: 24px;
font-family: "iconfont" !important;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.4px;
... ...
... ... @@ -158,6 +158,7 @@
height: auto;
color: #fff;
line-height: 40px;
font-size: 14px;
}
}
}
... ...