Showing
5 changed files
with
14 additions
and
7 deletions
@@ -12,7 +12,14 @@ exports.ensure = (req, res, next) => { | @@ -12,7 +12,14 @@ exports.ensure = (req, res, next) => { | ||
12 | const sku = Number.parseInt(req.query.sku, 10); | 12 | const sku = Number.parseInt(req.query.sku, 10); |
13 | const skn = Number.parseInt(req.query.skn, 10); | 13 | const skn = Number.parseInt(req.query.skn, 10); |
14 | const uid = req.user.uid; | 14 | const uid = req.user.uid; |
15 | - const orderInfo = req.cookies['order-info']; | 15 | + |
16 | + let orderInfo = req.cookies['order-info']; | ||
17 | + | ||
18 | + try { | ||
19 | + orderInfo = JSON.parse(req.cookies['order-info']) | ||
20 | + } catch (e) { | ||
21 | + orderInfo = {} | ||
22 | + } | ||
16 | 23 | ||
17 | // require skn, sku; | 24 | // require skn, sku; |
18 | if (!(sku && skn)) { | 25 | if (!(sku && skn)) { |
@@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
38 | "request-promise": "^3.0.0", | 38 | "request-promise": "^3.0.0", |
39 | "serve-favicon": "^2.3.0", | 39 | "serve-favicon": "^2.3.0", |
40 | "uuid": "^2.0.3", | 40 | "uuid": "^2.0.3", |
41 | - "yoho-node-lib": "0.1.23", | 41 | + "yoho-node-lib": "^0.1.24", |
42 | "yoho-zookeeper": "^1.0.3" | 42 | "yoho-zookeeper": "^1.0.3" |
43 | }, | 43 | }, |
44 | "devDependencies": { | 44 | "devDependencies": { |
@@ -27,7 +27,7 @@ function init() { | @@ -27,7 +27,7 @@ function init() { | ||
27 | msg: null, | 27 | msg: null, |
28 | cartType: 'ordinary' | 28 | cartType: 'ordinary' |
29 | }; | 29 | }; |
30 | - window.setCookie('order-info', JSON.stringify(info)); | 30 | + window.setCookie('order-info', JSON.stringify(info), {path: '/cart'}); |
31 | } | 31 | } |
32 | 32 | ||
33 | // info 必须是 JSON 字符串 | 33 | // info 必须是 JSON 字符串 |
@@ -47,5 +47,5 @@ exports.orderInfo = function(key, value) { | @@ -47,5 +47,5 @@ exports.orderInfo = function(key, value) { | ||
47 | return info[key]; | 47 | return info[key]; |
48 | } | 48 | } |
49 | info[key] = value; | 49 | info[key] = value; |
50 | - window.setCookie('order-info', JSON.stringify(info)); | 50 | + window.setCookie('order-info', JSON.stringify(info), {path: '/cart'}); |
51 | }; | 51 | }; |
@@ -284,7 +284,7 @@ function submitOrder() { | @@ -284,7 +284,7 @@ function submitOrder() { | ||
284 | } else { | 284 | } else { |
285 | url = '/home/orders/pay?order_code=' + res.data.order_code; | 285 | url = '/home/orders/pay?order_code=' + res.data.order_code; |
286 | } | 286 | } |
287 | - window.setCookie('order-info', ''); | 287 | + window.setCookie('order-info', '', {path: '/cart'}); |
288 | window.location.href = url; | 288 | window.location.href = url; |
289 | } else if (res.message) { | 289 | } else if (res.message) { |
290 | tip.show(res.message); | 290 | tip.show(res.message); |
@@ -21,10 +21,10 @@ function tranformPayment(data, orderInfo) { | @@ -21,10 +21,10 @@ function tranformPayment(data, orderInfo) { | ||
21 | 21 | ||
22 | result.name = cookieAddress ? cookieAddress.consignee : addressData.consignee; | 22 | result.name = cookieAddress ? cookieAddress.consignee : addressData.consignee; |
23 | result.phoneNum = cookieAddress ? cookieAddress.mobile : addressData.mobile; | 23 | result.phoneNum = cookieAddress ? cookieAddress.mobile : addressData.mobile; |
24 | - result.addressId = cookieAddress ? crypto.decrypt(null, cookieAddress.address_id) : addressData.address_id; | 24 | + result.addressId = cookieAddress ? parseInt(crypto.decrypt(null, cookieAddress.address_id), 10) : addressData.address_id; |
25 | result.addressInfo = cookieAddress ? cookieAddress.address_info : [addressData.area, addressData.address].join(' '); | 25 | result.addressInfo = cookieAddress ? cookieAddress.address_info : [addressData.area, addressData.address].join(' '); |
26 | 26 | ||
27 | - result.addressId = crypto.encryption(null, result.addressId); | 27 | + result.addressId = crypto.encryption(null, result.addressId + ''); |
28 | } | 28 | } |
29 | 29 | ||
30 | // delivery_way 配送信息 | 30 | // delivery_way 配送信息 |
-
Please register or login to post a comment