Authored by 王水玲

sale bug 修改

... ... @@ -122,7 +122,7 @@ exports.discountDetail = (req, res) => {
let id = req.query.id;
let params = processPublicData(req, '', 'discount-detail');
saleModel.getDiscountDetailData(id).then((result) => {
saleModel.getDiscountDetailData(id, params.channel).then((result) => {
params.renderData.pageHeader.navTitle = result.title;
res.render('sale/discount-detail', Object.assign(params.renderData, result));
}).catch((err) => {
... ... @@ -184,14 +184,14 @@ exports.search = (req, res) => {
let vipObj = {};
if (req.query.saleType === '2') {
vipObj = Object.assign({
vipObj = {
saleVip: (req.query.saleType === '2' && (!uid || vipLevel === '0')),
vipLevel: vipLevel,
saleViplogin: vipLevel >= 1 ? true : false,
vipPrice1: vipLevel === '1',
vipPrice2: vipLevel === '2',
vipPrice3: vipLevel === '3'
}, vipObj);
};
}
res.render('sale/product', Object.assign({
... ...
... ... @@ -28,7 +28,10 @@ const typeCont = {
discount: ['p_d_desc', 'p_d_asc'],
sale: ['s_n_desc', 's_n_asc'],
newest: ['s_t_desc,s_s_desc', 's_t_asc,s_s_asc'],
stock: ['s_s_desc', 's_s_asc']
// newest: ['s_t_desc', 's_t_asc'],
stock: ['s_s_desc', 's_s_asc'],
all: ['d_s_desc', 'd_s_asc']
};
const channelType = {
... ... @@ -100,14 +103,14 @@ class Sale {
* @param {[object]} params
* @return {[array]}
*/
static discount(yhChannel) {
yhChannel = yhChannel || 'boys';
return api.get('', sign.apiSign({
static discount(params) {
params = params || {};
return api.get('', sign.apiSign(Object.assign({
method: 'app.activity.get',
sort: 2,
plateform: 3,
yh_channel: channelType[yhChannel] || '1'
}));
plateform: 2
}, params)));
}
/**
... ... @@ -124,16 +127,25 @@ class Sale {
list = camelCase(list);
_.forEach(list, (data, index) => {
const allSub = [];
data.sub.key = index;
sub.push(data.sub);
_.forEach(data.sub, (dataSub) => {
allSub.push(dataSub.sizeId);
});
sort.push({
sortName: data.sortName,
sortId: data.sortId
sortId: data.sortId,
allSub: allSub
});
data.sub.key = index;
sub.push(data.sub);
});
formatData.sortData = sort;
formatData.sub = sub;
return formatData;
}
... ... @@ -234,7 +246,10 @@ class Sale {
return Promise.all([
Sale.searchSales(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || []);
return productProcess.processProductList(result.data.product_list || [], {
yh_channel: params.yh_channel,
showSale: false
});
} else {
logger.error('SALE 商品搜索返回 code 不是 200');
return [];
... ... @@ -309,12 +324,14 @@ class Sale {
* @param {[object]} params
* @return {[object]}
*/
static getDiscountData(params) {
static getDiscountData(yhChannel) {
const discountData = {};
return Sale.discount(params).then((result) => {
return Sale.discount({
yh_channel: channelType[yhChannel] || '1'
}).then((result) => {
if (result && result.code === 200) {
discountData.data = Sale.processDiscount(result.data, params);
discountData.data = Sale.processDiscount(result.data, yhChannel);
return discountData;
} else {
logger.error('折扣专场专题列表返回 code 不是 200');
... ... @@ -328,10 +345,11 @@ class Sale {
* @param {[string]} id
* @return {[object]}
*/
static getDiscountDetailData(id) {
static getDiscountDetailData(id, yhChannel) {
let res = {};
let param = {
id: id
id: id,
yh_channel: channelType[yhChannel] || '1'
};
return Sale.discount(param).then((result) => {
... ... @@ -340,9 +358,9 @@ class Sale {
return {
title: res[0].title,
productPool: res[0].productPool,
activity: {
coverUrl: res[0].coverUrl,
time: res[0].time,
leftTime: res[0].leftTime
}
};
... ...
... ... @@ -9,7 +9,7 @@
<ul id="list-nav" class="list-nav clearfix">
{{# sortData}}
<li {{#if @first}} class="active" {{/if}} data-id="{{sortId}}">
<li {{#if @first}} class="active" {{/if}} data-id="{{sortId}}" data-allSub="{{allSub}}">
<a href="javascript:void(0);">
<span class="span-test">{{sortName}}</span>
</a>
... ... @@ -23,18 +23,19 @@
</a>
</li>
</ul>
{{# sub}}
<div class="size-area">
<div class="swiper-size" id="size-swiper-{{key}}" {{#if @first}}style="display:block"{{/if}}>
<ul class="swiper-wrapper">
{{# this}}
<li class="swiper-slide" data-id="{{sizeId}}">{{sizeName}}</li>
{{/ this}}
</ul>
<div class="sub-size">
{{# sub}}
<div class="size-area">
<div class="swiper-size" id="size-swiper-{{key}}" {{#if @first}}style="display:block"{{/if}}>
<ul class="swiper-wrapper">
{{# this}}
<li class="swiper-slide" data-id="{{sizeId}}">{{sizeName}}</li>
{{/ this}}
</ul>
</div>
</div>
</div>
{{/ sub}}
{{/ sub}}
</div>
{{/ nav}}
<div id="goods-container" class="goods-container">
... ...
<div class="discount-detail-page goods-page yoho-page">
<div class="discount-detail-page goods-page yoho-page" data-product-pool="{{productPool}}">
{{> product/sale/banner}}
<ul id="list-nav" class="list-nav clearfix">
... ...
... ... @@ -6,8 +6,8 @@
{{/content}}
{{# activity}}
<img src="{{image coverUrl 640 250}}"/>
<p class="activity-time" data-time-ms="{{leftTime}}"><i class="iconfont time-ico">&#xe603;</i><span>{{time}}</span></p>
<img src="{{image coverUrl 640 200}}"/>
<p class="activity-time" data-time-ms="{{leftTime}}"><i class="iconfont time-ico">&#xe603;</i><span></span></p>
{{/ activity}}
</div>
... ...
... ... @@ -20,7 +20,9 @@ const config = require('../config/common');
exports.image = (url, width, height, mode) => {
mode = _.isNumber(mode) ? mode : 2;
url = url || '';
return url.replace(/{width}/g, width).replace(/{height}/g, height).replace(/{mode}/g, mode);
url = url.replace(/{width}/g, width).replace(/{height}/g, height).replace(/{mode}/g, mode);
return url.replace('http:', '');
};
/**
... ... @@ -106,6 +108,14 @@ exports.round = (num, precision) => {
};
/**
* 链接改成自适应链接
* @return {[type]}
*/
exports.https = (url) => {
return url.replace('http:', '');
};
/**
* 时间格式化
* @param format 格式化token @see{http://momentjs.cn/docs/#/displaying/format/}
* @param date 日期或者数字
... ...
... ... @@ -35,26 +35,22 @@ var $listNav = $('#list-nav'),
coat: {
reload: true,
page: 0,
end: false,
saleType: 1
end: false
},
trouser: {
reload: true,
page: 0,
end: false,
saleType: 1
end: false
},
shoes: {
reload: true,
page: 0,
end: false,
saleType: 1
end: false
},
other: {
reload: true,
page: 0,
end: false,
saleType: 1
end: false
}
},
$pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项
... ... @@ -85,7 +81,8 @@ function getUrlParam(name) {
}
defaultOpt = $.extend({
yh_channel: getUrlParam('channel') || 'boys'
yh_channel: getUrlParam('channel') || 'boys',
saleType: 1
}, defaultOpt);
storeOpt = $.extend({}, defaultOpt);
... ... @@ -202,6 +199,16 @@ function search(opt) {
p_d: opt[i].id
};
break;
case 'breakSort':
ext = {
breakSort: opt[i].id
};
break;
case 'breakSize':
ext = {
breakSize: opt[i].id
};
break;
default:
break;
}
... ... @@ -335,7 +342,7 @@ $listNav.bind('contextmenu', function() {
$listNav.on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li'),
nav, sortId, navType, $active;
nav, sortId, allSub, navType, $active;
e.preventDefault();
if ($this.hasClass('filter')) {
... ... @@ -366,6 +373,11 @@ $listNav.on('touchend touchcancel', function(e) {
$active = $this.siblings('.active');
if ($this.attr('class') !== $pre.attr('class')) {
// 重置筛选项
filter.resetFilter();
}
$pre = $this; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
if ($active.hasClass('filter')) {
... ... @@ -404,6 +416,7 @@ $listNav.on('touchend touchcancel', function(e) {
$active.removeClass('active');
$this.addClass('active');
sortId = $this.data('id');
allSub = $this.data('allsub');
$swiperSize.hide();
$('#size-swiper-' + $this.index()).show();
swipers[$this.index()].onResize();
... ... @@ -411,8 +424,11 @@ $listNav.on('touchend touchcancel', function(e) {
if (nav.reload) {
search([{
type: 'sort',
type: 'breakSort',
id: sortId
}, {
type: 'breakSize',
id: allSub
}]);
}
}
... ... @@ -423,7 +439,7 @@ $listNav.on('touchend touchcancel', function(e) {
// 尺码选择事件
$swiperSize.on('click', function(e) {
var $this = $(e.target).closest('li'),
index = $this.parents('.swiper-size').index(),
index = $this.parents('.size-area').index(),
$parentType = $listNav.find('li').eq(index),
nav, sortId, sizeId, navType, $active;
... ... @@ -452,10 +468,10 @@ $swiperSize.on('click', function(e) {
if (nav.reload) {
search([{
type: 'sort',
type: 'breakSort',
id: sortId
}, {
type: 'size',
type: 'breakSize',
id: sizeId
}]);
}
... ... @@ -480,8 +496,11 @@ $(window).scroll(function() {
// 初始请求最新第一页数据
search([{
type: 'sort',
type: 'breakSort',
id: $('.coat').data('id')
}, {
type: 'breakSize',
id: $('.coat').data('allsub')
}]);
$listNav.on('touchstart', 'li', function() {
... ...
... ... @@ -30,13 +30,13 @@ var $listNav = $('#list-nav'),
// 导航数据信息
navInfo = {
all: {
order: 1,
order: 0,
reload: true,
page: 0,
end: false
},
newest: {
order: 1,
order: 0,
reload: true,
page: 0,
end: false
... ... @@ -92,6 +92,13 @@ function getUrlParam(name) {
return null; // 返回参数值
}
if ($('.sale-vip-page').length > 0) {
defaultOpt.saleType = 2;
} else if ($('.discount-detail-page').length > 0) {
defaultOpt.saleType = 3;
defaultOpt.productPool = $('.discount-detail-page').data('product-pool') || '';
}
// 获取频道
$.extend(defaultOpt, {
yh_channel: getUrlParam('channel') || 'all'
... ... @@ -210,12 +217,6 @@ function search(opt, params) {
return;
}
if ($('.sale-vip-page').length > 0) {
defaultOpt.saleType = 2;
} else if ($('.sale-channel-page').length > 0) {
defaultOpt.saleType = 3;
}
if (params) {
defaultParams = params;
$.extend(setting, params, {
... ...
.goods-page {
.banner-swiper {
height: 200px;
max-height: 200px;
ul {
height: 200px;
max-height: 200px;
}
}
.list-nav {
border-top: 1px solid #e6e6e6;
... ...
... ... @@ -10,12 +10,12 @@ const helpers = require('../library/helpers');
* 否则优先从cover1 --》 cover2 -- 》 images_url
*
*/
const procProductImg = (product, gender) => {
if (gender === '2,3') {
return product.cover2 || product.cover1 || product.imagesUrl || '';
const procProductImg = (product, gender, yhChannel) => {
if (gender === '2,3' || gender === '2' || gender === '3' && yhChannel === '2') {
return product.cover2 || product.imagesUrl || product.cover1 || '';
}
return product.cover1 || product.cover2 || product.imagesUrl || '';
return product.cover1 || product.imagesUrl || product.cover2 || '';
};
... ... @@ -57,38 +57,17 @@ exports.processProductList = (list, options) => {
return;
}
if (goods.isDefault === 'Y') {
product.defaultImages = procProductImg(goods);
// product.defaultImages = procProductImg(goods);
product.defaultImages = product.defaultImages;
flag = true;
}
});
// 如果还未赋值,则取第一个skc产品的默认图片
if (!flag) {
product.defaultImages = procProductImg(product.goodsList[0]);
product.defaultImages = procProductImg(product.goodsList[0], product.gender, options.yh_channel);
}
// product = Object.assign(product, {
// id: product.productSkn,
// thumb: product.defaultImages
// });
// if (options.showPoint) {
// // product.marketPrice += '.00';
// // product.salesPrice += '.00';
// // if (product.vip1Price) {
// // product.vip1Price = parseInt(product.vip1Price) + '.00';
// // }
// // if (product.vip2Price) {
// // product.vip2Price = parseInt(product.vip2Price) + '.00';
// // }
// // if (product.vip3Price) {
// // product.vip3Price = parseInt(product.vip3Price) + '.00';
// // }
// }
product.isSoonSoldOut = product.isSoonSoldOut === 'Y';
product.url = helpers.urlFormat(`/product/pro_${product.productId}_${product.goodsList[0].goodsId}/${product.cnAlphabet}.html`); // eslint-disable-line
... ... @@ -147,7 +126,8 @@ exports.processFilter = (list, options) => {
dataId: 'id',
subsName: 'brandName',
firstSub: 0,
dataType: 'brand'
dataType: 'brand',
sortNum: '1'
},
color: {
name: '所有颜色',
... ... @@ -155,7 +135,8 @@ exports.processFilter = (list, options) => {
dataId: 'colorId',
subsName: 'colorName',
firstSub: 0,
dataType: 'color'
dataType: 'color',
sortNum: '3'
},
discount: {
name: '所有商品',
... ... @@ -163,7 +144,8 @@ exports.processFilter = (list, options) => {
dataId: 'key',
subsName: 'name',
firstSub: '0.1,0.9',
dataType: 'p_d'
dataType: 'p_d',
sortNum: '6'
},
gender: {
name: '所有性别',
... ... @@ -171,7 +153,8 @@ exports.processFilter = (list, options) => {
dataId: 'key',
subsName: 'flag',
firstSub: '1,2,3',
dataType: 'gender'
dataType: 'gender',
sortNum: '0'
},
groupSort: {
name: '所有品类',
... ... @@ -179,7 +162,8 @@ exports.processFilter = (list, options) => {
dataId: 'relationParameter',
subsName: 'categoryName',
firstSub: 0,
dataType: 'sort'
dataType: 'sort',
sortNum: '2'
},
priceRange: {
name: '所有价格',
... ... @@ -187,7 +171,8 @@ exports.processFilter = (list, options) => {
dataId: 'key',
subsName: 'flag',
firstSub: 0,
dataType: 'price'
dataType: 'price',
sortNum: '5'
},
size: {
name: '所有尺码',
... ... @@ -195,7 +180,8 @@ exports.processFilter = (list, options) => {
dataId: 'sizeId',
subsName: 'sizeName',
firstSub: 0,
dataType: 'size'
dataType: 'size',
sortNum: '4'
}
};
... ... @@ -251,7 +237,7 @@ exports.processFilter = (list, options) => {
classify.subs.push(subs);
});
filters.classify.push(classify);
filters.classify[filtersType[key].sortNum] = classify;
});
return filters;
... ...