Authored by 毕凯

增加订单提交

@@ -30,6 +30,35 @@ function dispacthTapEvt(e) { @@ -30,6 +30,35 @@ function dispacthTapEvt(e) {
30 $cur.addClass('chosed'); 30 $cur.addClass('chosed');
31 } 31 }
32 32
  33 +dispatchModeHammer = new Hammer(document.getElementsByClassName('dispatch-mode')[0]);
  34 +dispatchModeHammer.on('tap', dispacthTapEvt);
  35 +
  36 +dispatchTimeHammer = new Hammer(document.getElementsByClassName('dispatch-time')[0]);
  37 +dispatchTimeHammer.on('tap', dispacthTapEvt);
  38 +
  39 +$('.checkbox').on('touchstart', function() {
  40 + var $this = $(this);
  41 +
  42 + if ($this.hasClass('icon-cb-checked')) {
  43 + $this.removeClass('icon-cb-checked').addClass('icon-checkbox');
  44 + return;
  45 + }
  46 + if ($this.hasClass('icon-checkbox')) {
  47 + $this.removeClass('icon-checkbox').addClass('icon-cb-checked');
  48 + }
  49 +});
  50 +
  51 +$('.invoice').on('touchend', '.checkbox', function() {
  52 + var $this = $(this);
  53 +
  54 + if ($this.hasClass('icon-cb-checked')) {
  55 + $('.invoice').addClass('focus');
  56 + }
  57 + if ($this.hasClass('icon-checkbox')) {
  58 + $('.invoice').removeClass('focus');
  59 + }
  60 +});
  61 +
33 function orderCompute() { 62 function orderCompute() {
34 $.ajax({ 63 $.ajax({
35 method: 'POST', 64 method: 'POST',
@@ -62,34 +91,29 @@ function orderCompute() { @@ -62,34 +91,29 @@ function orderCompute() {
62 }); 91 });
63 } 92 }
64 93
65 -dispatchModeHammer = new Hammer(document.getElementsByClassName('dispatch-mode')[0]);  
66 -dispatchModeHammer.on('tap', dispacthTapEvt);  
67 -  
68 -dispatchTimeHammer = new Hammer(document.getElementsByClassName('dispatch-time')[0]);  
69 -dispatchTimeHammer.on('tap', dispacthTapEvt);  
70 -  
71 -$('.checkbox').on('touchstart', function() {  
72 - var $this = $(this);  
73 -  
74 - if ($this.hasClass('icon-cb-checked')) {  
75 - $this.removeClass('icon-cb-checked').addClass('icon-checkbox');  
76 - return;  
77 - }  
78 - if ($this.hasClass('icon-checkbox')) {  
79 - $this.removeClass('icon-checkbox').addClass('icon-cb-checked');  
80 - }  
81 -});  
82 -  
83 -$('.invoice').on('touchend', '.checkbox', function() {  
84 - var $this = $(this);  
85 -  
86 - if ($this.hasClass('icon-cb-checked')) {  
87 - $('.invoice').addClass('focus');  
88 - }  
89 - if ($this.hasClass('icon-checkbox')) {  
90 - $('.invoice').removeClass('focus');  
91 - }  
92 -}); 94 +function submitOrder() {
  95 + $.ajax({
  96 + method: 'POST',
  97 + url: '/shoppingCart/orderSub',
  98 + data: {
  99 + addressId: orderInfo('addressId'),
  100 + cartType: orderInfo('cartType'),
  101 + deliveryId: orderInfo('deliveryId'),
  102 + deliveryTimeId: orderInfo('deliveryTimeId'),
  103 + invoiceText: orderInfo('invoiceText'),
  104 + invoiceType: orderInfo('invoiceType'),
  105 + msg: orderInfo('msg'),
  106 + paymentTypeId: orderInfo('paymentTypeId'),
  107 + paymentType: orderInfo('paymentType'), //支付方式
  108 + couponCode: orderInfo('couponCode'),
  109 + yohoCoin: orderInfo('yohoCoin')
  110 + }
  111 + }).then(function(res) {
  112 + console.log(res);
  113 + }).fail(function() {
  114 + tip.show('网络出错');
  115 + });
  116 +}
93 117
94 // 界面点击,状态存 cookie 118 // 界面点击,状态存 cookie
95 $('.dispatch-mode').on('touchend', 'li', function() { 119 $('.dispatch-mode').on('touchend', 'li', function() {
@@ -132,4 +156,6 @@ $('#msg').find('input').on('blur', function() { @@ -132,4 +156,6 @@ $('#msg').find('input').on('blur', function() {
132 156
133 $('.pay-mode').on('click', 'li', function() { 157 $('.pay-mode').on('click', 'li', function() {
134 orderInfo('paymentTypeId', $(this).data('pay-id')); 158 orderInfo('paymentTypeId', $(this).data('pay-id'));
  159 + orderInfo('paymentType', $(this).data('pay-type'));
  160 + submitOrder();
135 }); 161 });
@@ -128,7 +128,7 @@ @@ -128,7 +128,7 @@
128 128
129 <ul class="pay-mode"> 129 <ul class="pay-mode">
130 {{# paymentWay}} 130 {{# paymentWay}}
131 - <li class="{{#if default}}default{{/if}}" data-pay-id={{id}}> 131 + <li class="{{#if default}}default{{/if}}" data-pay-type="{{paymentType}}" data-pay-id="{{id}}">
132 <span class="iconfont"> 132 <span class="iconfont">
133 {{#if default}} 133 {{#if default}}
134 &#xe62f; 134 &#xe62f;
@@ -156,7 +156,6 @@ class ShoppingCartController extends AbstractAction @@ -156,7 +156,6 @@ class ShoppingCartController extends AbstractAction
156 'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData) 156 'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData)
157 ); 157 );
158 158
159 -  
160 $this->_view->display('order-ensure', $data); 159 $this->_view->display('order-ensure', $data);
161 } 160 }
162 161
@@ -268,13 +267,13 @@ class ShoppingCartController extends AbstractAction @@ -268,13 +267,13 @@ class ShoppingCartController extends AbstractAction
268 $uid = $this->getUid(true); 267 $uid = $this->getUid(true);
269 $addressId = $this->post('addressId', null); 268 $addressId = $this->post('addressId', null);
270 $cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车 269 $cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车
271 - $deliveryTime = $this->post('deliveryTime', 1); // 默认只工作日配送  
272 - $deliveryWay = $this->post('deliveryWay', 1); // 默认普通快递  
273 - $invoiceTitle = $this->post('invoiceTitle', null);  
274 - $invoiceId = $this->post('invoiceId', null);  
275 - $paymentId = $this->post('paymentId', 15); 270 + $deliveryTime = $this->post('deliveryTimeId', 1); // 默认只工作日配送
  271 + $deliveryWay = $this->post('deliveryId', 1); // 默认普通快递
  272 + $invoiceTitle = $this->post('invoiceText', null);
  273 + $invoiceId = $this->post('invoiceType', null);
  274 + $paymentId = $this->post('paymentTypeId', 15);
276 $paymentType = $this->post('paymentType', 1); // 默认在线支付 275 $paymentType = $this->post('paymentType', 1); // 默认在线支付
277 - $remark = $this->post('remark', null); // 默认在线支付 276 + $remark = $this->post('msg', null);
278 $yohoCoin = $this->post('yohoCoin', 1); 277 $yohoCoin = $this->post('yohoCoin', 1);
279 $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin); 278 $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin);
280 } 279 }
@@ -283,7 +282,7 @@ class ShoppingCartController extends AbstractAction @@ -283,7 +282,7 @@ class ShoppingCartController extends AbstractAction
283 echo ' '; 282 echo ' ';
284 } else { 283 } else {
285 // 提交成功清除Cookie 284 // 提交成功清除Cookie
286 - $this->setCookie('orderInfo', null); 285 + $this->setCookie('order-info', null);
287 286
288 $this->echoJson($result); 287 $this->echoJson($result);
289 } 288 }