...
|
...
|
@@ -6,25 +6,22 @@ |
|
|
|
|
|
var $ = require('jquery'),
|
|
|
lazyLoad = require('yoho.lazyload'),
|
|
|
Hammer = require('yoho.hammer'),
|
|
|
Handlebars = require('yoho.handlebars'),
|
|
|
tip = require('../plugin/tip'),
|
|
|
loading = require('../plugin/loading'),
|
|
|
order = require('./order-info');
|
|
|
|
|
|
var dispatchModeHammer,
|
|
|
dispatchTimeHammer,
|
|
|
$invoice = $('.invoice'),
|
|
|
$price = $('.price-cal'),
|
|
|
var $invoice = $('.invoice'),
|
|
|
$couponUse = $('.coupon-use.used'),
|
|
|
$addressWrap = $('.address-wrap'),
|
|
|
$coinCheck = $('.coin-check'),
|
|
|
$coinUsed = $('.coin .used'),
|
|
|
$subBlock = $('.sub-block'),
|
|
|
payType,
|
|
|
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
|
|
|
queryString = $.queryString(),
|
|
|
orderInfo = order.orderInfo,
|
|
|
isSubmiting;
|
|
|
isSubmiting,
|
|
|
dispatchInfo,
|
|
|
total;
|
|
|
|
|
|
require('../common');
|
|
|
|
...
|
...
|
@@ -71,7 +68,7 @@ isLimitGood() && (function() { |
|
|
|
|
|
var data = getQueryParam();
|
|
|
|
|
|
data['type'] = 'limitcode';
|
|
|
data.type = 'limitcode';
|
|
|
|
|
|
a.push(data);
|
|
|
orderInfo('skuList', JSON.stringify(a));
|
...
|
...
|
@@ -82,42 +79,36 @@ if (queryString.cartType || queryString.carttype || !orderInfo('cartType')) { |
|
|
orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary');
|
|
|
}
|
|
|
|
|
|
function dispacthTapEvt(e) {
|
|
|
var $cur = $(e.target).closest('li');
|
|
|
// function dispacthTapEvt(e) {
|
|
|
// var $cur = $(e.target).closest('li');
|
|
|
|
|
|
if ($cur.length === 0 || $cur.hasClass('chosed')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$cur.siblings('li.chosed').removeClass('chosed');
|
|
|
$cur.addClass('chosed');
|
|
|
}
|
|
|
|
|
|
dispatchModeHammer = new Hammer(document.getElementsByClassName('dispatch-mode')[0]);
|
|
|
dispatchModeHammer.on('tap', dispacthTapEvt);
|
|
|
// if ($cur.length === 0 || $cur.hasClass('chosed')) {
|
|
|
// return;
|
|
|
// }
|
|
|
|
|
|
dispatchTimeHammer = new Hammer(document.getElementsByClassName('dispatch-time')[0]);
|
|
|
dispatchTimeHammer.on('tap', dispacthTapEvt);
|
|
|
// $cur.siblings('li.chosed').removeClass('chosed');
|
|
|
// $cur.addClass('chosed');
|
|
|
// }
|
|
|
|
|
|
$('.checkbox').on('touchstart', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if ($this.hasClass('icon-cb-checked')) {
|
|
|
$this.removeClass('icon-cb-checked').addClass('icon-checkbox');
|
|
|
if ($this.hasClass('icon-cb-radio')) {
|
|
|
$this.removeClass('icon-cb-radio').addClass('icon-radio');
|
|
|
return;
|
|
|
}
|
|
|
if ($this.hasClass('icon-checkbox')) {
|
|
|
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
|
|
|
if ($this.hasClass('icon-radio')) {
|
|
|
$this.removeClass('icon-radio').addClass('icon-cb-radio');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$invoice.on('touchend', '.checkbox', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if ($this.hasClass('icon-cb-checked')) {
|
|
|
if ($this.hasClass('icon-cb-radio')) {
|
|
|
$invoice.addClass('focus');
|
|
|
}
|
|
|
if ($this.hasClass('icon-checkbox')) {
|
|
|
if ($this.hasClass('icon-radio')) {
|
|
|
$invoice.removeClass('focus');
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -138,12 +129,10 @@ function orderCompute() { |
|
|
skuList: isLimitGood() ? orderInfo('skuList') : undefined
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
var priceHtml;
|
|
|
|
|
|
if ($.type(res) !== 'object') {
|
|
|
window.location.reload();
|
|
|
} else {
|
|
|
if (res.last_order_amount) {
|
|
|
if (typeof res.last_order_amount !== undefined) {
|
|
|
res.last_order_amount = (+res.last_order_amount).toFixed(2);
|
|
|
}
|
|
|
if (res.use_yoho_coin) {
|
...
|
...
|
@@ -152,12 +141,18 @@ function orderCompute() { |
|
|
$coinCheck.find('em').show();
|
|
|
$coinUsed.show();
|
|
|
}
|
|
|
priceHtml = priceTmpl({
|
|
|
cartPayData: res.promotion_formula_list,
|
|
|
price: res.last_order_amount
|
|
|
});
|
|
|
|
|
|
$price.html(priceHtml);
|
|
|
total = '';
|
|
|
if (res.promotion_formula_list) {
|
|
|
$.each(res.promotion_formula_list, function(index, value) {
|
|
|
total += '<li>' +
|
|
|
'<p>' + value.promotion + '</p>' +
|
|
|
'<span>' + value.promotion_amount + '</span>' +
|
|
|
'</li>';
|
|
|
});
|
|
|
$('.price-cost span').html('¥' + res.last_order_amount);
|
|
|
$('.bill span').html('¥' + res.last_order_amount);
|
|
|
$('.total').html(total);
|
|
|
}
|
|
|
}
|
|
|
}).fail(function() {
|
|
|
window.location.reload();
|
...
|
...
|
@@ -170,10 +165,6 @@ function submitOrder() { |
|
|
var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
|
|
|
msg = $('#msg').find('input').val() || orderInfo('msg');
|
|
|
|
|
|
if (orderInfo('deliveryId') === 2 && !$addressWrap.data('support')) {
|
|
|
tip.show('当前地址不支持顺丰快递');
|
|
|
return;
|
|
|
}
|
|
|
if (isSubmiting) {
|
|
|
return false;
|
|
|
}
|
...
|
...
|
@@ -248,17 +239,8 @@ if (!orderInfo('addressId')) { |
|
|
}
|
|
|
|
|
|
$('.dispatch-mode').on('touchend', 'li', function() {
|
|
|
var $defaultMode = $('.dispatch-mode [data-id="1"]');
|
|
|
|
|
|
if (!$addressWrap.data('support') && $(this).data('id') === 2) {
|
|
|
dispacthTapEvt({
|
|
|
target: $defaultMode
|
|
|
});
|
|
|
tip.show('当前地址不支持顺丰快递');
|
|
|
} else {
|
|
|
orderInfo('deliveryId', $(this).data('id'));
|
|
|
orderCompute();
|
|
|
}
|
|
|
orderInfo('deliveryId', $(this).data('id'));
|
|
|
orderCompute();
|
|
|
});
|
|
|
|
|
|
$('.dispatch-time').on('touchend', 'li', function() {
|
...
|
...
|
@@ -268,7 +250,7 @@ $('.dispatch-time').on('touchend', 'li', function() { |
|
|
$('.coin').on('touchend', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if ($this.find('.checkbox').hasClass('icon-cb-checked')) {
|
|
|
if ($this.find('.checkbox').hasClass('icon-cb-radio')) {
|
|
|
orderInfo('yohoCoin', $this.data('yoho-coin'));
|
|
|
$this.find('.can-use').hide();
|
|
|
} else {
|
...
|
...
|
@@ -283,7 +265,7 @@ $('.coin').on('touchend', function() { |
|
|
$invoice.on('touchend', '.checkbox', function(e) {
|
|
|
var $this = $(this);
|
|
|
|
|
|
orderInfo('invoice', $this.hasClass('icon-cb-checked'));
|
|
|
orderInfo('invoice', $this.hasClass('icon-cb-radio'));
|
|
|
e.preventDefault();
|
|
|
e.stopPropagation();
|
|
|
});
|
...
|
...
|
@@ -304,9 +286,61 @@ $('.pay-mode').on('click', 'li', function() { |
|
|
orderInfo('paymentTypeId', $this.data('pay-id'));
|
|
|
orderInfo('paymentType', $this.data('pay-type'));
|
|
|
payType = $this.data('pay-type');
|
|
|
submitOrder();
|
|
|
});
|
|
|
|
|
|
$('form').on('submit', function() {
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
// xwg 2016/3/21 13:22
|
|
|
$('.dispatch').on('touchend', 'h3', function() {
|
|
|
if ($(this).siblings('ul').is(':hidden')) {
|
|
|
$('.dispatch h3').removeClass('border-none');
|
|
|
$(this).addClass('border-none');
|
|
|
$('.down').removeClass('hide');
|
|
|
$('.up').addClass('hide');
|
|
|
$('.up', this).removeClass('hide');
|
|
|
$('.down', this).addClass('hide');
|
|
|
$('.dispatch ul').hide();
|
|
|
$(this).siblings('ul').show();
|
|
|
} else {
|
|
|
$(this).removeClass('border-none');
|
|
|
$('.down', this).removeClass('hide');
|
|
|
$('.up', this).addClass('hide');
|
|
|
$(this).siblings('ul').hide();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$subBlock.on('touchstart', 'li', function() {
|
|
|
$.each($(this).parents('ul').find('i'), function() {
|
|
|
$(this).parents('ul').find('i').removeClass('icon-cb-radio').addClass('icon-radio');
|
|
|
});
|
|
|
$(this).parents('ul').hide();
|
|
|
$('.down').removeClass('hide');
|
|
|
$('.up').addClass('hide');
|
|
|
$('.dispatch h3').removeClass('border-none');
|
|
|
dispatchInfo = $(this).find('span').html();
|
|
|
$(this).parents('.sub-block').find('h3 span').html(dispatchInfo);
|
|
|
if ($(this).find('i').hasClass('icon-cb-radio')) {
|
|
|
$(this).find('i').addClass('icon-radio');
|
|
|
} else if ($(this).find('i').hasClass('icon-radio')) {
|
|
|
$(this).find('i').addClass('icon-cb-radio');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
$('.bill a').on('touchstart', function() {
|
|
|
orderInfo('paymentTypeId', $('.delivery-id .icon-cb-radio').data('id'));
|
|
|
orderInfo('paymentType', $('.payment-type .icon-cb-radio').data('id'));
|
|
|
|
|
|
payType = $('.payment-type .icon-cb-radio').data('id');
|
|
|
submitOrder();
|
|
|
});
|
|
|
|
|
|
function phoneHidden(phone) {
|
|
|
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
|
|
|
}
|
|
|
|
|
|
$('.info-phone').html(phoneHidden($('.info-phone').html()));
|
|
|
|
|
|
|
...
|
...
|
|