Authored by 姜枫

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

@@ -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;  
96 - res.render('plustar/detail', {  
97 - module: 'guang',  
98 - page: 'plustar-detail',  
99 - title: result.brand_name,  
100 - pageHeader: headerModel.setNav({  
101 - navTitle: result.brand_name  
102 - }),  
103 - ps: result  
104 - }); 95 + result.brandIntro = htmlProcess.removeHtml(result.brandIntro);
  96 +
  97 + if (!isApp & !isWeixin) {
  98 + res.render('plustar/detail', {
  99 + module: 'guang',
  100 + page: 'plustar-detail',
  101 + title: result.brandName,
  102 + pageHeader: headerModel.setNav({
  103 + navTitle: result.brandName
  104 + }),
  105 + ps: result
  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
@@ -46,9 +46,12 @@ const getAllChannels = (params) => { @@ -46,9 +46,12 @@ const getAllChannels = (params) => {
46 * @return {[array]} 46 * @return {[array]}
47 */ 47 */
48 const getProductBatch = (productSkn, options) => { 48 const getProductBatch = (productSkn, options) => {
49 - productSkn = _.isArray(productSkn) ? productSkn : [productSkn]; 49 + productSkn = _.uniq(_.isArray(productSkn) ? productSkn : [productSkn]);
  50 +
50 return api.get('', { 51 return api.get('', {
51 method: 'h5.product.batch', 52 method: 'h5.product.batch',
  53 + limit: productSkn.length,
  54 + page: 1,
52 productSkn: productSkn.join(',') 55 productSkn: productSkn.join(',')
53 }).then(result => { 56 }).then(result => {
54 return result && result.data ? productProcess.processProductList(result.data.product_list, options) : []; 57 return result && result.data ? productProcess.processProductList(result.data.product_list, options) : [];
@@ -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;
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": {
@@ -161,6 +161,10 @@ $('.coupon-message-op-rel').on('click', function() { @@ -161,6 +161,10 @@ $('.coupon-message-op-rel').on('click', function() {
161 location.reload(); 161 location.reload();
162 }); 162 });
163 163
  164 +$('.nav-home').on('touchstart', function() {
  165 + $('.homebuttom').toggleClass('hide');
  166 +});
  167 +
164 if ($('#noData').length > 0) { 168 if ($('#noData').length > 0) {
165 if (location.href.indexOf('?openby:yohobuy=') <= 0) { 169 if (location.href.indexOf('?openby:yohobuy=') <= 0) {
166 tip.show('网络异常!'); 170 tip.show('网络异常!');
@@ -170,4 +174,4 @@ if ($('#noData').length > 0) { @@ -170,4 +174,4 @@ if ($('#noData').length > 0) {
170 $mask.on('click', function() { 174 $mask.on('click', function() {
171 $mask.hide(); 175 $mask.hide();
172 $message.hide(); 176 $message.hide();
173 -}); 177 +});
@@ -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
@@ -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,15 +24,36 @@ $('#nav-tab').on('touchend touchcancel', function(e) { @@ -30,15 +24,36 @@ $('#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');
  31 +
  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 + }
35 43
36 - $(document).trigger('scroll'); //Trigger lazyLoad 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
41 target.className = 'bytouch ' + target.className; 56 target.className = 'bytouch ' + target.className;
42 }).on('touchend touchcancel', function() { 57 }).on('touchend touchcancel', function() {
43 $navs.removeClass('bytouch'); 58 $navs.removeClass('bytouch');
44 -});  
  59 +});
@@ -23,6 +23,8 @@ var $addressForm = $('.edit-address'), @@ -23,6 +23,8 @@ var $addressForm = $('.edit-address'),
23 newArea = [], 23 newArea = [],
24 chinaAddressList; 24 chinaAddressList;
25 25
  26 +require('../common.js');
  27 +
26 $($editAddressPage, $addressListPage).css('min-height', function() { 28 $($editAddressPage, $addressListPage).css('min-height', function() {
27 return $(window).height() - $('#yoho-header').height(); 29 return $(window).height() - $('#yoho-header').height();
28 }); 30 });
@@ -80,6 +82,7 @@ $addressForm.on('submit', function() { @@ -80,6 +82,7 @@ $addressForm.on('submit', function() {
80 isSubmiting = true; 82 isSubmiting = true;
81 loading.showLoadingMask(); 83 loading.showLoadingMask();
82 $submit.css('background', '#777'); 84 $submit.css('background', '#777');
  85 + console.log(window.queryString.refer);
83 $.ajax({ 86 $.ajax({
84 method: 'POST', 87 method: 'POST',
85 url: '/home/saveAddress', 88 url: '/home/saveAddress',
@@ -46,8 +46,8 @@ @@ -46,8 +46,8 @@
46 overflow: hidden; 46 overflow: hidden;
47 width: 100%; 47 width: 100%;
48 height: 90px; 48 height: 90px;
49 - background-color: #fff;  
50 - //background-image: linear-gradient(#323232, #414141); 49 + background-color: #000;
  50 + background-image: linear-gradient(#323232, #414141);
51 color: #fff; 51 color: #fff;
52 line-height: 90px; 52 line-height: 90px;
53 53
@@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
14 padding: 10px 30px; 14 padding: 10px 30px;
15 min-width: 246px; 15 min-width: 246px;
16 border-radius: 10px; 16 border-radius: 10px;
17 - background-color: #fff;  
18 - //background-image: linear-gradient(to bottom, #000 0%, #333 100%); 17 + background-color: #000;
  18 + background-image: linear-gradient(to bottom, #000 0%, #333 100%);
19 box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.6); 19 box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.6);
20 text-align: center; 20 text-align: center;
21 font-size: 28px; 21 font-size: 28px;