Authored by htoooth

Merge remote-tracking branch 'origin/release/5.4' into release/5.4

... ... @@ -46,7 +46,8 @@ const detail = (req, res, next) => {
contId: +req.query.contId || 0,
keywords: req.query.helpQuery,
channel: req.query.channel ? req.query.channel : 'boys',
url: req.originalUrl
url: req.originalUrl,
page: q.page || 1
};
let nav = [
... ...
... ... @@ -53,10 +53,12 @@ const helpSearch = (params) => {
});
};
const allQA = () => {
const allQA = (page) => {
return api.get('', {
method: 'app.helper.allQA',
showPlatform: 'yohobuy_pc'
showPlatform: 'yohobuy_pc',
viewNum: 15,
page: page
}, {
code: 200
});
... ...
... ... @@ -231,12 +231,18 @@ const _processDetailData = (result, params) => {
});
if (params.id === 1 && !params.keywords) {
let page = pager(_.get(result, '[3].data.page_total', 0), {
id: params.id,
page: params.page
});
contData = {
isShowMenu: _processCountLength(data.faqs),
id: 1,
commonProblem: true,
faqs: data.faqs,
allQa: _.get(result, '[3].data', [])
allQa: _.get(result, '[3].data.list', []),
footPager: page
};
}
}
... ... @@ -309,7 +315,7 @@ const detailData = (params) => {
];
if (params.id === 1 && !params.keywords) {
promiseData.push(helpApi.allQA());
promiseData.push(helpApi.allQA(params.page));
}
return Promise.all(promiseData).then(result => {
... ...
... ... @@ -14,6 +14,7 @@
</li>
{{/allQa}}
</ul>
{{> common/foot-pager}}
</div>
... ...
... ... @@ -16,7 +16,8 @@ const arrive = require(`${mRoot}/newArrive-service`);
*/
exports.index = (req, res, next) => {
let pjax = req.query._pjax;
//加载最新上架数据
// 加载最新上架数据
if (pjax) {
arrive.getRecList(req).then(result => {
Object.assign(result, {layout: false});
... ... @@ -25,7 +26,8 @@ exports.index = (req, res, next) => {
return;
}
//加载所有
// 加载所有
arrive.index(req).then(result => {
res.render('list/new-arrive', result);
}).catch(next);
... ...
... ... @@ -26,6 +26,107 @@ const channelMap = {
};
/**
* 处理列表数据、及页码
* @param data
* @returns {{footPager: type[], newProList: Array}}
* @private
*/
const _proListHandler = (data, params) => {
let total = data.total || '',
proList = data.product_list || [],
newProList = [];
// 页码
let footPager = searchHandler.handlePagerData(total,
Object.assign(params, {limit: _.get(data, 'page_size', '50')}), true);
// 商品列表
_.forEach(proList, pro => {
let proObj = {};
// 应季热门
if (pro.recommend_type === 'seasonSort') {
let tags = [];
_.forEach(pro.data, subData => {
tags.push({
url: helpers.urlFormat('', {sort: subData.relationParameter}, 'list'),
name: subData.categoryName
});
});
proObj.tags = tags;
proObj.tagType = true;
}
// 热门搜索
if (pro.recommend_type === 'hotSearchTerm') {
let tags = [];
_.forEach(pro.data, subData => {
tags.push({
url: helpers.urlFormat('', {query: subData}, 'search'),
name: subData
});
});
proObj.tags = tags;
proObj.tagType = true;
proObj.hotSearch = true;
}
// 店铺
if (pro.recommend_type === 'hotShop') {
proObj = {
url: helpers.urlFormat('', {shopId: pro.data.shops_id}, pro.data.shop_domain),
src: pro.data.shop_logo,
newNum: pro.data.new_product_num,
collNum: pro.data.favorite_num
};
proObj.shopType = true;
}
// 文章
if (pro.recommend_type === 'fashionArticle') {
proObj = {
url: helpers.urlFormat('/' + pro.data.id + '.html', {channel: params.channel}, 'guang'),
src: pro.data.src,
title: pro.data.title,
publishTime: moment(parseInt(pro.data.publish_time_long, 10)).format('YYYY年MM月DD HH:mm'),
num: pro.data.browse || 0
};
proObj.articalType = true;
}
// 普通商品
if (!pro.recommend_type) {
let defaultGoods = _.find(pro.goods_list, {is_default: 'Y'});
// 无默认商品取商品列表第一个
if (!defaultGoods) {
defaultGoods = pro.goods_list[0];
}
proObj = {
url: helpers.getUrlBySkc(pro.product_id, defaultGoods.goods_id, pro.cn_alphabet),
src: pro.default_images,
proName: pro.product_name,
salesPrice: pro.sales_price
};
proObj.goodsType = true;
}
newProList.push(proObj);
});
return {
footPager: footPager,
newProList: newProList
};
};
/**
* 加载新品到着首页
* @param req
* @returns {Promise.<TResult>}
... ... @@ -83,8 +184,8 @@ const index = (req) => {
// 面包屑头部
Object.assign(respData, searchHandler.handlePathNavData({}, {}, 'new', channel));
if (result[1].code === 200 && result[1].data && result[1].data.shop_list) {
let shopsData = result[1].data.shop_list,
if (result[1].code === 200 && result[1].data) {
let shopsData = _.get(result, '[1].data.shop_list', []),
dataList = [];
_.forEach(shopsData, shop => {
... ... @@ -98,7 +199,7 @@ const index = (req) => {
// 为您推荐
Object.assign(respData.recommond.dataList, dataList);
_.forEach(result[1].data.ads, ads => {
_.forEach(_.get(result, '[1].data.ads', []), ads => {
// banner
if (ads.template_name === 'focus') {
Object.assign(respData.slide.list, ads.data);
... ... @@ -113,8 +214,8 @@ const index = (req) => {
}
// 新品牌入驻
if (result[2].code === 200 && result[2].data && result[2].data.new_brand_list) {
let brandsData = result[2].data.new_brand_list,
if (result[2].code === 200 && result[2].data) {
let brandsData = _.get(result, '[2].data.new_brand_list', []),
brandList = [];
_.forEach(brandsData, brand => {
... ... @@ -129,7 +230,7 @@ const index = (req) => {
// 最新上架
if (result[3].code === 200 && result[3].data) {
let groupSort = result[3].data.filter.group_sort || [],
let groupSort = _.get(result, '[3].data.filter.group_sort', []),
ctyList = [];
// 推荐品类
... ... @@ -148,7 +249,8 @@ const index = (req) => {
Object.assign(respData.newProduct.ctyList, ctyList);
// 列表数据
Object.assign(respData.newProduct, _proListHandler(result[3].data, Object.assign({}, params, {channel: channel})));
Object.assign(respData.newProduct, _proListHandler(result[3].data,
Object.assign({}, recParams, {channel: channel})));
}
// 数据为空,不显示页面模块
... ... @@ -172,116 +274,18 @@ const index = (req) => {
};
/**
* 处理列表数据、及页码
* @param data
* @returns {{footPager: type[], newProList: Array}}
* @private
*/
const _proListHandler = (data, params) => {
let total = data.total || '',
proList = data.product_list || [],
newProList = [];
// 页码
let footPager = searchHandler.handlePagerData(total, params);
// 商品列表
_.forEach(proList, pro => {
let proObj = {};
// 应季热门
if (pro.recommend_type === 'seasonSort') {
let tags = [];
_.forEach(pro.data, subData => {
tags.push({
url: helpers.urlFormat('', {sort: subData.relationParameter}, 'list'),
name: subData.categoryName
});
});
proObj.tags = tags;
proObj.tagType = true;
}
// 热门搜索
if (pro.recommend_type === 'hotSearchTerm') {
let tags = [];
_.forEach(pro.data, subData => {
tags.push({
url: helpers.urlFormat('', {query: subData}, 'search'),
name: subData
});
});
proObj.tags = tags;
proObj.tagType = true;
proObj.hotSearch = true;
}
// 店铺
if (pro.recommend_type === 'hotShop') {
proObj = {
url: helpers.urlFormat('', {shopId: pro.data.shops_id}, pro.data.shop_domain),
src: pro.data.shop_logo,
newNum: pro.data.new_product_num,
collNum: pro.data.favorite_num
};
proObj.shopType = true;
}
// 文章
if (pro.recommend_type === 'fashionArticle') {
proObj = {
url: helpers.urlFormat('/' + pro.data.id + '.html', {channel: params.channel}, 'guang'),
src: pro.data.src,
title: pro.data.title,
publishTime: moment(parseInt(pro.data.publish_time_long)).format('YYYY年MM月DD HH:mm'),
num: pro.data.browse || 0
};
proObj.articalType = true;
}
// 普通商品
if (!pro.recommend_type) {
let defaultGoods = _.find(pro.goods_list, {is_default: 'Y'});
// 无默认商品取商品列表第一个
if (!defaultGoods) {
defaultGoods = pro.goods_list[0];
}
proObj = {
url: helpers.getUrlBySkc(pro.product_id, defaultGoods.goods_id, pro.cn_alphabet),
src: pro.default_images,
proName: pro.product_name,
salesPrice: pro.sales_price
};
proObj.goodsType = true;
}
newProList.push(proObj);
});
return {
footPager: footPager,
newProList: newProList
};
};
/**
* 加载最新上架数据
* @param req
* @returns {Promise.<TResult>}
*/
const getRecList = (req) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
let params = {
yh_channel: channelMap[channel].yh_channel,
uid: req.user.uid || ''
};
Object.assign(params, {
sort: req.query.sort || '',
page: req.query.page || 1
... ... @@ -293,6 +297,7 @@ const getRecList = (req) => {
return Promise.all(apiMethod).then(result => {
let respData = {};
if (result[0].code === 200 && result[0].data) {
Object.assign(respData, _proListHandler(result[0].data, params));
}
... ...
... ... @@ -5,13 +5,15 @@ var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
var Swiper = require('yoho-swiper');
require('../common');
require('../plugins/slider');
require('yoho-jquery-pjax');
$('.slide-container').slider();
$('.left-one').slider();
var recSwiper = new Swiper('.rec-swiper', {
new Swiper('.rec-swiper', {
pagination: '.swiper-pagination',
paginationClickable: true,
slidesPerView: 6,
... ... @@ -22,7 +24,7 @@ var recSwiper = new Swiper('.rec-swiper', {
prevButton: '.prev'
});
var brandSwiper = new Swiper('.brand-swiper', {
new Swiper('.brand-swiper', {
pagination: '.swiper-pagination',
paginationClickable: true,
slidesPerView: 6,
... ... @@ -31,6 +33,7 @@ var brandSwiper = new Swiper('.brand-swiper', {
nextButton: '.next',
prevButton: '.prev'
});
lazyLoad($('img.lazy'));
require('./detail/latest-walk'); // 最近浏览
... ... @@ -67,14 +70,13 @@ $(function() {
// 轮播数量不够隐藏左右箭头
var $recSwiper = $('#rec-swiper');
var recNum = $recSwiper.find('.swiper-wrapper > .swiper-slide').length;
var $brandSwiper = $('#brand-swiper');
var brandNum = $brandSwiper.find('.swiper-wrapper > .swiper-slide').length;
if (recNum <= 12) {
$recSwiper.find('.prev,.next').addClass('hide');
}
var $brandSwiper = $('#brand-swiper');
var brandNum = $brandSwiper.find('.swiper-wrapper > .swiper-slide').length;
if (brandNum <= 6) {
$brandSwiper.find('.prev,.next').addClass('hide');
}
... ...
/**
* Swiper 3.3.1
* Most modern mobile touch slider and framework with hardware accelerated transitions
*
*
* http://www.idangero.us/swiper/
*
*
* Copyright 2016, Vladimir Kharlampidi
* The iDangero.us
* http://www.idangero.us/
*
*
* Licensed under MIT
*
*
* Released on: February 7, 2016
*/
.swiper-container {
... ... @@ -137,31 +137,25 @@
}
.swiper-button-prev,
.swiper-container-rtl .swiper-button-next {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23007aff'%2F%3E%3C%2Fsvg%3E");
left: 10px;
right: auto;
}
.swiper-button-prev.swiper-button-black,
.swiper-container-rtl .swiper-button-next.swiper-button-black {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23000000'%2F%3E%3C%2Fsvg%3E");
}
}
.swiper-button-prev.swiper-button-white,
.swiper-container-rtl .swiper-button-next.swiper-button-white {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23ffffff'%2F%3E%3C%2Fsvg%3E");
}
.swiper-button-next,
.swiper-container-rtl .swiper-button-prev {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23007aff'%2F%3E%3C%2Fsvg%3E");
right: 10px;
left: auto;
}
.swiper-button-next.swiper-button-black,
.swiper-container-rtl .swiper-button-prev.swiper-button-black {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23000000'%2F%3E%3C%2Fsvg%3E");
}
}
.swiper-button-next.swiper-button-white,
.swiper-container-rtl .swiper-button-prev.swiper-button-white {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23ffffff'%2F%3E%3C%2Fsvg%3E");
}
/* Pagination Styles */
.swiper-pagination {
... ... @@ -526,15 +520,13 @@ button.swiper-pagination-bullet {
content: "";
width: 100%;
height: 100%;
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20viewBox%3D'0%200%20120%20120'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20xmlns%3Axlink%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink'%3E%3Cdefs%3E%3Cline%20id%3D'l'%20x1%3D'60'%20x2%3D'60'%20y1%3D'7'%20y2%3D'27'%20stroke%3D'%236c6c6c'%20stroke-width%3D'11'%20stroke-linecap%3D'round'%2F%3E%3C%2Fdefs%3E%3Cg%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(30%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(60%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(90%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(120%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(150%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.37'%20transform%3D'rotate(180%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.46'%20transform%3D'rotate(210%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.56'%20transform%3D'rotate(240%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.66'%20transform%3D'rotate(270%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.75'%20transform%3D'rotate(300%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.85'%20transform%3D'rotate(330%2060%2C60)'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
background-position: 50%;
-webkit-background-size: 100%;
background-size: 100%;
background-repeat: no-repeat;
}
.swiper-lazy-preloader-white:after {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20viewBox%3D'0%200%20120%20120'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20xmlns%3Axlink%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink'%3E%3Cdefs%3E%3Cline%20id%3D'l'%20x1%3D'60'%20x2%3D'60'%20y1%3D'7'%20y2%3D'27'%20stroke%3D'%23fff'%20stroke-width%3D'11'%20stroke-linecap%3D'round'%2F%3E%3C%2Fdefs%3E%3Cg%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(30%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(60%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(90%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(120%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(150%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.37'%20transform%3D'rotate(180%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.46'%20transform%3D'rotate(210%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.56'%20transform%3D'rotate(240%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.66'%20transform%3D'rotate(270%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.75'%20transform%3D'rotate(300%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.85'%20transform%3D'rotate(330%2060%2C60)'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
}
}
@-webkit-keyframes swiper-preloader-spin {
100% {
-webkit-transform: rotate(360deg);
... ...
... ... @@ -85,6 +85,16 @@
}
}
.all-problem {
.cont {
height: auto;
img {
max-width: 100%;
}
}
}
.help-cont {
.cont {
padding: 15px 20px;
... ...