Authored by 陈峰

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

@@ -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));
@@ -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);