Authored by 陈峰

merge

**/bundle/**/*.js
**/dist/**/*.js
coverage
public/js/home/jquery.upload.js
\ No newline at end of file
... ...
... ... @@ -9,6 +9,8 @@
const headerModel = require('../../../doraemon/models/header'); // 头部model
const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab
const indexModel = require('../models/brand');
const typeLib = require('../../../config/type-lib');
const qs = require('querystring');
/**
* 品牌一览
... ... @@ -17,7 +19,6 @@ const indexModel = require('../models/brand');
* @param int channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
*/
let index = (req, res, next) => {
let responseData = {
module: 'channel',
page: 'brand',
... ... @@ -26,17 +27,39 @@ let index = (req, res, next) => {
// title: '品牌一览 | Yoho!Buy有货 | 潮流购物逛不停',
showFooterTab: footerModel.getUrlData('category')
};
let channel;
if (!req.query.channel) {
channel = '1';
} else if (!typeLib.channels[req.query.channel]) {
channel = req.query.channel;
} else {
channel = typeLib.channels[req.query.channel] + '';
}
let param = {
channel: req.query.channel || '1',
gender: req.query.gender || '1,3'
channel
};
indexModel.getBrandByChannel(param.channel).then(result => {
res.render('brand/index', Object.assign(responseData, result));
res.render('brand/index', Object.assign(responseData, result, {
params: {
yhChannel: channel
}
}));
}).catch(next);
};
// 301到新路由
let indexRedirect = (req, res) => {
let param = qs.stringify(req.query);
if (param) {
param = '?' + param;
}
res.redirect(`/${req.yoho.channel}-brands/${param}`);
};
let brandList = (req, res, next) => {
var channel = req.query.channel || '1';
... ... @@ -152,5 +175,6 @@ module.exports = {
brandList,
delBrandHistory,
addBrandSearch,
searchAsync
searchAsync,
indexRedirect
};
... ...
... ... @@ -84,13 +84,17 @@ const getBrandByChannel = (channel) => {
let resu = {
channel: {
channels: [{
name: 'Boy'
name: 'Boy',
channelName: 'boys'
}, {
name: 'Girl'
name: 'Girl',
channelName: 'girls'
}, {
name: 'Kid'
name: 'Kid',
channelName: 'kids'
}, {
name: 'Lifestyle'
name: 'Lifestyle',
channelName: 'lifestyle'
}],
topData: {
bannerTop: {},
... ... @@ -157,52 +161,58 @@ const getBrandListByChannel = (channel) => {
let allList = result.data.all_list;
for (let key in allList) {
let obj = {
title: key,
list: []
};
allList[key].forEach(row => {
obj.list.push({
name: row.brand_name,
isHot: row.is_hot === 'Y' ? true : false,
isNew: row.is_show_new === 'Y' ? true : false,
url: helpers.urlFormat('/product/index/brand?domain=' + row.brand_domain)
if (key) {
let obj = {
title: key,
list: []
};
allList[key].forEach(row => {
obj.list.push({
name: row.brand_name,
isHot: row.is_hot === 'Y' ? true : false,
isNew: row.is_show_new === 'Y' ? true : false,
url: helpers.urlFormat('/product/index/brand?domain=' + row.brand_domain)
});
});
});
resu.brandList.push(obj);
resu.brandList.push(obj);
}
}
// 新入驻品牌
let newList = result.data.new_list;
for (let key in newList) {
let obj = {
list: []
};
if (key) {
let obj = {
list: []
};
obj.list.push({
brandName: newList[key].brand_name,
url: helpers.urlFormat('/product/index/brand?domain=' + newList[key].brand_domain),
img: helpers.image(newList[key].brand_ico, 186, 115),
});
resu.newBrandWall.push(obj);
obj.list.push({
brandName: newList[key].brand_name,
url: helpers.urlFormat('/product/index/brand?domain=' + newList[key].brand_domain),
img: helpers.image(newList[key].brand_ico, 186, 115),
});
resu.newBrandWall.push(obj);
}
}
// 推荐品牌
let hotList = result.data.hot_list;
for (let key in hotList) {
let obj = {
list: []
};
if (key) {
let obj = {
list: []
};
obj.list.push({
brandName: hotList[key].brand_name,
url: helpers.urlFormat('/product/index/brand?domain=' + hotList[key].brand_domain),
img: helpers.image(hotList[key].brand_ico, 186, 115),
});
resu.recommandBrandWall.push(obj);
obj.list.push({
brandName: hotList[key].brand_name,
url: helpers.urlFormat('/product/index/brand?domain=' + hotList[key].brand_domain),
img: helpers.image(hotList[key].brand_ico, 186, 115),
});
resu.recommandBrandWall.push(obj);
}
}
return resu;
... ... @@ -419,25 +429,22 @@ const branchSearch = (params) => {
let obj = {};
for (let key in brandList) {
let build = [];
brandList[key].forEach(row => {
build.push({
name: row.brand_name,
isHot: row.is_hot === 'Y' ? true : false,
isNew: row.is_show_new === 'Y' ? true : false,
url: helpers.urlFormat('/product/index/brand?domain=' + row.brand_domain),
brandId: row.id,
brandDomain: row.brand_domain,
searchName: row.brand_name_en + row.brand_name_cn
if (key) {
let build = [];
brandList[key].forEach(row => {
build.push({
name: row.brand_name,
isHot: row.is_hot === 'Y' ? true : false,
isNew: row.is_show_new === 'Y' ? true : false,
url: helpers.urlFormat('/product/index/brand?domain=' + row.brand_domain),
brandId: row.id,
brandDomain: row.brand_domain,
searchName: row.brand_name_en + row.brand_name_cn
});
obj[key] = build;
});
obj[key] = build;
});
}
}
resu.brandList = JSON.stringify(obj);
... ... @@ -449,17 +456,15 @@ const branchSearch = (params) => {
let hotList = result[1].data;
for (let key in hotList) {
if (key) {
let obj = {};
let obj = {};
obj = Object.assign(obj, {
name: hotList[key].brandName
});
resu.hot.push(obj);
obj = Object.assign(obj, {
name: hotList[key].brandName
});
resu.hot.push(obj);
}
}
}
// if (result && result[1] && result[1].data) {
... ... @@ -527,12 +532,12 @@ const branchSearchHistoryAsync = (uid) => {
};
for (let key in hisList) {
obj.push({
name: hisList[key].searchTerms,
searchTime: hisList[key].searchTime
});
if (key) {
obj.push({
name: hisList[key].searchTerms,
searchTime: hisList[key].searchTime
});
}
}
build.list = obj;
... ...
... ... @@ -12,6 +12,7 @@ const channel = require(cRoot);
const cate = require(cRoot + '/cate');
const brandController = require(`${cRoot}/brand`);
const custom = require(`${cRoot}/custom`);
const rewrite = require('../../doraemon/middleware/rewrite');
const router = express.Router(); // eslint-disable-line
... ... @@ -25,7 +26,8 @@ router.get('/channel/getResourceContent', channel.getResourceContent);// 获取
router.get('/(:channel)/bottomBanner', channel.bottomBanner);
router.get('/cate', cate.index);
router.get('/brands', brandController.index); // 品牌首页
router.get('/brands', rewrite.channel, brandController.indexRedirect); // 品牌首页
router.get(/^\/(.*?)-brands/, rewrite.resolve, brandController.index); // 品牌首页 SEO优化
router.get('/brands/search', brandController.search); // 品牌搜索页
router.get('/brands/getBrandList', brandController.brandList); // 获取品牌列表
router.post('/brands/searchAsync', brandController.searchAsync); // 品牌搜索异步数据
... ...
... ... @@ -4,7 +4,7 @@
<div class="genderNav">
<ul>
{{# channels}}
<li {{#if active}}class="active"{{/if}} data-id="{{@index}}">
<li {{#if active}}class="active"{{/if}} data-id="{{@index}}" data-name="{{channelName}}">
<span>{{name}}</span>
<span class="split-border"></span>
</li>
... ... @@ -56,4 +56,8 @@
</div>
{{/channel}}
</div>
{{> footer-tab}}
\ No newline at end of file
{{> footer-tab}}
{{# params}}
{{> common/query-param}}
{{/params}}
<input type="hidden" id="no-download">
\ No newline at end of file
... ...
... ... @@ -6,6 +6,7 @@
'use strict';
const mRoot = '../models';
const typeLib = require('../../../config/type-lib');
const indexModel = require(`${mRoot}/index`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab
... ... @@ -25,11 +26,14 @@ const channels = {
const editor = (req, res, next) => {
let uid = req.user.uid,
udid = req.sessionID,
id = req.query.id || 0,
id = req.query.id || req.params[0] || 0,
title = '编辑简介',
parameter = {},
isApp = req.yoho.isApp,
gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
gender = req.query.gender ||
req.query.channel && typeLib.channels[req.query.channel] ||
req.cookies._Channel && channels[req.cookies._Channel] ||
1;
if (isApp) {
uid = req.query.uid;
... ... @@ -40,44 +44,54 @@ const editor = (req, res, next) => {
})
};
}
return Promise.all([indexModel.getAuthor(id), indexModel.getArticleList(gender, 0, uid, udid, 1, null, id)]).then(datas => {
let authorData = datas[0],
articleListData = datas[1];
let build = [];
if (articleListData.data && articleListData.data.list && articleListData.data.list.artList) {
articleListData.data.list.artList.forEach(articleData => {
articleData.colparam = {
urlpath: req.path,
param: `?id=${id}`
};
build.push(guangProcess.formatArticle(articleData, true, isApp, false, uid));
});
if (!build.length) {
res.set('Cache-Control', 'no-cache');
return Promise.all([
indexModel.getAuthor(id),
indexModel.getArticleList(gender, 0, uid, udid, 1, null, id)]
).then(datas => {
let authorData = datas[0],
articleListData = datas[1];
let build = [];
if (articleListData.data && articleListData.data.list && articleListData.data.list.artList) {
articleListData.data.list.artList.forEach(articleData => {
articleData.colparam = {
urlpath: req.path,
param: `?id=${id}`
};
build.push(guangProcess.formatArticle(articleData, true, isApp, false, uid));
});
if (!build.length) {
res.set('Cache-Control', 'no-cache');
}
res.render('index/list', Object.assign({
page: 'index-editor',
title: title,
guangList: true,
gender: gender,
guang: {
infos: build,
isApp: isApp,
authorInfo: authorData.data
},
localCss: true
}, parameter));
} else {
return next();
}
}).catch(next);
res.render('index/list', Object.assign({
page: 'index-editor',
title: title,
guangList: true,
gender: gender,
guang: {
infos: build,
isApp: isApp,
authorInfo: authorData.data
},
localCss: true
}, parameter));
} else {
return next();
}
}).catch(next);
};
// 301到新路由
const editorRedirect = (req, res, next) => {
if (req.query.id) {
res.redirect(`${req.query.id}`);
} else {
return next();
}
};
/**
... ... @@ -130,19 +144,28 @@ const pageData = (req, res, next) => {
if (!authorId && isNaN(authorId)) {
showAuthor = true;
}
return indexModel.getPageData(gender, sortId, uid, udid, page, tag, authorId, isApp, showAuthor, isTab).then(data => {
if (data) {
res.render('index/page', Object.assign(data, {
layout: false
}));
} else {
res.json({
code: 400,
message: '',
data: ''
});
}
}).catch(next);
return indexModel.getPageData(gender,
sortId,
uid,
udid,
page,
tag,
authorId,
isApp,
showAuthor,
isTab).then(data => {
if (data) {
res.render('index/page', Object.assign(data, {
layout: false
}));
} else {
res.json({
code: 400,
message: '',
data: ''
});
}
}).catch(next);
};
... ... @@ -165,7 +188,7 @@ const index = (req, res, next) => {
uid: req.user.uid || req.query.uid,
udid: req.user.udid,
type: req.query.type || '0',
gender: req.query.gender || '1,3'
gender: req.query.gender || req.query.channel && typeLib.gender[req.query.channel] || '1,3'
};
indexModel.getArticle(param).then(result => {
... ... @@ -276,5 +299,6 @@ module.exports = {
index,
tag,
listDynamicData,
detailDynamicData
detailDynamicData,
editorRedirect
};
... ...
... ... @@ -6,6 +6,8 @@
'use strict';
const helpers = global.yoho.helpers;
const mRoot = '../models';
const typeLib = require('../../../config/type-lib');
const _ = require('lodash');
const infoModel = require(`${mRoot}/info`);
const stringProcess = require(`${global.utils}/string-process`);
const guangProcess = require(`${global.utils}/guang-process`);
... ... @@ -72,7 +74,9 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe
} else if (art.shareCode) {
let shareCode;
if (art.shareCode.qqShareImgUrl || art.shareCode.wechatShareImgUrl || art.shareCode.showShareImgUrl) {
if (art.shareCode.qqShareImgUrl ||
art.shareCode.wechatShareImgUrl ||
art.shareCode.showShareImgUrl) {
if (isWeixin) {
shareCode = art.shareCode.wechatShareImgUrl;
} else if (isqq) {
... ... @@ -116,7 +120,15 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe
if (o > 3) {
break;
}
d.push(guangProcess.formatProduct(goods, false, true, true, 235, 314, isApp, true, gender));
d.push(guangProcess.formatProduct(goods,
false,
true,
true,
235,
314,
isApp,
true,
gender));
}
d.forEach(p => {
if (arr[p.id]) {
... ... @@ -127,7 +139,9 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe
}
// 多个商品
if (product.data.product_list && product.data.product_list.length && (product.data.product_list.length > 1)) {
if (product.data.product_list &&
product.data.product_list.length &&
(product.data.product_list.length > 1)) {
build.relatedReco = reco;
} else if (product.data.product_list && product.data.product_list.length === 1) { // 单个商品
build.relatedReco = reco[0];
... ... @@ -163,8 +177,15 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe
if (product && product.data && product.data.product_list) {
let g = [];
product.data.product_list.forEach(_ => {
g.push(guangProcess.formatProduct(_, false, true, true, 235, 314, isApp, gender));
product.data.product_list.forEach(p => {
g.push(guangProcess.formatProduct(p,
false,
true,
true,
235,
314,
isApp,
gender));
});
g.forEach(p => {
if (arr[p.id]) {
... ... @@ -283,13 +304,16 @@ const _shareInfo = (id, getArticle) => {
* [逛资讯详情页]
*/
const index = (req, res, next) => {
let id = req.query.id || req.params.id,
gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1,
let id = req.query.id || req.params[0] || req.params.id,
gender = req.query.gender ||
req.query.channel && typeLib.channels[req.query.channel] ||
req.cookies._Channel && channels[req.cookies._Channel] ||
1,
isApp = req.query.app_version || req.query.appVersion || false, // 标识是不是APP访问的
parameter = {},
title = '逛',
isWeixin = req.yoho.isWechat,
channel = req.cookies._Channel,
channel = req.query.channel || req.cookies._Channel,
isqq = req.yoho.isqq,
isWeibo = req.yoho.isWeibo,
isShare;
... ... @@ -358,14 +382,14 @@ const index = (req, res, next) => {
// guang双头部的问题 20160601
// 正确的URL
data.guang.author.url = helpers.https(`${detail.getAuthor.url}&openby:yohobuy={"action":"go.h5","params":{"param":{},"share":"","id":${detail.getAuthor.author_id},"type":0,"islogin":"N","url":"${detail.getAuthor.url}"}}`);
let url = `${detail.getAuthor.url}&openby:yohobuy={"action":"go.h5","params":{"param":{},"share":"","id":${detail.getAuthor.author_id},"type":0,"islogin":"N","url":"${detail.getAuthor.url}"}}`; // eslint-disable-line
// 错误的URL
// data.guang.author.url = helpers.https(`${detail.getAuthor.url}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${detail.getAuthor.author_id}"},"share":"","id":${detail.getAuthor.author_id},"type":0,"islogin":"N","url":"${helpers.urlFormat('/author/index', {}, 'guang')}"}}`);
data.guang.author.url = helpers.https(url);
}
let guang = data.guang;
guang.detail = {
id: _.get(detail, 'getArticle.id'),
title: detail.getArticle.article_title,
publishTime: detail.getArticle.publishTime,
pageView: detail.getArticle.pageViews,
... ... @@ -375,47 +399,52 @@ const index = (req, res, next) => {
if (detail.getArticleContent) {
// 生成内容部分
return _pageArticleContent(detail.getArticleContent, isApp, gender, isWeixin, isqq, isWeibo).then((contents) => {
guang.detail.content = contents;
// 相关品牌
if (detail.getBrand && detail.getBrand.length) {
guang.relatedBrand = _relatedBrand(detail.getBrand);
}
return _pageArticleContent(detail.getArticleContent,
isApp,
gender,
isWeixin,
isqq,
isWeibo).then((contents) => {
guang.detail.content = contents;
// 相关品牌
if (detail.getBrand && detail.getBrand.length) {
guang.relatedBrand = _relatedBrand(detail.getBrand);
}
// 相关标签
if (detail.getArticle.tags && detail.getArticle.tags.length) {
guang.relatedTag = _relatedTag(detail.getArticle.tags, isApp);
}
// 相关标签
if (detail.getArticle.tags && detail.getArticle.tags.length) {
guang.relatedTag = _relatedTag(detail.getArticle.tags, isApp);
}
// 相关文章
if (detail.getOtherArticle && detail.getOtherArticle.length) {
guang.relatedInfo = _relatedInfo(detail.getOtherArticle, isApp);
}
// 相关文章
if (detail.getOtherArticle && detail.getOtherArticle.length) {
guang.relatedInfo = _relatedInfo(detail.getOtherArticle, isApp);
}
// 分享参数
if (detail.getArticle.cover_image) {
let shareInfo = _shareInfo(id, detail.getArticle);
// 分享参数
if (detail.getArticle.cover_image) {
let shareInfo = _shareInfo(id, detail.getArticle);
Object.assign(guang, shareInfo);
data.title = detail.getArticle.article_title + ' | Yoho!Buy有货 | 潮流购物逛不停';
data.title_more = true;
data.description = detail.getArticle.article_summary;
data.description_more = true;
}
Object.assign(guang, shareInfo);
data.title = detail.getArticle.article_title + ' | Yoho!Buy有货 | 潮流购物逛不停';
data.title_more = true;
data.description = detail.getArticle.article_summary;
data.description_more = true;
}
// 标识有微信分享
data.hasWxShare = true;
res.render('info/index', Object.assign({
page: 'info-index',
title: '逛',
gender: gender,
wechatShare: true,
isWeixin: isWeixin,
localCss: true,
isShare: isShare
}, data, parameter));
});
// 标识有微信分享
data.hasWxShare = true;
res.render('info/index', Object.assign({
page: 'info-index',
title: '逛',
gender: gender,
wechatShare: true,
isWeixin: isWeixin,
localCss: true,
isShare: isShare
}, data, parameter));
});
} else {
next();
return;
... ... @@ -425,6 +454,15 @@ const index = (req, res, next) => {
}).catch(next);
};
// 301到新路由
const indexRedirect = (req, res, next) => {
if (req.query.id) {
res.redirect(`${req.query.id}`);
} else {
return next();
}
};
/**
* [逛mini内容页]
*/
... ... @@ -565,5 +603,6 @@ const foryoho = (req, res, next) => {
module.exports = {
index,
mini,
foryoho
foryoho,
indexRedirect
};
... ...
... ... @@ -6,9 +6,11 @@
'use strict';
const mRoot = '../models';
const typeLib = require('../../../config/type-lib');
const plusstarModel = require(`${mRoot}/plusstar`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
const _ = require('lodash');
const qs = require('querystring');
let channels = {
boys: 1,
girl: 2,
... ... @@ -23,7 +25,10 @@ exports.index = (req, res, next) => {
let isApp = req.query.app_version || req.query.appVersion || false;
let parameter = {};
let title = '潮流优选';
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
let gender = req.query.gender ||
req.query.channel && typeLib.channels[req.query.channel] ||
req.cookies._Channel && channels[req.cookies._Channel] ||
1;
if (isApp === false) {
parameter = {
... ... @@ -36,6 +41,21 @@ exports.index = (req, res, next) => {
let result = {};
switch (gender) {
case typeLib.gender.boys:
gender = 1;
break;
case typeLib.gender.girls:
gender = 2;
break;
case typeLib.gender.kids:
gender = 3;
break;
case typeLib.gender.lifestyle:
gender = 4;
break;
}
plusstarModel.getAllChannels({
gender: gender,
app_type: 0
... ... @@ -52,6 +72,12 @@ exports.index = (req, res, next) => {
});
}).then(data => {
result = Object.assign(result, data);
// 此处 channel 需要读取 cookies 的 channel
if (req.cookies._Channel) {
res.locals.pageChannel = {};
res.locals.pageChannel[req.cookies._Channel] = true;
}
res.render('plusstar/index', Object.assign({
page: 'plusstar-index',
result: result,
... ... @@ -62,6 +88,16 @@ exports.index = (req, res, next) => {
}).catch(next);
};
// 301到新路由
exports.indexRedirect = (req, res) => {
let param = qs.stringify(req.query);
if (param) {
param = '?' + param;
}
res.redirect(`/guang/${req.yoho.channel}-plusstar/${param}`);
};
exports.userSkn = (req, res, next) => {
let isApp = req.body.app_version || req.body.appVersion || false;
let uid = '';
... ...
... ... @@ -11,6 +11,7 @@ const cRoot = './controllers';
const star = require(cRoot + '/star');
const homeController = require(`${cRoot}/index`);
const plusstar = require(cRoot + '/plusstar');
const rewrite = require('../../doraemon/middleware/rewrite');
const index = require(cRoot + '/index');
const opt = require(cRoot + '/opt');
... ... @@ -31,8 +32,10 @@ router.get('/star/collocation/list', star.collocationList); // 星潮教室星
router.post('/star/setFavorite', star.setFavorite); // 收藏文章
router.get('/', homeController.index); // 逛首页
// router.get(/^\/((boys)|(girls)|(kids)|(lifestyle)-[^\/]+)/, rewrite.resolve, homeController.index); // 逛首页 SEO优化
router.get('/plusstar', plusstar.index); // 潮流优选
router.get('/plusstar', rewrite.channel, plusstar.indexRedirect); // 潮流优选
router.get(/^\/(.*?)-plusstar/, rewrite.resolve, plusstar.index); // 潮流优选 SEO优化
router.post('/plusstar/userSkn', plusstar.userSkn); // 用户推荐skn
router.get('/plusstar/resources-template', plusstar.resourcesTemplate); // 潮流优选首页-资源位
router.post('/plusstar/resources-goodsList', plusstar.resourcesGoodsList); // 潮流优选首页-资源位-商品列表
... ... @@ -40,6 +43,7 @@ router.get('/', index.index); // 逛首页
router.get('/tags/index', index.tag); // 逛标签页
router.get('/author/index', index.editor); // 编辑简介
router.get(/^\/author-([^\/]+)/, rewrite.resolve, index.editor); // 编辑简介 SEO优化
router.get('/index/page', index.pageData); // 逛列表页面的资讯分页
... ... @@ -48,6 +52,7 @@ router.post('/opt/collectArticle', opt.collectArticle); // 资讯文章收藏 (H
router.post('/opt/favoriteBrand', opt.favoriteBrand); // 品牌收藏
router.get('/info/index', info.index); // 逛详情页
// router.get(/^\/info\/(.*?-\d+)/, rewrite.resolve, info.index); // 逛详情页 SEO优化
router.get('/:id.html', info.index); // 逛详情页(兼容 PC 跳转过来的链接)
router.get('/info/mini', info.mini); // 逛mini内容页
router.get('/info/foryoho', info.foryoho); // 逛foryoho内容页
... ...
... ... @@ -15,7 +15,7 @@
</div>
{{/ author}}
{{# detail}}
<div class="detail">
<div class="detail" data-id="{{id}}">
<div class="post-title">
<p class="title">{{title}}</p>
{{> index/tvls}}
... ...
... ... @@ -13,6 +13,7 @@ const newModel = require(`${mRoot}/new`);
const searchModel = require(`${mRoot}/search`);
const _ = require('lodash');
const helpers = global.yoho.helpers;
const qs = require('querystring');
// 新品到着(blk)
const blkNewGoods = (req, res, next) => {
... ... @@ -78,6 +79,16 @@ const newGoods = (req, res, next) => {
}).catch(next);
};
// 301到新路由
const newGoodsRedirect = (req, res) => {
let param = qs.stringify(req.query);
if (param) {
param = '?' + param;
}
res.redirect(`/product/${req.yoho.channel}-new/${param}`);
};
/**
* 重构的新品到着页面
*/
... ... @@ -242,5 +253,6 @@ module.exports = {
recommendShop,
fetchNew,
goodsFilter
goodsFilter,
newGoodsRedirect
};
... ...
... ... @@ -10,6 +10,7 @@ const mRoot = '../models';
// const cookie = require(`${library}/cookie`);
const headerModel = require('../../../doraemon/models/header');
const saleModel = require(`${mRoot}/sale`);
const qs = require('querystring');
// const queryParam = {
// brand: '0',
... ... @@ -55,7 +56,7 @@ const _processPublicData = (req, title, page, backUrl) => {
let index = (req, res, next) => {
let refer = req.get('Referer') || `${global.yoho.config.siteUrl}/${req.cookies._Channel || ''}`;
let reqPath = req.baseUrl + req.path;
let backUrl = refer.indexOf(reqPath) === -1 ? refer : '';
let backUrl = refer.indexOf(reqPath) === -1 && refer.indexOf('-sale') === -1 ? refer : '';
if (['boys', 'girls', 'kids', 'lifestyle'].indexOf(req.yoho.channel) === -1) {
return next();
... ... @@ -68,11 +69,13 @@ let index = (req, res, next) => {
let params = _processPublicData(req, 'SALE', 'sale', backUrl);
params.channel = req.query.channel || params.channel;
saleModel.getSaleData(params.channel).then((result) => {
// 扩展头部频道选择数据
Object.assign(params.renderData.pageHeader, {
saleNav: saleModel.saleNav(req.yoho.channel)
saleNav: saleModel.saleNav(params.channel, req.params[0] || !req.query.channel)
});
// 此处 channel 需要读取 cookies 的 channel
... ... @@ -96,6 +99,16 @@ let index = (req, res, next) => {
}).catch(next);
};
// 301到新路由
let indexRedirect = (req, res) => {
let param = qs.stringify(req.query);
if (param) {
param = '?' + param;
}
res.redirect(`/product/${req.yoho.channel}-sale/${param}`);
};
/**
* 断码区
* @param {[object]} req
... ... @@ -250,5 +263,6 @@ module.exports = {
vip,
filter,
search,
getTime
getTime,
indexRedirect
};
... ...
... ... @@ -51,22 +51,26 @@ const channelHash = {
lifestyle: 'Lifestyle'
};
const saleNav = (channel) => {
const saleNav = (channel, shortUrl) => {
return {
channel: channelHash[channel],
list: [
{
title: 'Boy',
url: helpers.urlFormat('/product/sale', {channel: 'boys'})
url: shortUrl ? helpers.urlFormat('/product/boys-sale/') :
helpers.urlFormat('/product/sale', {channel: 'boys'})
}, {
title: 'Girl',
url: helpers.urlFormat('/product/sale', {channel: 'girls'})
url: shortUrl ? helpers.urlFormat('/product/girls-sale/') :
helpers.urlFormat('/product/sale', {channel: 'girls'})
}, {
title: 'Kid',
url: helpers.urlFormat('/product/sale', {channel: 'kids'})
url: shortUrl ? helpers.urlFormat('/product/kids-sale/') :
helpers.urlFormat('/product/sale', {channel: 'kids'})
}, {
title: 'Lifestyle',
url: helpers.urlFormat('/product/sale', {channel: 'lifestyle'})
url: shortUrl ? helpers.urlFormat('/product/lifestyle-sale/') :
helpers.urlFormat('/product/sale', {channel: 'lifestyle'})
}
]
};
... ...
... ... @@ -10,6 +10,8 @@ const router = require('express').Router(); // eslint-disable-line
const auth = require('../../doraemon/middleware/auth');
const rewrite = require('../../doraemon/middleware/rewrite');
const cRoot = './controllers';
// 商品详情controller
... ... @@ -61,6 +63,7 @@ router.get(/^\/seckill\/pro_([\d]+)_([\d]+)/, seckillDetail.index); // 秒杀商
router.get(/^\/pro_([\d]+)_([\d]+)/, newDetail.index); // 商品详情页
// /show_51047967.html
router.get(/^\/show_([\d]+)/, newDetail.index); // 商品详情页 SKN 进入
// router.get(/^\/p([\d]+)\.html/, newDetail.index); // 商品详情页 SKN 进入 SEO优化
router.get('/detail/sknData.json', newDetail.sknData); // 商品咨询,评价,店铺
router.get('/detail/intro/:productskn', detail.intro); // 商品内嵌页
... ... @@ -85,10 +88,16 @@ router.get('/seckillDetail/seckillData/:productskn', seckillDetail.getSeckillDat
router.post('/detail/consultupvote', detail.consultUpvoteOrUseful); // 商品咨询提交接口
router.post('/detail/consultuseful', detail.consultUpvoteOrUseful); // 商品咨询提交接口
router.get('/sale', sale.index);
router.get('/sale', rewrite.channel, sale.indexRedirect);
router.get(/^\/(.*?)-sale/, rewrite.resolve, sale.index); // 折扣专区 SEO优化
router.get('/sale/discount', sale.discount);
// router.get(/^\/(.*?)-sale\/discount/, rewrite.resolve, sale.discount);
router.get('/sale/discount/detail', sale.discountDetail);
router.get('/sale/breakingYards', sale.breakingYards);
// router.get(/^\/(.*?)-sale\/breakingYards/, rewrite.resolve, sale.breakingYards); // SEO优化
router.get('/sale/vip', sale.vip);
router.get('/sale/discount/getTime', sale.getTime);
... ... @@ -156,7 +165,11 @@ router.get('/index/intro', list.shopIntro);
router.get('/opt/favoriteBrand', list.favoriteBrand);
// 新品到着
router.get('/new', news.newGoods);
router.get('/new', rewrite.channel, news.newGoodsRedirect);
// 新品到着 SEO优化
router.get(/^\/(.*?)-new/, rewrite.resolve, news.newGoods);
router.get('/list/new', news.newGoods); // 兼容 PC 的链接
router.get('/new/selectNewSale', news.selectNewSale);
router.get('/new/filter', news.filter);
... ...
/**
* 类型映射配置
* @author: chenfeng<feng.chen@yoho.cn>
* @date: 2017/02/20
*/
'use strict';
const channels = {
boys: 1,
girl: 2,
girls: 2,
kids: 3,
lifestyle: 4
};
const channelNames = {
[1]: 'boys',
[2]: 'girls',
[3]: 'kids',
[4]: 'lifestyle'
};
const gender = {
boys: '1,3',
girl: '2,3',
girls: '2,3',
kids: '3,3',
lifestyle: '4'
};
module.exports = {
channels,
channelNames,
gender
};
... ...
/**
* 路由重写
* @author: chenfeng<feng.chen@yoho.cn>
* @date: 2017/2/20
*/
'use strict';
const typeLib = require('../../config/type-lib');
const _ = require('lodash');
const resolve = (req, res, next) => {
let path = req.params[0],
params = {
channel: req.yoho.channel
};
if (!path) {
return next();
}
let conditions = path.replace('.html', '').split('-');
_.each(conditions, condition => {
if (typeLib.channels[condition]) {
params.channel = condition;
} else if (condition.indexOf('_') >= 0) {
let item = condition.split('_');
if (item.length === 2) {
params[item[0]] = item[1];
}
} else if (condition >= 0) {
params.id = _.parseInt(condition);
}
});
req.yoho.channel = params.channel;
res.locals.channel = params.channel;
res.locals.pageChannel = { [params.channel]: true };
res.locals.setChannel = true;
Object.assign(req.query, params);
next();
};
const channel = (req, res, next) => {
let channelName;
if (req.query.channel) {
if (req.query.channel >= 0) {
channelName = typeLib.channelNames[req.query.channel];
} else if (typeLib.channels[req.query.channel]) {
channelName = req.query.channel;
}
} else if (req.query.gender) {
let gender = req.query.gender;
switch (gender) {
case typeLib.gender.boys:
gender = 1;
break;
case typeLib.gender.girls:
gender = 2;
break;
case typeLib.gender.kids:
gender = 3;
break;
case typeLib.gender.lifestyle:
gender = 4;
break;
}
channelName = typeLib.channelNames[gender];
}
channelName = channelName || req.yoho.channel;
req.yoho.channel = channelName;
delete req.query.channel;
delete req.query.gender;
next();
};
module.exports = {
resolve,
channel
};
... ...
{{#pageHeader}}
{{# @root.pageChannel}}
<header id="yoho-header" class="yoho-header{{#if boys}} boys{{/if}}{{#if girls}} girls{{/if}}{{#if kids}} kids{{/if}}{{#if lifeStyle}} life-style{{/if}}{{#if lifestyle}} life-style{{/if}}">
<header id="yoho-header" class="yoho-header{{#if @root.setChannel}} set-channel{{/if}}{{#if boys}} boys{{/if}}{{#if girls}} girls{{/if}}{{#if kids}} kids{{/if}}{{#if lifeStyle}} life-style{{/if}}{{#if lifestyle}} life-style{{/if}}">
{{^}}
<header id="yoho-header" class="yoho-header">
{{/ @root.pageChannel}}
... ... @@ -53,7 +53,7 @@
{{/if}}
{{#navBtn}}
{{# @root.pageChannel}}
<div class="homebuttom hide {{#if boys}} boys{{/if}}{{#if girls}} girls{{/if}}{{#if kids}} kids{{/if}}{{#if lifeStyle}} life-style{{/if}}{{#if lifestyle}} life-style{{/if}}">
<div class="homebuttom hide{{#if @root.setChannel}} set-channel{{/if}} {{#if boys}} boys{{/if}}{{#if girls}} girls{{/if}}{{#if kids}} kids{{/if}}{{#if lifeStyle}} life-style{{/if}}{{#if lifestyle}} life-style{{/if}}">
{{^}}
<div class="homebuttom hide">
{{/ @root.pageChannel}}
... ...
{
"name": "m-yohobuy-node",
"version": "5.4.14",
"version": "5.4.15",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -5,15 +5,15 @@
*/
require('channel/brand.page.css');
var $ = require('yoho-jquery'),
let $ = require('yoho-jquery'),
Hammer = require('../common/toy-hammer'),
Swiper = require('yoho-swiper'),
lazyLoad = require('yoho-jquery-lazyload');
var ranToken = ' ??++ ';
var ranToken2 = ' ???--- ';
let ranToken = ' ??++ ';
let ranToken2 = ' ???--- ';
var $brandList,
let $brandList,
$newBrandWall,
$recommandBrandWall,
$icon = $('.search-icon'),
... ... @@ -26,26 +26,26 @@ var $brandList,
$searchResult = $('.search-result'),
$navBtn = $('.nav-home');
var brandsData,
let brandsData,
$keyword = $('#keyword');
var $history = $('.local-history');
var $searchPage = $('.search-brand-page');
var $historySearch = $('.history-search');
var $hotSearch = $('.hot-search');
var $clearHistory = $('#clear-history');
var isSearchPage = $('.brand-search-page').length > 0;
let $history = $('.local-history');
let $searchPage = $('.search-brand-page');
let $historySearch = $('.history-search');
let $hotSearch = $('.hot-search');
let $clearHistory = $('#clear-history');
let isSearchPage = $('.brand-search-page').length > 0;
require('../common');
require('../footer');
function getBrandList() {
var listHbs = require('channel/brandlist.hbs');
let listHbs = require('channel/brandlist.hbs');
$.ajax({
url: '/brands/getBrandList',
data: {
channel: window.queryString.channel
channel: window.queryString.channel || $('.query-param[data-attr="yhChannel"]').val()
},
success: function(data) {
$('#placeholder-brandlist').replaceWith(listHbs(data));
... ... @@ -53,7 +53,7 @@ function getBrandList() {
lazyLoad($('img.lazy'));
// 改变背景色
changeBackground();
changeBackground(); //eslint-disable-line
$brandList = $('.brand-list');
$newBrandWall = $('.new-brand-wall');
... ... @@ -65,7 +65,7 @@ function getBrandList() {
}
function changeBackground() {
var brandList = $('.brand-list').find('p');
let brandList = $('.brand-list').find('p');
brandList.on('touchstart', function() {
brandList.css('background', '#fff');
... ... @@ -115,11 +115,11 @@ function searchInput() {
// $(this).closest('.search-box').css('width', '12.5rem');
$searchAction.find('.clear-text').hide();
}
searchResult();
searchResult(); //eslint-disable-line
}
function isLocalStorageSupported() {
var testKey = 'test',
let testKey = 'test',
storage = Window.prototype.localStorage || window.localStorage;
try {
... ... @@ -132,20 +132,16 @@ function isLocalStorageSupported() {
}
// 绑定提交前的存local操作
function bindWriteLocal($brandList, list) {
$brandList.on('click', 'p , li', function(e) {
var brandName, brandId, brandDomain, url;
var a = $(this).find('a');
var myDate = new Date();
var query = a.attr('brandName') + ranToken2 + myDate.getTime(),
function bindWriteLocal(brandListEle, list) {
brandListEle.on('click', 'p , li', function(e) {
let brandName, url;
let a = $(this).find('a');
let myDate = new Date();
let query = a.attr('brandName') + ranToken2 + myDate.getTime(),
historys;
brandName = a.attr('brandName');
brandId = a.attr('brandId');
brandDomain = a.attr('brandDomain');
url = a.attr('href');
e.preventDefault();
... ... @@ -200,8 +196,8 @@ function bindWriteLocal($brandList, list) {
}
function searchResult() {
var keyword = ($keyword.val() + '').toLowerCase();
var result = {},
let keyword = ($keyword.val() + '').toLowerCase();
let result = {},
i = 0,
html = '';
... ... @@ -212,7 +208,7 @@ function searchResult() {
if ($.isArray(v)) {
// 遍历品牌,进行匹配
$.each(v, function(i, brand) {
$.each(v, function(index, brand) {
if (brand.searchName.toLowerCase().indexOf(keyword) > -1) {
result[k] = result[k] || [];
result[k].push(brand);
... ... @@ -223,13 +219,13 @@ function searchResult() {
// 根据搜索结果生成 HTML
$.each(result, function(k, v) {
var brandHtml = ['<div class="brand-list bar-', i, '">'];
let brandHtml = ['<div class="brand-list bar-', i, '">'];
i++;
brandHtml.push('<div class="title-bar"><h2>');
brandHtml.push(k);
brandHtml.push('</h2></div>');
$.each(v, function(i, brand) {
$.each(v, function(index, brand) {
brandHtml.push('<p><a href="' + brand.url + '" brandName = "' + brand.name +
'" brandId = "' + brand.brandId + '" brandDomain = "' + brand.brandDomain + '">' + brand.name);
... ... @@ -262,8 +258,8 @@ function searchResult() {
(function() {
if ($('.banner-top').length === 0) {
var h1 = $('.genderNav').height();
var h2 = $('.newbrand-search').height();
let h1 = $('.genderNav').height();
let h2 = $('.newbrand-search').height();
$('.hot-brands').css('padding-top', (h1 + h2) + 'px');
}
... ... @@ -285,13 +281,19 @@ function searchResult() {
});
$genderItem.on('touchstart', function() {
var index = $(this).data('id') + 1;
if (window.queryString.channel) {
let index = $(this).data('id') + 1;
window.location.search = 'channel=' + index;
window.location.search = 'channel=' + index;
} else {
let name = $(this).data('name').toLowerCase();
window.location.href = `/${name}-brands/`;
}
});
$brandItem.on('click', function() {
var index = $(this).data('id');
let index = $(this).data('id');
$('.brandNav ul .active').removeClass('active');
$(this).addClass('active');
... ... @@ -351,7 +353,7 @@ if (isSearchPage) {
$keyword.closest('.search-box').css('width', '13rem');
$searchAction.show().find('.clear-text').hide();
var clearTextHammer = new Hammer($('.clear-text')[0]);
let clearTextHammer = new Hammer($('.clear-text')[0]);
clearTextHammer.on('tap', function(e) {
$searchResult.html('');
... ... @@ -380,7 +382,7 @@ if (isSearchPage) {
}
$netHistory = $('.net-history');
var chHammer = new Hammer($clearHistory[0]);
let chHammer = new Hammer($clearHistory[0]);
chHammer.on('tap', function() {
if (isLocalStorageSupported()) {
... ... @@ -399,7 +401,7 @@ if (isSearchPage) {
// 搜索页面
(function() {
var html = '',
let html = '',
history,
historys, i,
localHistory,
... ... @@ -417,7 +419,7 @@ if (isSearchPage) {
dict = {
brand: brand,
time: time
}, dictc, dict;
}, dictc, dict; //eslint-disable-line
netArr.push(dict);
});
... ...
... ... @@ -182,9 +182,6 @@ $.extend({
var user = getUser();
var backToTopHammer;
var floatTopHammer;
setTimeout(function() {
rePosFooter(); // 计算底部位置
}, 500);
... ... @@ -343,8 +340,8 @@ function givePoint(parameter) {
}
// 男:1,女:2,潮童:3,创意生活:4
var CID = _ChannelVary[cookie('_Channel')] || 1;
var isAppOp = parameter.isAppOp;
let CID = _ChannelVary[cookie('_Channel')] || 1;
let isAppOp = parameter.isAppOp;
parameter = $.extend({
REC_ID: RECID,
... ... @@ -370,39 +367,41 @@ function givePoint(parameter) {
var header = $('#yoho-header, .homebuttom');
var footer = $('.footer-tab .tab-item.current');
if (!/^\/home/.test(location.pathname)) {
switch (channel) {
case 'boys':
if (!header.hasClass('boys')) {
header.addClass('boys');
}
break;
case 'girls':
if (!header.hasClass('girls')) {
header.addClass('girls');
}
break;
case 'lifestyle':
if (!header.hasClass('life-style')) {
header.addClass('life-style');
}
break;
case 'kids':
if (!header.hasClass('kids')) {
header.addClass('kids');
}
break;
default:
if (!header.hasClass('boys')) {
header.addClass('boys');
}
break;
if (!header.hasClass('set-channel')) {
if (!/^\/home/.test(location.pathname)) {
switch (channel) {
case 'boys':
if (!header.hasClass('boys')) {
header.addClass('boys');
}
break;
case 'girls':
if (!header.hasClass('girls')) {
header.addClass('girls');
}
break;
case 'lifestyle':
if (!header.hasClass('life-style')) {
header.addClass('life-style');
}
break;
case 'kids':
if (!header.hasClass('kids')) {
header.addClass('kids');
}
break;
default:
if (!header.hasClass('boys')) {
header.addClass('boys');
}
break;
}
} else {
header.removeClass('kids');
header.removeClass('girls');
header.removeClass('life-style');
header.addClass('boys');
}
} else {
header.removeClass('kids');
header.removeClass('girls');
header.removeClass('life-style');
header.addClass('boys');
}
switch (channel) {
... ...
... ... @@ -32,7 +32,7 @@ function refreshData() {
var qs = window.queryString;
var id = qs.id;
var id = qs.id || $('.detail').data('id');
getDynamicById(id).done(renderData);
}
... ...
... ... @@ -6,7 +6,7 @@
require('product/sale/break-code-index.page.css');
var $ = require('yoho-jquery'),
let $ = require('yoho-jquery'),
Swiper = require('yoho-swiper2'),
ellipsis = require('yoho-mlellipsis'),
lazyLoad = require('yoho-jquery-lazyload'),
... ... @@ -14,24 +14,24 @@ var $ = require('yoho-jquery'),
filter = require('../plugin/filter'),
loading = require('../plugin/loading');
var $goodsContainer = $('#goods-container'),
let $goodsContainer = $('#goods-container'),
$goodsChildren = $goodsContainer.children(),
$coatGc = $($goodsChildren.get(0)),
$trouserGc = $($goodsChildren.get(1)),
$shoesgc = $($goodsChildren.get(2)),
$othergc = $($goodsChildren.get(3));
var $filterMask;
let $filterMask;
var winH = $(window).height(),
let winH = $(window).height(),
noResult = '<p class="no-result">未找到相关搜索结果</p>';
// 默认筛选条件
var defaultOpt = require('../common/query-param');
let defaultOpt = require('../common/query-param');
var storeOpt = {};
let storeOpt = {};
var $listNav = $('#list-nav'),
let $listNav = $('#list-nav'),
$sizeArea = $('.size-area'),
$subSize = $('.sub-size'),
... ... @@ -61,7 +61,7 @@ var $listNav = $('#list-nav'),
$pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项
searching;
var goodsType = ['coat', 'trouser', 'shoes', 'other'];
let goodsType = ['coat', 'trouser', 'shoes', 'other'];
require('../common');
require('../common/suspend-cart'); // 悬浮购物车
... ... @@ -83,7 +83,7 @@ function getUrlParam(name) {
}
defaultOpt = $.extend({
yh_channel: getUrlParam('channel') || 'boys',
yh_channel: getUrlParam('channel') || defaultOpt.channel || 'boys', //TODO GO ON!
saleType: 1
}, defaultOpt);
... ...
... ... @@ -6,13 +6,14 @@
require('product/sale/index.page.css');
var $ = require('yoho-jquery'),
let $ = require('yoho-jquery'),
Swiper = require('yoho-swiper2'),
ellipsis = require('yoho-mlellipsis'),
fastclick = require('yoho-fastclick'),
lazyload = require('yoho-jquery-lazyload');
var search = require('./sale/search');
let search = require('./sale/search');
let defaultOpt = require('../common/query-param');
require('../common');
... ... @@ -52,7 +53,7 @@ $(function() {
$.ajax({
url: '/product/sale/search',
data: {
yh_channel: window.queryString.channel || 'boys',
yh_channel: window.queryString.channel || defaultOpt.channel || 'boys',
saleType: '2',
productPool: $vipFloor.data('id'),
limit: '4'
... ...
... ... @@ -106,7 +106,7 @@ if ($('.sale-vip-page').length > 0) {
// 获取频道
$.extend(defaultOpt, {
yh_channel: getUrlParam('channel') || 'all'
yh_channel: getUrlParam('channel') || defaultOpt.channel || 'all'
});
// 判断导航类型
... ... @@ -251,7 +251,7 @@ function search(opt, params, isScroll) {
loading.showLoadingMask();
/* TODO tar add 161125 sale dicount no yh_channel*/
var discount = $('#discount').val();
let discount = $('#discount').val();
if (discount === 'discount') {
delete setting.yh_channel;
... ...
... ... @@ -21,10 +21,15 @@ const transHttpsUrl = (url) => {
* @return {[strng]}
*/
const getFilterUrl = (url) => {
url = url.replace('.m.yohobuy.com', global.yoho.config.subDomains.host).replace('www.yohobuy.com', global.yoho.config.siteUrl);
url = url.replace('.m.yohobuy.com', global.yoho.config.subDomains.host)
.replace('www.yohobuy.com', global.yoho.config.siteUrl);
const whiteDomains = ['m.yohobuy.com', 'cdn.yoho.cn/myohobuy'];
const blackDomains = ['sale.m.yohobuy.com', 'cuxiao.m.yohobuy.com', 'activity.m.yohobuy.com', 'huodong.m.yohobuy.com', '/home/orders/pay'];
const blackDomains = ['sale.m.yohobuy.com',
'cuxiao.m.yohobuy.com',
'activity.m.yohobuy.com',
'huodong.m.yohobuy.com',
'/home/orders/pay'];
if (whiteDomains.every(_ => url.includes(_)) &&
blackDomains.every(_ => !url.includes(_))) {
... ... @@ -53,10 +58,9 @@ const getFilterUrl = (url) => {
* @param {Boolean} isApp [是否显示分享,在APP客户端里嵌入需要传url链接]
* @param {[Boolean]} showAuthor [控制是否显示作者信息]
* @param {[int]} uid [当前登录的用户ID]
* @param {[string]} reqQueryString [查询字符串]
* @return {[array | false]}
*/
const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryString) => {
const formatArticle = (articleData, showTag, isApp, showAuthor, uid) => {
// 资讯ID不存在,则不显示
if (!articleData.id) {
return false;
... ... @@ -65,7 +69,7 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr
id: articleData.id,
showTags: showTag,
img: articleData.src ? helpers.image(articleData.src, 640, 640) : '',
url: isApp ? `${helpers.https(articleData.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${articleData.id}"},"shareparam":{"id":"${articleData.id}"},"share":"/guang/api/v1/share/guang","id":${articleData.id},"type":1,"url":"http:${helpers.urlFormat('/info/index', null, 'guang')}","islogin":"N"}}` : articleData.url,
url: isApp ? `${helpers.https(articleData.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${articleData.id}"},"shareparam":{"id":"${articleData.id}"},"share":"/guang/api/v1/share/guang","id":${articleData.id},"type":1,"url":"http:${helpers.urlFormat('/info/index', null, 'guang')}","islogin":"N"}}` : articleData.url, //eslint-disable-line
title: articleData.title,
text: articleData.intro,
publishTime: articleData.publish_time,
... ... @@ -92,7 +96,7 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr
if (!uid) {
let playUrlEncode = `${originUrl}${colparam.param}`.replace(/\//g, '\\\/');
collectUrl = `${originUrl}?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"${playUrlEncode}","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}`;
collectUrl = `${originUrl}?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"${playUrlEncode}","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}`; //eslint-disable-line
}
result.collect.url = collectUrl;
} else { // 点赞
... ... @@ -104,19 +108,20 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr
if (isApp && articleData.share.url) {
// 分享链接
result.share = `${articleData.share.url}?openby:yohobuy={"action":"go.share","params":{"title":"${articleData.title}","content":"${articleData.intro}","url":"${articleData.share.url}","pic":"https:${result.img}"}}`;
result.share = `${articleData.share.url}?openby:yohobuy={"action":"go.share","params":{"title":"${articleData.title}","content":"${articleData.intro}","url":"${articleData.share.url}","pic":"https:${result.img}"}}`; //eslint-disable-line
}
// 判断是否显示作者信息
if (showAuthor && articleData.author) {
if (!isApp) {
articleData.author.url = getFilterUrl(articleData.author.url);
}
} else {
// 编辑人员 app跳转url处理 20160601
let isLogin = uid ? true : false;
// 编辑人员 app跳转url处理 20160601
let isLogin = uid ? true : false;
articleData.author.url = `${helpers.https(articleData.author.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{},"share":"","id":${articleData.author.author_id},"type":0,"islogin":"${isLogin}","url":"${articleData.author.url}"}}`; //eslint-disable-line
}
articleData.author.url = `${helpers.https(articleData.author.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{},"share":"","id":${articleData.author.author_id},"type":0,"islogin":"${isLogin}","url":"${articleData.author.url}"}}`;
result.author = articleData.author;
if (result.author.avatar) {
result.author.avatar = result.author.avatar.replace('http://', '//');
... ... @@ -281,14 +286,14 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height,
productData.cn_alphabet = productNameProcess(productData.cn_alphabet);
}
let url = encodeURI(helpers.urlFormat(`/product/pro_${productData.product_id}_${productData.goods_list[0].goods_id}/${productData.cn_alphabet}.html`));
let url = encodeURI(helpers.urlFormat(`/product/pro_${productData.product_id}_${productData.goods_list[0].goods_id}/${productData.cn_alphabet}.html`)); //eslint-disable-line
result.url = url.replace('http://', '//');
// APP访问需要加附加的参数
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if (isApp) {
result.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${productData.product_skn}}}`;
result.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${productData.product_skn}}}`; //eslint-disable-line
}
if (showTags) {
result.tags = {
... ... @@ -305,7 +310,10 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height,
if (result.is_soon_sold_out && result.tags.is_discount) {
result.tags.is_new = false;
} else if (result.tags.is_discount &&
(result.tags.is_new || result.tags.is_limited || result.tags.is_yohood || result.tags.is_advance) // 打折与其它组合则隐藏打折
(result.tags.is_new ||
result.tags.is_limited ||
result.tags.is_yohood ||
result.tags.is_advance) // 打折与其它组合则隐藏打折
) {
result.tags.is_discount = false;
} else if (result.tags.is_yohood && result.tags.is_new) { // YOHOOD和新品组合显示YOHOOD
... ...