Authored by 陈峰

Merge branch 'feature/cart' into 'release/5.4.1'

Feature/cart



See merge request !221
@@ -10,6 +10,13 @@ const orderModel = require('../models/order'); @@ -10,6 +10,13 @@ const orderModel = require('../models/order');
10 const crypto = global.yoho.crypto; 10 const crypto = global.yoho.crypto;
11 const authcode = require(global.utils + '/authcode'); 11 const authcode = require(global.utils + '/authcode');
12 12
  13 +// cookie 参数
  14 +const actCkOpthn = {
  15 + expires: 0,
  16 + path: '/cart/index',
  17 + domain: '.m.yohobuy.com'
  18 +};
  19 +
13 exports.orderEnsure = (req, res, next) => { 20 exports.orderEnsure = (req, res, next) => {
14 let headerData = headerModel.setNav({ 21 let headerData = headerModel.setNav({
15 navTitle: '确认订单', 22 navTitle: '确认订单',
@@ -25,6 +32,7 @@ exports.orderEnsure = (req, res, next) => { @@ -25,6 +32,7 @@ exports.orderEnsure = (req, res, next) => {
25 orderInfo = JSON.parse(req.cookies['order-info']); 32 orderInfo = JSON.parse(req.cookies['order-info']);
26 } catch (e) { 33 } catch (e) {
27 orderInfo = {}; 34 orderInfo = {};
  35 + res.cookie('order-info', null, actCkOpthn);
28 } 36 }
29 37
30 let cookieCartType = _.get(orderInfo, 'cartType'); 38 let cookieCartType = _.get(orderInfo, 'cartType');
@@ -149,6 +157,7 @@ exports.orderSub = (req, res) => { @@ -149,6 +157,7 @@ exports.orderSub = (req, res) => {
149 orderInfo = JSON.parse(req.cookies['order-info']); 157 orderInfo = JSON.parse(req.cookies['order-info']);
150 } catch (e) { 158 } catch (e) {
151 orderInfo = {}; 159 orderInfo = {};
  160 + res.cookie('order-info', null, actCkOpthn);
152 } 161 }
153 162
154 let times = req.body.times || 1; 163 let times = req.body.times || 1;
@@ -216,9 +225,8 @@ exports.orderSub = (req, res) => { @@ -216,9 +225,8 @@ exports.orderSub = (req, res) => {
216 } 225 }
217 226
218 // 提交成功清除Cookie 227 // 提交成功清除Cookie
219 - res.cookie('order-info', null, {  
220 - domain: 'yohobuy.com'  
221 - }); 228 + orderInfo = {};
  229 + res.cookie('order-info', null, actCkOpthn);
222 230
223 if (result.code === 409) { 231 if (result.code === 409) {
224 return res.json(decodeURI(result)); 232 return res.json(decodeURI(result));
@@ -6,13 +6,13 @@ @@ -6,13 +6,13 @@
6 <span class="tel">{{mobile}}</span> 6 <span class="tel">{{mobile}}</span>
7 <p class="address-info">{{area}} {{address}}</p> 7 <p class="address-info">{{area}} {{address}}</p>
8 <div class="action iconfont"> 8 <div class="action iconfont">
9 - <span class="edit" data-href="/home/addressAct?id={{address_id}}&refer=shopping">&#xe61e;</span> 9 + <span class="edit" href="/home/addressAct?id={{address_id}}&refer=shopping">&#xe61e;</span>
10 <span class="del" data-id="{{address_id}}">&#xe621;</span> 10 <span class="del" data-id="{{address_id}}">&#xe621;</span>
11 </div> 11 </div>
12 </div> 12 </div>
13 {{/ address}} 13 {{/ address}}
14 14
15 - <a class="add-address" data-href="/home/addressAct?refer=shopping"> 15 + <a class="add-address" href="/home/addressAct?refer=shopping">
16 添加新地址 16 添加新地址
17 </a> 17 </a>
18 18
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 </div> 8 </div>
9 {{/ address}} 9 {{/ address}}
10 10
11 - <a class="add-address" data-href="/home/addressAct?refer=modify"> 11 + <a class="add-address" href="/home/addressAct?refer=modify">
12 添加新地址 12 添加新地址
13 </a> 13 </a>
14 14
@@ -27,6 +27,13 @@ var isRefreshByDelete = window.cookie('_yoho-cart-refreshByDelete') === 'true' ? @@ -27,6 +27,13 @@ var isRefreshByDelete = window.cookie('_yoho-cart-refreshByDelete') === 'true' ?
27 27
28 var lowStockCount = 0; 28 var lowStockCount = 0;
29 29
  30 +// cookie 参数
  31 +var actCkOpthn = {
  32 + expires: 'Session',
  33 + path: '/cart/index',
  34 + domain: '.m.yohobuy.com'
  35 +};
  36 +
30 37
31 loading.showLoadingMask(); 38 loading.showLoadingMask();
32 39
@@ -115,7 +122,7 @@ function showChooseGifDialog() { @@ -115,7 +122,7 @@ function showChooseGifDialog() {
115 var info = window.cookie('order-info'); 122 var info = window.cookie('order-info');
116 123
117 if (info) { 124 if (info) {
118 - window.setCookie('order-info', ''); 125 + window.setCookie('order-info', '', actCkOpthn);
119 } 126 }
120 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; 127 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
121 }); 128 });
@@ -207,7 +214,7 @@ $('.btn-balance').on('touchend', function() { @@ -207,7 +214,7 @@ $('.btn-balance').on('touchend', function() {
207 214
208 if (hasChecked()) { 215 if (hasChecked()) {
209 if (info) { 216 if (info) {
210 - window.setCookie('order-info', ''); 217 + window.setCookie('order-info', '', actCkOpthn);
211 } 218 }
212 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; 219 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
213 } else { 220 } else {
@@ -10,6 +10,13 @@ let $ = require('yoho-jquery'), @@ -10,6 +10,13 @@ let $ = require('yoho-jquery'),
10 tip = require('../../plugin/tip'), 10 tip = require('../../plugin/tip'),
11 dialog = require('../../plugin/dialog'); 11 dialog = require('../../plugin/dialog');
12 12
  13 +// cookie 参数
  14 +let actCkOpthn = {
  15 + expires: 'Session',
  16 + path: '/cart/index',
  17 + domain: '.m.yohobuy.com'
  18 +};
  19 +
13 let cartObj = { 20 let cartObj = {
14 init(handle) { 21 init(handle) {
15 let self = this; 22 let self = this;
@@ -144,7 +151,7 @@ let cartObj = { @@ -144,7 +151,7 @@ let cartObj = {
144 self.toOrderEnsure(cartType); 151 self.toOrderEnsure(cartType);
145 }, 152 },
146 toOrderEnsure(cartType) { 153 toOrderEnsure(cartType) {
147 - window.cookie('order-info') && window.setCookie('order-info', ''); 154 + window.cookie('order-info') && window.setCookie('order-info', '', actCkOpthn);
148 window.location.href = '/cart/index/new/orderEnsure?cartType=' + cartType; 155 window.location.href = '/cart/index/new/orderEnsure?cartType=' + cartType;
149 }, 156 },
150 toGiftPromotion(cartType) { 157 toGiftPromotion(cartType) {
@@ -46,6 +46,13 @@ var invoiceCont = { @@ -46,6 +46,13 @@ var invoiceCont = {
46 2: '电子' 46 2: '电子'
47 }; 47 };
48 48
  49 + // cookie 参数
  50 +var actCkOpthn = {
  51 + expires: 'Session',
  52 + path: '/cart/index',
  53 + domain: '.m.yohobuy.com'
  54 +};
  55 +
49 require('../common'); 56 require('../common');
50 57
51 lazyLoad(); 58 lazyLoad();
@@ -325,7 +332,7 @@ function submitOrder() { @@ -325,7 +332,7 @@ function submitOrder() {
325 }, true); 332 }, true);
326 } 333 }
327 334
328 - window.setCookie('order-info', ''); 335 + window.setCookie('order-info', '', actCkOpthn);
329 window.setCookie('activity-info', '', { 336 window.setCookie('activity-info', '', {
330 expires: 'Session', 337 expires: 'Session',
331 path: '/', 338 path: '/',
@@ -6,6 +6,12 @@ @@ -6,6 +6,12 @@
6 require('../common'); 6 require('../common');
7 var info = window.cookie('order-info'); 7 var info = window.cookie('order-info');
8 8
  9 +// cookie 参数
  10 +var actCkOpthn = {
  11 + expires: 'Session',
  12 + path: '/cart/index',
  13 + domain: '.m.yohobuy.com'
  14 +};
9 15
10 function init() { 16 function init() {
11 info = { 17 info = {
@@ -27,7 +33,7 @@ function init() { @@ -27,7 +33,7 @@ function init() {
27 msg: null, 33 msg: null,
28 cartType: 'ordinary' 34 cartType: 'ordinary'
29 }; 35 };
30 - window.setCookie('order-info', JSON.stringify(info)); 36 + window.setCookie('order-info', JSON.stringify(info), actCkOpthn);
31 } 37 }
32 38
33 // info 必须是 JSON 字符串 39 // info 必须是 JSON 字符串
@@ -47,5 +53,5 @@ exports.orderInfo = function(key, value) { @@ -47,5 +53,5 @@ exports.orderInfo = function(key, value) {
47 return info[key]; 53 return info[key];
48 } 54 }
49 info[key] = value; 55 info[key] = value;
50 - window.setCookie('order-info', JSON.stringify(info)); 56 + window.setCookie('order-info', JSON.stringify(info), actCkOpthn);
51 }; 57 };
@@ -44,6 +44,12 @@ var invoiceCont = { @@ -44,6 +44,12 @@ var invoiceCont = {
44 2: '电子' 44 2: '电子'
45 }; 45 };
46 46
  47 +// cookie 参数
  48 +var actCkOpthn = {
  49 + expires: 'Session',
  50 + path: '/cart/index',
  51 + domain: '.m.yohobuy.com'
  52 +};
47 53
48 lazyLoad(); 54 lazyLoad();
49 55
@@ -293,7 +299,7 @@ function submitOrder() { @@ -293,7 +299,7 @@ function submitOrder() {
293 } else { 299 } else {
294 url = '/home/orders/pay?order_code=' + res.data.order_code; 300 url = '/home/orders/pay?order_code=' + res.data.order_code;
295 } 301 }
296 - window.setCookie('order-info', ''); 302 + window.setCookie('order-info', '', actCkOpthn);
297 window.location.href = url; 303 window.location.href = url;
298 } else if (res.message) { 304 } else if (res.message) {
299 tip.show(res.message); 305 tip.show(res.message);
@@ -399,7 +399,10 @@ function givePoint(parameter) { @@ -399,7 +399,10 @@ function givePoint(parameter) {
399 break; 399 break;
400 } 400 }
401 } else { 401 } else {
402 - header.removeClass('girls', 'life-style', 'kids').addClass('boys'); 402 + header.removeClass('kids');
  403 + header.removeClass('girls');
  404 + header.removeClass('life-style');
  405 + header.addClass('boys');
403 } 406 }
404 407
405 switch (channel) { 408 switch (channel) {
@@ -96,7 +96,7 @@ $addressForm.on('submit', function() { @@ -96,7 +96,7 @@ $addressForm.on('submit', function() {
96 loading.hideLoadingMask(); 96 loading.hideLoadingMask();
97 } else if (window.queryString) { 97 } else if (window.queryString) {
98 if (window.queryString.refer === 'shopping') { 98 if (window.queryString.refer === 'shopping') {
99 - window.location.href = '/cart/index/selectAddress'; 99 + window.location.href = '/cart/index/new/selectAddress';
100 } else if (window.queryString.refer === 'modify') { 100 } else if (window.queryString.refer === 'modify') {
101 window.location.href = '/home/addressModify'; 101 window.location.href = '/home/addressModify';
102 } else { 102 } else {
@@ -87,7 +87,7 @@ exports.showDialog = function(data, callback, callbackForLeft, fullWithBtn) { @@ -87,7 +87,7 @@ exports.showDialog = function(data, callback, callbackForLeft, fullWithBtn) {
87 event.preventDefault(); 87 event.preventDefault();
88 event.stopPropagation(); 88 event.stopPropagation();
89 }); 89 });
90 - }, 100); 90 + }, 500);
91 }; 91 };
92 92
93 exports.hideDialog = function() { 93 exports.hideDialog = function() {
@@ -52,7 +52,7 @@ @@ -52,7 +52,7 @@
52 i { 52 i {
53 position: absolute; 53 position: absolute;
54 left: 16px; 54 left: 16px;
55 - top: 0; 55 + top: 40px;
56 font-size: 44px; 56 font-size: 44px;
57 } 57 }
58 58
@@ -638,7 +638,7 @@ @@ -638,7 +638,7 @@
638 border-radius: 28px; 638 border-radius: 28px;
639 width: 28px; 639 width: 28px;
640 height: 28px; 640 height: 28px;
641 - line-height: 28px; 641 + line-height: 36px;
642 text-align: center; 642 text-align: center;
643 color: #fff; 643 color: #fff;
644 font-size: 22px; 644 font-size: 22px;