...
|
...
|
@@ -7,11 +7,15 @@ |
|
|
var $ = require('jquery'),
|
|
|
lazyLoad = require('yoho.lazyload'),
|
|
|
Hammer = require('yoho.hammer'),
|
|
|
Handlebars = require('yoho.handlebars'),
|
|
|
tip = require('../plugin/tip'),
|
|
|
orderInfo = require('./order-info').orderInfo;
|
|
|
|
|
|
var dispatchModeHammer,
|
|
|
dispatchTimeHammer,
|
|
|
$invoice = $('.invoice');
|
|
|
$invoice = $('.invoice'),
|
|
|
$price = $('.price-cal'),
|
|
|
priceTmpl = Handlebars.compile($('#tmpl-price').html());
|
|
|
|
|
|
lazyLoad();
|
|
|
|
...
|
...
|
@@ -26,6 +30,38 @@ function dispacthTapEvt(e) { |
|
|
$cur.addClass('chosed');
|
|
|
}
|
|
|
|
|
|
function orderCompute() {
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/shoppingCart/orderCompute',
|
|
|
data: {
|
|
|
cartType: orderInfo('cartType'),
|
|
|
deliveryId: orderInfo('deliveryId'),
|
|
|
paymentTypeId: orderInfo('paymentTypeId'),
|
|
|
couponCode: orderInfo('couponCode'),
|
|
|
yohoCoin: orderInfo('yohoCoin')
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
var priceHtml;
|
|
|
|
|
|
if (!res) {
|
|
|
tip.show('网络出错');
|
|
|
} else {
|
|
|
priceHtml = priceTmpl({
|
|
|
sumPrice: res.order_amount,
|
|
|
salePrice: res.discount_amount,
|
|
|
freight: res.promotion_formula_list[1].promotion_amount,
|
|
|
yohoCoin: res.use_yoho_coin,
|
|
|
price: res.last_order_amount
|
|
|
});
|
|
|
|
|
|
$price.html(priceHtml);
|
|
|
}
|
|
|
}).fail(function() {
|
|
|
tip.show('网络出错');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
dispatchModeHammer = new Hammer(document.getElementsByClassName('dispatch-mode')[0]);
|
|
|
dispatchModeHammer.on('tap', dispacthTapEvt);
|
|
|
|
...
|
...
|
@@ -58,6 +94,7 @@ $('.invoice').on('touchend', '.checkbox', function() { |
|
|
// 界面点击,状态存 cookie
|
|
|
$('.dispatch-mode').on('touchend', 'li', function() {
|
|
|
orderInfo('deliveryId', $(this).data('id'));
|
|
|
orderCompute();
|
|
|
});
|
|
|
|
|
|
$('.dispatch-time').on('touchend', 'li', function() {
|
...
|
...
|
@@ -69,9 +106,12 @@ $('.coin').on('touchend', function() { |
|
|
|
|
|
if ($this.find('.checkbox').hasClass('icon-cb-checked')) {
|
|
|
orderInfo('yohoCoin', $this.data('yoho-coin'));
|
|
|
$this.find('.coin-check em').show();
|
|
|
} else {
|
|
|
orderInfo('yohoCoin', 0);
|
|
|
$this.find('.coin-check em').hide();
|
|
|
}
|
|
|
orderCompute();
|
|
|
});
|
|
|
|
|
|
$invoice.on('touchend', function() {
|
...
|
...
|
|