Authored by 毕凯

赠加 cookie 操作

@@ -6,9 +6,12 @@ @@ -6,9 +6,12 @@
6 6
7 var $ = require('jquery'), 7 var $ = require('jquery'),
8 lazyLoad = require('yoho.lazyload'), 8 lazyLoad = require('yoho.lazyload'),
9 - Hammer = require('yoho.hammer'); 9 + Hammer = require('yoho.hammer'),
  10 + orderInfo = require('./order-info').orderInfo;
10 11
11 -var dispatchModeHammer, dispatchTimeHammer; 12 +var dispatchModeHammer,
  13 + dispatchTimeHammer,
  14 + $invoice = $('.invoice');
12 15
13 lazyLoad(); 16 lazyLoad();
14 17
@@ -51,3 +54,42 @@ $('.invoice').on('touchend', '.checkbox', function() { @@ -51,3 +54,42 @@ $('.invoice').on('touchend', '.checkbox', function() {
51 $('.invoice').removeClass('focus'); 54 $('.invoice').removeClass('focus');
52 } 55 }
53 }); 56 });
  57 +
  58 +// 界面点击,状态存 cookie
  59 +$('.dispatch-mode').on('touchend', 'li', function() {
  60 + orderInfo('deliveryId', $(this).data('id'));
  61 +});
  62 +
  63 +$('.dispatch-time').on('touchend', 'li', function() {
  64 + orderInfo('deliveryTimeId', $(this).data('id'));
  65 +});
  66 +
  67 +$('.coin').on('touchend', function() {
  68 + var $this = $(this);
  69 +
  70 + if ($this.find('.checkbox').hasClass('icon-cb-checked')) {
  71 + orderInfo('yohoCoin', $this.data('yoho-coin'));
  72 + } else {
  73 + orderInfo('yohoCoin', 0);
  74 + }
  75 +});
  76 +
  77 +$invoice.on('touchend', function() {
  78 + var $this = $(this);
  79 +
  80 + orderInfo('invoice', $this.find('.checkbox').hasClass('icon-cb-checked'));
  81 +});
  82 +
  83 +$invoice.find('[name="invoice-title"]').on('blur', function() {
  84 + orderInfo('invoiceText', $(this).val());
  85 +}).end().find('.invoice-type').on('change', function() {
  86 + orderInfo('invoiceType', $(this).val());
  87 +});
  88 +
  89 +$('#msg').find('input').on('blur', function() {
  90 + orderInfo('msg', $(this).val());
  91 +});
  92 +
  93 +$('.pay-mode').on('click', 'li', function() {
  94 + orderInfo('paymentTypeId', $(this).data('pay-id'));
  95 +});
@@ -41,7 +41,10 @@ $newCoupon.on('submit', function() { @@ -41,7 +41,10 @@ $newCoupon.on('submit', function() {
41 }); 41 });
42 42
43 $('#coupon-list').on('touchend', '.employ-main', function() { 43 $('#coupon-list').on('touchend', '.employ-main', function() {
44 - orderInfo('couponCode', $(this).data('coupon-code')); 44 + var $this = $(this);
  45 +
  46 + orderInfo('couponCode', $this.data('coupon-code'));
  47 + orderInfo('couponValue', $this.data('coupon-value'));
45 }); 48 });
46 49
47 $newCoupon.find('input').on('input', function() { 50 $newCoupon.find('input').on('input', function() {
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <p class="infos"> 5 <p class="infos">
6 收货地址 6 收货地址
7 <span class="per-info">{{name}} {{phoneNum}}</span> 7 <span class="per-info">{{name}} {{phoneNum}}</span>
8 - <span class="address">{{address}}</span> 8 + <span class="address">{{area}} {{address}}</span>
9 </p> 9 </p>
10 <span class="iconfont">&#xe614;</span> 10 <span class="iconfont">&#xe614;</span>
11 </a> 11 </a>
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 <h3 class="title">配送方式</h3> 15 <h3 class="title">配送方式</h3>
16 <ul class="dispatch-mode clearfix"> 16 <ul class="dispatch-mode clearfix">
17 {{#each dispatchMode}} 17 {{#each dispatchMode}}
18 - <li {{#if @first}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li> 18 + <li {{#if isSelected}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li>
19 {{/each}} 19 {{/each}}
20 </ul> 20 </ul>
21 </div> 21 </div>
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 <h3 class="title">送货时间</h3> 24 <h3 class="title">送货时间</h3>
25 <ul class="dispatch-time clearfix"> 25 <ul class="dispatch-time clearfix">
26 {{#each dispatchTime}} 26 {{#each dispatchTime}}
27 - <li {{#if @first}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li> 27 + <li {{#if isSelected}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li>
28 {{/each}} 28 {{/each}}
29 </ul> 29 </ul>
30 </div> 30 </div>
@@ -52,14 +52,14 @@ @@ -52,14 +52,14 @@
52 </span> 52 </span>
53 {{/if}} 53 {{/if}}
54 54
55 - {{#if notUsed}}  
56 - <span class="not-used coupon-use">  
57 - 未使用 55 + {{#if value}}
  56 + <span class="used coupon-use">
  57 + {{value}}
58 <i class="iconfont">&#xe614;</i> 58 <i class="iconfont">&#xe614;</i>
59 </span> 59 </span>
60 {{^}} 60 {{^}}
61 - <span class="used coupon-use">  
62 - {{value}} 61 + <span class="not-used coupon-use">
  62 + 未使用
63 <i class="iconfont">&#xe614;</i> 63 <i class="iconfont">&#xe614;</i>
64 </span> 64 </span>
65 {{/if}} 65 {{/if}}
@@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@
68 {{/ coupon}} 68 {{/ coupon}}
69 69
70 {{# yohoCoin}} 70 {{# yohoCoin}}
71 - <li class="coin"> 71 + <li class="coin" data-yoho-coin="{{.}}">
72 <span class="title">YOHO币</span> 72 <span class="title">YOHO币</span>
73 <span class="desc">可抵用¥{{.}}</span> 73 <span class="desc">可抵用¥{{.}}</span>
74 <span class="coin-check"> 74 <span class="coin-check">
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 <script id="tmpl-coupon" type="text/tmpl"> 11 <script id="tmpl-coupon" type="text/tmpl">
12 \{{#coupons}} 12 \{{#coupons}}
13 \{{^ notAvailable}} 13 \{{^ notAvailable}}
14 - <a class="employ-main" data-coupon-code="\{{ couponCode}}" href="/shoppingCart/orderEnsure"> 14 + <a class="employ-main" data-coupon-code="\{{ couponCode}}" data-coupon-value="\{{ couponValue}}" href="/shoppingCart/orderEnsure">
15 <span>\{{ couponValue}}</span> 15 <span>\{{ couponValue}}</span>
16 <p class="coupon-name">\{{ couponDetailInfomation}}</p> 16 <p class="coupon-name">\{{ couponDetailInfomation}}</p>
17 <p>有效期:\{{ couponValidity}}</p> 17 <p>有效期:\{{ couponValidity}}</p>
@@ -319,7 +319,8 @@ class CartModel @@ -319,7 +319,8 @@ class CartModel
319 $result['addressId'] = isset($address['address_id']) ? $address['address_id'] : $payReturn['delivery_address']['address_id']; 319 $result['addressId'] = isset($address['address_id']) ? $address['address_id'] : $payReturn['delivery_address']['address_id'];
320 $result['name'] = isset($address['consignee']) ? $address['consignee'] : $payReturn['delivery_address']['consignee']; 320 $result['name'] = isset($address['consignee']) ? $address['consignee'] : $payReturn['delivery_address']['consignee'];
321 $result['phoneNum'] = isset($address['mobile']) ? $address['mobile'] : $payReturn['delivery_address']['mobile']; 321 $result['phoneNum'] = isset($address['mobile']) ? $address['mobile'] : $payReturn['delivery_address']['mobile'];
322 - $result['address'] = isset($address['address']) ? $address['address'] : $payReturn['delivery_address']['address']; 322 + $result['area'] = isset($address['area']) ? $address['area'] : $payReturn['delivery_address']['area'];
  323 + $result['address'] = isset($address['address']) ? $address['address'] : $payReturn['delivery_address']['address'];
323 $result['isSupport'] = ($payReturn['delivery_address']['is_support'] === 'Y'); 324 $result['isSupport'] = ($payReturn['delivery_address']['is_support'] === 'Y');
324 } 325 }
325 326
@@ -330,9 +331,11 @@ class CartModel @@ -330,9 +331,11 @@ class CartModel
330 $oneDeliv = array(); 331 $oneDeliv = array();
331 $oneDeliv['id'] = $val['delivery_way_id']; 332 $oneDeliv['id'] = $val['delivery_way_id'];
332 $oneDeliv['name'] = $val['delivery_way_name']; 333 $oneDeliv['name'] = $val['delivery_way_name'];
333 - $oneDeliv['default'] = ($val['default'] === 'Y'); 334 +
334 isset($orderInfo['deliveryId']) && $orderInfo['deliveryId'] === $oneDeliv['id'] && $oneDeliv['isSelected'] = true; 335 isset($orderInfo['deliveryId']) && $orderInfo['deliveryId'] === $oneDeliv['id'] && $oneDeliv['isSelected'] = true;
335 336
  337 + !isset($oneDeliv['isSelected']) && $oneDeliv['isSelected'] = ($val['default'] === 'Y');
  338 +
336 $result['dispatchMode'][] = $oneDeliv; 339 $result['dispatchMode'][] = $oneDeliv;
337 } 340 }
338 } 341 }
@@ -390,7 +393,7 @@ class CartModel @@ -390,7 +393,7 @@ class CartModel
390 $sumPrice = isset($orderCompute['order_amount']) ? $orderCompute['order_amount'] : $payReturn['shopping_cart_data']['order_amount']; 393 $sumPrice = isset($orderCompute['order_amount']) ? $orderCompute['order_amount'] : $payReturn['shopping_cart_data']['order_amount'];
391 $salePrice = isset($orderCompute['discount_amount']) ? $orderCompute['discount_amount'] : $payReturn['shopping_cart_data']['discount_amount']; 394 $salePrice = isset($orderCompute['discount_amount']) ? $orderCompute['discount_amount'] : $payReturn['shopping_cart_data']['discount_amount'];
392 $price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount']; 395 $price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount'];
393 - $freight = isset($orderCompute['promotion_formula_list']['promotion_amount']) ? $orderCompute['promotion_formula_list']['promotion_amount'] : $payReturn['shopping_cart_data']['promotion_formula_list']['promotion_amount']; 396 + $freight = isset($orderCompute['promotion_formula_list']['promotion_amount']) ? $orderCompute['promotion_formula_list']['promotion_amount'] : $payReturn['shopping_cart_data']['promotion_formula_list'][1]['promotion_amount'];
394 $result['sumPrice'] = Helpers::transPrice($sumPrice); 397 $result['sumPrice'] = Helpers::transPrice($sumPrice);
395 $result['salePrice'] = Helpers::transPrice($salePrice); 398 $result['salePrice'] = Helpers::transPrice($salePrice);
396 $result['price'] = Helpers::transPrice($price); 399 $result['price'] = Helpers::transPrice($price);
@@ -411,7 +414,7 @@ class CartModel @@ -411,7 +414,7 @@ class CartModel
411 414
412 // 优惠券数据 415 // 优惠券数据
413 $coupons = array('notUsed' => true); 416 $coupons = array('notUsed' => true);
414 - !empty($orderCompute['coupon_amount']) && $coupons['notUsed'] = $orderInfo['couponName']; 417 + !empty($orderCompute['coupon_amount']) && $coupons['value'] = $orderInfo['couponValue'];
415 $coupons += self::getCouponList($uid, 0, 1, true); 418 $coupons += self::getCouponList($uid, 0, 1, true);
416 $result['coupon'] = $coupons; 419 $result['coupon'] = $coupons;
417 } 420 }