Authored by 陈峰

Merge branch 'hotfix/mobileRefer' into 'gray'

Hotfix/mobile refer

guang首页

See merge request !197
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 'use strict'; 4 'use strict';
5 5
6 const _ = require('lodash'); 6 const _ = require('lodash');
  7 +const queryString = require('querystring');
7 8
8 const ptm = { 9 const ptm = {
9 // 首页 10 // 首页
@@ -28,6 +29,13 @@ const ptm = { @@ -28,6 +29,13 @@ const ptm = {
28 29
29 }; 30 };
30 31
  32 +const genderMap = {
  33 + boys: '1,3',
  34 + girls: '2,3',
  35 + kids: '1,2,3',
  36 + lifestyle: '1,2,3'
  37 +};
  38 +
31 module.exports = () => { 39 module.exports = () => {
32 return (req, res, next) => { 40 return (req, res, next) => {
33 let domain = 'm.yohobuy.com'; 41 let domain = 'm.yohobuy.com';
@@ -44,7 +52,11 @@ module.exports = () => { @@ -44,7 +52,11 @@ module.exports = () => {
44 } else if (url === '/product/index/brand') { 52 } else if (url === '/product/index/brand') {
45 data.mobileRefer = `//${req.query.domain}.${domain}`; 53 data.mobileRefer = `//${req.query.domain}.${domain}`;
46 } else if (url === '/product/search/index') { 54 } else if (url === '/product/search/index') {
47 - data.mobileRefer = `//search.${domain}`; 55 + data.mobileRefer = `//search.${domain}${req.url}`;
  56 + } else if (url === '/guang/') {
  57 + req.query.gender = genderMap[req.query.channel];
  58 + _.unset(req.query, 'channel');
  59 + data.mobileRefer = `//${domain}/guang?${queryString.stringify(req.query)}`;
48 } else if (proRegNew.test(url)) { 60 } else if (proRegNew.test(url)) {
49 data.mobileRefer = url.replace(proRegNew, `//${domain}/product/$1.html$2`); 61 data.mobileRefer = url.replace(proRegNew, `//${domain}/product/$1.html$2`);
50 } 62 }