Authored by 毕凯

赠加 cookie 操作

... ... @@ -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'));
});
... ...
... ... @@ -41,7 +41,10 @@ $newCoupon.on('submit', function() {
});
$('#coupon-list').on('touchend', '.employ-main', function() {
orderInfo('couponCode', $(this).data('coupon-code'));
var $this = $(this);
orderInfo('couponCode', $this.data('coupon-code'));
orderInfo('couponValue', $this.data('coupon-value'));
});
$newCoupon.find('input').on('input', function() {
... ...
... ... @@ -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">&#xe614;</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">&#xe614;</i>
</span>
{{^}}
<span class="used coupon-use">
{{value}}
<span class="not-used coupon-use">
未使用
<i class="iconfont">&#xe614;</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">
... ...
... ... @@ -11,7 +11,7 @@
<script id="tmpl-coupon" type="text/tmpl">
\{{#coupons}}
\{{^ notAvailable}}
<a class="employ-main" data-coupon-code="\{{ couponCode}}" href="/shoppingCart/orderEnsure">
<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>
... ...
... ... @@ -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;
}
}
... ... @@ -390,7 +393,7 @@ class CartModel
$sumPrice = isset($orderCompute['order_amount']) ? $orderCompute['order_amount'] : $payReturn['shopping_cart_data']['order_amount'];
$salePrice = isset($orderCompute['discount_amount']) ? $orderCompute['discount_amount'] : $payReturn['shopping_cart_data']['discount_amount'];
$price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount'];
$freight = isset($orderCompute['promotion_formula_list']['promotion_amount']) ? $orderCompute['promotion_formula_list']['promotion_amount'] : $payReturn['shopping_cart_data']['promotion_formula_list']['promotion_amount'];
$freight = isset($orderCompute['promotion_formula_list']['promotion_amount']) ? $orderCompute['promotion_formula_list']['promotion_amount'] : $payReturn['shopping_cart_data']['promotion_formula_list'][1]['promotion_amount'];
$result['sumPrice'] = Helpers::transPrice($sumPrice);
$result['salePrice'] = Helpers::transPrice($salePrice);
$result['price'] = Helpers::transPrice($price);
... ... @@ -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;
}
... ...