Authored by ccbikai(👎🏻🍜)

Merge branch 'release/guang'

@@ -165,16 +165,15 @@ const tag = (req, res, next) => { @@ -165,16 +165,15 @@ const tag = (req, res, next) => {
165 pageHeader: headerData, 165 pageHeader: headerData,
166 module: 'guang', 166 module: 'guang',
167 page: 'index-editor', 167 page: 'index-editor',
168 - title: tagTitle + ' | Yoho!Buy有货 | 潮流购物逛不停',  
169 - pageFooter: true 168 + title: tagTitle + ' | Yoho!Buy有货 | 潮流购物逛不停'
170 }; 169 };
171 170
172 let param = { 171 let param = {
173 tag: req.query.query, 172 tag: req.query.query,
174 isApp: req.query.app_version || req.query.appVersion || false, 173 isApp: req.query.app_version || req.query.appVersion || false,
175 - gender: req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3',  
176 - uid: req.user.uid,  
177 - udid: req.user.udid, 174 + gender: req.query.gender || '1,3',
  175 + uid: req.user.uid || 0,
  176 + udid: req.sessionID,
178 type: req.query.type || 0 177 type: req.query.type || 0
179 178
180 }; 179 };
@@ -288,7 +288,11 @@ const index = (req, res, next) => { @@ -288,7 +288,11 @@ const index = (req, res, next) => {
288 }; 288 };
289 289
290 // guang双头部的问题 20160601 290 // guang双头部的问题 20160601
291 - 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')}"}}`); 291 + // 正确的URL
  292 + 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}"}}`);
  293 +
  294 + // 错误的URL
  295 + // 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')}"}}`);
292 } 296 }
293 let guang = data.guang; 297 let guang = data.guang;
294 298
@@ -16,29 +16,59 @@ let channels = { @@ -16,29 +16,59 @@ let channels = {
16 lifestyle: '4' 16 lifestyle: '4'
17 }; 17 };
18 18
  19 +let yhChannel = {
  20 + boys: 1,
  21 + girl: 2
  22 +};
  23 +
19 const getListData = (req, res, next) => { 24 const getListData = (req, res, next) => {
20 let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3'; 25 let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
21 let recom = '4'; 26 let recom = '4';
22 let all = '1'; 27 let all = '1';
  28 + let type = req.query.type;
  29 + let channel = req.cookies._Channel && yhChannel[req.cookies._Channel] || 1;
  30 + let isRecommend = '0';
  31 + let starBrand = '2';
  32 + let originalBrand = '3';
23 33
24 - plustarModel.getListData(gender, recom, all).then((result) => { 34 + if (type === '2') {
  35 + plustarModel.getBrandsData(gender, starBrand, originalBrand, channel, isRecommend).then((result) => {
  36 + res.render('plustar/list', {
  37 + module: 'guang',
  38 + page: 'plustar-list',
  39 + title: '明星原创',
  40 + pageHeader: headerModel.setNav({
  41 + navTitle: '明星原创'
  42 + }),
  43 + pageFooter: true,
  44 + ps: {
  45 + sName: '明星潮品',
  46 + pName: '原创潮牌',
  47 + star: result.star,
  48 + plus: result.plus
  49 + }
  50 + });
  51 + }).catch(next);
  52 + } else {
  53 + plustarModel.getListData(gender, recom, all).then((result) => {
25 54
26 - res.render('plustar/list', {  
27 - module: 'guang',  
28 - page: 'plustar-list',  
29 - title: '国际优选',  
30 - pageHeader: headerModel.setNav({  
31 - navTitle: '国际优选'  
32 - }),  
33 - pageFooter: true,  
34 - ps: {  
35 - sName: '设计师',  
36 - pName: '经典潮牌',  
37 - star: result.star,  
38 - plus: result.plus  
39 - }  
40 - });  
41 - }).catch(next); 55 + res.render('plustar/list', {
  56 + module: 'guang',
  57 + page: 'plustar-list',
  58 + title: '国际优选',
  59 + pageHeader: headerModel.setNav({
  60 + navTitle: '国际优选'
  61 + }),
  62 + pageFooter: true,
  63 + ps: {
  64 + sName: '设计师',
  65 + pName: '经典潮牌',
  66 + star: result.star,
  67 + plus: result.plus
  68 + }
  69 + });
  70 + }).catch(next);
  71 + }
42 }; 72 };
43 73
44 const getDetailData = (req, res, next) => { 74 const getDetailData = (req, res, next) => {
@@ -141,10 +141,10 @@ const _article = (param) => { @@ -141,10 +141,10 @@ const _article = (param) => {
141 page: param.page || 1, 141 page: param.page || 1,
142 uid: param.uid, 142 uid: param.uid,
143 udid: param.udid, 143 udid: param.udid,
144 - sort_id: param.type === '0' ? param.type : '1', 144 + sort_id: 0,
145 tag: param.tag ? param.tag : null, 145 tag: param.tag ? param.tag : null,
146 - author_id: param.authorId ? param.authorId : null,  
147 - limit: param.limit ? param.limit : null 146 + //author_id: param.authorId ? param.authorId : null,
  147 + //limit: param.limit ? param.limit : null
148 }, { 148 }, {
149 cache: true, 149 cache: true,
150 code: 200 150 code: 200
@@ -278,13 +278,14 @@ const getTagEditor = (param) => { @@ -278,13 +278,14 @@ const getTagEditor = (param) => {
278 } 278 }
279 }; 279 };
280 280
281 - if (result && result[0] && result[0].data && result[0].data.list) { 281 + if (result && result[0] && result[0].data && result[0].data.list && result[0].data.list.artList) {
282 282
283 let inf = []; 283 let inf = [];
284 284
285 let infoList = result[0].data.list.artList; 285 let infoList = result[0].data.list.artList;
286 286
287 infoList.forEach(val => { 287 infoList.forEach(val => {
  288 + val.url = helpers.https(`${val.url}&openby:yohobuy={"action":"go.h5","params":{"param":{},"share":"","id":"","type":0,"islogin":"N","url":"${val.url}"}}`);
288 inf.push(guangProcess.formatArticle(val, true, false, true)); 289 inf.push(guangProcess.formatArticle(val, true, false, true));
289 }); 290 });
290 291
@@ -40,7 +40,7 @@ const packageData = (id, isApp) => { @@ -40,7 +40,7 @@ const packageData = (id, isApp) => {
40 cache: true 40 cache: true
41 }).then(data => { 41 }).then(data => {
42 // 接口要判断一下返回状态是否成功 42 // 接口要判断一下返回状态是否成功
43 - if (data.code !== 200) { 43 + if (data === '' && data.code !== 200) {
44 result.code = 400; 44 result.code = 400;
45 return result; 45 return result;
46 } 46 }
@@ -110,28 +110,43 @@ const packageData = (id, isApp) => { @@ -110,28 +110,43 @@ const packageData = (id, isApp) => {
110 } 110 }
111 111
112 return Promise.all(promises).then(datas => { 112 return Promise.all(promises).then(datas => {
113 - let getArticleContent = datas[1].data; 113 + if (datas) {
  114 + if (datas[1]) {
114 115
115 - if (isApp && datas[4].data) { 116 + let getArticleContent = datas[1].data;
116 117
117 - let preCount = 0;  
118 - let i; 118 + result.getArticleContent = getArticleContent;
119 119
120 - for (i = 0; i < getArticleContent.length; i++) {  
121 - if (getArticleContent[i].singleImage || getArticleContent[i].text || getArticleContent[i].smallPic) {  
122 - preCount++; 120 + }
  121 +
  122 + if (isApp && datas[4] && datas[4].data) {
  123 +
  124 + let preCount = 0;
  125 + let i;
  126 +
  127 + for (i = 0; i < getArticleContent.length; i++) {
  128 + if (getArticleContent[i].singleImage || getArticleContent[i].text || getArticleContent[i].smallPic) {
  129 + preCount++;
  130 + }
123 } 131 }
  132 +
  133 + getArticleContent.splice(preCount, 0, {weixinPublic: datas[4].data});
  134 + }
  135 + if (datas[0]) {
  136 + result.getAuthor = datas[0].data;
124 } 137 }
125 138
126 - getArticleContent.splice(preCount, 0, {weixinPublic: datas[4].data});  
127 - }  
128 139
129 - result.getAuthor = datas[0].data;  
130 - result.getArticleContent = getArticleContent;  
131 - result.getBrand = datas[2].data;  
132 - if (datas.length === 5 && isApp || datas.length === 4 && !isApp) {  
133 - result.getOtherArticle = datas[3].data; 140 + if (datas[2]) {
  141 + result.getBrand = datas[2].data;
  142 + }
  143 + if (datas.length === 5 && isApp || datas.length === 4 && !isApp) {
  144 + if (datas[3]) {
  145 + result.getOtherArticle = datas[3].data;
  146 + }
  147 + }
134 } 148 }
  149 +
135 return result; 150 return result;
136 }); 151 });
137 }); 152 });
@@ -9,11 +9,9 @@ const helpers = global.yoho.helpers; @@ -9,11 +9,9 @@ const helpers = global.yoho.helpers;
9 const formaData = (data, gender) => { 9 const formaData = (data, gender) => {
10 let build = []; 10 let build = [];
11 11
12 - // console.log(data)  
13 _.forEach(data, function(val) { 12 _.forEach(data, function(val) {
14 // 多张图 13 // 多张图
15 if (val.data[1]) { 14 if (val.data[1]) {
16 -  
17 let imgs = []; 15 let imgs = [];
18 16
19 _.forEach(val.data, function(list) { 17 _.forEach(val.data, function(list) {
@@ -34,7 +32,7 @@ const formaData = (data, gender) => { @@ -34,7 +32,7 @@ const formaData = (data, gender) => {
34 } 32 }
35 33
36 // 单张图 34 // 单张图
37 - if (val.data[0]) { 35 + if (val.data[0] && !val.data[1]) {
38 _.forEach(val.data, function(list) { 36 _.forEach(val.data, function(list) {
39 build.push({ 37 build.push({
40 url: '/guang/plustar/brandinfo?id=' + val.id + '&gender=' + gender, 38 url: '/guang/plustar/brandinfo?id=' + val.id + '&gender=' + gender,
@@ -48,15 +46,19 @@ const formaData = (data, gender) => { @@ -48,15 +46,19 @@ const formaData = (data, gender) => {
48 return build; 46 return build;
49 }; 47 };
50 48
  49 +const getContentData = (gender, type, channel, isRecommend) => {
  50 + let param = {
  51 + gender: gender,
  52 + brand_type: type,
  53 + yh_channel: channel
  54 + };
51 55
52 -const getContentData = (gender, type) => { 56 + if (isRecommend) {
  57 + param.is_recommend = isRecommend;
  58 + }
53 59
54 - return serviceAPI.get('guang/api/v3/plustar/getlist', {  
55 - gender: gender,  
56 - brand_type: type  
57 - }).then((result) => { 60 + return serviceAPI.get('guang/api/v3/plustar/getlist', param).then((result) => {
58 if (result && result.code === 200) { 61 if (result && result.code === 200) {
59 - // console.log(result)  
60 return formaData(result.data.data.list[0].data, gender); 62 return formaData(result.data.data.list[0].data, gender);
61 } else { 63 } else {
62 logger.error('列表 list data return code is not 200'); 64 logger.error('列表 list data return code is not 200');
@@ -74,6 +76,15 @@ const getListData = (gender, recom, all) => { @@ -74,6 +76,15 @@ const getListData = (gender, recom, all) => {
74 }); 76 });
75 }; 77 };
76 78
  79 +const getBrandsData = (gender, starBrand, originalBrand, channel, isRecommend) => {
  80 + return Promise.all([getContentData(gender, starBrand, isRecommend, channel), getContentData(gender, originalBrand, isRecommend, channel)]).then((result) => {
  81 + return {
  82 + star: result[0],
  83 + plus: result[1]
  84 + };
  85 + });
  86 +};
  87 +
77 // 新品到着 88 // 新品到着
78 const getNewProduct = (brandId, gender, url) => { 89 const getNewProduct = (brandId, gender, url) => {
79 90
@@ -97,7 +108,6 @@ const getNewProduct = (brandId, gender, url) => { @@ -97,7 +108,6 @@ const getNewProduct = (brandId, gender, url) => {
97 let obj = {}; 108 let obj = {};
98 let price; 109 let price;
99 110
100 - // console.log(list)  
101 if (index <= 5) { 111 if (index <= 5) {
102 let tag = []; 112 let tag = [];
103 113
@@ -270,5 +280,6 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => { @@ -270,5 +280,6 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
270 module.exports = { 280 module.exports = {
271 getListData, 281 getListData,
272 getContentData, 282 getContentData,
273 - getDetailData 283 + getDetailData,
  284 + getBrandsData
274 }; 285 };
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 <div class="loading status hide"> 22 <div class="loading status hide">
23 正在加载... 23 正在加载...
24 </div> 24 </div>
25 - <span class="no-more status">没有更多啦</span> 25 + <span class="no-more status hide">没有更多啦</span>
26 </div> 26 </div>
27 27
28 {{#if tag}} 28 {{#if tag}}
@@ -13,7 +13,6 @@ @@ -13,7 +13,6 @@
13 <div class="swiper-pagination"></div> 13 <div class="swiper-pagination"></div>
14 </div> 14 </div>
15 {{/if}} 15 {{/if}}
16 -  
17 {{# infos}} 16 {{# infos}}
18 {{> index/info}} 17 {{> index/info}}
19 {{/ infos}} 18 {{/ infos}}
@@ -195,7 +195,7 @@ function reMarginFooter(fixedElement) { @@ -195,7 +195,7 @@ function reMarginFooter(fixedElement) {
195 a.async = 1; 195 a.async = 1;
196 a.src = j; 196 a.src = j;
197 m.parentNode.insertBefore(a, m); 197 m.parentNode.insertBefore(a, m);
198 -})(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas'); 198 +}(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas'));
199 199
200 (function() { 200 (function() {
201 var uid = getUid(); 201 var uid = getUid();
@@ -215,7 +215,7 @@ function loadMore($container, opt, url) { @@ -215,7 +215,7 @@ function loadMore($container, opt, url) {
215 success: function(data) { 215 success: function(data) {
216 var $newItems; 216 var $newItems;
217 217
218 - if (data === ' ') { 218 + if (data === '') {
219 opt.end = true; 219 opt.end = true;
220 searching = false; 220 searching = false;
221 221