Authored by 毕凯

不同用户 确认订单cookie信息隔离

@@ -10,7 +10,7 @@ var $ = require('jquery'), @@ -10,7 +10,7 @@ var $ = require('jquery'),
10 Handlebars = require('yoho.handlebars'), 10 Handlebars = require('yoho.handlebars'),
11 tip = require('../plugin/tip'), 11 tip = require('../plugin/tip'),
12 loading = require('../plugin/loading'), 12 loading = require('../plugin/loading'),
13 - orderInfo = require('./order-info').orderInfo; 13 + order = require('./order-info');
14 14
15 var dispatchModeHammer, 15 var dispatchModeHammer,
16 dispatchTimeHammer, 16 dispatchTimeHammer,
@@ -18,10 +18,15 @@ var dispatchModeHammer, @@ -18,10 +18,15 @@ var dispatchModeHammer,
18 $price = $('.price-cal'), 18 $price = $('.price-cal'),
19 payType, 19 payType,
20 priceTmpl = Handlebars.compile($('#tmpl-price').html()), 20 priceTmpl = Handlebars.compile($('#tmpl-price').html()),
21 - queryString = $.queryString(); 21 + queryString = $.queryString(),
  22 + orderInfo = order.orderInfo;
22 23
23 lazyLoad(); 24 lazyLoad();
24 25
  26 +if (window.getUid() !== orderInfo('uid')) {
  27 + order.init();
  28 +}
  29 +
25 function dispacthTapEvt(e) { 30 function dispacthTapEvt(e) {
26 var $cur = $(e.target).closest('li'); 31 var $cur = $(e.target).closest('li');
27 32
@@ -6,11 +6,9 @@ @@ -6,11 +6,9 @@
6 var $ = require('jquery'); 6 var $ = require('jquery');
7 var info = window.cookie('order-info'); 7 var info = window.cookie('order-info');
8 8
9 -// info 必须是 JSON 字符串  
10 -try {  
11 - info = JSON.parse(info);  
12 -} catch (e) { 9 +function init() {
13 info = { 10 info = {
  11 + uid: window.getUid(),
14 deliveryId: 1, 12 deliveryId: 1,
15 deliveryTimeId: 1, 13 deliveryTimeId: 1,
16 paymentTypeId: 1, 14 paymentTypeId: 1,
@@ -26,6 +24,15 @@ try { @@ -26,6 +24,15 @@ try {
26 window.setCookie('order-info', JSON.stringify(info)); 24 window.setCookie('order-info', JSON.stringify(info));
27 } 25 }
28 26
  27 +// info 必须是 JSON 字符串
  28 +try {
  29 + info = JSON.parse(info);
  30 +} catch (e) {
  31 + init();
  32 +}
  33 +
  34 +exports.init = init;
  35 +
29 exports.orderInfo = function(key, value) { 36 exports.orderInfo = function(key, value) {
30 if (value === undefined) { 37 if (value === undefined) {
31 return info[key]; 38 return info[key];