Authored by 毕凯

Merge branch 'feature/shop' into 'master'

店铺新品到着登录相关问题



See merge request !523
@@ -70,23 +70,26 @@ exports.orderEnsure = (req, res, next) => { @@ -70,23 +70,26 @@ exports.orderEnsure = (req, res, next) => {
70 addressModel.addressData(uid) 70 addressModel.addressData(uid)
71 ]; 71 ];
72 72
73 - if (_.isUndefined(req.cookies._isNewUser)) {  
74 - allPromise.push(orderModel.isNewUser(uid));  
75 - } 73 + /* tar note 170426 品众去除 */
  74 + // if (_.isUndefined(req.cookies._isNewUser)) {
  75 + // allPromise.push(orderModel.isNewUser(uid));
  76 + // }
76 77
77 return Promise.all(allPromise).then(result => { 78 return Promise.all(allPromise).then(result => {
78 let order = result[0]; 79 let order = result[0];
79 let userProfile = result[1]; 80 let userProfile = result[1];
80 let address = result[2]; 81 let address = result[2];
81 - let isNewUser = result[3];  
82 82
83 - if (!_.isUndefined(isNewUser)) {  
84 - if (isNewUser) {  
85 - res.cookie('_isNewUser', true, actCkOpthn);  
86 - } else {  
87 - res.cookie('_isNewUser', false, actCkOpthn);  
88 - }  
89 - } 83 + /* tar note 170426 品众去除 */
  84 + // let isNewUser = result[3];
  85 +
  86 + // if (!_.isUndefined(isNewUser)) {
  87 + // if (isNewUser) {
  88 + // res.cookie('_isNewUser', true, actCkOpthn);
  89 + // } else {
  90 + // res.cookie('_isNewUser', false, actCkOpthn);
  91 + // }
  92 + // }
90 93
91 if (order.cartUrl) { 94 if (order.cartUrl) {
92 logger.info(`orderEnsure: order cartUrl has value:${order.cartUrl}, order data is null`); 95 logger.info(`orderEnsure: order cartUrl has value:${order.cartUrl}, order data is null`);
@@ -117,8 +117,29 @@ const common = { @@ -117,8 +117,29 @@ const common = {
117 return next(); 117 return next();
118 }); 118 });
119 } 119 }
  120 + },
  121 + isLoginUser: (req, res, next) => {
  122 + // 微信里边已经登录的时候,不再跳转登录
  123 + if (req.user.uid) {
  124 + AuthHelper.profile(req.user.uid).then(function(result) {
  125 + if (result.code !== 200) {
  126 + return next();
120 } 127 }
  128 + let refer = req.query.refer || decodeURI(req.cookies.refer) || config.siteUrl;
121 129
  130 + if (/sign|login/.test(refer)) {
  131 + refer = `${config.siteUrl}/home`;
  132 + }
  133 +
  134 + refer = utils.refererLimit(refer);
  135 + return res.redirect(refer);
  136 + }).catch(() => {
  137 + return next();
  138 + });
  139 + } else {
  140 + return next();
  141 + }
  142 + }
122 }; 143 };
123 144
124 145
@@ -280,19 +301,6 @@ const local = { @@ -280,19 +301,6 @@ const local = {
280 301
281 const wechat = { 302 const wechat = {
282 login: (req, res, next) => { 303 login: (req, res, next) => {
283 - // 微信里边已经登录的时候,不再跳转登录  
284 - // 与 5.6 的 session 有冲突  
285 - // if (req.user.uid) {  
286 - // let refer = req.query.refer || decodeURI(req.cookies.refer) || config.siteUrl;  
287 -  
288 - // if (/sign|login/.test(refer)) {  
289 - // refer = `${config.siteUrl}/home`;  
290 - // }  
291 -  
292 - // refer = utils.refererLimit(refer);  
293 - // return res.redirect(refer);  
294 - // }  
295 -  
296 // 设置为原链接标识originalUrl 304 // 设置为原链接标识originalUrl
297 req.session.originalUrl = 'true'; 305 req.session.originalUrl = 'true';
298 req.session.authState = uuid.v4(); 306 req.session.authState = uuid.v4();
@@ -75,7 +75,7 @@ router.post('/passport/sms_login/password.json', smsLogin.password); @@ -75,7 +75,7 @@ router.post('/passport/sms_login/password.json', smsLogin.password);
75 router.get('/passport/login/user', login.user); 75 router.get('/passport/login/user', login.user);
76 76
77 // 微信登录 77 // 微信登录
78 -router.get('/passport/login/wechat', login.common.beforeLogin, login.wechat.login); 78 +router.get('/passport/login/wechat', login.common.beforeLogin, login.common.isLoginUser, login.wechat.login);
79 router.get('/passport/login/wechat/callback', login.wechat.callback); 79 router.get('/passport/login/wechat/callback', login.wechat.callback);
80 80
81 // sina登录 81 // sina登录
@@ -43,6 +43,9 @@ @@ -43,6 +43,9 @@
43 <div id="red-index" class="tab-panel red-shop-index active"> 43 <div id="red-index" class="tab-panel red-shop-index active">
44 <div class="shop-coupon coupon-group"></div> 44 <div class="shop-coupon coupon-group"></div>
45 {{> reds-shop/modules}} 45 {{> reds-shop/modules}}
  46 + <div id="indexGoodsContainer" class="goods-container">
  47 + <div class="default-goods container clearfix"></div>
  48 + </div>
46 <div class="all-goods"> 49 <div class="all-goods">
47 <a href="{{allGoodsUrl}}">点击查看全部商品</a> 50 <a href="{{allGoodsUrl}}">点击查看全部商品</a>
48 </div> 51 </div>
1 <div class="item"> 1 <div class="item">
2 <a {{#if link}}href="{{link}}"{{/if}}> 2 <a {{#if link}}href="{{link}}"{{/if}}>
3 {{#if isGood}} 3 {{#if isGood}}
4 - {{#ifor triple double}}  
5 - <img class="item-pic" src="{{image2 src w=235 h=314}}" alt=""> 4 + {{#ifor triple double single}}
  5 + {{#within index 3}}
  6 + <img class="item-pic" src="{{image2 src w=235 h=314}}">
  7 + {{^}}
  8 + <img class="item-pic lazy" data-original="{{image2 src w=235 h=314}}">
  9 + {{/within}}
6 {{/ifor}} 10 {{/ifor}}
7 {{^}} 11 {{^}}
  12 + {{#within index 3}}
8 <img class="item-pic" src="{{image2 src}}" alt=""> 13 <img class="item-pic" src="{{image2 src}}" alt="">
  14 + {{^}}
  15 + <img class="item-pic lazy" data-original="{{image2 src}}">
  16 + {{/within}}
9 {{/if}} 17 {{/if}}
10 </a> 18 </a>
11 19
@@ -15,13 +15,13 @@ @@ -15,13 +15,13 @@
15 <ul class="swiper-wrapper"> 15 <ul class="swiper-wrapper">
16 {{#each ../pics}} 16 {{#each ../pics}}
17 <li class="swiper-slide"> 17 <li class="swiper-slide">
18 - {{#if link}}  
19 - <a href="{{link}}"> 18 + <a{{#if link}} href="{{link}}"{{/if}}>
  19 + {{#within @../index 3}}
20 <img src="{{image2 src}}" alt=""> 20 <img src="{{image2 src}}" alt="">
21 - </a>  
22 {{^}} 21 {{^}}
23 - <img src="{{image2 src}}" alt="">  
24 - {{/if}} 22 + <img class="lazy" data-original="{{image2 src}}" alt="">
  23 + {{/within}}
  24 + </a>
25 </li> 25 </li>
26 {{/each}} 26 {{/each}}
27 </ul> 27 </ul>
@@ -51,7 +51,7 @@ @@ -51,7 +51,7 @@
51 {{#isEqual module_type 'SingleImage'}} 51 {{#isEqual module_type 'SingleImage'}}
52 <div class="items-s1 clearfix"> 52 <div class="items-s1 clearfix">
53 {{#each ../pics}} 53 {{#each ../pics}}
54 - {{> reds-shop/item}} 54 + {{> reds-shop/item index=@../index single=true}}
55 {{/each}} 55 {{/each}}
56 </div> 56 </div>
57 {{#if ../isModuleMargin}} 57 {{#if ../isModuleMargin}}
@@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
61 {{#isEqual module_type 'DoubleImage'}} 61 {{#isEqual module_type 'DoubleImage'}}
62 <div class="items-s2 clearfix"> 62 <div class="items-s2 clearfix">
63 {{#each ../pics}} 63 {{#each ../pics}}
64 - {{> reds-shop/item double=true}} 64 + {{> reds-shop/item index=@../index double=true}}
65 {{/each}} 65 {{/each}}
66 </div> 66 </div>
67 {{#if ../isModuleMargin}} 67 {{#if ../isModuleMargin}}
@@ -71,7 +71,7 @@ @@ -71,7 +71,7 @@
71 {{#isEqual module_type 'TripleImage'}} 71 {{#isEqual module_type 'TripleImage'}}
72 <div class="{{#isEqual ../displayType 1}}items-3-3{{/isEqual}}{{#isEqual ../displayType 2}}items-3-3 items-small{{/isEqual}}{{#isEqual ../displayType 3}}items-3-2 items-3-2-right{{/isEqual}}{{#isEqual ../displayType 4}}items-3-2 items-3-2-left{{/isEqual}} clearfix"> 72 <div class="{{#isEqual ../displayType 1}}items-3-3{{/isEqual}}{{#isEqual ../displayType 2}}items-3-3 items-small{{/isEqual}}{{#isEqual ../displayType 3}}items-3-2 items-3-2-right{{/isEqual}}{{#isEqual ../displayType 4}}items-3-2 items-3-2-left{{/isEqual}} clearfix">
73 {{#each ../pics}} 73 {{#each ../pics}}
74 - {{> reds-shop/item triple=true}} 74 + {{> reds-shop/item index=@../index triple=true}}
75 {{/each}} 75 {{/each}}
76 </div> 76 </div>
77 {{#if ../isModuleMargin}} 77 {{#if ../isModuleMargin}}
@@ -81,7 +81,7 @@ @@ -81,7 +81,7 @@
81 {{#isEqual module_type 'FourImage'}} 81 {{#isEqual module_type 'FourImage'}}
82 <div class="items-s4 clearfix"> 82 <div class="items-s4 clearfix">
83 {{#each ../pics}} 83 {{#each ../pics}}
84 - {{> reds-shop/item four=true}} 84 + {{> reds-shop/item index=@../index four=true}}
85 {{/each}} 85 {{/each}}
86 </div> 86 </div>
87 {{#if ../isModuleMargin}} 87 {{#if ../isModuleMargin}}
@@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
57 <link rel="apple-touch-startup-image" sizes="320x460" href="http://static.yohobuy.com/m/v1/img/startup/startup.png" media="screen and (max-device-width: 320)"> 57 <link rel="apple-touch-startup-image" sizes="320x460" href="http://static.yohobuy.com/m/v1/img/startup/startup.png" media="screen and (max-device-width: 320)">
58 </head> 58 </head>
59 <body class="{{pageStyle}} {{#if isWechat}}wechat-body{{/if}} {{#if width750}}width750{{/if}} {{#if isPassportPage}}passport-body{{/if}} {{#if isStarIndexPage}}star-index-bg{{/if}} {{#if isStarDetailPage}}star-class-body{{/if}} {{#if isInstallmentPage}}installment-body{{/if}}"> 59 <body class="{{pageStyle}} {{#if isWechat}}wechat-body{{/if}} {{#if width750}}width750{{/if}} {{#if isPassportPage}}passport-body{{/if}} {{#if isStarIndexPage}}star-index-bg{{/if}} {{#if isStarDetailPage}}star-class-body{{/if}} {{#if isInstallmentPage}}installment-body{{/if}}">
60 - <div class="main-wrap" id="main-wrap" {{#if appPath}}data-apppath='{{appPath}}'{{/if}}> 60 + <div class="main-wrap" id="main-wrap" {{#if appPath}}data-apppath='{{{appPath}}}'{{/if}}>
61 {{#if systemUpdate}} 61 {{#if systemUpdate}}
62 {{> updata}} 62 {{> updata}}
63 {{/if}} 63 {{/if}}
@@ -75,8 +75,8 @@ @@ -75,8 +75,8 @@
75 }, 1000); 75 }, 1000);
76 }()); 76 }());
77 77
78 - /* tar add 190222 */  
79 - window._fxcmd = window._fxcmd || []; 78 + /* tar add 170426 品众代码去除 */
  79 + {{!--window._fxcmd = window._fxcmd || [];
80 _fxcmd.sid = 'bb3b16fa1106a6ab8619da0095755f32'; 80 _fxcmd.sid = 'bb3b16fa1106a6ab8619da0095755f32';
81 _fxcmd.trackAll = false; 81 _fxcmd.trackAll = false;
82 // 参数配置(可选)... 82 // 参数配置(可选)...
@@ -89,7 +89,7 @@ @@ -89,7 +89,7 @@
89 _pzfx.src = '//static.w3t.cn/fx/1/1/fx.js'; 89 _pzfx.src = '//static.w3t.cn/fx/1/1/fx.js';
90 var sc = document.getElementsByTagName('script')[0]; 90 var sc = document.getElementsByTagName('script')[0];
91 sc.parentNode.insertBefore(_pzfx,sc); 91 sc.parentNode.insertBefore(_pzfx,sc);
92 - }, 1000); 92 + }, 1000);--}}
93 93
94 94
95 </script> 95 </script>
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "5.6.3", 3 + "version": "5.6.4",
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": {
@@ -323,15 +323,15 @@ function submitOrder() { @@ -323,15 +323,15 @@ function submitOrder() {
323 }, true); 323 }, true);
324 } 324 }
325 325
326 - /* tar add 190222 */  
327 - if (window._fxcmd) {  
328 - window._fxcmd.push(['trackOrder', {  
329 - oid: res.data.order_code,  
330 - otp: res.data.order_amount,  
331 - u_info: cookie.get('_UID'),  
332 - u_type: cookie.get('_isNewUser') ? 1 : 0  
333 - }, []]);  
334 - } 326 + /* tar add 170426 品众代码去除 */
  327 + // if (window._fxcmd) {
  328 + // window._fxcmd.push(['trackOrder', {
  329 + // oid: res.data.order_code,
  330 + // otp: res.data.order_amount,
  331 + // u_info: cookie.get('_UID'),
  332 + // u_type: cookie.get('_isNewUser') ? 1 : 0
  333 + // }, []]);
  334 + // }
335 335
336 cookie.remove(['order-info', 'activity-info']); 336 cookie.remove(['order-info', 'activity-info']);
337 window.location.href = url; 337 window.location.href = url;
@@ -2,19 +2,64 @@ @@ -2,19 +2,64 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-03-23 11:31:51 3 * @Date: 2017-03-23 11:31:51
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-04-14 11:17:55 5 + * @Last Modified time: 2017-04-25 11:45:13
6 */ 6 */
7 7
8 /** ***************** 8 /** *****************
9 * 红人店铺首页 9 * 红人店铺首页
10 ********************/ 10 ********************/
11 const Swiper2 = require('yoho-swiper2'); 11 const Swiper2 = require('yoho-swiper2');
  12 +const lazyLoad = require('yoho-jquery-lazyload');
12 let tip = require('../../plugin/tip'); 13 let tip = require('../../plugin/tip');
13 let $goodsContainer = $('.index-goods-container'); 14 let $goodsContainer = $('.index-goods-container');
  15 +let $indexGoodsContaniner = $('#indexGoodsContainer');
14 let $collect = $('#collect'); 16 let $collect = $('#collect');
15 17
16 const shopId = $('#shopId').val(); 18 const shopId = $('#shopId').val();
17 19
  20 +lazyLoad($('.lazy'));
  21 +
  22 +/**
  23 + * 异步检测是否已经收藏
  24 + */
  25 +$.ajax({
  26 + type: 'GET',
  27 + url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
  28 + xhrFields: {
  29 + withCredentials: true
  30 + },
  31 + data: {
  32 + shopId: shopId
  33 + },
  34 + success: function(data) {
  35 + if (data.collect) {
  36 + $collect.attr('class', 'already-collect pull-left');
  37 + }
  38 + },
  39 + error: function() {
  40 + tip.show('网络断开连接了~');
  41 + }
  42 +});
  43 +
  44 +/**
  45 + * 店铺轮播图
  46 + */
  47 +if ($('.shop-swiper')) {
  48 + let num = $('.shop-swiper').length;
  49 +
  50 + for (let i = 1; i <= num; i++) {
  51 + new Swiper2('.shop-swiper-' + i, {
  52 + lazyLoading: true,
  53 + lazyLoadingInPrevNext: true,
  54 + loop: true,
  55 + autoplay: 3000,
  56 + slideElement: 'li',
  57 + paginationClickable: true,
  58 + pagination: $(this).closest('.shop-swiper-' + i).find('.pagination-inner').get(0)
  59 + });
  60 + }
  61 +}
  62 +
18 /** 63 /**
19 * 异步加载推荐商品 64 * 异步加载推荐商品
20 */ 65 */
@@ -47,51 +92,33 @@ $.each($goodsContainer, function(index, elem) { @@ -47,51 +92,33 @@ $.each($goodsContainer, function(index, elem) {
47 }, 92 },
48 data: data, 93 data: data,
49 success: function(result) { 94 success: function(result) {
  95 + let $result = $(result);
  96 +
  97 + lazyLoad($result.find('img[class=lazy]'));
50 $(elem).html(result); 98 $(elem).html(result);
51 } 99 }
52 }); 100 });
53 }); 101 });
54 102
55 /** 103 /**
56 - * 异步检测是否已经收藏 104 + * 异步加载首页全部商品
57 */ 105 */
58 $.ajax({ 106 $.ajax({
59 type: 'GET', 107 type: 'GET',
60 - url: location.protocol + '//m.yohobuy.com/product/index/shopFav', 108 + url: '/product/search/search',
61 xhrFields: { 109 xhrFields: {
62 withCredentials: true 110 withCredentials: true
63 }, 111 },
64 data: { 112 data: {
65 - shopId: shopId 113 + shop_id: shopId
66 }, 114 },
67 - success: function(data) {  
68 - if (data.collect) {  
69 - $collect.attr('class', 'already-collect pull-left');  
70 - }  
71 - },  
72 - error: function() {  
73 - tip.show('网络断开连接了~');  
74 - }  
75 -});  
76 -  
77 -/**  
78 - * 店铺轮播图  
79 - */  
80 -if ($('.shop-swiper')) {  
81 - let num = $('.shop-swiper').length; 115 + success: function(result) {
  116 + let $result = $(result);
82 117
83 - for (let i = 1; i <= num; i++) {  
84 - new Swiper2('.shop-swiper-' + i, {  
85 - lazyLoading: true,  
86 - lazyLoadingInPrevNext: true,  
87 - loop: true,  
88 - autoplay: 3000,  
89 - slideElement: 'li',  
90 - paginationClickable: true,  
91 - pagination: $(this).closest('.shop-swiper-' + i).find('.pagination-inner').get(0)  
92 - }); 118 + lazyLoad($result.find('img[class=lazy]'));
  119 + $indexGoodsContaniner.find('.container').html($result);
93 } 120 }
94 -} 121 +});
95 122
96 /** 123 /**
97 * 店铺收藏取消收藏操作 124 * 店铺收藏取消收藏操作
@@ -53,6 +53,8 @@ body { @@ -53,6 +53,8 @@ body {
53 53
54 .goods-container { 54 .goods-container {
55 overflow: hidden; 55 overflow: hidden;
  56 + background-color: #fff;
  57 + padding-left: 15px;
56 58
57 .goods-box { 59 .goods-box {
58 .no-result { 60 .no-result {
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-03-23 17:12:53 3 * @Date: 2017-03-23 17:12:53
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-04-20 10:19:41 5 + * @Last Modified time: 2017-04-25 15:54:23
6 */ 6 */
7 // 红人店铺首页 7 // 红人店铺首页
8 8
@@ -230,16 +230,29 @@ @@ -230,16 +230,29 @@
230 230
231 /* 四张小图 */ 231 /* 四张小图 */
232 .items-s4 { 232 .items-s4 {
  233 + border-bottom: 1px solid #e0e0e0;
  234 +
233 .item { 235 .item {
234 float: left; 236 float: left;
235 width: 25%; 237 width: 25%;
  238 + border-top: 1px solid #e0e0e0;
  239 + border-right: 1px solid #e0e0e0;
  240 + }
  241 +
  242 + .item:last-child {
  243 + border-right: none;
236 } 244 }
237 245
238 .item-info { 246 .item-info {
239 text-align: center; 247 text-align: center;
  248 + background-color: #f5f7f6;
240 color: #000; 249 color: #000;
241 position: relative; 250 position: relative;
242 251
  252 + .text {
  253 + line-height: 36px;
  254 + }
  255 +
243 .name, 256 .name,
244 .price { 257 .price {
245 display: none; 258 display: none;
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-03-23 11:02:31 3 * @Date: 2017-03-23 11:02:31
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-04-20 15:41:44 5 + * @Last Modified time: 2017-04-26 16:33:07
6 */ 6 */
7 /* 红人店铺数据处理 */ 7 /* 红人店铺数据处理 */
8 8
@@ -339,8 +339,11 @@ const pushGoodsInfo = (decorators, goodsList) => { @@ -339,8 +339,11 @@ const pushGoodsInfo = (decorators, goodsList) => {
339 decorators[key].pics[subKey].marketPrice = marketPrice ? '¥' + marketPrice : ''; 339 decorators[key].pics[subKey].marketPrice = marketPrice ? '¥' + marketPrice : '';
340 decorators[key].pics[subKey].isGood = true; 340 decorators[key].pics[subKey].isGood = true;
341 341
342 - if (value.module_type === 'TripleImage' || value.module_type === 'DoubleImage') {  
343 - decorators[key].pics[subKey].src = imageSrc; 342 + if (value.module_type === 'TripleImage' ||
  343 + value.module_type === 'DoubleImage' ||
  344 + value.module_type === 'SingleImage') {
  345 +
  346 + // decorators[key].pics[subKey].src = imageSrc; // 为了和 APP 统一,图暂时不取商品图
344 } else if (value.module_type === 'FourImage') { 347 } else if (value.module_type === 'FourImage') {
345 decorators[key].pics[subKey].isGood = false; 348 decorators[key].pics[subKey].isGood = false;
346 } else { 349 } else {