Authored by 徐祁xuqi

Merge branch 'qCloud' of http://git.yoho.cn/fe/yohobuywap-node into qCloud

Conflicts:
	package.json
@@ -81,6 +81,8 @@ const getDetailData = (req, res, next) => { @@ -81,6 +81,8 @@ const getDetailData = (req, res, next) => {
81 let isApp = req.query.app_version || req.query.appVersion || false; 81 let isApp = req.query.app_version || req.query.appVersion || false;
82 let clientType = req.body.client_type || ''; 82 let clientType = req.body.client_type || '';
83 let version = req.body.app_version || ''; 83 let version = req.body.app_version || '';
  84 + let userAgent = req.get('User-Agent');
  85 + let isWeixin = userAgent.includes('MicroMessenger'); // 标识是否是微信访问
84 86
85 if (clientType.toLowerCase() === 'ios' && version) { 87 if (clientType.toLowerCase() === 'ios' && version) {
86 clientType = 'iphone'; 88 clientType = 'iphone';
@@ -90,18 +92,26 @@ const getDetailData = (req, res, next) => { @@ -90,18 +92,26 @@ const getDetailData = (req, res, next) => {
90 clientType = 'h5'; 92 clientType = 'h5';
91 } 93 }
92 plustarModel.getDetailData(id, uid, udid, gender, isApp, clientType).then((result) => { 94 plustarModel.getDetailData(id, uid, udid, gender, isApp, clientType).then((result) => {
93 - result.brand_intro = htmlProcess.removeHtml(result.brand_intro);  
94 - result.clientType = clientType;  
95 - result.brandId = result.brand_id; 95 + result.brandIntro = htmlProcess.removeHtml(result.brandIntro);
  96 +
  97 + if (!isApp & !isWeixin) {
96 res.render('plustar/detail', { 98 res.render('plustar/detail', {
97 module: 'guang', 99 module: 'guang',
98 page: 'plustar-detail', 100 page: 'plustar-detail',
99 - title: result.brand_name, 101 + title: result.brandName,
100 pageHeader: headerModel.setNav({ 102 pageHeader: headerModel.setNav({
101 - navTitle: result.brand_name 103 + navTitle: result.brandName
102 }), 104 }),
103 ps: result 105 ps: result
104 }); 106 });
  107 + } else {
  108 + res.render('plustar/detail', {
  109 + module: 'guang',
  110 + page: 'plustar-detail',
  111 + title: result.brandName,
  112 + ps: result
  113 + });
  114 + }
105 }).catch(next); 115 }).catch(next);
106 }; 116 };
107 117
@@ -114,10 +114,13 @@ const packageData = (id, isApp) => { @@ -114,10 +114,13 @@ const packageData = (id, isApp) => {
114 } 114 }
115 115
116 return Promise.all(promises).then(datas => { 116 return Promise.all(promises).then(datas => {
  117 +
  118 + let getArticleContent = {};
  119 +
117 if (datas) { 120 if (datas) {
118 if (datas[1]) { 121 if (datas[1]) {
119 122
120 - let getArticleContent = datas[1].data; 123 + getArticleContent = datas[1].data;
121 124
122 result.getArticleContent = getArticleContent; 125 result.getArticleContent = getArticleContent;
123 126
@@ -4,6 +4,15 @@ const serviceAPI = global.yoho.ServiceAPI; @@ -4,6 +4,15 @@ const serviceAPI = global.yoho.ServiceAPI;
4 const _ = require('lodash'); 4 const _ = require('lodash');
5 const logger = global.yoho.logger; 5 const logger = global.yoho.logger;
6 const helpers = global.yoho.helpers; 6 const helpers = global.yoho.helpers;
  7 +const htmlProcess = require(`${global.utils}/html-process`);
  8 +
  9 +const privateKeyList = {
  10 + android: 'fd4ad5fcfa0de589ef238c0e7331b585',
  11 + iphone: 'a85bb0674e08986c6b115d5e3a4884fa',
  12 + ipad: 'ad9fcda2e679cf9229e37feae2cdcf80',
  13 + web: '0ed29744ed318fd28d2c07985d3ba633',
  14 + h5: 'fd4ad5fcfa0de589ef238c0e7331b585'
  15 +};
7 16
8 const formaData = (data, gender) => { 17 const formaData = (data, gender) => {
9 let build = []; 18 let build = [];
@@ -60,7 +69,7 @@ const getContentData = (gender, type, channel, isRecommend) => { @@ -60,7 +69,7 @@ const getContentData = (gender, type, channel, isRecommend) => {
60 if (result && result.code === 200) { 69 if (result && result.code === 200) {
61 return formaData(result.data.data.list[0].data, gender); 70 return formaData(result.data.data.list[0].data, gender);
62 } else { 71 } else {
63 - logger.error('列表 list data return code is not 200'); 72 + logger.error('list data return code is not 200');
64 return {}; 73 return {};
65 } 74 }
66 }); 75 });
@@ -85,7 +94,7 @@ const getBrandsData = (gender, starBrand, originalBrand, channel, isRecommend) = @@ -85,7 +94,7 @@ const getBrandsData = (gender, starBrand, originalBrand, channel, isRecommend) =
85 }; 94 };
86 95
87 // 新品到着 96 // 新品到着
88 -const getNewProduct = (brandId, gender, url) => { 97 +const getNewProduct = (brandId, gender, url, isApp) => {
89 98
90 return api.get('', { 99 return api.get('', {
91 method: 'app.search.li', 100 method: 'app.search.li',
@@ -143,6 +152,14 @@ const getNewProduct = (brandId, gender, url) => { @@ -143,6 +152,14 @@ const getNewProduct = (brandId, gender, url) => {
143 152
144 newArrival.moreUrl = url; 153 newArrival.moreUrl = url;
145 154
  155 + let productUrl = '//m.yohobuy.com/product/pro_' + list.product_id + '_' +
  156 + list.goods_list[0].goods_id + '/' + list.cn_alphabet + '.html';
  157 +
  158 + if (isApp) {
  159 + console.log(productUrl);
  160 + productUrl += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${list.product_skn}"}}`;
  161 + }
  162 +
146 obj = _.assign(obj, { 163 obj = _.assign(obj, {
147 id: list.product_skn, 164 id: list.product_skn,
148 product_id: list.product_id, 165 product_id: list.product_id,
@@ -152,8 +169,7 @@ const getNewProduct = (brandId, gender, url) => { @@ -152,8 +169,7 @@ const getNewProduct = (brandId, gender, url) => {
152 studentPrice: list.sales_price * 0.9, 169 studentPrice: list.sales_price * 0.9,
153 is_soon_sold_out: list.is_soon_sold_out === 'Y', 170 is_soon_sold_out: list.is_soon_sold_out === 'Y',
154 isShowSaleTagDis: list.sales_price * 2 < list.market_price, 171 isShowSaleTagDis: list.sales_price * 2 < list.market_price,
155 - url: '/product/pro_' + list.product_id + '_' +  
156 - list.goods_list[0].goods_id + '/' + list.cn_alphabet + '.html', 172 + url: productUrl,
157 tags: tag 173 tags: tag
158 }); 174 });
159 175
@@ -167,6 +183,8 @@ const getNewProduct = (brandId, gender, url) => { @@ -167,6 +183,8 @@ const getNewProduct = (brandId, gender, url) => {
167 183
168 } 184 }
169 }); 185 });
  186 +
  187 +
170 } 188 }
171 189
172 return newArrival; 190 return newArrival;
@@ -178,14 +196,15 @@ const getNewProduct = (brandId, gender, url) => { @@ -178,14 +196,15 @@ const getNewProduct = (brandId, gender, url) => {
178 }; 196 };
179 197
180 // 相关资讯 198 // 相关资讯
181 -const getRelatedEditorial = (brandId, uid, udid, clientType) => { 199 +const getRelatedEditorial = (brandId, uid, udid, clientType, isApp) => {
182 200
183 return serviceAPI.get('guang/service/v1/article/getArticleByBrand', { 201 return serviceAPI.get('guang/service/v1/article/getArticleByBrand', {
184 brand_id: brandId, 202 brand_id: brandId,
185 uid: uid, 203 uid: uid,
186 udid: udid, 204 udid: udid,
187 client_type: clientType, 205 client_type: clientType,
188 - limit: 3 206 + limit: 3,
  207 + private_key: privateKeyList[clientType]
189 }).then((result) => { 208 }).then((result) => {
190 209
191 if (result && result.code === 200) { 210 if (result && result.code === 200) {
@@ -193,9 +212,13 @@ const getRelatedEditorial = (brandId, uid, udid, clientType) => { @@ -193,9 +212,13 @@ const getRelatedEditorial = (brandId, uid, udid, clientType) => {
193 let list = []; 212 let list = [];
194 213
195 _.forEach(result.data, function(data) { 214 _.forEach(result.data, function(data) {
  215 + if (isApp) {
  216 + data.url = data.url + '';
  217 + }
  218 +
196 list.push({ 219 list.push({
197 id: data.id, 220 id: data.id,
198 - url: data.url, 221 + url: isApp ? `${helpers.https(data.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${data.id}"},"shareparam":{"id":"${data.id}"},"share":"/guang/api/v1/share/guang","id":${data.id},"type":1,"url":"http:${helpers.urlFormat('/info/index', null, 'guang')}","islogin":"N"}}` : data.url,
199 title: data.title, 222 title: data.title,
200 text: data.intro, 223 text: data.intro,
201 img: helpers.image(data.src, 640, 640), 224 img: helpers.image(data.src, 640, 640),
@@ -205,6 +228,8 @@ const getRelatedEditorial = (brandId, uid, udid, clientType) => { @@ -205,6 +228,8 @@ const getRelatedEditorial = (brandId, uid, udid, clientType) => {
205 }); 228 });
206 }); 229 });
207 230
  231 +
  232 +
208 return list; 233 return list;
209 } else { 234 } else {
210 logger.error('editorial data return code is not 200'); 235 logger.error('editorial data return code is not 200');
@@ -218,7 +243,8 @@ const isCollection = (uid, brandId, clientType) => { @@ -218,7 +243,8 @@ const isCollection = (uid, brandId, clientType) => {
218 return serviceAPI.get('shops/service/v1/favorite/getUidBrandFav', { 243 return serviceAPI.get('shops/service/v1/favorite/getUidBrandFav', {
219 uid: uid, 244 uid: uid,
220 brandId: brandId, 245 brandId: brandId,
221 - client_type: clientType 246 + client_type: clientType,
  247 + private_key: privateKeyList[clientType]
222 }).then((result) => { 248 }).then((result) => {
223 249
224 if (result && result.code === 200) { 250 if (result && result.code === 200) {
@@ -243,6 +269,7 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => { @@ -243,6 +269,7 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
243 }).then((result) => { 269 }).then((result) => {
244 if (result && result.code === 200) { 270 if (result && result.code === 200) {
245 let list = result.data || []; 271 let list = result.data || [];
  272 + let jumpToApp;
246 273
247 let url; 274 let url;
248 275
@@ -256,12 +283,34 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => { @@ -256,12 +283,34 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
256 url = '//' + brandDomain + '.m.yohobuy.com'; 283 url = '//' + brandDomain + '.m.yohobuy.com';
257 } 284 }
258 285
259 - // return Promise.all([isCollection(uid, brandId, clientType), getRelatedEditorial(brandId, uid, udid, clientType), getNewProduct(brandId, gender, url)]).then((result) => { //pagecache重构  
260 - return getNewProduct(brandId, gender, url).then((result) => { 286 + if (isApp & !uid) {
  287 + jumpToApp = 1;
  288 + }
  289 +
  290 + let likeUrl = helpers.urlFormat('/plustar/brandinfo', {
  291 + id: brandId
  292 + }, 'guang');
  293 +
  294 + if (isApp) {
  295 + let $url = likeUrl;
  296 + $url += '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
  297 + + brandId + '}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"' + brandId + '"}},"priority":"Y"}}';
  298 + } else {
  299 + let $url = helpers.urlFormat('/signin.html', {refer: likeUrl});
  300 + }
  301 +
  302 + return Promise.all([isCollection(uid, brandId, clientType), getRelatedEditorial(brandId, uid, udid, clientType, isApp), getNewProduct(brandId, gender, url, isApp)]).then((result) => {
  303 +
261 list = _.assign(list, { 304 list = _.assign(list, {
262 - // isLike: result[0], //pagecache重构  
263 - // infos: result[1], //pagecache重构  
264 - newArrival: result 305 +
  306 + isLike: result[0],
  307 + infos: result[1],
  308 + newArrival: result[2],
  309 + jumpToApp: jumpToApp,
  310 + shareLink: '//guang.m.yohobuy.com/plustar/brandinfo?id=' + id,
  311 + shareTitle: list.brandName,
  312 + shareImg: list.brandIco,
  313 + shareDesc: htmlProcess.removeHtml(list.brandIntro)
265 }); 314 });
266 315
267 return list; 316 return list;
@@ -121,7 +121,7 @@ @@ -121,7 +121,7 @@
121 121
122 <div id="productDesc" {{#if limit}}class="limit"{{/if}}> </div> 122 <div id="productDesc" {{#if limit}}class="limit"{{/if}}> </div>
123 {{> detail/recommend-for-you}} 123 {{> detail/recommend-for-you}}
124 - {{> cart/chose-panel}} 124 + <div class="chose-panel"></div>
125 125
126 <div class="cart-bar data-bind"> 126 <div class="cart-bar data-bind">
127 <a href="" class="num-incart iconfont"><span class="num-tag hide"></span>&#xe62c;</a> 127 <a href="" class="num-incart iconfont"><span class="num-tag hide"></span>&#xe62c;</a>
1 -<div class="chose-panel data-bind">  
2 - <div class="main">  
3 - <div class="infos">  
4 - <div class="basic-info" >  
5 - <img class="thumb" src="">  
6 - <div class="text-info">  
7 - <p class="name"></p>  
8 - <p class="price">  
9 - <span class="sale-price"></span>  
10 - <span class="market-price data-bind"></span>  
11 - </p>  
12 - </div>  
13 - </div>  
14 - <div class="chose-items">  
15 - <div class="color-list block-list">  
16 - <span class="name"></span>  
17 - <ul id="" data-index="" class="size-row clearfix ">  
18 - <li class="block" data-num="">  
19 - </li>  
20 - </ul>  
21 - </div>  
22 - <div class="size-list block-list">  
23 - <span class="name"></span>  
24 - <ul class="size-row clearfix">  
25 - <li class="block " data-num="" data-id="" data-skuid="">  
26 - </li>  
27 - </ul>  
28 - </div>  
29 1
30 - <div class="num">  
31 - <span class="name">数量</span>  
32 - <div class="clearfix">  
33 - <a class="btn btn-minus" href="javascript:void(0);">  
34 - <span class="iconfont ">&#xe625;</span>  
35 - </a>  
36 - <input id="good-num" class="good-num disabled" type="text" value="1" disabled="true">  
37 - <a class="btn btn-plus" href="javascript:void(0);">  
38 - <span class="iconfont ">&#xe624;</span>  
39 - </a>  
40 - </div>  
41 - <span class="left-num"></span>  
42 - <input id="left-num" type="hidden" value="0">  
43 - <input id="limitNum" type="hidden" value="">  
44 - </div>  
45 -  
46 - </div>  
47 - </div>  
48 - <div class="btn-wrap">  
49 - <button id="chose-btn-sure" class="btn btn-sure"></button>  
50 - </div>  
51 - </div>  
52 -</div>  
53 -<input id="promotionId" type="hidden" value="">  
54 -<input id="single" type="hidden" value="">  
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "11.11.1", 3 + "version": "5.0.11",
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": {
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 "request-promise": "^3.0.0", 38 "request-promise": "^3.0.0",
39 "serve-favicon": "^2.3.0", 39 "serve-favicon": "^2.3.0",
40 "uuid": "^2.0.3", 40 "uuid": "^2.0.3",
41 - "yoho-node-lib": "0.1.22", 41 + "yoho-node-lib": "0.1.23",
42 "yoho-zookeeper": "^1.0.3" 42 "yoho-zookeeper": "^1.0.3"
43 }, 43 },
44 "devDependencies": { 44 "devDependencies": {
@@ -198,7 +198,7 @@ function reMarginFooter(fixedElement) { @@ -198,7 +198,7 @@ function reMarginFooter(fixedElement) {
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() || queryString().uid;
202 202
203 uid = uid === 0 ? '' : uid; 203 uid = uid === 0 ? '' : uid;
204 204
@@ -8,6 +8,61 @@ module.exports = function(data, callback) { @@ -8,6 +8,61 @@ module.exports = function(data, callback) {
8 callback && callback(); 8 callback && callback();
9 }; 9 };
10 function render(data) { 10 function render(data) {
  11 + var htmlTemplate = '<div class="main">' +
  12 + ' <div class="infos">' +
  13 + ' <div class="basic-info" >' +
  14 + ' <img class="thumb" src="">' +
  15 + ' <div class="text-info">' +
  16 + ' <p class="name"></p>' +
  17 + ' <p class="price">' +
  18 + ' <span class="sale-price"></span>' +
  19 + ' <span class="market-price data-bind"></span>' +
  20 + ' </p>' +
  21 + ' </div>' +
  22 + ' </div>' +
  23 + ' <div class="chose-items">' +
  24 + ' <div class="color-list block-list">' +
  25 + ' <span class="name"></span>' +
  26 + ' <ul id="" data-index="" class="size-row clearfix ">' +
  27 + ' <li class="block" data-num="">' +
  28 + ' </li>' +
  29 + ' </ul>' +
  30 + ' </div>' +
  31 + ' <div class="size-list block-list">' +
  32 + ' <span class="name"></span>' +
  33 + ' <ul class="size-row clearfix">' +
  34 + ' <li class="block " data-num="" data-id="" data-skuid="">' +
  35 + ' </li>' +
  36 + ' </ul>' +
  37 + ' </div>' +
  38 +'' +
  39 + ' <div class="num">' +
  40 + ' <span class="name">数量</span>' +
  41 + ' <div class="clearfix">' +
  42 + ' <a class="btn btn-minus" href="javascript:void(0);">' +
  43 + ' <span class="iconfont ">&#xe625;</span>' +
  44 + ' </a>' +
  45 + ' <input id="good-num" class="good-num disabled" type="text" value="1" disabled="true">' +
  46 + ' <a class="btn btn-plus" href="javascript:void(0);">' +
  47 + ' <span class="iconfont ">&#xe624;</span>' +
  48 + ' </a>' +
  49 + ' </div>' +
  50 + ' <span class="left-num"></span>' +
  51 + ' <input id="left-num" type="hidden" value="0">' +
  52 + ' <input id="limitNum" type="hidden" value="">' +
  53 + ' </div>' +
  54 +'' +
  55 + ' </div>' +
  56 + ' </div>' +
  57 + ' <div class="btn-wrap">' +
  58 + ' <button id="chose-btn-sure" class="btn btn-sure"></button>' +
  59 + ' </div>' +
  60 + '</div>';
  61 +
  62 + $('#promotionId').remove();
  63 + $('#single').remove();
  64 + $('.chose-panel').addClass('data-bind').html(htmlTemplate).append('<input id="promotionId" type="hidden" value="">').append('<input id="single" type="hidden" value="">');
  65 +
11 if (data.cartInfo) { 66 if (data.cartInfo) {
12 $chosePanel.removeClass(dbClass); 67 $chosePanel.removeClass(dbClass);
13 var cartInfo = data.cartInfo; 68 var cartInfo = data.cartInfo;
@@ -206,6 +206,8 @@ function loadMore($container, opt, url) { @@ -206,6 +206,8 @@ function loadMore($container, opt, url) {
206 loading.showLoadingMask(); 206 loading.showLoadingMask();
207 } 207 }
208 208
  209 + opt.app_version = '1';
  210 +
209 num = $container.find('.guang-info').length; 211 num = $container.find('.guang-info').length;
210 searching = true; 212 searching = true;
211 $.ajax({ 213 $.ajax({
@@ -9,20 +9,14 @@ var mySwiper; @@ -9,20 +9,14 @@ var mySwiper;
9 9
10 require('../common'); 10 require('../common');
11 11
12 -lazyLoad($('img.lazy'));  
13 -  
14 -$('.star-content li').each(function(key, item) {  
15 - $(item).find('.swiper-container').addClass('swiper-' + key); 12 +var mySwiper;
16 13
17 - mySwiper = new Swiper('.swiper-' + key, {  
18 - lazyLoading: true,  
19 - pagination: '.swiper-' + key + ' .pagination-inner'  
20 - });  
21 -}); 14 +lazyLoad($('img.lazy'));
22 15
23 $('#nav-tab').bind('contextmenu', function(e) { 16 $('#nav-tab').bind('contextmenu', function(e) {
24 return false; 17 return false;
25 }); 18 });
  19 +
26 $('#nav-tab').on('touchend touchcancel', function(e) { 20 $('#nav-tab').on('touchend touchcancel', function(e) {
27 var $this = $(e.target).closest('li'); 21 var $this = $(e.target).closest('li');
28 22
@@ -30,11 +24,32 @@ $('#nav-tab').on('touchend touchcancel', function(e) { @@ -30,11 +24,32 @@ $('#nav-tab').on('touchend touchcancel', function(e) {
30 return; 24 return;
31 } 25 }
32 26
33 - $navs.toggleClass('focus');  
34 - $contents.toggleClass('hide'); 27 + $navs.removeClass('focus');
  28 + $this.addClass('focus');
  29 + $contents.addClass('hide');
  30 + $contents.eq($this.index()).removeClass('hide');
35 31
36 - $(document).trigger('scroll'); //Trigger lazyLoad 32 + if (typeof $this.swiper === 'undefined') { // 解决隐藏式,swiper不渲染
  33 + $this.swiper = false;
  34 + $contents.find('li').each(function(key, item) {
  35 + $(item).find('.swiper-container').addClass('swiper-' + key);
  36 +
  37 + mySwiper = new Swiper('.swiper-' + key, {
  38 + lazyLoading: true,
  39 + pagination: '.swiper-' + key + ' .pagination-inner'
  40 + });
  41 + });
  42 + }
  43 +
  44 + $(document).trigger('scroll'); // Trigger lazyLoad
37 }); 45 });
  46 +
  47 +if ($('#nav-tab').find('li:eq(0)').hasClass('focus')) {
  48 + // 解决li隐藏 swiper不渲染的问题
  49 + $('#nav-tab').find('li:eq(0)').removeClass('focus');
  50 + $('#nav-tab').find('li:eq(0)').trigger('touchend');
  51 +}
  52 +
38 $('#nav-tab').on('touchstart', function(e) { 53 $('#nav-tab').on('touchstart', function(e) {
39 var target = e.target || e.srcElement; 54 var target = e.target || e.srcElement;
40 55