Authored by 周少峰

list

@@ -7,7 +7,6 @@ const sm = require('sitemap'); @@ -7,7 +7,6 @@ const sm = require('sitemap');
7 const staticUrls = require('../../../config/staticUrls'); 7 const staticUrls = require('../../../config/staticUrls');
8 const api = global.yoho.API; 8 const api = global.yoho.API;
9 const Service = global.yoho.ServiceAPI; 9 const Service = global.yoho.ServiceAPI;
10 -const headerModel = require('../../../doraemon/models/header');  
11 10
12 const getStaticUrls = (currentStatics) => { 11 const getStaticUrls = (currentStatics) => {
13 let urls = []; 12 let urls = [];
@@ -34,36 +33,6 @@ const getStaticUrls = (currentStatics) => { @@ -34,36 +33,6 @@ const getStaticUrls = (currentStatics) => {
34 return Promise.resolve(urls); 33 return Promise.resolve(urls);
35 }; 34 };
36 35
37 -// m 地图数据  
38 -const mXmlData = () => {// eslint-disable-line  
39 - return getStaticUrls(_.get(staticUrls, 'm'));  
40 -};  
41 -  
42 -// list 地图数据  
43 -const listXmlData = () => {// eslint-disable-line  
44 - return Promise.all([getStaticUrls(_.get(staticUrls, 'list')), headerModel.requestHeaderData()]).then(result => {  
45 -  
46 - // 获取导航中的列表链接  
47 - let listNav = [],  
48 - listPatten = /list\.yohobuy\.com/;  
49 -  
50 - _.forEach(_.get(result[1], 'headerData.subNavGroup'), val => {  
51 - _.forEach(val.subNav, sub => {  
52 - if (listPatten.test(sub.link)) {  
53 - listNav.push({url: `https:${sub.link}`, changefreq: 'daily', priority: 0.3});  
54 - }  
55 - _.forEach(_.get(sub, 'thirdNav'), third => {  
56 - if (listPatten.test(third.link)) {  
57 - listNav.push({url: `https:${third.link}`, changefreq: 'daily', priority: 0.3});  
58 - }  
59 - });  
60 - });  
61 - });  
62 -  
63 - return _.union(result[0], _.uniqBy(listNav, 'url'));  
64 - });  
65 -};  
66 -  
67 // item 地图数据 36 // item 地图数据
68 const itemXmlData = () => {// eslint-disable-line 37 const itemXmlData = () => {// eslint-disable-line
69 let urls = []; 38 let urls = [];
@@ -71,7 +40,7 @@ const itemXmlData = () => {// eslint-disable-line @@ -71,7 +40,7 @@ const itemXmlData = () => {// eslint-disable-line
71 return api.get('', {method: 'web.product.bdPromotion'}, {cache: 86400}).then(res => { 40 return api.get('', {method: 'web.product.bdPromotion'}, {cache: 86400}).then(res => {
72 _.forEach(_.get(res, 'data', ''), val => { 41 _.forEach(_.get(res, 'data', ''), val => {
73 urls.push({ 42 urls.push({
74 - url: `https:${helpers.getUrlBySkc(val.id)}`, 43 + url: 'https:' + helpers.urlFormat(`/product/${val.id}.html`, '', null),
75 changefreq: 'daily', 44 changefreq: 'daily',
76 priority: 0.3 45 priority: 0.3
77 }); 46 });
@@ -81,6 +50,18 @@ const itemXmlData = () => {// eslint-disable-line @@ -81,6 +50,18 @@ const itemXmlData = () => {// eslint-disable-line
81 }); 50 });
82 }; 51 };
83 52
  53 +// m 地图数据
  54 +const mXmlData = () => {// eslint-disable-line
  55 + return Promise.all([getStaticUrls(_.get(staticUrls, 'm')), itemXmlData()]).then(result => {
  56 + return _.union(result[0], result[1]);
  57 + });
  58 +};
  59 +
  60 +// list 地图数据
  61 +const listXmlData = () => {// eslint-disable-line
  62 + return getStaticUrls(_.get(staticUrls, 'list'));
  63 +};
  64 +
84 const getArticleUrls = () => { 65 const getArticleUrls = () => {
85 let urls = []; 66 let urls = [];
86 67
@@ -107,15 +88,13 @@ const guangXmlData = () => {// eslint-disable-line @@ -107,15 +88,13 @@ const guangXmlData = () => {// eslint-disable-line
107 88
108 // 站点地图 89 // 站点地图
109 const siteMap = (req, res, next) => { 90 const siteMap = (req, res, next) => {
110 -  
111 let siteList = ['m', 'list', 'item', 'guang'], 91 let siteList = ['m', 'list', 'item', 'guang'],
112 - subdomain = req.subdomains[0] || 'm'; 92 + subdomain = req.subdomains[1] || 'm';
113 93
114 if (_.find(siteList, subdomain)) { 94 if (_.find(siteList, subdomain)) {
115 res.end('end'); 95 res.end('end');
116 return; 96 return;
117 } 97 }
118 -  
119 eval(subdomain + 'XmlData')().then(urls => {// eslint-disable-line 98 eval(subdomain + 'XmlData')().then(urls => {// eslint-disable-line
120 sm.createSitemap({ 99 sm.createSitemap({
121 hostname: `https://${subdomain}.yohobuy.com`, 100 hostname: `https://${subdomain}.yohobuy.com`,
@@ -10,7 +10,7 @@ module.exports = { @@ -10,7 +10,7 @@ module.exports = {
10 m: { 10 m: {
11 // 频道 11 // 频道
12 channel: { 12 channel: {
13 - loc: ['https:m.yohobuy.com/', 'https://m.yohobuy.com/girls/', 'https://m.yohobuy.com/kids/', 'https://m.yohobuy.com/lifestyle/'], 13 + loc: ['https://m.yohobuy.com/', 'https://m.yohobuy.com/girls/', 'https://m.yohobuy.com/kids/', 'https://m.yohobuy.com/lifestyle/'],
14 lastmod: today, 14 lastmod: today,
15 changefreq: 'daily', 15 changefreq: 'daily',
16 priority: 0.8 16 priority: 0.8
@@ -271,9 +271,9 @@ module.exports = { @@ -271,9 +271,9 @@ module.exports = {
271 }, 271 },
272 guang: { 272 guang: {
273 loc: ['https://guang.m.yohobuy.com/?gender=1%2C3', 'https://guang.m.yohobuy.com/?gender=2%2C3', 'https://guang.m.yohobuy.com/?gender=1%2C2%2C3', 'https://guang.m.yohobuy.com/?id=2&name=%E6%90%AD%E9%85%8D', 'https://guang.m.yohobuy.com/?id=4', 'http://guang.m.yohobuy.com/?id=0', 'https://guang.m.yohobuy.com/?id=1', 'https://guang.m.yohobuy.com/?id=3', 'https://guang.m.yohobuy.com/?id=5', 273 loc: ['https://guang.m.yohobuy.com/?gender=1%2C3', 'https://guang.m.yohobuy.com/?gender=2%2C3', 'https://guang.m.yohobuy.com/?gender=1%2C2%2C3', 'https://guang.m.yohobuy.com/?id=2&name=%E6%90%AD%E9%85%8D', 'https://guang.m.yohobuy.com/?id=4', 'http://guang.m.yohobuy.com/?id=0', 'https://guang.m.yohobuy.com/?id=1', 'https://guang.m.yohobuy.com/?id=3', 'https://guang.m.yohobuy.com/?id=5',
274 - 'https://guang.m.yohobuy.com/guang/author-8168253/', 'https://guang.m.yohobuy.com/guang/author-8168291', 'https://guang.m.yohobuy.com/guang/author-8168283', 'https://guang.m.yohobuy.com/guang/author-8168239', 'https://guang.m.yohobuy.com/guang/author-8168287', 'https://guang.m.yohobuy.com/guang/author-8168287', 'https://guang.m.yohobuy.com/guang/author-8168259', 'https://guang.m.yohobuy.com/guang/author-7823335', 'https://guang.m.yohobuy.com/guang/author-8123505',  
275 - 'https://guang.m.yohobuy.com/guang/author-6875335', 'https://guang.m.yohobuy.com/guang/author-8168275', 'https://guang.m.yohobuy.com/guang/author-8168289', 'https://guang.m.yohobuy.com/guang/author-8168257', 'https://guang.m.yohobuy.com/guang/author-8168265', 'https://guang.m.yohobuy.com/guang/author-8168271', 'https://guang.m.yohobuy.com/guang/author-8168227', 'https://guang.m.yohobuy.com/guang/author-8168244', 'https://guang.m.yohobuy.com/guang/author-8168255',  
276 - 'https://guang.m.yohobuy.com/guang/author-8168248', 'https://guang.m.yohobuy.com/guang/author-380463'], 274 + 'https://guang.m.yohobuy.com/guang/author-8168253/', 'https://guang.m.yohobuy.com/guang/author-8168291/', 'https://guang.m.yohobuy.com/guang/author-8168283/', 'https://guang.m.yohobuy.com/guang/author-8168239/', 'https://guang.m.yohobuy.com/guang/author-8168287/', 'https://guang.m.yohobuy.com/guang/author-8168287/', 'https://guang.m.yohobuy.com/guang/author-8168259/', 'https://guang.m.yohobuy.com/guang/author-7823335/', 'https://guang.m.yohobuy.com/guang/author-8123505/',
  275 + 'https://guang.m.yohobuy.com/guang/author-6875335/', 'https://guang.m.yohobuy.com/guang/author-8168275/', 'https://guang.m.yohobuy.com/guang/author-8168289/', 'https://guang.m.yohobuy.com/guang/author-8168257/', 'https://guang.m.yohobuy.com/guang/author-8168265/', 'https://guang.m.yohobuy.com/guang/author-8168271/', 'https://guang.m.yohobuy.com/guang/author-8168227/', 'https://guang.m.yohobuy.com/guang/author-8168244/', 'https://guang.m.yohobuy.com/guang/author-8168255/',
  276 + 'https://guang.m.yohobuy.com/guang/author-8168248/', 'https://guang.m.yohobuy.com/guang/author-380463/'],
277 lastmod: today, 277 lastmod: today,
278 changefreq: 'daily', 278 changefreq: 'daily',
279 priority: 0.3 279 priority: 0.3