Authored by ccbikai(👎🏻🍜)

Merge branch 'master' into release/5.5

@@ -6,6 +6,9 @@ exports.index = function(req, res, next) { @@ -6,6 +6,9 @@ exports.index = function(req, res, next) {
6 code: req.params.code, 6 code: req.params.code,
7 type: req.query.type 7 type: req.query.type
8 }).then((result) => { 8 }).then((result) => {
  9 + if (!result) {
  10 + return next();
  11 + }
9 res.render('feature', { 12 res.render('feature', {
10 module: 'activity', 13 module: 'activity',
11 page: 'feature', 14 page: 'feature',
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 'use strict'; 5 'use strict';
6 const mRoot = '../models'; 6 const mRoot = '../models';
7 const share = require(`${mRoot}/share`); 7 const share = require(`${mRoot}/share`);
  8 +const _ = require('lodash');
8 9
9 exports.getShareContent = (req, res, next) => { 10 exports.getShareContent = (req, res, next) => {
10 if (!req.query.shareId) { 11 if (!req.query.shareId) {
@@ -14,6 +15,13 @@ exports.getShareContent = (req, res, next) => { @@ -14,6 +15,13 @@ exports.getShareContent = (req, res, next) => {
14 }); 15 });
15 } 16 }
16 17
  18 + if (!_.isNumber(+req.query.shareId)) {
  19 + return res.jsonp({
  20 + code: 400,
  21 + message: 'shareId is invalid'
  22 + });
  23 + }
  24 +
17 share.getShareContent({ 25 share.getShareContent({
18 shareId: req.query.shareId 26 shareId: req.query.shareId
19 }).then(result => { 27 }).then(result => {
@@ -59,7 +59,7 @@ exports.feature = (req, res) => { @@ -59,7 +59,7 @@ exports.feature = (req, res) => {
59 if (req.yoho.isWechat || cover) { 59 if (req.yoho.isWechat || cover) {
60 // 微信中,不管是否已经种入cookie,直接覆盖 60 // 微信中,不管是否已经种入cookie,直接覆盖
61 res.cookie('mkt_code', mktCode, options); 61 res.cookie('mkt_code', mktCode, options);
62 - } else if (!req.cookies.mkt_code) { 62 + } else if (!req.cookies.mkt_code || mktCode === '100000000000349') {
63 // 如果没有种入mtk_code则种入 63 // 如果没有种入mtk_code则种入
64 res.cookie('mkt_code', mktCode, options); 64 res.cookie('mkt_code', mktCode, options);
65 } 65 }
@@ -55,10 +55,9 @@ module.exports = { @@ -55,10 +55,9 @@ module.exports = {
55 cache: true 55 cache: true
56 }); 56 });
57 } 57 }
58 - if (data.code === 200) {  
59 - data = data.data;  
60 - }  
61 - if (data.floors) { 58 +
  59 + data = data.data;
  60 + if (data && data.floors) {
62 data.floors.forEach(function(f) { 61 data.floors.forEach(function(f) {
63 if (f.component && f.component[0] && f.component[0].type === 'productGroup' && f.component[0].defaultSkns) { 62 if (f.component && f.component[0] && f.component[0].type === 'productGroup' && f.component[0].defaultSkns) {
64 sknsArr.push(_getProductBySkns(f.component[0])); 63 sknsArr.push(_getProductBySkns(f.component[0]));
@@ -69,6 +68,7 @@ module.exports = { @@ -69,6 +68,7 @@ module.exports = {
69 if (sknsArr.length) { 68 if (sknsArr.length) {
70 yield Promise.all(sknsArr); 69 yield Promise.all(sknsArr);
71 } 70 }
  71 +
72 return data; 72 return data;
73 })(); 73 })();
74 } 74 }
@@ -18,6 +18,9 @@ const _activity = () => { @@ -18,6 +18,9 @@ const _activity = () => {
18 }; 18 };
19 19
20 const _user = (params) => { 20 const _user = (params) => {
  21 + if (!params.uid) {
  22 + return Promise.resolve({});
  23 + }
21 return api.get('', { 24 return api.get('', {
22 method: 'app.passport.profile', 25 method: 'app.passport.profile',
23 uid: params.uid 26 uid: params.uid
@@ -384,6 +387,9 @@ const order = (params) => { @@ -384,6 +387,9 @@ const order = (params) => {
384 const getOrders = (params) => { 387 const getOrders = (params) => {
385 let finalResult = []; 388 let finalResult = [];
386 389
  390 + if (!params.uid) {
  391 + return Promise.resolve({});
  392 + }
387 return _getOrderData(params).then(result => { 393 return _getOrderData(params).then(result => {
388 if (result.data && result.data.page_total && params.page <= result.data.page_total && result.data.order_list) { 394 if (result.data && result.data.page_total && params.page <= result.data.page_total && result.data.order_list) {
389 let count = 0; 395 let count = 0;
@@ -227,7 +227,7 @@ router.get('/redbag/2017', redbag.index); @@ -227,7 +227,7 @@ router.get('/redbag/2017', redbag.index);
227 router.get('/individuation', individuation.productLst); 227 router.get('/individuation', individuation.productLst);
228 228
229 // 活动页模版 229 // 活动页模版
230 -router.get('/feature/:code', feature.index); 230 +router.get('/feature/:code.html', feature.index);
231 231
232 // 2016 年度账单 232 // 2016 年度账单
233 router.get('/annual-account', annualAccount.index); 233 router.get('/annual-account', annualAccount.index);
1 <div class="feature-page yoho-page"> 1 <div class="feature-page yoho-page">
2 - {{#content.share}}  
3 - <input id="shareLink" type="hidden" value="{{shareUrl}}">  
4 - <input id="shareDesc" type="hidden" value="{{shareTitleSub}}">  
5 - <input id="shareImg" type="hidden" value="{{shareImage}}">  
6 - <input id="shareTitle" type="hidden" value="{{shareTitleMain}}">  
7 - {{/content.share}} 2 + {{#content.webShare}}
  3 + <input id="shareLink" type="hidden" value="{{url}}">
  4 + <input id="shareDesc" type="hidden" value="{{content}}">
  5 + <input id="shareImg" type="hidden" value="{{pic}}">
  6 + <input id="shareTitle" type="hidden" value="{{title}}">
  7 + {{/content.webShare}}
8 {{#content.floors}} 8 {{#content.floors}}
9 {{#isEqualOr type 'sidebar'}} 9 {{#isEqualOr type 'sidebar'}}
10 {{! 侧悬浮}} 10 {{! 侧悬浮}}
@@ -71,7 +71,7 @@ @@ -71,7 +71,7 @@
71 71
72 {{#isEqualOr type 'productGroup'}} 72 {{#isEqualOr type 'productGroup'}}
73 {{! 商品池}} 73 {{! 商品池}}
74 - <div class="product-container item{{numOfOneRow}}" {{#if proBgImg}}style="background:url({{proBgImg}})repeat;"{{/if}}> 74 + <div class="product-container item{{numOfOneRow}}" {{#if proBgImg}}style="background:url({{image2 proBgImg q=60}})repeat;"{{/if}}>
75 <div class="product-source" {{#unless defaultPros.length}} {{#if searchCondition }}cloneitem="{{searchCondition.limit}}"{{/if}}{{/unless}} condition='{{stringify searchCondition}}' fp="{{getAnalysis ../this @index}}"> 75 <div class="product-source" {{#unless defaultPros.length}} {{#if searchCondition }}cloneitem="{{searchCondition.limit}}"{{/if}}{{/unless}} condition='{{stringify searchCondition}}' fp="{{getAnalysis ../this @index}}">
76 <input class="imgwh" type="hidden" value="193x257"> 76 <input class="imgwh" type="hidden" value="193x257">
77 {{#if defaultPros.length}} 77 {{#if defaultPros.length}}
@@ -419,16 +419,19 @@ let setPassword = (req, res, next) => { @@ -419,16 +419,19 @@ let setPassword = (req, res, next) => {
419 419
420 RegService.regMobileAes(area, mobile, password, shoppingKey, smsCode, isFromMy).then((result) => { 420 RegService.regMobileAes(area, mobile, password, shoppingKey, smsCode, isFromMy).then((result) => {
421 if (!result.code || result.code !== 200) { 421 if (!result.code || result.code !== 200) {
422 - return Promise.reject(result); 422 + return res.send(result);
423 } 423 }
424 if (!result.data || !result.data.uid) { 424 if (!result.data || !result.data.uid) {
425 - return Promise.reject(result); 425 + return res.send(result);
426 } 426 }
427 427
428 resultCopy = result; 428 resultCopy = result;
429 429
430 return AuthHelper.syncUserSession(result.data.uid, req, res); 430 return AuthHelper.syncUserSession(result.data.uid, req, res);
431 }).then(() => { 431 }).then(() => {
  432 + if (!resultCopy) {
  433 + return;
  434 + }
432 // 返回跳转到来源页面 435 // 返回跳转到来源页面
433 let refer = req.cookies.refer; 436 let refer = req.cookies.refer;
434 437
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
@@ -131,7 +131,7 @@ const getShopIntro = (shopId, uid) => { @@ -131,7 +131,7 @@ const getShopIntro = (shopId, uid) => {
131 shop_id: shopId 131 shop_id: shopId
132 }; 132 };
133 133
134 - if (uid) { 134 + if (uid && uid !== 'undefined') {
135 params.uid = uid; 135 params.uid = uid;
136 } 136 }
137 137
@@ -582,7 +582,8 @@ const getShopData = (req, shopId, uid, isApp) => { @@ -582,7 +582,8 @@ const getShopData = (req, shopId, uid, isApp) => {
582 let seoResult = _getBrandShopSeo(channel, shopInfoResult, req.query); 582 let seoResult = _getBrandShopSeo(channel, shopInfoResult, req.query);
583 583
584 /* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */ 584 /* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
585 - if (shopInfoResult && shopInfoResult.shop_template_type && parseInt(shopInfoResult.shop_template_type, 10) === 1) { 585 + if (shopInfoResult && shopInfoResult.shop_template_type &&
  586 + parseInt(shopInfoResult.shop_template_type, 10) === 1) {
586 return { 587 return {
587 goBrand: shopInfoResult 588 goBrand: shopInfoResult
588 }; 589 };
@@ -625,12 +626,10 @@ const getShopData = (req, shopId, uid, isApp) => { @@ -625,12 +626,10 @@ const getShopData = (req, shopId, uid, isApp) => {
625 626
626 if (result[0]) { 627 if (result[0]) {
627 shopFilterSearchData.filter = productProcess.processFilter(result[0].filter || []); 628 shopFilterSearchData.filter = productProcess.processFilter(result[0].filter || []);
628 - shopFilterSearchData.goods = productProcess.processProductList(result[0].product_list || [], {isApp: isApp}); 629 + shopFilterSearchData.goods =
  630 + productProcess.processProductList(result[0].product_list || [], {isApp: isApp});
629 } 631 }
630 632
631 - /* 店铺优惠券 */  
632 - let shopCoupons = result[1] || [];  
633 -  
634 // 店铺分类 633 // 店铺分类
635 return _getShopCategory(shopId, channel).then(shopCategory => { 634 return _getShopCategory(shopId, channel).then(shopCategory => {
636 635
@@ -34,6 +34,9 @@ module.exports = () => { @@ -34,6 +34,9 @@ module.exports = () => {
34 34
35 if (req.hostname === 'activity.yoho.cn') { 35 if (req.hostname === 'activity.yoho.cn') {
36 // 活动模版的活动页 36 // 活动模版的活动页
  37 + if (req.path === '/') {
  38 + return res.redirect('//m.yohobuy.com');
  39 + }
37 req.url = `/activity${req.url}`; 40 req.url = `/activity${req.url}`;
38 } else if (req.subdomains.length) { 41 } else if (req.subdomains.length) {
39 switch (req.subdomains[0]) { 42 switch (req.subdomains[0]) {
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 a.async = 1; 12 a.async = 1;
13 a.src = j; 13 a.src = j;
14 m.parentNode.insertBefore(a, m); 14 m.parentNode.insertBefore(a, m);
15 - }(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.3.3/yas.js', '_yas')); 15 + }(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.3.4/yas.js', '_yas'));
16 16
17 var _hmt = _hmt || []; 17 var _hmt = _hmt || [];
18 18
@@ -56,7 +56,7 @@ @@ -56,7 +56,7 @@
56 uid = uid === 0 ? '' : uid; 56 uid = uid === 0 ? '' : uid;
57 window._ozuid = uid; // 暴露ozuid 57 window._ozuid = uid; // 暴露ozuid
58 if (window._yas) { 58 if (window._yas) {
59 - window._yas(1 * new Date(), '2.3.3', 'yohobuy_m', uid, '', ''); 59 + window._yas(1 * new Date(), '2.3.4', 'yohobuy_m', uid, '', '');
60 } 60 }
61 61
62 setTimeout(function() { 62 setTimeout(function() {
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "5.4.29", 3 + "version": "5.4.31",
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": {
@@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
48 "xml2js": "^0.4.17", 48 "xml2js": "^0.4.17",
49 "yoho-express-session": "^2.0.0", 49 "yoho-express-session": "^2.0.0",
50 "yoho-node-lib": "^0.2.8", 50 "yoho-node-lib": "^0.2.8",
51 - "yoho-zookeeper": "^1.0.6" 51 + "yoho-zookeeper": "^1.0.8"
52 }, 52 },
53 "devDependencies": { 53 "devDependencies": {
54 "autoprefixer": "^6.7.4", 54 "autoprefixer": "^6.7.4",
@@ -335,7 +335,9 @@ $(window).scroll(function() { @@ -335,7 +335,9 @@ $(window).scroll(function() {
335 }); 335 });
336 336
337 // 初始化请求第一页数据 337 // 初始化请求第一页数据
338 -getOrders(); 338 +if ($('.order-page').length > 0) {
  339 + getOrders();
  340 +}
339 341
340 $(function() { 342 $(function() {
341 // 适配背景图 343 // 适配背景图
@@ -235,17 +235,47 @@ $.extend({ @@ -235,17 +235,47 @@ $.extend({
235 $footer.removeClass('hide'); 235 $footer.removeClass('hide');
236 236
237 // 单击下载按钮 - 接受微信商城或者第三方来源的数据埋点信息 237 // 单击下载按钮 - 接受微信商城或者第三方来源的数据埋点信息
238 - let mktc = queryString().union_type || queryString().mkt_code || ''; 238 + let unionType = queryString().union_type || '';
239 239
240 - if (mktc) {  
241 - setCookie('unionTypeYas', mktc, {  
242 - path: '/'  
243 - });  
244 - setCookie('mkt_code', mktc, { 240 + if (unionType) {
  241 + setCookie('unionTypeYas', unionType, {
245 path: '/' 242 path: '/'
246 }); 243 });
247 } 244 }
248 245
  246 + /*
  247 + 关于yas种cookies的逻辑澄清:
  248 +
  249 + 1. yas的关于渠道号的cookies的key 是 mkt_code
  250 + 2. mkt_code 失效时间为7天
  251 + 3. 如果url后面加union_type,mkt_code 在微信下是覆盖的,其他端不覆盖
  252 + 4. 如果mkt_code=100000000000349,则直接覆盖成对应的渠道号
  253 + 5. yas的cookies 种在 .yohobuy.com 根域下
  254 +
  255 + 周奇琪
  256 + */
  257 +
  258 + let isWechat = /micromessenger/i.test(navigator.userAgent || '');
  259 + let mktc = queryString().mkt_code || queryString().union_type || '';
  260 +
  261 + function saveMktCode() {
  262 + if (mktc) {
  263 + setCookie('mkt_code', mktc, {
  264 + path: '/',
  265 + domain: 'yohobuy.com',
  266 + expires: 7 // 7天
  267 + });
  268 + }
  269 + }
  270 +
  271 + if (isWechat) {
  272 + saveMktCode();
  273 + } else {
  274 + if (!cookie('mkt_code') || mktc === '100000000000349') {
  275 + saveMktCode();
  276 + }
  277 + }
  278 +
249 // 尝试打开 APP 279 // 尝试打开 APP
250 require('./common/open-app'); 280 require('./common/open-app');
251 281
@@ -87,7 +87,9 @@ if (canOpenApp()) { @@ -87,7 +87,9 @@ if (canOpenApp()) {
87 }, 2000); 87 }, 2000);
88 88
89 if (isiOS) { 89 if (isiOS) {
90 - window.location.href = appPath; 90 + setTimeout(function() {
  91 + window.location.href = appPath;
  92 + }, 2000);
91 } else { 93 } else {
92 ifr = document.createElement('iframe'); 94 ifr = document.createElement('iframe');
93 ifr.src = appPath; 95 ifr.src = appPath;
@@ -10,7 +10,7 @@ var $ = require('yoho-jquery'), @@ -10,7 +10,7 @@ var $ = require('yoho-jquery'),
10 Hammer = require('yoho-hammer'), 10 Hammer = require('yoho-hammer'),
11 dialog = require('plugin/dialog'); 11 dialog = require('plugin/dialog');
12 12
13 -var $input = $('#search-input').find('input[name="query"]'); 13 +var $input = $('#search-input input[name="query"]');
14 14
15 var $clear = $('#search-input .clear-input'); 15 var $clear = $('#search-input .clear-input');
16 16
@@ -327,14 +327,14 @@ @@ -327,14 +327,14 @@
327 id: id 327 id: id
328 }, resultData => { 328 }, resultData => {
329 329
330 - // /* 结果返回 */  
331 - // if (resultData.length < 1) {  
332 - // areaCode.val(id);  
333 - // let returnTitle = this.returnTitle();  
334 -  
335 - // area.val(returnTitle);  
336 - // this.show = false;  
337 - // } 330 + /* 结果返回 */
  331 + if (resultData.length < 1) {
  332 + areaCode.val(id);
  333 + let returnTitle = this.returnTitle();
  334 +
  335 + area.val(returnTitle);
  336 + this.show = false;
  337 + }
338 338
339 /* 数据绑定 */ 339 /* 数据绑定 */
340 switch ((id + '').length) { 340 switch ((id + '').length) {