Authored by 毕凯

发票抬头 留言 优惠券使用优化

... ... @@ -16,6 +16,7 @@ var dispatchModeHammer,
dispatchTimeHammer,
$invoice = $('.invoice'),
$price = $('.price-cal'),
$couponUse = $('.coupon-use.used'),
payType,
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
queryString = $.queryString(),
... ... @@ -27,6 +28,11 @@ if (window.getUid() !== orderInfo('uid')) {
order.init();
}
if ($couponUse.data('value') !== orderInfo('couponValue')) {
orderInfo('couponCode', null);
orderInfo('couponValue', null);
}
function dispacthTapEvt(e) {
var $cur = $(e.target).closest('li');
... ... @@ -110,9 +116,24 @@ function orderCompute() {
}
function submitOrder() {
if (orderInfo('invoice') && !orderInfo('invoiceText')) {
tip.show('请输入发票抬头');
return;
var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
msg = $('#msg').find('input').val() || orderInfo('msg');
if (orderInfo('invoice')) {
if (!invoiceText) {
tip.show('请输入发票抬头');
return;
}
if (invoiceText.length > 30) {
tip.show('发票抬头不得超过30个汉字');
return;
}
}
if (msg) {
if (msg.length > 40) {
tip.show('留言不得超过40个汉字');
return;
}
}
loading.showLoadingMask();
$.ajax({
... ... @@ -123,9 +144,9 @@ function submitOrder() {
cartType: queryString.cartType || queryString.carttype || 'ordinary',
deliveryId: orderInfo('deliveryId'),
deliveryTimeId: orderInfo('deliveryTimeId'),
invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
invoiceText: invoiceText,
invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'),
msg: $('#msg').find('input').val() || orderInfo('msg'),
msg: msg,
paymentTypeId: orderInfo('paymentTypeId'),
paymentType: orderInfo('paymentType'), //支付方式
couponCode: orderInfo('couponCode'),
... ... @@ -198,7 +219,7 @@ $invoice.find('[name="invoice-title"]').on('blur', function() {
orderInfo('invoiceType', $(this).val());
});
$('#msg').find('input').on('blur', function() {
$('#msg').find('textarea').on('blur', function() {
orderInfo('msg', $(this).val());
});
... ...
... ... @@ -166,19 +166,26 @@
}
}
.block input {
box-sizing: border-box;
margin: pxToRem(20px) 0;
padding: 0 pxToRem(12px);
width: 100%;
height: pxToRem(60px);
color: #444;
background: #efefef;
font-size: pxToRem(16px);
line-height: 1;
outline: 0;
border: 0;
@include border-radius(4px);
.block {
input, textarea {
box-sizing: border-box;
margin: pxToRem(20px) 0;
padding: 0 pxToRem(12px);
width: 100%;
height: pxToRem(60px);
color: #444;
background: #efefef;
font-size: pxToRem(16px);
line-height: 1;
outline: 0;
border: 0;
@include border-radius(4px);
}
textarea {
padding: pxToRem(12px);
height: auto;
resize: none;
}
}
#invoice {
... ...
... ... @@ -50,7 +50,7 @@
</span>
{{#if value}}
<span class="used coupon-use">
<span class="used coupon-use" data-value="{{value}}">
{{value}}
<i class="iconfont">&#xe614;</i>
</span>
... ... @@ -77,7 +77,7 @@
<span class="title">发票</span>
<span class="iconfont checkbox {{#if needInvoice}}icon-cb-checked{{else}}icon-checkbox{{/if}}"></span>
<form id="invoice">
<input type="text" name="invoice-title" value="{{invoiceText}}" placeholder="发票抬头">
<input type="text" name="invoice-title" value="{{invoiceText}}" maxlength="30" placeholder="发票抬头">
<label>
发票类型
<select class="invoice-type" name="invoice-type">
... ... @@ -92,7 +92,7 @@
</ul>
<form id="msg" action="" method="post">
<input type="text" name="msg" value="{{msg}}" placeholder="留言">
<textarea name="msg" rows="2" maxlength="40" placeholder="留言">{{msg}}</textarea>
</form>
</section>
... ...