Authored by 周少峰

Merge branch 'master' into feature/sessionback

... ... @@ -55,10 +55,28 @@ const keywordsPage = () => {
});
};
// 逛详情
const getArticleUrls = () => {
let urls = [];
return Service.get('/guang/api/v2/article/getLastArticleList', {limit: 1000}, {cache: 86400}).then(res => {
_.forEach(_.get(res, 'data.artList', ''), val => {
urls.push({
url: `https:${helpers.urlFormat(`/guang/${val.articleId}.html`, null)}`,
changefreq: 'daily',
priority: 0.3
});
});
return urls;
});
};
// www 地图数据
const wwwXmlData = () => {// eslint-disable-line
return Promise.all([keywordsPage(), getStaticUrls(_.get(staticUrls, 'www'))]).then(result => {
return _.concat(result[1], result[0]);
return Promise.all([keywordsPage(), getStaticUrls(_.get(staticUrls, 'www')), getArticleUrls()]).then(result => {
return _.concat(result[1], result[0], result[2]);
});
};
... ... @@ -104,34 +122,10 @@ const itemXmlData = () => {// eslint-disable-line
});
};
const getArticleUrls = () => {
let urls = [];
return Service.get('/guang/api/v2/article/getLastArticleList', {limit: 1000}, {cache: 86400}).then(res => {
_.forEach(_.get(res, 'data.artList', ''), val => {
urls.push({
url: `https:${helpers.urlFormat(`/${val.articleId}.html`, '', 'guang')}`,
changefreq: 'daily',
priority: 0.3
});
});
return urls;
});
};
// guang 地图数据
const guangXmlData = () => {// eslint-disable-line
return Promise.all([getStaticUrls(_.get(staticUrls, 'guang')), getArticleUrls()]).then(res => {
return _.union(res[0], res[1]);
});
};
// 站点地图
const siteMap = (req, res, next) => {
let siteList = ['www', 'list', 'item', 'guang'],
let siteList = ['www', 'list', 'item'],
subdomain = req.subdomains[0] || 'www';
if (_.find(siteList, subdomain)) {
... ...
... ... @@ -39,7 +39,7 @@ exports.index = (req, res, next) => {
reqCtx.getArticleList(gender, type, uid, udid, page, '', '', pageSize, channel, true),
reqCtx.getHotTags(page, pageSize, channel, isHotDegrade),
reqCtx.getAds(channel, isAdDegrade),
reqCtx.getRecoArticles(gender, 1, 10, channel),
reqCtx.getRecoArticles(gender, 1, 10),
headerModel.requestHeaderData(channel),
reqCtx.getTopList(gender, uid, udid, page, true)
]).then(ret => {
... ... @@ -102,7 +102,7 @@ exports.tags = (req, res, next) => {
reqCtx.getArticleList(gender, 0, uid, udid, page, query, '', pageSize, channel, true),
reqCtx.getHotTags(1, 20, channel, isHotDegrade),
reqCtx.getAds(channel, isAdDegrade),
reqCtx.getRecoArticles(gender, 1, 10, channel),
reqCtx.getRecoArticles(gender, 1, 10),
headerModel.requestHeaderData(channel)
]).then(ret => {
... ... @@ -162,7 +162,7 @@ exports.editor = (req, res, next) => {
reqCtx.getArticleList(gender, null, uid, udid, page, '', authorId, pageSize, channel, true),
reqCtx.getHotTags(1, 20, channel, isHotDegrade),
reqCtx.getAds(channel, isAdDegrade),
reqCtx.getRecoArticles(gender, 1, 10, channel),
reqCtx.getRecoArticles(gender, 1, 10),
headerModel.requestHeaderData(channel)
]).then(ret => {
... ... @@ -199,7 +199,7 @@ exports.editor = (req, res, next) => {
*/
exports.detail = (req, res, next) => {
let id = req.params.id || req.query.id;
let id = req.params.id || req.query.id || req.params[0];
let page = req.query.page || 1;
let pageSize = req.query.pageSize || 10;
let col = req.query.col || 0;
... ... @@ -254,7 +254,7 @@ exports.detail = (req, res, next) => {
reqCtx.getArticleComments(udid, uid, id, page, pageSize),
reqCtx.getArticleBaseInfo(id, uid, udid),
reqCtx.getArticleRelateBrand(id),
reqCtx.getRecoArticles(gender, 1, 10, channel),
reqCtx.getRecoArticles(gender, 1, 10),
reqCtx.getAds(channel, isAdDegrade),
tdk('article', id, req)
];
... ... @@ -266,7 +266,7 @@ exports.detail = (req, res, next) => {
}
if (info.tag) {
promises.push(req.ctx(guangModel).getRelateArticleList(id, info.tag, 2, channel));
promises.push(req.ctx(guangModel).getRelateArticleList(id, info.tag, 2));
} else {
promises.push({});
}
... ...
... ... @@ -64,7 +64,7 @@ const getUdid = (req, res) => {
* @param type id 产品编号
* @return type url
*/
const getArticleUrl = (url, id, channel) => {
const getArticleUrl = (url, id) => {
/* 格式由url:{url:'aaa'} 更改为 url: 'aaa'
try {
... ... @@ -79,13 +79,7 @@ const getArticleUrl = (url, id, channel) => {
return url;
}
let param = {};
if (channel) {
param.channel = channel;
}
return helpers.urlFormat(`/${id}.html`, param, 'guang');
return helpers.urlFormat(`/guang/${id}.html`);
};
const getIndexSeo = (params, tabs) => {
... ...
... ... @@ -71,27 +71,23 @@ module.exports = class extends global.yoho.BaseModel {
[{
name: '逛',
pathTitle: '逛',
href: helpers.urlFormat('', '', 'guang')
href: helpers.urlFormat('/guang/', null)
}]
);
return query ? _.concat(path, [{ name: query, pathTitle: query}]) : path;
}
_formatTag(tagData, channel) {
_formatTag(tagData) {
let name = tagData.name,
param = {
query: name
};
if (channel) {
param.channel = channel;
}
return {
tag: name,
name: name,
url: helpers.urlFormat('/tags/index', param, 'guang')
url: helpers.urlFormat('/guang/tags/index', param)
};
}
... ... @@ -128,7 +124,7 @@ module.exports = class extends global.yoho.BaseModel {
// isReco: articleData.is_recommended && Number(articleData.is_recommended) === 1 ? true : false,
url: +articleData.category_id === 9999 ?
helpers.urlFormat(`/${_.get(articleData, 'product_list[0].product_skn', 0)}.html`, null, 'item') :
ghelper.getArticleUrl(articleData.url, articleData.id, channel),
ghelper.getArticleUrl(articleData.url, articleData.id),
img: helpers.image(articleData.src, width, height, 1),
isSquareImg: isSquareImage,
title: articleData.title,
... ... @@ -243,7 +239,7 @@ module.exports = class extends global.yoho.BaseModel {
return {
img: helpers.image(adData.src, 640, 640),
url: helpers.urlFormat('/info/index', param, 'guang'),
url: helpers.urlFormat('/guang/info/index', param),
title: adData.title,
bgColor: adData.bgColor
};
... ... @@ -412,13 +408,9 @@ module.exports = class extends global.yoho.BaseModel {
query: it.tag_name
};
if (channel) {
param.channel = channel;
}
return {
tagName: it.tag_name,
url: helpers.urlFormat('/tags/index', param, 'guang')
url: helpers.urlFormat('/guang/tags/index', param)
};
});
});
... ... @@ -543,7 +535,7 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 推荐文章
*/
getRecoArticles(gender, page, limit, channel) {
getRecoArticles(gender, page, limit) {
let data = {
gender: gender,
... ... @@ -568,7 +560,7 @@ module.exports = class extends global.yoho.BaseModel {
let it = res.data[i];
let reco = {
url: ghelper.getArticleUrl(it.url, it.id, channel),
url: ghelper.getArticleUrl(it.url, it.id),
title: it.title
};
... ... @@ -962,7 +954,7 @@ module.exports = class extends global.yoho.BaseModel {
* @param bool $onlyUrl
* @return mixed
*/
getRelateArticleList(aid, tag, size, channel) {
getRelateArticleList(aid, tag, size) {
size = size || 3;
let data = {
... ... @@ -983,7 +975,7 @@ module.exports = class extends global.yoho.BaseModel {
if (res && res.code === 200 && res.data) {
return _.map(res.data, it => {
it.thumb = helpers.image(it.thumb, 264, 173, 1);
it.url = ghelper.getArticleUrl(it.url, it.id, channel);
it.url = ghelper.getArticleUrl(it.url, it.id);
return it;
});
}
... ... @@ -1037,10 +1029,10 @@ module.exports = class extends global.yoho.BaseModel {
pageSize: pageSize,
page: page,
list: list,
baseUrl: helpers.urlFormat('/info/index', {
baseUrl: helpers.urlFormat('/guang/info/index', {
id: aid,
pageSize: pageSize
}, 'guang')
})
};
});
}
... ...
... ... @@ -7,9 +7,9 @@
const helpers = global.yoho.helpers;
module.exports.editorUrl = function(channel, authorId) {
return helpers.urlFormat(`/author-${channel}-${authorId}/`, null, 'guang');
return helpers.urlFormat(`/guang/author-${channel}-${authorId}/`, null);
};
module.exports.listUrl = function(channel, type) {
return helpers.urlFormat(`/${channel}-t${type}/`, null, 'guang');
return helpers.urlFormat(`/guang/${channel}-t${type}/`, null);
};
... ...
... ... @@ -14,6 +14,7 @@ const sitemap = require('../3party/controllers/sitemap');
router.get(['/', '/index/index'], guangController.index);
router.get(['/detail/:id', '/info/index'], guangController.detail); // guang/info/index
router.get(/^\/([\d]+)(.*)/, guangController.detail);
router.get('/tags/index', guangController.tags);
router.get('/Index/editor', guangController.editor);
... ...
... ... @@ -239,7 +239,7 @@ const favoriteArticleListAsync = (uid, udid, page, limit, type)=> {
name: item.title,
img: helpers.image(item.src, 146, 96),
desc: item.intro,
url: helpers.urlFormat('/' + item.id + '.html', '', 'guang')
url: helpers.urlFormat(`/guang/${item.id}.html`, null)
};
});
... ...
... ... @@ -93,7 +93,7 @@
{{# colorSize}}
<ul class="sizeinfo" data-id="{{skc}}">
{{#each sizeList}}
<li data-id={{product_sku}} data-name={{size_name}}></li>
<li data-id="{{product_sku}}" data-name="{{size_name}}"></li>
{{/each}}
</ul>
{{/ colorSize}}
... ...
... ... @@ -722,7 +722,7 @@ const getShopData = (shopId, channel, params, shopInfo) => {
for (let i = 0; i < 3; i++) {
trendList.push({
href: helpers.urlFormat(`/${articleList[i].id}.html`, '', 'guang'),
href: helpers.urlFormat(`/guang/${articleList[i].id}.html`, null),
src: helpers.getForceSourceUrl(articleList[i].src) +
'?imageView2/1/w/{width}/h/{height}',
mainTitle: articleList[i].title,
... ...
... ... @@ -104,7 +104,7 @@ const _proListHandler = (data, params) => {
if (pro.recommend_type === 'fashionArticle') {
proObj = {
url: helpers.urlFormat('/' + pro.data.id + '.html', {channel: params.channel}, 'guang'),
url: helpers.urlFormat(`/guang/${pro.data.id}.html`, null),
src: pro.data.src,
title: pro.data.title,
publishTime: moment(parseInt(pro.data.publish_time_long, 10)).format('YYYY年MM月DD HH:mm'),
... ...
... ... @@ -39,6 +39,13 @@ module.exports = {
lastmod: today,
changefreq: 'daily',
priority: 0.3
},
guang: {
loc: ['https://www.yohobuy.com/guang/'],
lastmod: today,
changefreq: 'daily',
priority: 0.3
}
},
... ... @@ -68,14 +75,6 @@ module.exports = {
priority: 0.3
},
// 逛 编辑列表/标签列表/逛详情动态添加
guang: {
loc: ['https://guang.yohobuy.com/boys/', 'https://guang.yohobuy.com/girls/', 'https://guang.yohobuy.com/kids/', 'https://guang.yohobuy.com/lifestyle/'],
lastmod: today,
changefreq: 'daily',
priority: 0.3
},
// 商品详情动态添加
item: {
loc: [],
... ...
... ... @@ -7,108 +7,12 @@
const helpers = global.yoho.helpers;
const TYPE = require('../type');
const MOBILE_DOMAIN = '//guang.m.yohobuy.com';
module.exports = [
// 老的首页
{
type: TYPE.redirect,
origin: (req) => {
return req.path === '/';
},
origin: /^\/(.*)/,
target: (req) => {
return helpers.urlFormat(`/${req.yoho.channel}/`, null, 'guang');
}
},
// 首页
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)(\/*)$/,
target: (req, match, channel) => {
req.query.channel = channel;
return `/guang/?chanel=${channel}`;
}
},
// 老的首页 + 类型 + 翻页
{
type: TYPE.redirect,
origin: req => /index\/index/i.test(req.path),
target: (req) => {
return helpers.urlFormat(
`/${req.yoho.channel}-t${req.query.type || 0}${req.query.page ? '-p' + req.query.page : ''}/`,
null,
'guang'
);
}
},
// 首页 + 类型
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)-t([\d]+)(\/*)$/,
target: (req, match, channel, type) => {
req.query.channel = channel;
req.query.type = type;
return `/guang/?chanel=${channel}&type=${type}`;
}
},
// 列表页 + 类型 + 翻页
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)-t([\d]+)-p([\d]+)(\/*)$/,
target: (req, match, channel, type, page) => {
req.query.channel = channel;
req.query.type = type;
req.query.page = page;
return `/guang/index/index/?type=${type}&channel=${page}`;
}
},
// 老的编缉首页
{
type: TYPE.redirect,
origin: (req) => {
return /index\/editor/i.test(req.path);
},
target: (req) => {
let channel = req.yoho.channel;
let authorId = req.query.author_id;
let page = req.query.page;
if (!authorId) {
return helpers.urlFormat(`/${channel}/`, null, 'guang');
}
return helpers.urlFormat(`/author-${channel}-${authorId}${page ? '-p' + page : ''}/`, null, 'guang');
}
},
// 编缉首页
{
type: TYPE.rewrite,
origin: /^\/author-(boys|girls|kids|lifestyle)-([\d]+)(\/*)$/,
target: (req, match, channel, authorId) => {
req.query.channel = channel;
req.query.author_id = authorId;
req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}/`;
return `/guang/index/editor?channel=${channel}&author_id=${authorId}`;
}
},
// 编缉首页 + 翻页
{
type: TYPE.rewrite,
origin: /^\/author-(boys|girls|kids|lifestyle)-([\d]+)-p([\d]+)(\/*)$/,
target: (req, match, channel, authorId, page) => {
req.query.channel = channel;
req.query.author_id = authorId;
req.query.page = page;
req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}-p${page}/`;
return `/guang/index/editor?channel=${channel}&author_id=${authorId}&page=${page}`;
return helpers.urlFormat(`/guang${req.url}`, null);
}
}
];
... ...
... ... @@ -8,6 +8,7 @@
const helpers = global.yoho.helpers;
const TYPE = require('../type');
const MOBILE_DOMAIN = '//guang.m.yohobuy.com';
module.exports = [
{
... ... @@ -96,6 +97,65 @@ module.exports = [
type: TYPE.redirect,
origin: '/index.html',
target: helpers.urlFormat('/')
}
},
// 逛
// 首页
{
type: TYPE.rewrite,
origin: /^\/guang\/(boys|girls|kids|lifestyle)(\/*)$/,
target: (req, match, channel) => {
req.query.channel = channel;
return `/guang/?chanel=${channel}`;
}
},
// 首页 + 类型
{
type: TYPE.rewrite,
origin: /^\/guang\/(boys|girls|kids|lifestyle)-t([\d]+)(\/*)$/,
target: (req, match, channel, type) => {
req.query.channel = channel;
req.query.type = type;
return `/guang/?chanel=${channel}&type=${type}`;
}
},
// 列表页 + 类型 + 翻页
{
type: TYPE.rewrite,
origin: /^\/guang\/(boys|girls|kids|lifestyle)-t([\d]+)-p([\d]+)(\/*)$/,
target: (req, match, channel, type, page) => {
req.query.channel = channel;
req.query.type = type;
req.query.page = page;
return `/guang/index/index/?type=${type}&channel=${page}`;
}
},
// 编缉首页
{
type: TYPE.rewrite,
origin: /^\/guang\/author-(boys|girls|kids|lifestyle)-([\d]+)(\/*)$/,
target: (req, match, channel, authorId) => {
req.query.channel = channel;
req.query.author_id = authorId;
req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}/`;
return `/guang/index/editor?channel=${channel}&author_id=${authorId}`;
}
},
// 编缉首页 + 翻页
{
type: TYPE.rewrite,
origin: /^\/guang\/author-(boys|girls|kids|lifestyle)-([\d]+)-p([\d]+)(\/*)$/,
target: (req, match, channel, authorId, page) => {
req.query.channel = channel;
req.query.author_id = authorId;
req.query.page = page;
req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}-p${page}/`;
return `/guang/index/editor?channel=${channel}&author_id=${authorId}&page=${page}`;
}
}
];
... ...
... ... @@ -207,11 +207,18 @@
<div class="size section {{#unless size}}hide{{/unless}}" {{#if size}}data-load="true"{{/if}}>
<span class="title">尺码:</span>
<div class="attr-content clearfix">
{{# size}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">{{name}}</a>
{{/ size}}
<div class="attr-content size-content clearfix">
<div class="size-block clearfix">
{{# size}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">{{name}}</a>
{{/ size}}
</div>
</div>
<span id="size-more" class="size-more hide">
<em>更多</em>
<i class="iconfont">&#xe60b;</i>
</span>
</div>
{{#if seniorChose}}
... ...
{
"name": "yohobuy-node",
"version": "5.9.7",
"version": "5.9.8",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -33,6 +33,11 @@ var moreBrandLoaded = false,
var $brandMoreTxt, $brandMoreIcon;
var $sizeMore = $('#size-more'),
$sizeMoreTxt = $sizeMore.children('em'),
$sizeMoreIcon = $sizeMore.children('.iconfont'),
$sizeContent = $sizeMore.siblings('.attr-content');
// 价格相关变量
var $udPrice = $('.ud-price-range'),
interReg = /^\d+$/,
... ... @@ -444,6 +449,22 @@ $seniorAttrWrap.on('mouseenter', '.attr', function() {
}, 100);
});
$sizeMore.click(function() {
var $this = $(this),
$wrap = $this.siblings('.attr-content');
if ($wrap.hasClass('more')) {
$sizeMoreTxt.text('更多');
$sizeMoreIcon.html(moreUnicode.down);
$wrap.scrollTop(0);
} else {
$sizeMoreTxt.text('收起');
$sizeMoreIcon.html(moreUnicode.up);
}
$wrap.toggleClass('more');
});
// 【高级选项】多选
$('.senior-sub').on('click', '.multi-select', function() {
$(this).closest('.senior-sub').addClass('multi');
... ... @@ -504,3 +525,12 @@ $('.senior-sub').on('click', '.multi-select', function() {
}());
(function setSizeMoreBtnDisplay() {
var bh = $sizeContent.height(),
ch = $sizeContent.children().height();
if (ch > bh) {
$sizeMore.removeClass('hide');
}
}());
... ...
... ... @@ -94,8 +94,37 @@
-moz-user-select: none;
}
.color .attr {
margin-right: 0;
.color {
.attr-content {
margin-right: 100px;
}
.attr {
margin-right: 0;
}
}
.size {
position: relative;
.size-content {
margin-right: 130px;
max-height: 62px;
overflow-y: hidden;
}
.size-content.more {
max-height: 150px;
overflow-y: auto;
}
.size-more {
position: absolute;
right: 92px;
top: 15px;
color: #555;
cursor: pointer;
}
}
.checked .color-block {
... ...