diff --git a/static/js/shopping-cart/order-ensure.js b/static/js/shopping-cart/order-ensure.js index 432a450..44a1ac9 100644 --- a/static/js/shopping-cart/order-ensure.js +++ b/static/js/shopping-cart/order-ensure.js @@ -6,9 +6,12 @@ var $ = require('jquery'), lazyLoad = require('yoho.lazyload'), - Hammer = require('yoho.hammer'); + Hammer = require('yoho.hammer'), + orderInfo = require('./order-info').orderInfo; -var dispatchModeHammer, dispatchTimeHammer; +var dispatchModeHammer, + dispatchTimeHammer, + $invoice = $('.invoice'); lazyLoad(); @@ -51,3 +54,42 @@ $('.invoice').on('touchend', '.checkbox', function() { $('.invoice').removeClass('focus'); } }); + +// 界面点击,状态存 cookie +$('.dispatch-mode').on('touchend', 'li', function() { + orderInfo('deliveryId', $(this).data('id')); +}); + +$('.dispatch-time').on('touchend', 'li', function() { + orderInfo('deliveryTimeId', $(this).data('id')); +}); + +$('.coin').on('touchend', function() { + var $this = $(this); + + if ($this.find('.checkbox').hasClass('icon-cb-checked')) { + orderInfo('yohoCoin', $this.data('yoho-coin')); + } else { + orderInfo('yohoCoin', 0); + } +}); + +$invoice.on('touchend', function() { + var $this = $(this); + + orderInfo('invoice', $this.find('.checkbox').hasClass('icon-cb-checked')); +}); + +$invoice.find('[name="invoice-title"]').on('blur', function() { + orderInfo('invoiceText', $(this).val()); +}).end().find('.invoice-type').on('change', function() { + orderInfo('invoiceType', $(this).val()); +}); + +$('#msg').find('input').on('blur', function() { + orderInfo('msg', $(this).val()); +}); + +$('.pay-mode').on('click', 'li', function() { + orderInfo('paymentTypeId', $(this).data('pay-id')); +}); diff --git a/static/js/shopping-cart/order-info.js b/static/js/shopping-cart/order-info.js index 7bdc61d..6defde2 100644 --- a/static/js/shopping-cart/order-info.js +++ b/static/js/shopping-cart/order-info.js @@ -3,12 +3,11 @@ * @author: bikai<kai.bi@yoho.cn> * @date: 2015/12/14 */ -var info = window.cookie('order-info'), - orderInfo; +var info = window.cookie('order-info'); // info 必须是 JSON 字符串 try { - info = JSON.parse(orderInfo); + info = JSON.parse(info); } catch (e) { info = {}; } diff --git a/static/js/shopping-cart/select-coupon.js b/static/js/shopping-cart/select-coupon.js index ee366c5..3c65b14 100644 --- a/static/js/shopping-cart/select-coupon.js +++ b/static/js/shopping-cart/select-coupon.js @@ -16,14 +16,15 @@ var page = 1, isGetData; var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()), - conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()); + conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()), + $newCoupon = $('#new-coupon'); ellipsis.init(); -$('#search-coupon').on('submit', function() { +$newCoupon.on('submit', function() { $.ajax({ method: 'POST', - url: '/shoppingCart/coupon', + url: '/shoppingCart/couponSearch', data: $(this).serialize() }).then(function(res) { if (res.code === 200) { @@ -39,8 +40,19 @@ $('#search-coupon').on('submit', function() { return false; }); -$('#coupon-list').on('touchend', 'employ-main', function() { - orderInfo('couponCode', $(this).data('coupon-code')); +$('#coupon-list').on('touchend', '.employ-main', function() { + var $this = $(this); + + orderInfo('couponCode', $this.data('coupon-code')); + orderInfo('couponValue', $this.data('coupon-value')); +}); + +$newCoupon.find('input').on('input', function() { + if ($(this).val() !== '') { + $newCoupon.find('.submit').css('background', '#444'); + } else { + $newCoupon.find('.submit').css('background', '#b0b0b0'); + } }); function getCouponHandle(coupons) { @@ -117,7 +129,7 @@ function getCouponDate() { $.ajax({ type: 'POST', - url: '/home/couponData', + url: '/shoppingCart/couponList', dataType: 'json', data: { page: page diff --git a/static/sass/shopping-cart/_select-coupon.scss b/static/sass/shopping-cart/_select-coupon.scss index 6643372..ac42694 100644 --- a/static/sass/shopping-cart/_select-coupon.scss +++ b/static/sass/shopping-cart/_select-coupon.scss @@ -2,7 +2,7 @@ margin-top: pxToRem(30px); margin-bottom: pxToRem(30px); - #search-coupon { + #new-coupon { margin-bottom: pxToRem(30px); padding-left: pxToRem(30px); padding-right: pxToRem(30px); diff --git a/template/m.yohobuy.com/actions/index/shoppingCart/order-ensure.phtml b/template/m.yohobuy.com/actions/index/shoppingCart/order-ensure.phtml index 39bc9af..a055e09 100644 --- a/template/m.yohobuy.com/actions/index/shoppingCart/order-ensure.phtml +++ b/template/m.yohobuy.com/actions/index/shoppingCart/order-ensure.phtml @@ -5,7 +5,7 @@ <p class="infos"> 收货地址 <span class="per-info">{{name}} {{phoneNum}}</span> - <span class="address">{{address}}</span> + <span class="address">{{area}} {{address}}</span> </p> <span class="iconfont"></span> </a> @@ -15,7 +15,7 @@ <h3 class="title">配送方式</h3> <ul class="dispatch-mode clearfix"> {{#each dispatchMode}} - <li {{#if @first}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li> + <li {{#if isSelected}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li> {{/each}} </ul> </div> @@ -24,7 +24,7 @@ <h3 class="title">送货时间</h3> <ul class="dispatch-time clearfix"> {{#each dispatchTime}} - <li {{#if @first}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li> + <li {{#if isSelected}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li> {{/each}} </ul> </div> @@ -52,14 +52,14 @@ </span> {{/if}} - {{#if notUsed}} - <span class="not-used coupon-use"> - 未使用 + {{#if value}} + <span class="used coupon-use"> + -¥{{value}} <i class="iconfont"></i> </span> {{^}} - <span class="used coupon-use"> - -¥{{value}} + <span class="not-used coupon-use"> + 未使用 <i class="iconfont"></i> </span> {{/if}} @@ -68,7 +68,7 @@ {{/ coupon}} {{# yohoCoin}} - <li class="coin"> + <li class="coin" data-yoho-coin="{{.}}"> <span class="title">YOHO币</span> <span class="desc">可抵用¥{{.}}</span> <span class="coin-check"> diff --git a/template/m.yohobuy.com/actions/index/shoppingCart/select-address.phtml b/template/m.yohobuy.com/actions/index/shoppingCart/select-address.phtml index 0e4c24f..fc51ca6 100644 --- a/template/m.yohobuy.com/actions/index/shoppingCart/select-address.phtml +++ b/template/m.yohobuy.com/actions/index/shoppingCart/select-address.phtml @@ -2,7 +2,7 @@ <div class="my-address-page select-address-page yoho-page"> <div class="page-wrap"> {{# address}} - <a class="address-item" data-address-id="{{address_id}}" href="/shoppingCart/orderEnsure?address_id={{address_id}}"> + <a class="address-item" data-address-id="{{address_id}}" href="/shoppingCart/orderEnsure"> <span class="name">{{consignee}}</span> <span class="tel">{{mobile}}</span> <p class="address-info">{{area}} {{address}}</p> diff --git a/template/m.yohobuy.com/actions/index/shoppingCart/select-coupon.phtml b/template/m.yohobuy.com/actions/index/shoppingCart/select-coupon.phtml index 52ceb25..1a3377e 100644 --- a/template/m.yohobuy.com/actions/index/shoppingCart/select-coupon.phtml +++ b/template/m.yohobuy.com/actions/index/shoppingCart/select-coupon.phtml @@ -1,6 +1,6 @@ {{> layout/header}} <div class="yoho-page select-coupon-page my-coupon-page"> - <form id="search-coupon" method="POST" action=""> + <form id="new-coupon" method="POST" action=""> <input type="text" name="couponCode" value="" placeholder="输入优惠券码"> <button type="submit" class="submit">确定</button> </form> @@ -11,9 +11,9 @@ <script id="tmpl-coupon" type="text/tmpl"> \{{#coupons}} \{{^ notAvailable}} - <a class="employ-main" data-coupon-code="{{ coupon_code}}" href="/shoppingCart/orderEnsure?coupon_code={{ coupon_code}}"> - <span>\{{ money}}</span> - <p class="coupon-name">\{{ coupon_name}}</p> + <a class="employ-main" data-coupon-code="\{{ couponCode}}" data-coupon-value="\{{ couponValue}}" href="/shoppingCart/orderEnsure"> + <span>\{{ couponValue}}</span> + <p class="coupon-name">\{{ couponDetailInfomation}}</p> <p>有效期:\{{ couponValidity}}</p> </a> \{{/ notAvailable}} @@ -22,8 +22,8 @@ <script id="tmpl-coupon-not-avaliable" type="text/tmpl"> \{{# notAvailableCoupons}} <div class="employ-main not-avaliable"> - <span>\{{ money}}</span> - <p class="coupon-name">\{{ coupon_name}}</p> + <span>\{{ couponValue}}</span> + <p class="coupon-name">\{{ couponDetailInfomation}}</p> <p>有效期:\{{ couponValidity}}</p> </div> \{{/ notAvailableCoupons}} diff --git a/yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php b/yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php index 0b5b14c..58707dd 100644 --- a/yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php +++ b/yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php @@ -149,7 +149,7 @@ class ShoppingCartController extends AbstractAction $this->setNavHeader('购物车'); $cartType = $this->post('cartType', 'ordinary'); - $cookieData = $this->getCookie('orderInfo', null); + $cookieData = $this->getCookie('order-info', null); $uid = $this->getUid(true); $data = array( 'orderEnsurePage' => true, diff --git a/yohobuy/m.yohobuy.com/application/models/Index/Cart.php b/yohobuy/m.yohobuy.com/application/models/Index/Cart.php index 1bb44bf..e1d7c61 100644 --- a/yohobuy/m.yohobuy.com/application/models/Index/Cart.php +++ b/yohobuy/m.yohobuy.com/application/models/Index/Cart.php @@ -319,7 +319,8 @@ class CartModel $result['addressId'] = isset($address['address_id']) ? $address['address_id'] : $payReturn['delivery_address']['address_id']; $result['name'] = isset($address['consignee']) ? $address['consignee'] : $payReturn['delivery_address']['consignee']; $result['phoneNum'] = isset($address['mobile']) ? $address['mobile'] : $payReturn['delivery_address']['mobile']; - $result['address'] = isset($address['address']) ? $address['address'] : $payReturn['delivery_address']['address']; + $result['area'] = isset($address['area']) ? $address['area'] : $payReturn['delivery_address']['area']; + $result['address'] = isset($address['address']) ? $address['address'] : $payReturn['delivery_address']['address']; $result['isSupport'] = ($payReturn['delivery_address']['is_support'] === 'Y'); } @@ -330,9 +331,11 @@ class CartModel $oneDeliv = array(); $oneDeliv['id'] = $val['delivery_way_id']; $oneDeliv['name'] = $val['delivery_way_name']; - $oneDeliv['default'] = ($val['default'] === 'Y'); + isset($orderInfo['deliveryId']) && $orderInfo['deliveryId'] === $oneDeliv['id'] && $oneDeliv['isSelected'] = true; + !isset($oneDeliv['isSelected']) && $oneDeliv['isSelected'] = ($val['default'] === 'Y'); + $result['dispatchMode'][] = $oneDeliv; } } @@ -411,7 +414,7 @@ class CartModel // 优惠券数据 $coupons = array('notUsed' => true); - !empty($orderCompute['coupon_amount']) && $coupons['notUsed'] = $orderInfo['couponName']; + !empty($orderCompute['coupon_amount']) && $coupons['value'] = $orderInfo['couponValue']; $coupons += self::getCouponList($uid, 0, 1, true); $result['coupon'] = $coupons; } @@ -491,7 +494,7 @@ class CartModel $val['notAvailable'] = true; } } - !empty($couponArr) && $result['coupons'] = $couponArr; + !empty($couponArr) && $result = $couponArr; } }