Authored by 陈峰

merge

1 **/bundle/**/*.js 1 **/bundle/**/*.js
2 **/dist/**/*.js 2 **/dist/**/*.js
3 coverage 3 coverage
  4 +public/js/home/jquery.upload.js
@@ -9,6 +9,8 @@ @@ -9,6 +9,8 @@
9 const headerModel = require('../../../doraemon/models/header'); // 头部model 9 const headerModel = require('../../../doraemon/models/header'); // 头部model
10 const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab 10 const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab
11 const indexModel = require('../models/brand'); 11 const indexModel = require('../models/brand');
  12 +const typeLib = require('../../../config/type-lib');
  13 +const qs = require('querystring');
12 14
13 /** 15 /**
14 * 品牌一览 16 * 品牌一览
@@ -17,7 +19,6 @@ const indexModel = require('../models/brand'); @@ -17,7 +19,6 @@ const indexModel = require('../models/brand');
17 * @param int channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道 19 * @param int channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
18 */ 20 */
19 let index = (req, res, next) => { 21 let index = (req, res, next) => {
20 -  
21 let responseData = { 22 let responseData = {
22 module: 'channel', 23 module: 'channel',
23 page: 'brand', 24 page: 'brand',
@@ -26,17 +27,39 @@ let index = (req, res, next) => { @@ -26,17 +27,39 @@ let index = (req, res, next) => {
26 // title: '品牌一览 | Yoho!Buy有货 | 潮流购物逛不停', 27 // title: '品牌一览 | Yoho!Buy有货 | 潮流购物逛不停',
27 showFooterTab: footerModel.getUrlData('category') 28 showFooterTab: footerModel.getUrlData('category')
28 }; 29 };
  30 + let channel;
  31 +
  32 + if (!req.query.channel) {
  33 + channel = '1';
  34 + } else if (!typeLib.channels[req.query.channel]) {
  35 + channel = req.query.channel;
  36 + } else {
  37 + channel = typeLib.channels[req.query.channel] + '';
  38 + }
29 39
30 let param = { 40 let param = {
31 - channel: req.query.channel || '1',  
32 - gender: req.query.gender || '1,3' 41 + channel
33 }; 42 };
34 43
35 indexModel.getBrandByChannel(param.channel).then(result => { 44 indexModel.getBrandByChannel(param.channel).then(result => {
36 - res.render('brand/index', Object.assign(responseData, result)); 45 + res.render('brand/index', Object.assign(responseData, result, {
  46 + params: {
  47 + yhChannel: channel
  48 + }
  49 + }));
37 }).catch(next); 50 }).catch(next);
38 }; 51 };
39 52
  53 +// 301到新路由
  54 +let indexRedirect = (req, res) => {
  55 + let param = qs.stringify(req.query);
  56 +
  57 + if (param) {
  58 + param = '?' + param;
  59 + }
  60 + res.redirect(`/${req.yoho.channel}-brands/${param}`);
  61 +};
  62 +
40 let brandList = (req, res, next) => { 63 let brandList = (req, res, next) => {
41 var channel = req.query.channel || '1'; 64 var channel = req.query.channel || '1';
42 65
@@ -152,5 +175,6 @@ module.exports = { @@ -152,5 +175,6 @@ module.exports = {
152 brandList, 175 brandList,
153 delBrandHistory, 176 delBrandHistory,
154 addBrandSearch, 177 addBrandSearch,
155 - searchAsync 178 + searchAsync,
  179 + indexRedirect
156 }; 180 };
@@ -84,13 +84,17 @@ const getBrandByChannel = (channel) => { @@ -84,13 +84,17 @@ const getBrandByChannel = (channel) => {
84 let resu = { 84 let resu = {
85 channel: { 85 channel: {
86 channels: [{ 86 channels: [{
87 - name: 'Boy' 87 + name: 'Boy',
  88 + channelName: 'boys'
88 }, { 89 }, {
89 - name: 'Girl' 90 + name: 'Girl',
  91 + channelName: 'girls'
90 }, { 92 }, {
91 - name: 'Kid' 93 + name: 'Kid',
  94 + channelName: 'kids'
92 }, { 95 }, {
93 - name: 'Lifestyle' 96 + name: 'Lifestyle',
  97 + channelName: 'lifestyle'
94 }], 98 }],
95 topData: { 99 topData: {
96 bannerTop: {}, 100 bannerTop: {},
@@ -157,52 +161,58 @@ const getBrandListByChannel = (channel) => { @@ -157,52 +161,58 @@ const getBrandListByChannel = (channel) => {
157 let allList = result.data.all_list; 161 let allList = result.data.all_list;
158 162
159 for (let key in allList) { 163 for (let key in allList) {
160 - let obj = {  
161 - title: key,  
162 - list: []  
163 - };  
164 -  
165 - allList[key].forEach(row => {  
166 - obj.list.push({  
167 - name: row.brand_name,  
168 - isHot: row.is_hot === 'Y' ? true : false,  
169 - isNew: row.is_show_new === 'Y' ? true : false,  
170 - url: helpers.urlFormat('/product/index/brand?domain=' + row.brand_domain) 164 + if (key) {
  165 + let obj = {
  166 + title: key,
  167 + list: []
  168 + };
  169 +
  170 + allList[key].forEach(row => {
  171 + obj.list.push({
  172 + name: row.brand_name,
  173 + isHot: row.is_hot === 'Y' ? true : false,
  174 + isNew: row.is_show_new === 'Y' ? true : false,
  175 + url: helpers.urlFormat('/product/index/brand?domain=' + row.brand_domain)
  176 + });
171 }); 177 });
172 - });  
173 - resu.brandList.push(obj); 178 + resu.brandList.push(obj);
  179 + }
174 } 180 }
175 181
176 // 新入驻品牌 182 // 新入驻品牌
177 let newList = result.data.new_list; 183 let newList = result.data.new_list;
178 184
179 for (let key in newList) { 185 for (let key in newList) {
180 - let obj = {  
181 - list: []  
182 - }; 186 + if (key) {
  187 + let obj = {
  188 + list: []
  189 + };
183 190
184 - obj.list.push({  
185 - brandName: newList[key].brand_name,  
186 - url: helpers.urlFormat('/product/index/brand?domain=' + newList[key].brand_domain),  
187 - img: helpers.image(newList[key].brand_ico, 186, 115),  
188 - });  
189 - resu.newBrandWall.push(obj); 191 + obj.list.push({
  192 + brandName: newList[key].brand_name,
  193 + url: helpers.urlFormat('/product/index/brand?domain=' + newList[key].brand_domain),
  194 + img: helpers.image(newList[key].brand_ico, 186, 115),
  195 + });
  196 + resu.newBrandWall.push(obj);
  197 + }
190 } 198 }
191 199
192 // 推荐品牌 200 // 推荐品牌
193 let hotList = result.data.hot_list; 201 let hotList = result.data.hot_list;
194 202
195 for (let key in hotList) { 203 for (let key in hotList) {
196 - let obj = {  
197 - list: []  
198 - }; 204 + if (key) {
  205 + let obj = {
  206 + list: []
  207 + };
199 208
200 - obj.list.push({  
201 - brandName: hotList[key].brand_name,  
202 - url: helpers.urlFormat('/product/index/brand?domain=' + hotList[key].brand_domain),  
203 - img: helpers.image(hotList[key].brand_ico, 186, 115),  
204 - });  
205 - resu.recommandBrandWall.push(obj); 209 + obj.list.push({
  210 + brandName: hotList[key].brand_name,
  211 + url: helpers.urlFormat('/product/index/brand?domain=' + hotList[key].brand_domain),
  212 + img: helpers.image(hotList[key].brand_ico, 186, 115),
  213 + });
  214 + resu.recommandBrandWall.push(obj);
  215 + }
206 } 216 }
207 217
208 return resu; 218 return resu;
@@ -419,25 +429,22 @@ const branchSearch = (params) => { @@ -419,25 +429,22 @@ const branchSearch = (params) => {
419 let obj = {}; 429 let obj = {};
420 430
421 for (let key in brandList) { 431 for (let key in brandList) {
422 -  
423 - let build = [];  
424 -  
425 - brandList[key].forEach(row => {  
426 -  
427 - build.push({  
428 - name: row.brand_name,  
429 - isHot: row.is_hot === 'Y' ? true : false,  
430 - isNew: row.is_show_new === 'Y' ? true : false,  
431 - url: helpers.urlFormat('/product/index/brand?domain=' + row.brand_domain),  
432 - brandId: row.id,  
433 - brandDomain: row.brand_domain,  
434 - searchName: row.brand_name_en + row.brand_name_cn 432 + if (key) {
  433 + let build = [];
  434 +
  435 + brandList[key].forEach(row => {
  436 + build.push({
  437 + name: row.brand_name,
  438 + isHot: row.is_hot === 'Y' ? true : false,
  439 + isNew: row.is_show_new === 'Y' ? true : false,
  440 + url: helpers.urlFormat('/product/index/brand?domain=' + row.brand_domain),
  441 + brandId: row.id,
  442 + brandDomain: row.brand_domain,
  443 + searchName: row.brand_name_en + row.brand_name_cn
  444 + });
  445 + obj[key] = build;
435 }); 446 });
436 -  
437 - obj[key] = build;  
438 -  
439 - });  
440 - 447 + }
441 } 448 }
442 449
443 resu.brandList = JSON.stringify(obj); 450 resu.brandList = JSON.stringify(obj);
@@ -449,17 +456,15 @@ const branchSearch = (params) => { @@ -449,17 +456,15 @@ const branchSearch = (params) => {
449 let hotList = result[1].data; 456 let hotList = result[1].data;
450 457
451 for (let key in hotList) { 458 for (let key in hotList) {
  459 + if (key) {
  460 + let obj = {};
452 461
453 - let obj = {};  
454 -  
455 - obj = Object.assign(obj, {  
456 - name: hotList[key].brandName  
457 - });  
458 -  
459 - resu.hot.push(obj);  
460 - 462 + obj = Object.assign(obj, {
  463 + name: hotList[key].brandName
  464 + });
  465 + resu.hot.push(obj);
  466 + }
461 } 467 }
462 -  
463 } 468 }
464 469
465 // if (result && result[1] && result[1].data) { 470 // if (result && result[1] && result[1].data) {
@@ -527,12 +532,12 @@ const branchSearchHistoryAsync = (uid) => { @@ -527,12 +532,12 @@ const branchSearchHistoryAsync = (uid) => {
527 }; 532 };
528 533
529 for (let key in hisList) { 534 for (let key in hisList) {
530 -  
531 - obj.push({  
532 - name: hisList[key].searchTerms,  
533 - searchTime: hisList[key].searchTime  
534 - });  
535 - 535 + if (key) {
  536 + obj.push({
  537 + name: hisList[key].searchTerms,
  538 + searchTime: hisList[key].searchTime
  539 + });
  540 + }
536 } 541 }
537 542
538 build.list = obj; 543 build.list = obj;
@@ -12,6 +12,7 @@ const channel = require(cRoot); @@ -12,6 +12,7 @@ const channel = require(cRoot);
12 const cate = require(cRoot + '/cate'); 12 const cate = require(cRoot + '/cate');
13 const brandController = require(`${cRoot}/brand`); 13 const brandController = require(`${cRoot}/brand`);
14 const custom = require(`${cRoot}/custom`); 14 const custom = require(`${cRoot}/custom`);
  15 +const rewrite = require('../../doraemon/middleware/rewrite');
15 16
16 const router = express.Router(); // eslint-disable-line 17 const router = express.Router(); // eslint-disable-line
17 18
@@ -25,7 +26,8 @@ router.get('/channel/getResourceContent', channel.getResourceContent);// 获取 @@ -25,7 +26,8 @@ router.get('/channel/getResourceContent', channel.getResourceContent);// 获取
25 router.get('/(:channel)/bottomBanner', channel.bottomBanner); 26 router.get('/(:channel)/bottomBanner', channel.bottomBanner);
26 27
27 router.get('/cate', cate.index); 28 router.get('/cate', cate.index);
28 -router.get('/brands', brandController.index); // 品牌首页 29 +router.get('/brands', rewrite.channel, brandController.indexRedirect); // 品牌首页
  30 +router.get(/^\/(.*?)-brands/, rewrite.resolve, brandController.index); // 品牌首页 SEO优化
29 router.get('/brands/search', brandController.search); // 品牌搜索页 31 router.get('/brands/search', brandController.search); // 品牌搜索页
30 router.get('/brands/getBrandList', brandController.brandList); // 获取品牌列表 32 router.get('/brands/getBrandList', brandController.brandList); // 获取品牌列表
31 router.post('/brands/searchAsync', brandController.searchAsync); // 品牌搜索异步数据 33 router.post('/brands/searchAsync', brandController.searchAsync); // 品牌搜索异步数据
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <div class="genderNav"> 4 <div class="genderNav">
5 <ul> 5 <ul>
6 {{# channels}} 6 {{# channels}}
7 - <li {{#if active}}class="active"{{/if}} data-id="{{@index}}"> 7 + <li {{#if active}}class="active"{{/if}} data-id="{{@index}}" data-name="{{channelName}}">
8 <span>{{name}}</span> 8 <span>{{name}}</span>
9 <span class="split-border"></span> 9 <span class="split-border"></span>
10 </li> 10 </li>
@@ -56,4 +56,8 @@ @@ -56,4 +56,8 @@
56 </div> 56 </div>
57 {{/channel}} 57 {{/channel}}
58 </div> 58 </div>
59 -{{> footer-tab}}  
  59 +{{> footer-tab}}
  60 +{{# params}}
  61 +{{> common/query-param}}
  62 +{{/params}}
  63 +<input type="hidden" id="no-download">
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 'use strict'; 6 'use strict';
7 7
8 const mRoot = '../models'; 8 const mRoot = '../models';
  9 +const typeLib = require('../../../config/type-lib');
9 const indexModel = require(`${mRoot}/index`); 10 const indexModel = require(`${mRoot}/index`);
10 const headerModel = require('../../../doraemon/models/header'); // 头部model 11 const headerModel = require('../../../doraemon/models/header'); // 头部model
11 const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab 12 const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab
@@ -25,11 +26,14 @@ const channels = { @@ -25,11 +26,14 @@ const channels = {
25 const editor = (req, res, next) => { 26 const editor = (req, res, next) => {
26 let uid = req.user.uid, 27 let uid = req.user.uid,
27 udid = req.sessionID, 28 udid = req.sessionID,
28 - id = req.query.id || 0, 29 + id = req.query.id || req.params[0] || 0,
29 title = '编辑简介', 30 title = '编辑简介',
30 parameter = {}, 31 parameter = {},
31 isApp = req.yoho.isApp, 32 isApp = req.yoho.isApp,
32 - gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1; 33 + gender = req.query.gender ||
  34 + req.query.channel && typeLib.channels[req.query.channel] ||
  35 + req.cookies._Channel && channels[req.cookies._Channel] ||
  36 + 1;
33 37
34 if (isApp) { 38 if (isApp) {
35 uid = req.query.uid; 39 uid = req.query.uid;
@@ -40,44 +44,54 @@ const editor = (req, res, next) => { @@ -40,44 +44,54 @@ const editor = (req, res, next) => {
40 }) 44 })
41 }; 45 };
42 } 46 }
43 -  
44 - return Promise.all([indexModel.getAuthor(id), indexModel.getArticleList(gender, 0, uid, udid, 1, null, id)]).then(datas => {  
45 - let authorData = datas[0],  
46 - articleListData = datas[1];  
47 - let build = [];  
48 -  
49 - if (articleListData.data && articleListData.data.list && articleListData.data.list.artList) {  
50 - articleListData.data.list.artList.forEach(articleData => {  
51 - articleData.colparam = {  
52 - urlpath: req.path,  
53 - param: `?id=${id}`  
54 - };  
55 -  
56 - build.push(guangProcess.formatArticle(articleData, true, isApp, false, uid));  
57 - });  
58 -  
59 - if (!build.length) {  
60 - res.set('Cache-Control', 'no-cache'); 47 + return Promise.all([
  48 + indexModel.getAuthor(id),
  49 + indexModel.getArticleList(gender, 0, uid, udid, 1, null, id)]
  50 + ).then(datas => {
  51 + let authorData = datas[0],
  52 + articleListData = datas[1];
  53 + let build = [];
  54 +
  55 + if (articleListData.data && articleListData.data.list && articleListData.data.list.artList) {
  56 + articleListData.data.list.artList.forEach(articleData => {
  57 + articleData.colparam = {
  58 + urlpath: req.path,
  59 + param: `?id=${id}`
  60 + };
  61 +
  62 + build.push(guangProcess.formatArticle(articleData, true, isApp, false, uid));
  63 + });
  64 +
  65 + if (!build.length) {
  66 + res.set('Cache-Control', 'no-cache');
  67 + }
  68 +
  69 + res.render('index/list', Object.assign({
  70 + page: 'index-editor',
  71 + title: title,
  72 + guangList: true,
  73 + gender: gender,
  74 + guang: {
  75 + infos: build,
  76 + isApp: isApp,
  77 + authorInfo: authorData.data
  78 + },
  79 + localCss: true
  80 + }, parameter));
  81 + } else {
  82 + return next();
61 } 83 }
  84 + }).catch(next);
62 85
63 - res.render('index/list', Object.assign({  
64 - page: 'index-editor',  
65 - title: title,  
66 - guangList: true,  
67 - gender: gender,  
68 - guang: {  
69 - infos: build,  
70 - isApp: isApp,  
71 - authorInfo: authorData.data  
72 - },  
73 - localCss: true  
74 - }, parameter));  
75 - } else {  
76 - return next();  
77 - }  
78 -  
79 - }).catch(next); 86 +};
80 87
  88 +// 301到新路由
  89 +const editorRedirect = (req, res, next) => {
  90 + if (req.query.id) {
  91 + res.redirect(`${req.query.id}`);
  92 + } else {
  93 + return next();
  94 + }
81 }; 95 };
82 96
83 /** 97 /**
@@ -130,19 +144,28 @@ const pageData = (req, res, next) => { @@ -130,19 +144,28 @@ const pageData = (req, res, next) => {
130 if (!authorId && isNaN(authorId)) { 144 if (!authorId && isNaN(authorId)) {
131 showAuthor = true; 145 showAuthor = true;
132 } 146 }
133 - return indexModel.getPageData(gender, sortId, uid, udid, page, tag, authorId, isApp, showAuthor, isTab).then(data => {  
134 - if (data) {  
135 - res.render('index/page', Object.assign(data, {  
136 - layout: false  
137 - }));  
138 - } else {  
139 - res.json({  
140 - code: 400,  
141 - message: '',  
142 - data: ''  
143 - });  
144 - }  
145 - }).catch(next); 147 + return indexModel.getPageData(gender,
  148 + sortId,
  149 + uid,
  150 + udid,
  151 + page,
  152 + tag,
  153 + authorId,
  154 + isApp,
  155 + showAuthor,
  156 + isTab).then(data => {
  157 + if (data) {
  158 + res.render('index/page', Object.assign(data, {
  159 + layout: false
  160 + }));
  161 + } else {
  162 + res.json({
  163 + code: 400,
  164 + message: '',
  165 + data: ''
  166 + });
  167 + }
  168 + }).catch(next);
146 169
147 }; 170 };
148 171
@@ -165,7 +188,7 @@ const index = (req, res, next) => { @@ -165,7 +188,7 @@ const index = (req, res, next) => {
165 uid: req.user.uid || req.query.uid, 188 uid: req.user.uid || req.query.uid,
166 udid: req.user.udid, 189 udid: req.user.udid,
167 type: req.query.type || '0', 190 type: req.query.type || '0',
168 - gender: req.query.gender || '1,3' 191 + gender: req.query.gender || req.query.channel && typeLib.gender[req.query.channel] || '1,3'
169 }; 192 };
170 193
171 indexModel.getArticle(param).then(result => { 194 indexModel.getArticle(param).then(result => {
@@ -276,5 +299,6 @@ module.exports = { @@ -276,5 +299,6 @@ module.exports = {
276 index, 299 index,
277 tag, 300 tag,
278 listDynamicData, 301 listDynamicData,
279 - detailDynamicData 302 + detailDynamicData,
  303 + editorRedirect
280 }; 304 };
@@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
6 'use strict'; 6 'use strict';
7 const helpers = global.yoho.helpers; 7 const helpers = global.yoho.helpers;
8 const mRoot = '../models'; 8 const mRoot = '../models';
  9 +const typeLib = require('../../../config/type-lib');
  10 +const _ = require('lodash');
9 const infoModel = require(`${mRoot}/info`); 11 const infoModel = require(`${mRoot}/info`);
10 const stringProcess = require(`${global.utils}/string-process`); 12 const stringProcess = require(`${global.utils}/string-process`);
11 const guangProcess = require(`${global.utils}/guang-process`); 13 const guangProcess = require(`${global.utils}/guang-process`);
@@ -72,7 +74,9 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe @@ -72,7 +74,9 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe
72 } else if (art.shareCode) { 74 } else if (art.shareCode) {
73 let shareCode; 75 let shareCode;
74 76
75 - if (art.shareCode.qqShareImgUrl || art.shareCode.wechatShareImgUrl || art.shareCode.showShareImgUrl) { 77 + if (art.shareCode.qqShareImgUrl ||
  78 + art.shareCode.wechatShareImgUrl ||
  79 + art.shareCode.showShareImgUrl) {
76 if (isWeixin) { 80 if (isWeixin) {
77 shareCode = art.shareCode.wechatShareImgUrl; 81 shareCode = art.shareCode.wechatShareImgUrl;
78 } else if (isqq) { 82 } else if (isqq) {
@@ -116,7 +120,15 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe @@ -116,7 +120,15 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe
116 if (o > 3) { 120 if (o > 3) {
117 break; 121 break;
118 } 122 }
119 - d.push(guangProcess.formatProduct(goods, false, true, true, 235, 314, isApp, true, gender)); 123 + d.push(guangProcess.formatProduct(goods,
  124 + false,
  125 + true,
  126 + true,
  127 + 235,
  128 + 314,
  129 + isApp,
  130 + true,
  131 + gender));
120 } 132 }
121 d.forEach(p => { 133 d.forEach(p => {
122 if (arr[p.id]) { 134 if (arr[p.id]) {
@@ -127,7 +139,9 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe @@ -127,7 +139,9 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe
127 } 139 }
128 140
129 // 多个商品 141 // 多个商品
130 - if (product.data.product_list && product.data.product_list.length && (product.data.product_list.length > 1)) { 142 + if (product.data.product_list &&
  143 + product.data.product_list.length &&
  144 + (product.data.product_list.length > 1)) {
131 build.relatedReco = reco; 145 build.relatedReco = reco;
132 } else if (product.data.product_list && product.data.product_list.length === 1) { // 单个商品 146 } else if (product.data.product_list && product.data.product_list.length === 1) { // 单个商品
133 build.relatedReco = reco[0]; 147 build.relatedReco = reco[0];
@@ -163,8 +177,15 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe @@ -163,8 +177,15 @@ const _pageArticleContent = (articleContent, isApp, gender, isWeixin, isqq, isWe
163 if (product && product.data && product.data.product_list) { 177 if (product && product.data && product.data.product_list) {
164 let g = []; 178 let g = [];
165 179
166 - product.data.product_list.forEach(_ => {  
167 - g.push(guangProcess.formatProduct(_, false, true, true, 235, 314, isApp, gender)); 180 + product.data.product_list.forEach(p => {
  181 + g.push(guangProcess.formatProduct(p,
  182 + false,
  183 + true,
  184 + true,
  185 + 235,
  186 + 314,
  187 + isApp,
  188 + gender));
168 }); 189 });
169 g.forEach(p => { 190 g.forEach(p => {
170 if (arr[p.id]) { 191 if (arr[p.id]) {
@@ -283,13 +304,16 @@ const _shareInfo = (id, getArticle) => { @@ -283,13 +304,16 @@ const _shareInfo = (id, getArticle) => {
283 * [逛资讯详情页] 304 * [逛资讯详情页]
284 */ 305 */
285 const index = (req, res, next) => { 306 const index = (req, res, next) => {
286 - let id = req.query.id || req.params.id,  
287 - gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1, 307 + let id = req.query.id || req.params[0] || req.params.id,
  308 + gender = req.query.gender ||
  309 + req.query.channel && typeLib.channels[req.query.channel] ||
  310 + req.cookies._Channel && channels[req.cookies._Channel] ||
  311 + 1,
288 isApp = req.query.app_version || req.query.appVersion || false, // 标识是不是APP访问的 312 isApp = req.query.app_version || req.query.appVersion || false, // 标识是不是APP访问的
289 parameter = {}, 313 parameter = {},
290 title = '逛', 314 title = '逛',
291 isWeixin = req.yoho.isWechat, 315 isWeixin = req.yoho.isWechat,
292 - channel = req.cookies._Channel, 316 + channel = req.query.channel || req.cookies._Channel,
293 isqq = req.yoho.isqq, 317 isqq = req.yoho.isqq,
294 isWeibo = req.yoho.isWeibo, 318 isWeibo = req.yoho.isWeibo,
295 isShare; 319 isShare;
@@ -358,14 +382,14 @@ const index = (req, res, next) => { @@ -358,14 +382,14 @@ const index = (req, res, next) => {
358 382
359 // guang双头部的问题 20160601 383 // guang双头部的问题 20160601
360 // 正确的URL 384 // 正确的URL
361 - 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}"}}`); 385 + 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
362 386
363 - // 错误的URL  
364 - // 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')}"}}`); 387 + data.guang.author.url = helpers.https(url);
365 } 388 }
366 let guang = data.guang; 389 let guang = data.guang;
367 390
368 guang.detail = { 391 guang.detail = {
  392 + id: _.get(detail, 'getArticle.id'),
369 title: detail.getArticle.article_title, 393 title: detail.getArticle.article_title,
370 publishTime: detail.getArticle.publishTime, 394 publishTime: detail.getArticle.publishTime,
371 pageView: detail.getArticle.pageViews, 395 pageView: detail.getArticle.pageViews,
@@ -375,47 +399,52 @@ const index = (req, res, next) => { @@ -375,47 +399,52 @@ const index = (req, res, next) => {
375 399
376 if (detail.getArticleContent) { 400 if (detail.getArticleContent) {
377 // 生成内容部分 401 // 生成内容部分
378 - return _pageArticleContent(detail.getArticleContent, isApp, gender, isWeixin, isqq, isWeibo).then((contents) => {  
379 - guang.detail.content = contents;  
380 -  
381 - // 相关品牌  
382 - if (detail.getBrand && detail.getBrand.length) {  
383 - guang.relatedBrand = _relatedBrand(detail.getBrand);  
384 - } 402 + return _pageArticleContent(detail.getArticleContent,
  403 + isApp,
  404 + gender,
  405 + isWeixin,
  406 + isqq,
  407 + isWeibo).then((contents) => {
  408 + guang.detail.content = contents;
  409 +
  410 + // 相关品牌
  411 + if (detail.getBrand && detail.getBrand.length) {
  412 + guang.relatedBrand = _relatedBrand(detail.getBrand);
  413 + }
385 414
386 - // 相关标签  
387 - if (detail.getArticle.tags && detail.getArticle.tags.length) {  
388 - guang.relatedTag = _relatedTag(detail.getArticle.tags, isApp);  
389 - } 415 + // 相关标签
  416 + if (detail.getArticle.tags && detail.getArticle.tags.length) {
  417 + guang.relatedTag = _relatedTag(detail.getArticle.tags, isApp);
  418 + }
390 419
391 - // 相关文章  
392 - if (detail.getOtherArticle && detail.getOtherArticle.length) {  
393 - guang.relatedInfo = _relatedInfo(detail.getOtherArticle, isApp);  
394 - } 420 + // 相关文章
  421 + if (detail.getOtherArticle && detail.getOtherArticle.length) {
  422 + guang.relatedInfo = _relatedInfo(detail.getOtherArticle, isApp);
  423 + }
395 424
396 - // 分享参数  
397 - if (detail.getArticle.cover_image) {  
398 - let shareInfo = _shareInfo(id, detail.getArticle); 425 + // 分享参数
  426 + if (detail.getArticle.cover_image) {
  427 + let shareInfo = _shareInfo(id, detail.getArticle);
399 428
400 - Object.assign(guang, shareInfo);  
401 - data.title = detail.getArticle.article_title + ' | Yoho!Buy有货 | 潮流购物逛不停';  
402 - data.title_more = true;  
403 - data.description = detail.getArticle.article_summary;  
404 - data.description_more = true;  
405 - } 429 + Object.assign(guang, shareInfo);
  430 + data.title = detail.getArticle.article_title + ' | Yoho!Buy有货 | 潮流购物逛不停';
  431 + data.title_more = true;
  432 + data.description = detail.getArticle.article_summary;
  433 + data.description_more = true;
  434 + }
406 435
407 - // 标识有微信分享  
408 - data.hasWxShare = true;  
409 - res.render('info/index', Object.assign({  
410 - page: 'info-index',  
411 - title: '逛',  
412 - gender: gender,  
413 - wechatShare: true,  
414 - isWeixin: isWeixin,  
415 - localCss: true,  
416 - isShare: isShare  
417 - }, data, parameter));  
418 - }); 436 + // 标识有微信分享
  437 + data.hasWxShare = true;
  438 + res.render('info/index', Object.assign({
  439 + page: 'info-index',
  440 + title: '逛',
  441 + gender: gender,
  442 + wechatShare: true,
  443 + isWeixin: isWeixin,
  444 + localCss: true,
  445 + isShare: isShare
  446 + }, data, parameter));
  447 + });
419 } else { 448 } else {
420 next(); 449 next();
421 return; 450 return;
@@ -425,6 +454,15 @@ const index = (req, res, next) => { @@ -425,6 +454,15 @@ const index = (req, res, next) => {
425 }).catch(next); 454 }).catch(next);
426 }; 455 };
427 456
  457 +// 301到新路由
  458 +const indexRedirect = (req, res, next) => {
  459 + if (req.query.id) {
  460 + res.redirect(`${req.query.id}`);
  461 + } else {
  462 + return next();
  463 + }
  464 +};
  465 +
428 /** 466 /**
429 * [逛mini内容页] 467 * [逛mini内容页]
430 */ 468 */
@@ -565,5 +603,6 @@ const foryoho = (req, res, next) => { @@ -565,5 +603,6 @@ const foryoho = (req, res, next) => {
565 module.exports = { 603 module.exports = {
566 index, 604 index,
567 mini, 605 mini,
568 - foryoho 606 + foryoho,
  607 + indexRedirect
569 }; 608 };
@@ -6,9 +6,11 @@ @@ -6,9 +6,11 @@
6 'use strict'; 6 'use strict';
7 7
8 const mRoot = '../models'; 8 const mRoot = '../models';
  9 +const typeLib = require('../../../config/type-lib');
9 const plusstarModel = require(`${mRoot}/plusstar`); 10 const plusstarModel = require(`${mRoot}/plusstar`);
10 const headerModel = require('../../../doraemon/models/header'); // 头部model 11 const headerModel = require('../../../doraemon/models/header'); // 头部model
11 const _ = require('lodash'); 12 const _ = require('lodash');
  13 +const qs = require('querystring');
12 let channels = { 14 let channels = {
13 boys: 1, 15 boys: 1,
14 girl: 2, 16 girl: 2,
@@ -23,7 +25,10 @@ exports.index = (req, res, next) => { @@ -23,7 +25,10 @@ exports.index = (req, res, next) => {
23 let isApp = req.query.app_version || req.query.appVersion || false; 25 let isApp = req.query.app_version || req.query.appVersion || false;
24 let parameter = {}; 26 let parameter = {};
25 let title = '潮流优选'; 27 let title = '潮流优选';
26 - let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1; 28 + let gender = req.query.gender ||
  29 + req.query.channel && typeLib.channels[req.query.channel] ||
  30 + req.cookies._Channel && channels[req.cookies._Channel] ||
  31 + 1;
27 32
28 if (isApp === false) { 33 if (isApp === false) {
29 parameter = { 34 parameter = {
@@ -36,6 +41,21 @@ exports.index = (req, res, next) => { @@ -36,6 +41,21 @@ exports.index = (req, res, next) => {
36 41
37 let result = {}; 42 let result = {};
38 43
  44 + switch (gender) {
  45 + case typeLib.gender.boys:
  46 + gender = 1;
  47 + break;
  48 + case typeLib.gender.girls:
  49 + gender = 2;
  50 + break;
  51 + case typeLib.gender.kids:
  52 + gender = 3;
  53 + break;
  54 + case typeLib.gender.lifestyle:
  55 + gender = 4;
  56 + break;
  57 + }
  58 +
39 plusstarModel.getAllChannels({ 59 plusstarModel.getAllChannels({
40 gender: gender, 60 gender: gender,
41 app_type: 0 61 app_type: 0
@@ -52,6 +72,12 @@ exports.index = (req, res, next) => { @@ -52,6 +72,12 @@ exports.index = (req, res, next) => {
52 }); 72 });
53 }).then(data => { 73 }).then(data => {
54 result = Object.assign(result, data); 74 result = Object.assign(result, data);
  75 +
  76 + // 此处 channel 需要读取 cookies 的 channel
  77 + if (req.cookies._Channel) {
  78 + res.locals.pageChannel = {};
  79 + res.locals.pageChannel[req.cookies._Channel] = true;
  80 + }
55 res.render('plusstar/index', Object.assign({ 81 res.render('plusstar/index', Object.assign({
56 page: 'plusstar-index', 82 page: 'plusstar-index',
57 result: result, 83 result: result,
@@ -62,6 +88,16 @@ exports.index = (req, res, next) => { @@ -62,6 +88,16 @@ exports.index = (req, res, next) => {
62 }).catch(next); 88 }).catch(next);
63 }; 89 };
64 90
  91 +// 301到新路由
  92 +exports.indexRedirect = (req, res) => {
  93 + let param = qs.stringify(req.query);
  94 +
  95 + if (param) {
  96 + param = '?' + param;
  97 + }
  98 + res.redirect(`/guang/${req.yoho.channel}-plusstar/${param}`);
  99 +};
  100 +
65 exports.userSkn = (req, res, next) => { 101 exports.userSkn = (req, res, next) => {
66 let isApp = req.body.app_version || req.body.appVersion || false; 102 let isApp = req.body.app_version || req.body.appVersion || false;
67 let uid = ''; 103 let uid = '';
@@ -11,6 +11,7 @@ const cRoot = './controllers'; @@ -11,6 +11,7 @@ const cRoot = './controllers';
11 const star = require(cRoot + '/star'); 11 const star = require(cRoot + '/star');
12 const homeController = require(`${cRoot}/index`); 12 const homeController = require(`${cRoot}/index`);
13 const plusstar = require(cRoot + '/plusstar'); 13 const plusstar = require(cRoot + '/plusstar');
  14 +const rewrite = require('../../doraemon/middleware/rewrite');
14 15
15 const index = require(cRoot + '/index'); 16 const index = require(cRoot + '/index');
16 const opt = require(cRoot + '/opt'); 17 const opt = require(cRoot + '/opt');
@@ -31,8 +32,10 @@ router.get('/star/collocation/list', star.collocationList); // 星潮教室星 @@ -31,8 +32,10 @@ router.get('/star/collocation/list', star.collocationList); // 星潮教室星
31 32
32 router.post('/star/setFavorite', star.setFavorite); // 收藏文章 33 router.post('/star/setFavorite', star.setFavorite); // 收藏文章
33 router.get('/', homeController.index); // 逛首页 34 router.get('/', homeController.index); // 逛首页
  35 +// router.get(/^\/((boys)|(girls)|(kids)|(lifestyle)-[^\/]+)/, rewrite.resolve, homeController.index); // 逛首页 SEO优化
34 36
35 -router.get('/plusstar', plusstar.index); // 潮流优选 37 +router.get('/plusstar', rewrite.channel, plusstar.indexRedirect); // 潮流优选
  38 +router.get(/^\/(.*?)-plusstar/, rewrite.resolve, plusstar.index); // 潮流优选 SEO优化
36 router.post('/plusstar/userSkn', plusstar.userSkn); // 用户推荐skn 39 router.post('/plusstar/userSkn', plusstar.userSkn); // 用户推荐skn
37 router.get('/plusstar/resources-template', plusstar.resourcesTemplate); // 潮流优选首页-资源位 40 router.get('/plusstar/resources-template', plusstar.resourcesTemplate); // 潮流优选首页-资源位
38 router.post('/plusstar/resources-goodsList', plusstar.resourcesGoodsList); // 潮流优选首页-资源位-商品列表 41 router.post('/plusstar/resources-goodsList', plusstar.resourcesGoodsList); // 潮流优选首页-资源位-商品列表
@@ -40,6 +43,7 @@ router.get('/', index.index); // 逛首页 @@ -40,6 +43,7 @@ router.get('/', index.index); // 逛首页
40 router.get('/tags/index', index.tag); // 逛标签页 43 router.get('/tags/index', index.tag); // 逛标签页
41 44
42 router.get('/author/index', index.editor); // 编辑简介 45 router.get('/author/index', index.editor); // 编辑简介
  46 +router.get(/^\/author-([^\/]+)/, rewrite.resolve, index.editor); // 编辑简介 SEO优化
43 47
44 router.get('/index/page', index.pageData); // 逛列表页面的资讯分页 48 router.get('/index/page', index.pageData); // 逛列表页面的资讯分页
45 49
@@ -48,6 +52,7 @@ router.post('/opt/collectArticle', opt.collectArticle); // 资讯文章收藏 (H @@ -48,6 +52,7 @@ router.post('/opt/collectArticle', opt.collectArticle); // 资讯文章收藏 (H
48 router.post('/opt/favoriteBrand', opt.favoriteBrand); // 品牌收藏 52 router.post('/opt/favoriteBrand', opt.favoriteBrand); // 品牌收藏
49 53
50 router.get('/info/index', info.index); // 逛详情页 54 router.get('/info/index', info.index); // 逛详情页
  55 +// router.get(/^\/info\/(.*?-\d+)/, rewrite.resolve, info.index); // 逛详情页 SEO优化
51 router.get('/:id.html', info.index); // 逛详情页(兼容 PC 跳转过来的链接) 56 router.get('/:id.html', info.index); // 逛详情页(兼容 PC 跳转过来的链接)
52 router.get('/info/mini', info.mini); // 逛mini内容页 57 router.get('/info/mini', info.mini); // 逛mini内容页
53 router.get('/info/foryoho', info.foryoho); // 逛foryoho内容页 58 router.get('/info/foryoho', info.foryoho); // 逛foryoho内容页
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 </div> 15 </div>
16 {{/ author}} 16 {{/ author}}
17 {{# detail}} 17 {{# detail}}
18 - <div class="detail"> 18 + <div class="detail" data-id="{{id}}">
19 <div class="post-title"> 19 <div class="post-title">
20 <p class="title">{{title}}</p> 20 <p class="title">{{title}}</p>
21 {{> index/tvls}} 21 {{> index/tvls}}
@@ -13,6 +13,7 @@ const newModel = require(`${mRoot}/new`); @@ -13,6 +13,7 @@ const newModel = require(`${mRoot}/new`);
13 const searchModel = require(`${mRoot}/search`); 13 const searchModel = require(`${mRoot}/search`);
14 const _ = require('lodash'); 14 const _ = require('lodash');
15 const helpers = global.yoho.helpers; 15 const helpers = global.yoho.helpers;
  16 +const qs = require('querystring');
16 17
17 // 新品到着(blk) 18 // 新品到着(blk)
18 const blkNewGoods = (req, res, next) => { 19 const blkNewGoods = (req, res, next) => {
@@ -78,6 +79,16 @@ const newGoods = (req, res, next) => { @@ -78,6 +79,16 @@ const newGoods = (req, res, next) => {
78 }).catch(next); 79 }).catch(next);
79 }; 80 };
80 81
  82 +// 301到新路由
  83 +const newGoodsRedirect = (req, res) => {
  84 + let param = qs.stringify(req.query);
  85 +
  86 + if (param) {
  87 + param = '?' + param;
  88 + }
  89 + res.redirect(`/product/${req.yoho.channel}-new/${param}`);
  90 +};
  91 +
81 /** 92 /**
82 * 重构的新品到着页面 93 * 重构的新品到着页面
83 */ 94 */
@@ -242,5 +253,6 @@ module.exports = { @@ -242,5 +253,6 @@ module.exports = {
242 253
243 recommendShop, 254 recommendShop,
244 fetchNew, 255 fetchNew,
245 - goodsFilter 256 + goodsFilter,
  257 + newGoodsRedirect
246 }; 258 };
@@ -10,6 +10,7 @@ const mRoot = '../models'; @@ -10,6 +10,7 @@ const mRoot = '../models';
10 // const cookie = require(`${library}/cookie`); 10 // const cookie = require(`${library}/cookie`);
11 const headerModel = require('../../../doraemon/models/header'); 11 const headerModel = require('../../../doraemon/models/header');
12 const saleModel = require(`${mRoot}/sale`); 12 const saleModel = require(`${mRoot}/sale`);
  13 +const qs = require('querystring');
13 14
14 // const queryParam = { 15 // const queryParam = {
15 // brand: '0', 16 // brand: '0',
@@ -55,7 +56,7 @@ const _processPublicData = (req, title, page, backUrl) => { @@ -55,7 +56,7 @@ const _processPublicData = (req, title, page, backUrl) => {
55 let index = (req, res, next) => { 56 let index = (req, res, next) => {
56 let refer = req.get('Referer') || `${global.yoho.config.siteUrl}/${req.cookies._Channel || ''}`; 57 let refer = req.get('Referer') || `${global.yoho.config.siteUrl}/${req.cookies._Channel || ''}`;
57 let reqPath = req.baseUrl + req.path; 58 let reqPath = req.baseUrl + req.path;
58 - let backUrl = refer.indexOf(reqPath) === -1 ? refer : ''; 59 + let backUrl = refer.indexOf(reqPath) === -1 && refer.indexOf('-sale') === -1 ? refer : '';
59 60
60 if (['boys', 'girls', 'kids', 'lifestyle'].indexOf(req.yoho.channel) === -1) { 61 if (['boys', 'girls', 'kids', 'lifestyle'].indexOf(req.yoho.channel) === -1) {
61 return next(); 62 return next();
@@ -68,11 +69,13 @@ let index = (req, res, next) => { @@ -68,11 +69,13 @@ let index = (req, res, next) => {
68 69
69 let params = _processPublicData(req, 'SALE', 'sale', backUrl); 70 let params = _processPublicData(req, 'SALE', 'sale', backUrl);
70 71
  72 + params.channel = req.query.channel || params.channel;
  73 +
71 saleModel.getSaleData(params.channel).then((result) => { 74 saleModel.getSaleData(params.channel).then((result) => {
72 75
73 // 扩展头部频道选择数据 76 // 扩展头部频道选择数据
74 Object.assign(params.renderData.pageHeader, { 77 Object.assign(params.renderData.pageHeader, {
75 - saleNav: saleModel.saleNav(req.yoho.channel) 78 + saleNav: saleModel.saleNav(params.channel, req.params[0] || !req.query.channel)
76 }); 79 });
77 80
78 // 此处 channel 需要读取 cookies 的 channel 81 // 此处 channel 需要读取 cookies 的 channel
@@ -96,6 +99,16 @@ let index = (req, res, next) => { @@ -96,6 +99,16 @@ let index = (req, res, next) => {
96 }).catch(next); 99 }).catch(next);
97 }; 100 };
98 101
  102 +// 301到新路由
  103 +let indexRedirect = (req, res) => {
  104 + let param = qs.stringify(req.query);
  105 +
  106 + if (param) {
  107 + param = '?' + param;
  108 + }
  109 + res.redirect(`/product/${req.yoho.channel}-sale/${param}`);
  110 +};
  111 +
99 /** 112 /**
100 * 断码区 113 * 断码区
101 * @param {[object]} req 114 * @param {[object]} req
@@ -250,5 +263,6 @@ module.exports = { @@ -250,5 +263,6 @@ module.exports = {
250 vip, 263 vip,
251 filter, 264 filter,
252 search, 265 search,
253 - getTime 266 + getTime,
  267 + indexRedirect
254 }; 268 };
@@ -51,22 +51,26 @@ const channelHash = { @@ -51,22 +51,26 @@ const channelHash = {
51 lifestyle: 'Lifestyle' 51 lifestyle: 'Lifestyle'
52 }; 52 };
53 53
54 -const saleNav = (channel) => { 54 +const saleNav = (channel, shortUrl) => {
55 return { 55 return {
56 channel: channelHash[channel], 56 channel: channelHash[channel],
57 list: [ 57 list: [
58 { 58 {
59 title: 'Boy', 59 title: 'Boy',
60 - url: helpers.urlFormat('/product/sale', {channel: 'boys'}) 60 + url: shortUrl ? helpers.urlFormat('/product/boys-sale/') :
  61 + helpers.urlFormat('/product/sale', {channel: 'boys'})
61 }, { 62 }, {
62 title: 'Girl', 63 title: 'Girl',
63 - url: helpers.urlFormat('/product/sale', {channel: 'girls'}) 64 + url: shortUrl ? helpers.urlFormat('/product/girls-sale/') :
  65 + helpers.urlFormat('/product/sale', {channel: 'girls'})
64 }, { 66 }, {
65 title: 'Kid', 67 title: 'Kid',
66 - url: helpers.urlFormat('/product/sale', {channel: 'kids'}) 68 + url: shortUrl ? helpers.urlFormat('/product/kids-sale/') :
  69 + helpers.urlFormat('/product/sale', {channel: 'kids'})
67 }, { 70 }, {
68 title: 'Lifestyle', 71 title: 'Lifestyle',
69 - url: helpers.urlFormat('/product/sale', {channel: 'lifestyle'}) 72 + url: shortUrl ? helpers.urlFormat('/product/lifestyle-sale/') :
  73 + helpers.urlFormat('/product/sale', {channel: 'lifestyle'})
70 } 74 }
71 ] 75 ]
72 }; 76 };
@@ -10,6 +10,8 @@ const router = require('express').Router(); // eslint-disable-line @@ -10,6 +10,8 @@ const router = require('express').Router(); // eslint-disable-line
10 10
11 const auth = require('../../doraemon/middleware/auth'); 11 const auth = require('../../doraemon/middleware/auth');
12 12
  13 +const rewrite = require('../../doraemon/middleware/rewrite');
  14 +
13 const cRoot = './controllers'; 15 const cRoot = './controllers';
14 16
15 // 商品详情controller 17 // 商品详情controller
@@ -61,6 +63,7 @@ router.get(/^\/seckill\/pro_([\d]+)_([\d]+)/, seckillDetail.index); // 秒杀商 @@ -61,6 +63,7 @@ router.get(/^\/seckill\/pro_([\d]+)_([\d]+)/, seckillDetail.index); // 秒杀商
61 router.get(/^\/pro_([\d]+)_([\d]+)/, newDetail.index); // 商品详情页 63 router.get(/^\/pro_([\d]+)_([\d]+)/, newDetail.index); // 商品详情页
62 // /show_51047967.html 64 // /show_51047967.html
63 router.get(/^\/show_([\d]+)/, newDetail.index); // 商品详情页 SKN 进入 65 router.get(/^\/show_([\d]+)/, newDetail.index); // 商品详情页 SKN 进入
  66 +// router.get(/^\/p([\d]+)\.html/, newDetail.index); // 商品详情页 SKN 进入 SEO优化
64 67
65 router.get('/detail/sknData.json', newDetail.sknData); // 商品咨询,评价,店铺 68 router.get('/detail/sknData.json', newDetail.sknData); // 商品咨询,评价,店铺
66 router.get('/detail/intro/:productskn', detail.intro); // 商品内嵌页 69 router.get('/detail/intro/:productskn', detail.intro); // 商品内嵌页
@@ -85,10 +88,16 @@ router.get('/seckillDetail/seckillData/:productskn', seckillDetail.getSeckillDat @@ -85,10 +88,16 @@ router.get('/seckillDetail/seckillData/:productskn', seckillDetail.getSeckillDat
85 router.post('/detail/consultupvote', detail.consultUpvoteOrUseful); // 商品咨询提交接口 88 router.post('/detail/consultupvote', detail.consultUpvoteOrUseful); // 商品咨询提交接口
86 router.post('/detail/consultuseful', detail.consultUpvoteOrUseful); // 商品咨询提交接口 89 router.post('/detail/consultuseful', detail.consultUpvoteOrUseful); // 商品咨询提交接口
87 90
88 -router.get('/sale', sale.index); 91 +router.get('/sale', rewrite.channel, sale.indexRedirect);
  92 +router.get(/^\/(.*?)-sale/, rewrite.resolve, sale.index); // 折扣专区 SEO优化
  93 +
89 router.get('/sale/discount', sale.discount); 94 router.get('/sale/discount', sale.discount);
  95 +
  96 +// router.get(/^\/(.*?)-sale\/discount/, rewrite.resolve, sale.discount);
90 router.get('/sale/discount/detail', sale.discountDetail); 97 router.get('/sale/discount/detail', sale.discountDetail);
91 router.get('/sale/breakingYards', sale.breakingYards); 98 router.get('/sale/breakingYards', sale.breakingYards);
  99 +
  100 +// router.get(/^\/(.*?)-sale\/breakingYards/, rewrite.resolve, sale.breakingYards); // SEO优化
92 router.get('/sale/vip', sale.vip); 101 router.get('/sale/vip', sale.vip);
93 router.get('/sale/discount/getTime', sale.getTime); 102 router.get('/sale/discount/getTime', sale.getTime);
94 103
@@ -156,7 +165,11 @@ router.get('/index/intro', list.shopIntro); @@ -156,7 +165,11 @@ router.get('/index/intro', list.shopIntro);
156 router.get('/opt/favoriteBrand', list.favoriteBrand); 165 router.get('/opt/favoriteBrand', list.favoriteBrand);
157 166
158 // 新品到着 167 // 新品到着
159 -router.get('/new', news.newGoods); 168 +router.get('/new', rewrite.channel, news.newGoodsRedirect);
  169 +
  170 +// 新品到着 SEO优化
  171 +router.get(/^\/(.*?)-new/, rewrite.resolve, news.newGoods);
  172 +
160 router.get('/list/new', news.newGoods); // 兼容 PC 的链接 173 router.get('/list/new', news.newGoods); // 兼容 PC 的链接
161 router.get('/new/selectNewSale', news.selectNewSale); 174 router.get('/new/selectNewSale', news.selectNewSale);
162 router.get('/new/filter', news.filter); 175 router.get('/new/filter', news.filter);
  1 +/**
  2 + * 类型映射配置
  3 + * @author: chenfeng<feng.chen@yoho.cn>
  4 + * @date: 2017/02/20
  5 + */
  6 +
  7 +'use strict';
  8 +
  9 +const channels = {
  10 + boys: 1,
  11 + girl: 2,
  12 + girls: 2,
  13 + kids: 3,
  14 + lifestyle: 4
  15 +};
  16 +
  17 +const channelNames = {
  18 + [1]: 'boys',
  19 + [2]: 'girls',
  20 + [3]: 'kids',
  21 + [4]: 'lifestyle'
  22 +};
  23 +
  24 +const gender = {
  25 + boys: '1,3',
  26 + girl: '2,3',
  27 + girls: '2,3',
  28 + kids: '3,3',
  29 + lifestyle: '4'
  30 +};
  31 +
  32 +module.exports = {
  33 + channels,
  34 + channelNames,
  35 + gender
  36 +};
  1 +/**
  2 + * 路由重写
  3 + * @author: chenfeng<feng.chen@yoho.cn>
  4 + * @date: 2017/2/20
  5 + */
  6 +'use strict';
  7 +
  8 +const typeLib = require('../../config/type-lib');
  9 +const _ = require('lodash');
  10 +
  11 +const resolve = (req, res, next) => {
  12 + let path = req.params[0],
  13 + params = {
  14 + channel: req.yoho.channel
  15 + };
  16 +
  17 + if (!path) {
  18 + return next();
  19 + }
  20 + let conditions = path.replace('.html', '').split('-');
  21 +
  22 + _.each(conditions, condition => {
  23 + if (typeLib.channels[condition]) {
  24 + params.channel = condition;
  25 + } else if (condition.indexOf('_') >= 0) {
  26 + let item = condition.split('_');
  27 +
  28 + if (item.length === 2) {
  29 + params[item[0]] = item[1];
  30 + }
  31 + } else if (condition >= 0) {
  32 + params.id = _.parseInt(condition);
  33 + }
  34 + });
  35 + req.yoho.channel = params.channel;
  36 + res.locals.channel = params.channel;
  37 + res.locals.pageChannel = { [params.channel]: true };
  38 + res.locals.setChannel = true;
  39 + Object.assign(req.query, params);
  40 + next();
  41 +};
  42 +
  43 +const channel = (req, res, next) => {
  44 + let channelName;
  45 +
  46 + if (req.query.channel) {
  47 + if (req.query.channel >= 0) {
  48 + channelName = typeLib.channelNames[req.query.channel];
  49 + } else if (typeLib.channels[req.query.channel]) {
  50 + channelName = req.query.channel;
  51 + }
  52 + } else if (req.query.gender) {
  53 + let gender = req.query.gender;
  54 +
  55 + switch (gender) {
  56 + case typeLib.gender.boys:
  57 + gender = 1;
  58 + break;
  59 + case typeLib.gender.girls:
  60 + gender = 2;
  61 + break;
  62 + case typeLib.gender.kids:
  63 + gender = 3;
  64 + break;
  65 + case typeLib.gender.lifestyle:
  66 + gender = 4;
  67 + break;
  68 + }
  69 + channelName = typeLib.channelNames[gender];
  70 + }
  71 + channelName = channelName || req.yoho.channel;
  72 + req.yoho.channel = channelName;
  73 + delete req.query.channel;
  74 + delete req.query.gender;
  75 + next();
  76 +};
  77 +
  78 +module.exports = {
  79 + resolve,
  80 + channel
  81 +};
1 {{#pageHeader}} 1 {{#pageHeader}}
2 {{# @root.pageChannel}} 2 {{# @root.pageChannel}}
3 -<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}}"> 3 +<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}}">
4 {{^}} 4 {{^}}
5 <header id="yoho-header" class="yoho-header"> 5 <header id="yoho-header" class="yoho-header">
6 {{/ @root.pageChannel}} 6 {{/ @root.pageChannel}}
@@ -53,7 +53,7 @@ @@ -53,7 +53,7 @@
53 {{/if}} 53 {{/if}}
54 {{#navBtn}} 54 {{#navBtn}}
55 {{# @root.pageChannel}} 55 {{# @root.pageChannel}}
56 -<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}}"> 56 +<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}}">
57 {{^}} 57 {{^}}
58 <div class="homebuttom hide"> 58 <div class="homebuttom hide">
59 {{/ @root.pageChannel}} 59 {{/ @root.pageChannel}}
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "5.4.14", 3 + "version": "5.4.15",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -5,15 +5,15 @@ @@ -5,15 +5,15 @@
5 */ 5 */
6 require('channel/brand.page.css'); 6 require('channel/brand.page.css');
7 7
8 -var $ = require('yoho-jquery'), 8 +let $ = require('yoho-jquery'),
9 Hammer = require('../common/toy-hammer'), 9 Hammer = require('../common/toy-hammer'),
10 Swiper = require('yoho-swiper'), 10 Swiper = require('yoho-swiper'),
11 lazyLoad = require('yoho-jquery-lazyload'); 11 lazyLoad = require('yoho-jquery-lazyload');
12 12
13 -var ranToken = ' ??++ ';  
14 -var ranToken2 = ' ???--- '; 13 +let ranToken = ' ??++ ';
  14 +let ranToken2 = ' ???--- ';
15 15
16 -var $brandList, 16 +let $brandList,
17 $newBrandWall, 17 $newBrandWall,
18 $recommandBrandWall, 18 $recommandBrandWall,
19 $icon = $('.search-icon'), 19 $icon = $('.search-icon'),
@@ -26,26 +26,26 @@ var $brandList, @@ -26,26 +26,26 @@ var $brandList,
26 $searchResult = $('.search-result'), 26 $searchResult = $('.search-result'),
27 $navBtn = $('.nav-home'); 27 $navBtn = $('.nav-home');
28 28
29 -var brandsData, 29 +let brandsData,
30 $keyword = $('#keyword'); 30 $keyword = $('#keyword');
31 31
32 -var $history = $('.local-history');  
33 -var $searchPage = $('.search-brand-page');  
34 -var $historySearch = $('.history-search');  
35 -var $hotSearch = $('.hot-search');  
36 -var $clearHistory = $('#clear-history');  
37 -var isSearchPage = $('.brand-search-page').length > 0; 32 +let $history = $('.local-history');
  33 +let $searchPage = $('.search-brand-page');
  34 +let $historySearch = $('.history-search');
  35 +let $hotSearch = $('.hot-search');
  36 +let $clearHistory = $('#clear-history');
  37 +let isSearchPage = $('.brand-search-page').length > 0;
38 38
39 require('../common'); 39 require('../common');
40 require('../footer'); 40 require('../footer');
41 41
42 function getBrandList() { 42 function getBrandList() {
43 - var listHbs = require('channel/brandlist.hbs'); 43 + let listHbs = require('channel/brandlist.hbs');
44 44
45 $.ajax({ 45 $.ajax({
46 url: '/brands/getBrandList', 46 url: '/brands/getBrandList',
47 data: { 47 data: {
48 - channel: window.queryString.channel 48 + channel: window.queryString.channel || $('.query-param[data-attr="yhChannel"]').val()
49 }, 49 },
50 success: function(data) { 50 success: function(data) {
51 $('#placeholder-brandlist').replaceWith(listHbs(data)); 51 $('#placeholder-brandlist').replaceWith(listHbs(data));
@@ -53,7 +53,7 @@ function getBrandList() { @@ -53,7 +53,7 @@ function getBrandList() {
53 lazyLoad($('img.lazy')); 53 lazyLoad($('img.lazy'));
54 54
55 // 改变背景色 55 // 改变背景色
56 - changeBackground(); 56 + changeBackground(); //eslint-disable-line
57 57
58 $brandList = $('.brand-list'); 58 $brandList = $('.brand-list');
59 $newBrandWall = $('.new-brand-wall'); 59 $newBrandWall = $('.new-brand-wall');
@@ -65,7 +65,7 @@ function getBrandList() { @@ -65,7 +65,7 @@ function getBrandList() {
65 } 65 }
66 66
67 function changeBackground() { 67 function changeBackground() {
68 - var brandList = $('.brand-list').find('p'); 68 + let brandList = $('.brand-list').find('p');
69 69
70 brandList.on('touchstart', function() { 70 brandList.on('touchstart', function() {
71 brandList.css('background', '#fff'); 71 brandList.css('background', '#fff');
@@ -115,11 +115,11 @@ function searchInput() { @@ -115,11 +115,11 @@ function searchInput() {
115 // $(this).closest('.search-box').css('width', '12.5rem'); 115 // $(this).closest('.search-box').css('width', '12.5rem');
116 $searchAction.find('.clear-text').hide(); 116 $searchAction.find('.clear-text').hide();
117 } 117 }
118 - searchResult(); 118 + searchResult(); //eslint-disable-line
119 } 119 }
120 120
121 function isLocalStorageSupported() { 121 function isLocalStorageSupported() {
122 - var testKey = 'test', 122 + let testKey = 'test',
123 storage = Window.prototype.localStorage || window.localStorage; 123 storage = Window.prototype.localStorage || window.localStorage;
124 124
125 try { 125 try {
@@ -132,20 +132,16 @@ function isLocalStorageSupported() { @@ -132,20 +132,16 @@ function isLocalStorageSupported() {
132 } 132 }
133 133
134 // 绑定提交前的存local操作 134 // 绑定提交前的存local操作
135 -function bindWriteLocal($brandList, list) {  
136 - $brandList.on('click', 'p , li', function(e) {  
137 - var brandName, brandId, brandDomain, url;  
138 - var a = $(this).find('a');  
139 - var myDate = new Date();  
140 - var query = a.attr('brandName') + ranToken2 + myDate.getTime(), 135 +function bindWriteLocal(brandListEle, list) {
  136 + brandListEle.on('click', 'p , li', function(e) {
  137 + let brandName, url;
  138 + let a = $(this).find('a');
  139 + let myDate = new Date();
  140 + let query = a.attr('brandName') + ranToken2 + myDate.getTime(),
141 historys; 141 historys;
142 142
143 brandName = a.attr('brandName'); 143 brandName = a.attr('brandName');
144 144
145 - brandId = a.attr('brandId');  
146 -  
147 - brandDomain = a.attr('brandDomain');  
148 -  
149 url = a.attr('href'); 145 url = a.attr('href');
150 146
151 e.preventDefault(); 147 e.preventDefault();
@@ -200,8 +196,8 @@ function bindWriteLocal($brandList, list) { @@ -200,8 +196,8 @@ function bindWriteLocal($brandList, list) {
200 } 196 }
201 197
202 function searchResult() { 198 function searchResult() {
203 - var keyword = ($keyword.val() + '').toLowerCase();  
204 - var result = {}, 199 + let keyword = ($keyword.val() + '').toLowerCase();
  200 + let result = {},
205 i = 0, 201 i = 0,
206 html = ''; 202 html = '';
207 203
@@ -212,7 +208,7 @@ function searchResult() { @@ -212,7 +208,7 @@ function searchResult() {
212 if ($.isArray(v)) { 208 if ($.isArray(v)) {
213 209
214 // 遍历品牌,进行匹配 210 // 遍历品牌,进行匹配
215 - $.each(v, function(i, brand) { 211 + $.each(v, function(index, brand) {
216 if (brand.searchName.toLowerCase().indexOf(keyword) > -1) { 212 if (brand.searchName.toLowerCase().indexOf(keyword) > -1) {
217 result[k] = result[k] || []; 213 result[k] = result[k] || [];
218 result[k].push(brand); 214 result[k].push(brand);
@@ -223,13 +219,13 @@ function searchResult() { @@ -223,13 +219,13 @@ function searchResult() {
223 219
224 // 根据搜索结果生成 HTML 220 // 根据搜索结果生成 HTML
225 $.each(result, function(k, v) { 221 $.each(result, function(k, v) {
226 - var brandHtml = ['<div class="brand-list bar-', i, '">']; 222 + let brandHtml = ['<div class="brand-list bar-', i, '">'];
227 223
228 i++; 224 i++;
229 brandHtml.push('<div class="title-bar"><h2>'); 225 brandHtml.push('<div class="title-bar"><h2>');
230 brandHtml.push(k); 226 brandHtml.push(k);
231 brandHtml.push('</h2></div>'); 227 brandHtml.push('</h2></div>');
232 - $.each(v, function(i, brand) { 228 + $.each(v, function(index, brand) {
233 229
234 brandHtml.push('<p><a href="' + brand.url + '" brandName = "' + brand.name + 230 brandHtml.push('<p><a href="' + brand.url + '" brandName = "' + brand.name +
235 '" brandId = "' + brand.brandId + '" brandDomain = "' + brand.brandDomain + '">' + brand.name); 231 '" brandId = "' + brand.brandId + '" brandDomain = "' + brand.brandDomain + '">' + brand.name);
@@ -262,8 +258,8 @@ function searchResult() { @@ -262,8 +258,8 @@ function searchResult() {
262 258
263 (function() { 259 (function() {
264 if ($('.banner-top').length === 0) { 260 if ($('.banner-top').length === 0) {
265 - var h1 = $('.genderNav').height();  
266 - var h2 = $('.newbrand-search').height(); 261 + let h1 = $('.genderNav').height();
  262 + let h2 = $('.newbrand-search').height();
267 263
268 $('.hot-brands').css('padding-top', (h1 + h2) + 'px'); 264 $('.hot-brands').css('padding-top', (h1 + h2) + 'px');
269 } 265 }
@@ -285,13 +281,19 @@ function searchResult() { @@ -285,13 +281,19 @@ function searchResult() {
285 }); 281 });
286 282
287 $genderItem.on('touchstart', function() { 283 $genderItem.on('touchstart', function() {
288 - var index = $(this).data('id') + 1; 284 + if (window.queryString.channel) {
  285 + let index = $(this).data('id') + 1;
289 286
290 - window.location.search = 'channel=' + index; 287 + window.location.search = 'channel=' + index;
  288 + } else {
  289 + let name = $(this).data('name').toLowerCase();
  290 +
  291 + window.location.href = `/${name}-brands/`;
  292 + }
291 }); 293 });
292 294
293 $brandItem.on('click', function() { 295 $brandItem.on('click', function() {
294 - var index = $(this).data('id'); 296 + let index = $(this).data('id');
295 297
296 $('.brandNav ul .active').removeClass('active'); 298 $('.brandNav ul .active').removeClass('active');
297 $(this).addClass('active'); 299 $(this).addClass('active');
@@ -351,7 +353,7 @@ if (isSearchPage) { @@ -351,7 +353,7 @@ if (isSearchPage) {
351 $keyword.closest('.search-box').css('width', '13rem'); 353 $keyword.closest('.search-box').css('width', '13rem');
352 $searchAction.show().find('.clear-text').hide(); 354 $searchAction.show().find('.clear-text').hide();
353 355
354 - var clearTextHammer = new Hammer($('.clear-text')[0]); 356 + let clearTextHammer = new Hammer($('.clear-text')[0]);
355 357
356 clearTextHammer.on('tap', function(e) { 358 clearTextHammer.on('tap', function(e) {
357 $searchResult.html(''); 359 $searchResult.html('');
@@ -380,7 +382,7 @@ if (isSearchPage) { @@ -380,7 +382,7 @@ if (isSearchPage) {
380 } 382 }
381 383
382 $netHistory = $('.net-history'); 384 $netHistory = $('.net-history');
383 - var chHammer = new Hammer($clearHistory[0]); 385 + let chHammer = new Hammer($clearHistory[0]);
384 386
385 chHammer.on('tap', function() { 387 chHammer.on('tap', function() {
386 if (isLocalStorageSupported()) { 388 if (isLocalStorageSupported()) {
@@ -399,7 +401,7 @@ if (isSearchPage) { @@ -399,7 +401,7 @@ if (isSearchPage) {
399 401
400 // 搜索页面 402 // 搜索页面
401 (function() { 403 (function() {
402 - var html = '', 404 + let html = '',
403 history, 405 history,
404 historys, i, 406 historys, i,
405 localHistory, 407 localHistory,
@@ -417,7 +419,7 @@ if (isSearchPage) { @@ -417,7 +419,7 @@ if (isSearchPage) {
417 dict = { 419 dict = {
418 brand: brand, 420 brand: brand,
419 time: time 421 time: time
420 - }, dictc, dict; 422 + }, dictc, dict; //eslint-disable-line
421 netArr.push(dict); 423 netArr.push(dict);
422 }); 424 });
423 425
@@ -182,9 +182,6 @@ $.extend({ @@ -182,9 +182,6 @@ $.extend({
182 182
183 var user = getUser(); 183 var user = getUser();
184 184
185 - var backToTopHammer;  
186 - var floatTopHammer;  
187 -  
188 setTimeout(function() { 185 setTimeout(function() {
189 rePosFooter(); // 计算底部位置 186 rePosFooter(); // 计算底部位置
190 }, 500); 187 }, 500);
@@ -343,8 +340,8 @@ function givePoint(parameter) { @@ -343,8 +340,8 @@ function givePoint(parameter) {
343 } 340 }
344 341
345 // 男:1,女:2,潮童:3,创意生活:4 342 // 男:1,女:2,潮童:3,创意生活:4
346 - var CID = _ChannelVary[cookie('_Channel')] || 1;  
347 - var isAppOp = parameter.isAppOp; 343 + let CID = _ChannelVary[cookie('_Channel')] || 1;
  344 + let isAppOp = parameter.isAppOp;
348 345
349 parameter = $.extend({ 346 parameter = $.extend({
350 REC_ID: RECID, 347 REC_ID: RECID,
@@ -370,39 +367,41 @@ function givePoint(parameter) { @@ -370,39 +367,41 @@ function givePoint(parameter) {
370 var header = $('#yoho-header, .homebuttom'); 367 var header = $('#yoho-header, .homebuttom');
371 var footer = $('.footer-tab .tab-item.current'); 368 var footer = $('.footer-tab .tab-item.current');
372 369
373 - if (!/^\/home/.test(location.pathname)) {  
374 - switch (channel) {  
375 - case 'boys':  
376 - if (!header.hasClass('boys')) {  
377 - header.addClass('boys');  
378 - }  
379 - break;  
380 - case 'girls':  
381 - if (!header.hasClass('girls')) {  
382 - header.addClass('girls');  
383 - }  
384 - break;  
385 - case 'lifestyle':  
386 - if (!header.hasClass('life-style')) {  
387 - header.addClass('life-style');  
388 - }  
389 - break;  
390 - case 'kids':  
391 - if (!header.hasClass('kids')) {  
392 - header.addClass('kids');  
393 - }  
394 - break;  
395 - default:  
396 - if (!header.hasClass('boys')) {  
397 - header.addClass('boys');  
398 - }  
399 - break; 370 + if (!header.hasClass('set-channel')) {
  371 + if (!/^\/home/.test(location.pathname)) {
  372 + switch (channel) {
  373 + case 'boys':
  374 + if (!header.hasClass('boys')) {
  375 + header.addClass('boys');
  376 + }
  377 + break;
  378 + case 'girls':
  379 + if (!header.hasClass('girls')) {
  380 + header.addClass('girls');
  381 + }
  382 + break;
  383 + case 'lifestyle':
  384 + if (!header.hasClass('life-style')) {
  385 + header.addClass('life-style');
  386 + }
  387 + break;
  388 + case 'kids':
  389 + if (!header.hasClass('kids')) {
  390 + header.addClass('kids');
  391 + }
  392 + break;
  393 + default:
  394 + if (!header.hasClass('boys')) {
  395 + header.addClass('boys');
  396 + }
  397 + break;
  398 + }
  399 + } else {
  400 + header.removeClass('kids');
  401 + header.removeClass('girls');
  402 + header.removeClass('life-style');
  403 + header.addClass('boys');
400 } 404 }
401 - } else {  
402 - header.removeClass('kids');  
403 - header.removeClass('girls');  
404 - header.removeClass('life-style');  
405 - header.addClass('boys');  
406 } 405 }
407 406
408 switch (channel) { 407 switch (channel) {
@@ -32,7 +32,7 @@ function refreshData() { @@ -32,7 +32,7 @@ function refreshData() {
32 32
33 var qs = window.queryString; 33 var qs = window.queryString;
34 34
35 - var id = qs.id; 35 + var id = qs.id || $('.detail').data('id');
36 36
37 getDynamicById(id).done(renderData); 37 getDynamicById(id).done(renderData);
38 } 38 }
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 6
7 require('product/sale/break-code-index.page.css'); 7 require('product/sale/break-code-index.page.css');
8 8
9 -var $ = require('yoho-jquery'), 9 +let $ = require('yoho-jquery'),
10 Swiper = require('yoho-swiper2'), 10 Swiper = require('yoho-swiper2'),
11 ellipsis = require('yoho-mlellipsis'), 11 ellipsis = require('yoho-mlellipsis'),
12 lazyLoad = require('yoho-jquery-lazyload'), 12 lazyLoad = require('yoho-jquery-lazyload'),
@@ -14,24 +14,24 @@ var $ = require('yoho-jquery'), @@ -14,24 +14,24 @@ var $ = require('yoho-jquery'),
14 filter = require('../plugin/filter'), 14 filter = require('../plugin/filter'),
15 loading = require('../plugin/loading'); 15 loading = require('../plugin/loading');
16 16
17 -var $goodsContainer = $('#goods-container'), 17 +let $goodsContainer = $('#goods-container'),
18 $goodsChildren = $goodsContainer.children(), 18 $goodsChildren = $goodsContainer.children(),
19 $coatGc = $($goodsChildren.get(0)), 19 $coatGc = $($goodsChildren.get(0)),
20 $trouserGc = $($goodsChildren.get(1)), 20 $trouserGc = $($goodsChildren.get(1)),
21 $shoesgc = $($goodsChildren.get(2)), 21 $shoesgc = $($goodsChildren.get(2)),
22 $othergc = $($goodsChildren.get(3)); 22 $othergc = $($goodsChildren.get(3));
23 23
24 -var $filterMask; 24 +let $filterMask;
25 25
26 -var winH = $(window).height(), 26 +let winH = $(window).height(),
27 noResult = '<p class="no-result">未找到相关搜索结果</p>'; 27 noResult = '<p class="no-result">未找到相关搜索结果</p>';
28 28
29 // 默认筛选条件 29 // 默认筛选条件
30 -var defaultOpt = require('../common/query-param'); 30 +let defaultOpt = require('../common/query-param');
31 31
32 -var storeOpt = {}; 32 +let storeOpt = {};
33 33
34 -var $listNav = $('#list-nav'), 34 +let $listNav = $('#list-nav'),
35 $sizeArea = $('.size-area'), 35 $sizeArea = $('.size-area'),
36 $subSize = $('.sub-size'), 36 $subSize = $('.sub-size'),
37 37
@@ -61,7 +61,7 @@ var $listNav = $('#list-nav'), @@ -61,7 +61,7 @@ var $listNav = $('#list-nav'),
61 $pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项 61 $pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项
62 searching; 62 searching;
63 63
64 -var goodsType = ['coat', 'trouser', 'shoes', 'other']; 64 +let goodsType = ['coat', 'trouser', 'shoes', 'other'];
65 65
66 require('../common'); 66 require('../common');
67 require('../common/suspend-cart'); // 悬浮购物车 67 require('../common/suspend-cart'); // 悬浮购物车
@@ -83,7 +83,7 @@ function getUrlParam(name) { @@ -83,7 +83,7 @@ function getUrlParam(name) {
83 } 83 }
84 84
85 defaultOpt = $.extend({ 85 defaultOpt = $.extend({
86 - yh_channel: getUrlParam('channel') || 'boys', 86 + yh_channel: getUrlParam('channel') || defaultOpt.channel || 'boys', //TODO GO ON!
87 saleType: 1 87 saleType: 1
88 }, defaultOpt); 88 }, defaultOpt);
89 89
@@ -6,13 +6,14 @@ @@ -6,13 +6,14 @@
6 6
7 require('product/sale/index.page.css'); 7 require('product/sale/index.page.css');
8 8
9 -var $ = require('yoho-jquery'), 9 +let $ = require('yoho-jquery'),
10 Swiper = require('yoho-swiper2'), 10 Swiper = require('yoho-swiper2'),
11 ellipsis = require('yoho-mlellipsis'), 11 ellipsis = require('yoho-mlellipsis'),
12 fastclick = require('yoho-fastclick'), 12 fastclick = require('yoho-fastclick'),
13 lazyload = require('yoho-jquery-lazyload'); 13 lazyload = require('yoho-jquery-lazyload');
14 14
15 -var search = require('./sale/search'); 15 +let search = require('./sale/search');
  16 +let defaultOpt = require('../common/query-param');
16 17
17 require('../common'); 18 require('../common');
18 19
@@ -52,7 +53,7 @@ $(function() { @@ -52,7 +53,7 @@ $(function() {
52 $.ajax({ 53 $.ajax({
53 url: '/product/sale/search', 54 url: '/product/sale/search',
54 data: { 55 data: {
55 - yh_channel: window.queryString.channel || 'boys', 56 + yh_channel: window.queryString.channel || defaultOpt.channel || 'boys',
56 saleType: '2', 57 saleType: '2',
57 productPool: $vipFloor.data('id'), 58 productPool: $vipFloor.data('id'),
58 limit: '4' 59 limit: '4'
@@ -106,7 +106,7 @@ if ($('.sale-vip-page').length > 0) { @@ -106,7 +106,7 @@ if ($('.sale-vip-page').length > 0) {
106 106
107 // 获取频道 107 // 获取频道
108 $.extend(defaultOpt, { 108 $.extend(defaultOpt, {
109 - yh_channel: getUrlParam('channel') || 'all' 109 + yh_channel: getUrlParam('channel') || defaultOpt.channel || 'all'
110 }); 110 });
111 111
112 // 判断导航类型 112 // 判断导航类型
@@ -251,7 +251,7 @@ function search(opt, params, isScroll) { @@ -251,7 +251,7 @@ function search(opt, params, isScroll) {
251 loading.showLoadingMask(); 251 loading.showLoadingMask();
252 252
253 /* TODO tar add 161125 sale dicount no yh_channel*/ 253 /* TODO tar add 161125 sale dicount no yh_channel*/
254 - var discount = $('#discount').val(); 254 + let discount = $('#discount').val();
255 255
256 if (discount === 'discount') { 256 if (discount === 'discount') {
257 delete setting.yh_channel; 257 delete setting.yh_channel;
@@ -21,10 +21,15 @@ const transHttpsUrl = (url) => { @@ -21,10 +21,15 @@ const transHttpsUrl = (url) => {
21 * @return {[strng]} 21 * @return {[strng]}
22 */ 22 */
23 const getFilterUrl = (url) => { 23 const getFilterUrl = (url) => {
24 - url = url.replace('.m.yohobuy.com', global.yoho.config.subDomains.host).replace('www.yohobuy.com', global.yoho.config.siteUrl); 24 + url = url.replace('.m.yohobuy.com', global.yoho.config.subDomains.host)
  25 + .replace('www.yohobuy.com', global.yoho.config.siteUrl);
25 26
26 const whiteDomains = ['m.yohobuy.com', 'cdn.yoho.cn/myohobuy']; 27 const whiteDomains = ['m.yohobuy.com', 'cdn.yoho.cn/myohobuy'];
27 - const blackDomains = ['sale.m.yohobuy.com', 'cuxiao.m.yohobuy.com', 'activity.m.yohobuy.com', 'huodong.m.yohobuy.com', '/home/orders/pay']; 28 + const blackDomains = ['sale.m.yohobuy.com',
  29 + 'cuxiao.m.yohobuy.com',
  30 + 'activity.m.yohobuy.com',
  31 + 'huodong.m.yohobuy.com',
  32 + '/home/orders/pay'];
28 33
29 if (whiteDomains.every(_ => url.includes(_)) && 34 if (whiteDomains.every(_ => url.includes(_)) &&
30 blackDomains.every(_ => !url.includes(_))) { 35 blackDomains.every(_ => !url.includes(_))) {
@@ -53,10 +58,9 @@ const getFilterUrl = (url) => { @@ -53,10 +58,9 @@ const getFilterUrl = (url) => {
53 * @param {Boolean} isApp [是否显示分享,在APP客户端里嵌入需要传url链接] 58 * @param {Boolean} isApp [是否显示分享,在APP客户端里嵌入需要传url链接]
54 * @param {[Boolean]} showAuthor [控制是否显示作者信息] 59 * @param {[Boolean]} showAuthor [控制是否显示作者信息]
55 * @param {[int]} uid [当前登录的用户ID] 60 * @param {[int]} uid [当前登录的用户ID]
56 - * @param {[string]} reqQueryString [查询字符串]  
57 * @return {[array | false]} 61 * @return {[array | false]}
58 */ 62 */
59 -const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryString) => { 63 +const formatArticle = (articleData, showTag, isApp, showAuthor, uid) => {
60 // 资讯ID不存在,则不显示 64 // 资讯ID不存在,则不显示
61 if (!articleData.id) { 65 if (!articleData.id) {
62 return false; 66 return false;
@@ -65,7 +69,7 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr @@ -65,7 +69,7 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr
65 id: articleData.id, 69 id: articleData.id,
66 showTags: showTag, 70 showTags: showTag,
67 img: articleData.src ? helpers.image(articleData.src, 640, 640) : '', 71 img: articleData.src ? helpers.image(articleData.src, 640, 640) : '',
68 - 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, 72 + 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
69 title: articleData.title, 73 title: articleData.title,
70 text: articleData.intro, 74 text: articleData.intro,
71 publishTime: articleData.publish_time, 75 publishTime: articleData.publish_time,
@@ -92,7 +96,7 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr @@ -92,7 +96,7 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr
92 if (!uid) { 96 if (!uid) {
93 let playUrlEncode = `${originUrl}${colparam.param}`.replace(/\//g, '\\\/'); 97 let playUrlEncode = `${originUrl}${colparam.param}`.replace(/\//g, '\\\/');
94 98
95 - collectUrl = `${originUrl}?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"${playUrlEncode}","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}`; 99 + collectUrl = `${originUrl}?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"${playUrlEncode}","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}`; //eslint-disable-line
96 } 100 }
97 result.collect.url = collectUrl; 101 result.collect.url = collectUrl;
98 } else { // 点赞 102 } else { // 点赞
@@ -104,19 +108,20 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr @@ -104,19 +108,20 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr
104 if (isApp && articleData.share.url) { 108 if (isApp && articleData.share.url) {
105 109
106 // 分享链接 110 // 分享链接
107 - 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}"}}`; 111 + 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
108 } 112 }
109 113
110 // 判断是否显示作者信息 114 // 判断是否显示作者信息
111 if (showAuthor && articleData.author) { 115 if (showAuthor && articleData.author) {
112 if (!isApp) { 116 if (!isApp) {
113 articleData.author.url = getFilterUrl(articleData.author.url); 117 articleData.author.url = getFilterUrl(articleData.author.url);
114 - } 118 + } else {
  119 + // 编辑人员 app跳转url处理 20160601
  120 + let isLogin = uid ? true : false;
115 121
116 - // 编辑人员 app跳转url处理 20160601  
117 - let isLogin = uid ? true : false; 122 + 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
  123 + }
118 124
119 - 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}"}}`;  
120 result.author = articleData.author; 125 result.author = articleData.author;
121 if (result.author.avatar) { 126 if (result.author.avatar) {
122 result.author.avatar = result.author.avatar.replace('http://', '//'); 127 result.author.avatar = result.author.avatar.replace('http://', '//');
@@ -281,14 +286,14 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height, @@ -281,14 +286,14 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height,
281 productData.cn_alphabet = productNameProcess(productData.cn_alphabet); 286 productData.cn_alphabet = productNameProcess(productData.cn_alphabet);
282 } 287 }
283 288
284 - let url = encodeURI(helpers.urlFormat(`/product/pro_${productData.product_id}_${productData.goods_list[0].goods_id}/${productData.cn_alphabet}.html`)); 289 + let url = encodeURI(helpers.urlFormat(`/product/pro_${productData.product_id}_${productData.goods_list[0].goods_id}/${productData.cn_alphabet}.html`)); //eslint-disable-line
285 290
286 result.url = url.replace('http://', '//'); 291 result.url = url.replace('http://', '//');
287 292
288 // APP访问需要加附加的参数 293 // APP访问需要加附加的参数
289 // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 294 // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
290 if (isApp) { 295 if (isApp) {
291 - result.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${productData.product_skn}}}`; 296 + result.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${productData.product_skn}}}`; //eslint-disable-line
292 } 297 }
293 if (showTags) { 298 if (showTags) {
294 result.tags = { 299 result.tags = {
@@ -305,7 +310,10 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height, @@ -305,7 +310,10 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height,
305 if (result.is_soon_sold_out && result.tags.is_discount) { 310 if (result.is_soon_sold_out && result.tags.is_discount) {
306 result.tags.is_new = false; 311 result.tags.is_new = false;
307 } else if (result.tags.is_discount && 312 } else if (result.tags.is_discount &&
308 - (result.tags.is_new || result.tags.is_limited || result.tags.is_yohood || result.tags.is_advance) // 打折与其它组合则隐藏打折 313 + (result.tags.is_new ||
  314 + result.tags.is_limited ||
  315 + result.tags.is_yohood ||
  316 + result.tags.is_advance) // 打折与其它组合则隐藏打折
309 ) { 317 ) {
310 result.tags.is_discount = false; 318 result.tags.is_discount = false;
311 } else if (result.tags.is_yohood && result.tags.is_new) { // YOHOOD和新品组合显示YOHOOD 319 } else if (result.tags.is_yohood && result.tags.is_new) { // YOHOOD和新品组合显示YOHOOD