...
|
...
|
@@ -13,6 +13,7 @@ var $pdUsed = $('#pay-delivery-used'); |
|
|
var $balance = $('#balance-detail');
|
|
|
|
|
|
var couponsTpl = Hbs.compile($('#coupons-tpl').html());
|
|
|
var coinTpl = Hbs.compile($('#yoho-coin-tpl').html());
|
|
|
var promotionTpl = Hbs.compile($('#promotion-list-tpl').html());
|
|
|
|
|
|
var $coin = $('#coin-used');
|
...
|
...
|
@@ -58,16 +59,19 @@ function updateUsedPdShow(info) { |
|
|
}
|
|
|
|
|
|
// 订单计算
|
|
|
function compute() {
|
|
|
var coinUsed = $coin.data('coin');
|
|
|
// 传有货币数量则使用有货币,否者不使用,更改订单总价有货币使用数量重置为0
|
|
|
function compute(coin) {
|
|
|
var d = {
|
|
|
cartType: window.queryString().type,
|
|
|
deliveryWay: $('input[name="delivery-way-radio"]:checked').val(),
|
|
|
paymentType: $('#payment-way').data('id'),
|
|
|
coin: coinUsed ? parseInt(coinUsed, 10) : 0
|
|
|
coin: coin ? parseInt(coin, 10) : 0
|
|
|
};
|
|
|
var couponCode = $('#coupons-sure').data('coupons');
|
|
|
|
|
|
|
|
|
$coin.data('coin', d.coin);
|
|
|
|
|
|
if (couponCode) {
|
|
|
d.couponCode = couponCode;
|
|
|
}
|
...
|
...
|
@@ -97,6 +101,9 @@ function compute() { |
|
|
|
|
|
res = data.data;
|
|
|
|
|
|
// update yoho coin using
|
|
|
$('#using-coin-cont').html(coinTpl(res));
|
|
|
|
|
|
// update last order amount
|
|
|
$('#sum-row em').html(res.last_order_amount);
|
|
|
|
...
|
...
|
@@ -170,7 +177,7 @@ if ($('#use-coupons').length) { |
|
|
|
|
|
// 有货币
|
|
|
if ($coin) {
|
|
|
$coin.data($coin.data()); // 防止人为更改有货币使用数量
|
|
|
$coin.data($coin.data()); // 防止人为页面更改有货币使用数量
|
|
|
}
|
|
|
|
|
|
$('#use-coin, #coin-sure, #coin-cancel').click(function() {
|
...
|
...
|
@@ -185,10 +192,8 @@ $coinSure.click(function() { |
|
|
return;
|
|
|
}
|
|
|
|
|
|
$coin.data('coin', data.max);
|
|
|
|
|
|
// coin change trigger compute
|
|
|
compute();
|
|
|
compute(data.max);
|
|
|
});
|
|
|
|
|
|
$('#coin-cancel').click(function() {
|
...
|
...
|
@@ -197,7 +202,6 @@ $('#coin-cancel').click(function() { |
|
|
if (data.coin * 1 === 0) {
|
|
|
return;
|
|
|
}
|
|
|
$coin.data('coin', 0);
|
|
|
|
|
|
// coin cancel trigger compute
|
|
|
compute();
|
...
|
...
|
@@ -205,7 +209,7 @@ $('#coin-cancel').click(function() { |
|
|
|
|
|
// 结算信息列表中修改有货币按钮
|
|
|
$('.balance-detail').on('click', '.modify-coin', function() {
|
|
|
$('.coin-trigger').filter('.use-coin').addClass('hide').end().filter('.using-coin').removeClass('hide');
|
|
|
$('#use-coin').trigger('click');
|
|
|
});
|
|
|
|
|
|
// delivery way change trigger compute
|
...
|
...
|
|