Authored by 郭成尧

cookie-handle

@@ -13,9 +13,7 @@ const logger = global.yoho.logger; @@ -13,9 +13,7 @@ const logger = global.yoho.logger;
13 13
14 // cookie 参数 14 // cookie 参数
15 const actCkOpthn = { 15 const actCkOpthn = {
16 - expires: 0,  
17 - path: '/cart/index',  
18 - domain: 'm.yohobuy.com' 16 + path: '/cart/index'
19 }; 17 };
20 18
21 exports.orderEnsure = (req, res, next) => { 19 exports.orderEnsure = (req, res, next) => {
@@ -34,7 +32,7 @@ exports.orderEnsure = (req, res, next) => { @@ -34,7 +32,7 @@ exports.orderEnsure = (req, res, next) => {
34 } catch (e) { 32 } catch (e) {
35 logger.info(`orderEnsure: get orderInfo from cookie error:${JSON.stringify(e)}`); 33 logger.info(`orderEnsure: get orderInfo from cookie error:${JSON.stringify(e)}`);
36 orderInfo = {}; 34 orderInfo = {};
37 - res.cookie('order-info', null, actCkOpthn); 35 + res.clearCookie('order-info', actCkOpthn);
38 } 36 }
39 37
40 if (!cartType) { 38 if (!cartType) {
@@ -63,7 +61,7 @@ exports.orderEnsure = (req, res, next) => { @@ -63,7 +61,7 @@ exports.orderEnsure = (req, res, next) => {
63 } 61 }
64 let activityInfo = JSON.parse(req.cookies['activity-info']); 62 let activityInfo = JSON.parse(req.cookies['activity-info']);
65 63
66 - orderPromise = cartModel.cartPay(uid, cartType, null, null, sku, skn, buyNumber, activityInfo); 64 + orderPromise = cartModel.cartPay(uid, cartType, orderInfo, null, sku, skn, buyNumber, activityInfo);
67 } else { 65 } else {
68 orderPromise = cartModel.cartPay(uid, cartType, orderInfo, sku, skn, buyNumber); 66 orderPromise = cartModel.cartPay(uid, cartType, orderInfo, sku, skn, buyNumber);
69 } 67 }
@@ -48,13 +48,6 @@ var invoiceCont = { @@ -48,13 +48,6 @@ var invoiceCont = {
48 2: '电子' 48 2: '电子'
49 }; 49 };
50 50
51 - // cookie 参数  
52 -var actCkOpthn = {  
53 - expires: 'Session',  
54 - path: '/cart/index',  
55 - domain: 'm.yohobuy.com'  
56 -};  
57 -  
58 require('../common'); 51 require('../common');
59 52
60 lazyLoad(); 53 lazyLoad();
@@ -334,12 +327,7 @@ function submitOrder() { @@ -334,12 +327,7 @@ function submitOrder() {
334 }, true); 327 }, true);
335 } 328 }
336 329
337 - cookie.set('order-info', '', actCkOpthn);  
338 - cookie.set('activity-info', '', {  
339 - expires: 'Session',  
340 - path: '/',  
341 - domain: 'm.yohobuy.com'  
342 - }); 330 + cookie.remove(['order-info', 'activity-info']);
343 window.location.href = url; 331 window.location.href = url;
344 } else if (res.code === 409) { 332 } else if (res.code === 409) {
345 richTip.show(res.message, res.buttons); 333 richTip.show(res.message, res.buttons);
@@ -8,9 +8,7 @@ var info = window.cookie('order-info'); @@ -8,9 +8,7 @@ var info = window.cookie('order-info');
8 8
9 // cookie 参数 9 // cookie 参数
10 var actCkOpthn = { 10 var actCkOpthn = {
11 - expires: 'Session',  
12 - path: '/cart/index',  
13 - domain: 'm.yohobuy.com' 11 + path: '/cart/index'
14 }; 12 };
15 13
16 function init() { 14 function init() {
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 * Created by targaryen on 2016/11/28. 2 * Created by targaryen on 2016/11/28.
3 */ 3 */
4 var $ = require('yoho-jquery'), 4 var $ = require('yoho-jquery'),
5 - cookie = require('yoho-cookie'),  
6 tip = require('../plugin/tip'); 5 tip = require('../plugin/tip');
7 6
8 require('../common'); 7 require('../common');
@@ -11,15 +10,15 @@ var chosePanelRender = require('../common/chose-panel'), @@ -11,15 +10,15 @@ var chosePanelRender = require('../common/chose-panel'),
11 chosePanel = require('./bundle/chose-pannel'); 10 chosePanel = require('./bundle/chose-pannel');
12 11
13 var $selectBtn = $('.select-btn'), 12 var $selectBtn = $('.select-btn'),
14 - $buyNowBtn = $('#bundle-buy-now'),  
15 - actCkOpthn = {  
16 - expires: 'Session',  
17 - path: '/',  
18 - domain: 'm.yohobuy.com'  
19 - }; 13 + $buyNowBtn = $('#bundle-buy-now');
  14 +
  15 +// cookie 参数
  16 +var actCkOpthn = {
  17 + path: '/cart/index'
  18 +};
20 19
21 $(function() { 20 $(function() {
22 - cookie.set('activity-info', '', actCkOpthn); 21 + window.setCookie('activity-info', '', actCkOpthn);
23 }); 22 });
24 23
25 /** 24 /**
@@ -100,8 +99,8 @@ $buyNowBtn.on('click', function() { @@ -100,8 +99,8 @@ $buyNowBtn.on('click', function() {
100 } 99 }
101 100
102 if (gsknSelected) { 101 if (gsknSelected) {
103 - cookie.set('_cartType', 'bundle', actCkOpthn);  
104 - cookie.set('activity-info', JSON.stringify({ 102 + window.setCookie('_cartType', 'bundle', actCkOpthn);
  103 + window.setCookie('activity-info', JSON.stringify({
105 product_sku_list: bundleGoods, 104 product_sku_list: bundleGoods,
106 activity_id: bundleId 105 activity_id: bundleId
107 }), actCkOpthn); 106 }), actCkOpthn);