...
|
...
|
@@ -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();
|
|
|
|
...
|
...
|
@@ -55,9 +59,66 @@ $('.invoice').on('touchend', '.checkbox', function() { |
|
|
}
|
|
|
});
|
|
|
|
|
|
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('网络出错');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function submitOrder() {
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/shoppingCart/orderSub',
|
|
|
data: {
|
|
|
addressId: orderInfo('addressId'),
|
|
|
cartType: orderInfo('cartType'),
|
|
|
deliveryId: orderInfo('deliveryId'),
|
|
|
deliveryTimeId: orderInfo('deliveryTimeId'),
|
|
|
invoiceText: orderInfo('invoiceText'),
|
|
|
invoiceType: orderInfo('invoiceType'),
|
|
|
msg: orderInfo('msg'),
|
|
|
paymentTypeId: orderInfo('paymentTypeId'),
|
|
|
paymentType: orderInfo('paymentType'), //支付方式
|
|
|
couponCode: orderInfo('couponCode'),
|
|
|
yohoCoin: orderInfo('yohoCoin')
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
console.log(res);
|
|
|
}).fail(function() {
|
|
|
tip.show('网络出错');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 界面点击,状态存 cookie
|
|
|
$('.dispatch-mode').on('touchend', 'li', function() {
|
|
|
orderInfo('deliveryId', $(this).data('id'));
|
|
|
orderCompute();
|
|
|
});
|
|
|
|
|
|
$('.dispatch-time').on('touchend', 'li', function() {
|
...
|
...
|
@@ -69,9 +130,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() {
|
...
|
...
|
@@ -92,4 +156,6 @@ $('#msg').find('input').on('blur', function() { |
|
|
|
|
|
$('.pay-mode').on('click', 'li', function() {
|
|
|
orderInfo('paymentTypeId', $(this).data('pay-id'));
|
|
|
orderInfo('paymentType', $(this).data('pay-type'));
|
|
|
submitOrder();
|
|
|
}); |
...
|
...
|
|