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');
const crypto = global.yoho.crypto;
const authcode = require(global.utils + '/authcode');
// cookie 参数
const actCkOpthn = {
expires: 0,
path: '/cart/index',
domain: '.m.yohobuy.com'
};
exports.orderEnsure = (req, res, next) => {
let headerData = headerModel.setNav({
navTitle: '确认订单',
... ... @@ -25,6 +32,7 @@ exports.orderEnsure = (req, res, next) => {
orderInfo = JSON.parse(req.cookies['order-info']);
} catch (e) {
orderInfo = {};
res.cookie('order-info', null, actCkOpthn);
}
let cookieCartType = _.get(orderInfo, 'cartType');
... ... @@ -149,6 +157,7 @@ exports.orderSub = (req, res) => {
orderInfo = JSON.parse(req.cookies['order-info']);
} catch (e) {
orderInfo = {};
res.cookie('order-info', null, actCkOpthn);
}
let times = req.body.times || 1;
... ... @@ -216,9 +225,8 @@ exports.orderSub = (req, res) => {
}
// 提交成功清除Cookie
res.cookie('order-info', null, {
domain: 'yohobuy.com'
});
orderInfo = {};
res.cookie('order-info', null, actCkOpthn);
if (result.code === 409) {
return res.json(decodeURI(result));
... ...
... ... @@ -27,6 +27,13 @@ var isRefreshByDelete = window.cookie('_yoho-cart-refreshByDelete') === 'true' ?
var lowStockCount = 0;
// cookie 参数
var actCkOpthn = {
expires: 'Session',
path: '/cart/index',
domain: '.m.yohobuy.com'
};
loading.showLoadingMask();
... ... @@ -115,7 +122,7 @@ function showChooseGifDialog() {
var info = window.cookie('order-info');
if (info) {
window.setCookie('order-info', '');
window.setCookie('order-info', '', actCkOpthn);
}
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
});
... ... @@ -207,7 +214,7 @@ $('.btn-balance').on('touchend', function() {
if (hasChecked()) {
if (info) {
window.setCookie('order-info', '');
window.setCookie('order-info', '', actCkOpthn);
}
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
} else {
... ...
... ... @@ -10,6 +10,13 @@ let $ = require('yoho-jquery'),
tip = require('../../plugin/tip'),
dialog = require('../../plugin/dialog');
// cookie 参数
let actCkOpthn = {
expires: 'Session',
path: '/cart/index',
domain: '.m.yohobuy.com'
};
let cartObj = {
init(handle) {
let self = this;
... ... @@ -144,7 +151,7 @@ let cartObj = {
self.toOrderEnsure(cartType);
},
toOrderEnsure(cartType) {
window.cookie('order-info') && window.setCookie('order-info', '');
window.cookie('order-info') && window.setCookie('order-info', '', actCkOpthn);
window.location.href = '/cart/index/new/orderEnsure?cartType=' + cartType;
},
toGiftPromotion(cartType) {
... ...
... ... @@ -46,6 +46,13 @@ var invoiceCont = {
2: '电子'
};
// cookie 参数
var actCkOpthn = {
expires: 'Session',
path: '/cart/index',
domain: '.m.yohobuy.com'
};
require('../common');
lazyLoad();
... ... @@ -325,7 +332,7 @@ function submitOrder() {
}, true);
}
window.setCookie('order-info', '');
window.setCookie('order-info', '', actCkOpthn);
window.setCookie('activity-info', '', {
expires: 'Session',
path: '/',
... ...
... ... @@ -6,6 +6,12 @@
require('../common');
var info = window.cookie('order-info');
// cookie 参数
var actCkOpthn = {
expires: 'Session',
path: '/cart/index',
domain: '.m.yohobuy.com'
};
function init() {
info = {
... ... @@ -27,7 +33,7 @@ function init() {
msg: null,
cartType: 'ordinary'
};
window.setCookie('order-info', JSON.stringify(info));
window.setCookie('order-info', JSON.stringify(info), actCkOpthn);
}
// info 必须是 JSON 字符串
... ... @@ -47,5 +53,5 @@ exports.orderInfo = function(key, value) {
return info[key];
}
info[key] = value;
window.setCookie('order-info', JSON.stringify(info));
window.setCookie('order-info', JSON.stringify(info), actCkOpthn);
};
... ...
... ... @@ -44,6 +44,12 @@ var invoiceCont = {
2: '电子'
};
// cookie 参数
var actCkOpthn = {
expires: 'Session',
path: '/cart/index',
domain: '.m.yohobuy.com'
};
lazyLoad();
... ... @@ -293,7 +299,7 @@ function submitOrder() {
} else {
url = '/home/orders/pay?order_code=' + res.data.order_code;
}
window.setCookie('order-info', '');
window.setCookie('order-info', '', actCkOpthn);
window.location.href = url;
} else if (res.message) {
tip.show(res.message);
... ...