Showing
5 changed files
with
59 additions
and
30 deletions
@@ -303,14 +303,15 @@ class CartData | @@ -303,14 +303,15 @@ class CartData | ||
303 | * @param int $paymentId 支付方式ID | 303 | * @param int $paymentId 支付方式ID |
304 | * @param int $paymentType 支付类型ID | 304 | * @param int $paymentType 支付类型ID |
305 | * @param string $remark 留言 | 305 | * @param string $remark 留言 |
306 | + * @param string $couponCode 优惠券码 | ||
306 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 | 307 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 |
307 | * @return array 接口返回的数据 | 308 | * @return array 接口返回的数据 |
308 | */ | 309 | */ |
309 | - public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin) | 310 | + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin) |
310 | { | 311 | { |
311 | $param = Yohobuy::param(); | 312 | $param = Yohobuy::param(); |
312 | $param['method'] = 'app.Shopping.submit'; | 313 | $param['method'] = 'app.Shopping.submit'; |
313 | - $param['addressId'] = $addressId; | 314 | + $param['address_id'] = $addressId; |
314 | $param['cart_type'] = $cartType; | 315 | $param['cart_type'] = $cartType; |
315 | $param['delivery_time'] = $deliveryTime; | 316 | $param['delivery_time'] = $deliveryTime; |
316 | $param['delivery_way'] = $deliveryWay; | 317 | $param['delivery_way'] = $deliveryWay; |
@@ -324,6 +325,9 @@ class CartData | @@ -324,6 +325,9 @@ class CartData | ||
324 | $param['payment_id'] = $paymentId; | 325 | $param['payment_id'] = $paymentId; |
325 | $param['payment_type'] = $paymentType; | 326 | $param['payment_type'] = $paymentType; |
326 | $param['remark'] = $remark; | 327 | $param['remark'] = $remark; |
328 | + if (!empty($couponCode)) { | ||
329 | + $param['coupon_code'] = $couponCode; | ||
330 | + } | ||
327 | if (!empty($yohoCoin)) { | 331 | if (!empty($yohoCoin)) { |
328 | $param['use_yoho_coin'] = $yohoCoin; | 332 | $param['use_yoho_coin'] = $yohoCoin; |
329 | } | 333 | } |
@@ -15,6 +15,7 @@ var dispatchModeHammer, | @@ -15,6 +15,7 @@ var dispatchModeHammer, | ||
15 | dispatchTimeHammer, | 15 | dispatchTimeHammer, |
16 | $invoice = $('.invoice'), | 16 | $invoice = $('.invoice'), |
17 | $price = $('.price-cal'), | 17 | $price = $('.price-cal'), |
18 | + payType, | ||
18 | priceTmpl = Handlebars.compile($('#tmpl-price').html()); | 19 | priceTmpl = Handlebars.compile($('#tmpl-price').html()); |
19 | 20 | ||
20 | lazyLoad(); | 21 | lazyLoad(); |
@@ -99,23 +100,33 @@ function submitOrder() { | @@ -99,23 +100,33 @@ function submitOrder() { | ||
99 | addressId: orderInfo('addressId'), | 100 | addressId: orderInfo('addressId'), |
100 | cartType: orderInfo('cartType'), | 101 | cartType: orderInfo('cartType'), |
101 | deliveryId: orderInfo('deliveryId') || 1, | 102 | deliveryId: orderInfo('deliveryId') || 1, |
102 | - deliveryTimeId: orderInfo('deliveryTimeId') || 1, | ||
103 | - invoiceText: orderInfo('invoiceText'), | ||
104 | - invoiceType: orderInfo('invoiceType'), | ||
105 | - msg: orderInfo('msg'), | 103 | + deliveryTimeId: orderInfo('deliveryTimeId') || 2, |
104 | + invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), | ||
105 | + invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'), | ||
106 | + msg: $('#msg').find('input').val() || orderInfo('msg'), | ||
106 | paymentTypeId: orderInfo('paymentTypeId'), | 107 | paymentTypeId: orderInfo('paymentTypeId'), |
107 | paymentType: orderInfo('paymentType'), //支付方式 | 108 | paymentType: orderInfo('paymentType'), //支付方式 |
108 | couponCode: orderInfo('couponCode'), | 109 | couponCode: orderInfo('couponCode'), |
109 | yohoCoin: orderInfo('yohoCoin') | 110 | yohoCoin: orderInfo('yohoCoin') |
110 | } | 111 | } |
111 | }).then(function(res) { | 112 | }).then(function(res) { |
113 | + var url; | ||
114 | + | ||
112 | if (!res) { | 115 | if (!res) { |
113 | tip.show('网络出错'); | 116 | tip.show('网络出错'); |
117 | + return; | ||
114 | } | 118 | } |
115 | - if (res.code !== 200) { | ||
116 | - tip.show(res.message || '网络出错'); | 119 | + if (res.code === 200) { |
120 | + if (payType === 2) { | ||
121 | + | ||
122 | + // 货到付款的进入订单页面 | ||
123 | + url = '/home/orderDetail?order_code=' + res.data.order_code; | ||
124 | + } else { | ||
125 | + url = '/home/pay?order_code=' + res.data.order_code; | ||
126 | + } | ||
127 | + window.location.href = url; | ||
117 | } else { | 128 | } else { |
118 | - console.log(1); | 129 | + tip.show(res.messege || '网络出错'); |
119 | } | 130 | } |
120 | }).fail(function() { | 131 | }).fail(function() { |
121 | tip.show('网络出错'); | 132 | tip.show('网络出错'); |
@@ -124,7 +135,7 @@ function submitOrder() { | @@ -124,7 +135,7 @@ function submitOrder() { | ||
124 | 135 | ||
125 | // 界面点击,状态存 cookie | 136 | // 界面点击,状态存 cookie |
126 | if (!orderInfo('addressId')) { | 137 | if (!orderInfo('addressId')) { |
127 | - orderInfo('addressId', $('.address-wrap').data('address-id')); | 138 | + orderInfo('addressId', $('.address-wrap').data('id')); |
128 | } | 139 | } |
129 | 140 | ||
130 | $('.dispatch-mode').on('touchend', 'li', function() { | 141 | $('.dispatch-mode').on('touchend', 'li', function() { |
@@ -166,7 +177,10 @@ $('#msg').find('input').on('blur', function() { | @@ -166,7 +177,10 @@ $('#msg').find('input').on('blur', function() { | ||
166 | }); | 177 | }); |
167 | 178 | ||
168 | $('.pay-mode').on('click', 'li', function() { | 179 | $('.pay-mode').on('click', 'li', function() { |
169 | - orderInfo('paymentTypeId', $(this).data('pay-id')); | ||
170 | - orderInfo('paymentType', $(this).data('pay-type')); | 180 | + var $this = $(this); |
181 | + | ||
182 | + orderInfo('paymentTypeId', $this.data('pay-id')); | ||
183 | + orderInfo('paymentType', $this.data('pay-type')); | ||
184 | + payType = $this.data('pay-type'); | ||
171 | submitOrder(); | 185 | submitOrder(); |
172 | }); | 186 | }); |
1 | {{> layout/header}} | 1 | {{> layout/header}} |
2 | <div class="order-ensure-page yoho-page"> | 2 | <div class="order-ensure-page yoho-page"> |
3 | {{# orderEnsure}} | 3 | {{# orderEnsure}} |
4 | - <a class="address-wrap block" href="/shoppingCart/selectAddress" data-address-id="{{addressId}}"> | 4 | + <a class="address-wrap block" data-id="{{addressId}}" href="/shoppingCart/selectAddress"> |
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> |
@@ -67,16 +67,14 @@ | @@ -67,16 +67,14 @@ | ||
67 | </li> | 67 | </li> |
68 | {{/if}} | 68 | {{/if}} |
69 | 69 | ||
70 | - {{# yohoCoin}} | ||
71 | - <li class="coin" data-yoho-coin="{{.}}"> | ||
72 | - <span class="title">YOHO币</span> | ||
73 | - <span class="desc">可抵用¥{{.}}</span> | ||
74 | - <span class="coin-check"> | ||
75 | - <em>- ¥ {{.}}</em> | ||
76 | - <i class="iconfont checkbox icon-cb-checked"></i> | ||
77 | - </span> | ||
78 | - </li> | ||
79 | - {{/ yohoCoin}} | 70 | + <li class="coin" data-yoho-coin="{{yohoCoin}}"> |
71 | + <span class="title">YOHO币</span> | ||
72 | + <span class="desc">可抵用¥{{yohoCoin}}</span> | ||
73 | + <span class="coin-check"> | ||
74 | + <em>- ¥ {{yohoCoin}}</em> | ||
75 | + <i class="iconfont checkbox icon-cb-checked"></i> | ||
76 | + </span> | ||
77 | + </li> | ||
80 | 78 | ||
81 | {{#if invoice}} | 79 | {{#if invoice}} |
82 | <li class="invoice {{#if needInvoice}}focus{{/if}}"> | 80 | <li class="invoice {{#if needInvoice}}focus{{/if}}"> |
@@ -314,8 +314,9 @@ class ShoppingCartController extends AbstractAction | @@ -314,8 +314,9 @@ class ShoppingCartController extends AbstractAction | ||
314 | $paymentId = $this->post('paymentTypeId', 15); | 314 | $paymentId = $this->post('paymentTypeId', 15); |
315 | $paymentType = $this->post('paymentType', 1); // 默认在线支付 | 315 | $paymentType = $this->post('paymentType', 1); // 默认在线支付 |
316 | $remark = $this->post('msg', null); | 316 | $remark = $this->post('msg', null); |
317 | + $couponCode = $this->post('couponCode', null); | ||
317 | $yohoCoin = $this->post('yohoCoin', 1); | 318 | $yohoCoin = $this->post('yohoCoin', 1); |
318 | - $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin); | 319 | + $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin); |
319 | } | 320 | } |
320 | 321 | ||
321 | if (empty($result)) { | 322 | if (empty($result)) { |
@@ -567,16 +567,28 @@ class CartModel | @@ -567,16 +567,28 @@ class CartModel | ||
567 | * @param int $paymentId 支付方式ID | 567 | * @param int $paymentId 支付方式ID |
568 | * @param int $paymentType 支付类型ID | 568 | * @param int $paymentType 支付类型ID |
569 | * @param string $remark 留言 | 569 | * @param string $remark 留言 |
570 | + * @param string $couponCode 优惠券码 | ||
570 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 | 571 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 |
571 | * @return array 接口返回的数据 | 572 | * @return array 接口返回的数据 |
572 | */ | 573 | */ |
573 | - public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin) | 574 | + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin) |
574 | { | 575 | { |
575 | - $result = array(); | ||
576 | - | ||
577 | - $orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin); | ||
578 | - if ($orderSubRes && isset($orderSubRes['code'])) { | ||
579 | - $result = $orderSubRes; | 576 | + $result = array('code' => 400, 'message' => '出错啦'); |
577 | + | ||
578 | + if (empty($addressId)) { | ||
579 | + $result['code'] = 401; | ||
580 | + $result['message'] = '配送地址不能为空'; | ||
581 | + } elseif (empty($deliveryTime)) { | ||
582 | + $result['code'] = 402; | ||
583 | + $result['message'] = '请选择配送时间'; | ||
584 | + } elseif (empty($deliveryWay)) { | ||
585 | + $result['code'] = 403; | ||
586 | + $result['message'] = '请选择配送方式'; | ||
587 | + } else { | ||
588 | + $orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin); | ||
589 | + if ($orderSubRes && isset($orderSubRes['code'])) { | ||
590 | + $result = $orderSubRes; | ||
591 | + } | ||
580 | } | 592 | } |
581 | 593 | ||
582 | return $result; | 594 | return $result; |
-
Please register or login to post a comment