Authored by 毕凯

订单确认页面逻辑修改

@@ -10,8 +10,9 @@ var $ = require('jquery'), @@ -10,8 +10,9 @@ var $ = require('jquery'),
10 lazyLoad = require('yoho.lazyload'); 10 lazyLoad = require('yoho.lazyload');
11 11
12 var dialog = require('../me/dialog'), 12 var dialog = require('../me/dialog'),
13 - tip = require('../plugin/tip'),  
14 - orderInfo = require('./order-info').orderInfo; 13 + tip = require('../plugin/tip');
  14 +
  15 +// orderInfo = require('./order-info').orderInfo;
15 16
16 var $selectAllBtn = $('.balance .checkbox'), 17 var $selectAllBtn = $('.balance .checkbox'),
17 requesting = false; 18 requesting = false;
@@ -106,8 +107,9 @@ $('.icon-del').on('touchstart', function(e) { @@ -106,8 +107,9 @@ $('.icon-del').on('touchstart', function(e) {
106 autoHide: true, 107 autoHide: true,
107 fast: true 108 fast: true
108 }); 109 });
109 - orderInfo('couponCode', null);  
110 - orderInfo('couponName', null); 110 +
  111 + // orderInfo('couponCode', null);
  112 + // orderInfo('couponName', null);
111 window.setCookie('_yoho-cart-refreshByDelete', true); 113 window.setCookie('_yoho-cart-refreshByDelete', true);
112 window.location.href = '/cart/index/index?cartType=' + $('#cartType').val(); 114 window.location.href = '/cart/index/index?cartType=' + $('#cartType').val();
113 } else { 115 } else {
@@ -40,6 +40,12 @@ if ($couponUse.data('name') !== orderInfo('couponName')) { @@ -40,6 +40,12 @@ if ($couponUse.data('name') !== orderInfo('couponName')) {
40 orderInfo('couponName', null); 40 orderInfo('couponName', null);
41 } 41 }
42 42
  43 +// 来自购物车的链接默认不使用优惠券
  44 +if (document.referrer && document.referrer.indexOf('/cart/index/index') !== -1) {
  45 + orderInfo('couponCode', null);
  46 + orderInfo('couponName', null);
  47 +}
  48 +
43 orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary'); 49 orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary');
44 50
45 function dispacthTapEvt(e) { 51 function dispacthTapEvt(e) {
@@ -120,6 +126,9 @@ function orderCompute() { @@ -120,6 +126,9 @@ function orderCompute() {
120 }); 126 });
121 } 127 }
122 128
  129 +// 进入页面计算一次价格
  130 +orderCompute();
  131 +
123 function submitOrder() { 132 function submitOrder() {
124 var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), 133 var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
125 msg = $('#msg').find('input').val() || orderInfo('msg'); 134 msg = $('#msg').find('input').val() || orderInfo('msg');
@@ -30,9 +30,9 @@ function init() { @@ -30,9 +30,9 @@ function init() {
30 // info 必须是 JSON 字符串 30 // info 必须是 JSON 字符串
31 try { 31 try {
32 info = JSON.parse(info); 32 info = JSON.parse(info);
33 - 33 +
34 // 2015/12/31 hf: fixes bug to 购物车页面调用该JS, 会导致有YOHO币,值却没有传给服务端. 因此需要再设置一下 34 // 2015/12/31 hf: fixes bug to 购物车页面调用该JS, 会导致有YOHO币,值却没有传给服务端. 因此需要再设置一下
35 - info['yohoCoin'] = $('.coin').data('yoho-coin') || 0; 35 + // info.yohoCoin = $('.coin').data('yoho-coin') || 0;
36 } catch (e) { 36 } catch (e) {
37 init(); 37 init();
38 } 38 }
@@ -158,15 +158,14 @@ function getCouponHandle(coupons) { @@ -158,15 +158,14 @@ function getCouponHandle(coupons) {
158 couponCode: couponCode 158 couponCode: couponCode
159 } 159 }
160 }).then(function(res) { 160 }).then(function(res) {
161 - if (res.message) {  
162 - tip.show(res.message);  
163 - }  
164 if (res.code === 200) { 161 if (res.code === 200) {
165 162
166 //tip.show('优惠券可用'); 163 //tip.show('优惠券可用');
167 orderInfo('couponCode', res.data.coupon_code); 164 orderInfo('couponCode', res.data.coupon_code);
168 orderInfo('couponName', res.data.coupon_title); 165 orderInfo('couponName', res.data.coupon_title);
169 window.location.href = '/cart/index/orderEnsure'; 166 window.location.href = '/cart/index/orderEnsure';
  167 + } else if (res.message) {
  168 + tip.show(res.message);
170 } 169 }
171 }).fail(function() { 170 }).fail(function() {
172 tip.show('网络错误'); 171 tip.show('网络错误');