Authored by 毕凯

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

@@ -16,6 +16,7 @@ var dispatchModeHammer, @@ -16,6 +16,7 @@ var dispatchModeHammer,
16 dispatchTimeHammer, 16 dispatchTimeHammer,
17 $invoice = $('.invoice'), 17 $invoice = $('.invoice'),
18 $price = $('.price-cal'), 18 $price = $('.price-cal'),
  19 + $couponUse = $('.coupon-use.used'),
19 payType, 20 payType,
20 priceTmpl = Handlebars.compile($('#tmpl-price').html()), 21 priceTmpl = Handlebars.compile($('#tmpl-price').html()),
21 queryString = $.queryString(), 22 queryString = $.queryString(),
@@ -27,6 +28,11 @@ if (window.getUid() !== orderInfo('uid')) { @@ -27,6 +28,11 @@ if (window.getUid() !== orderInfo('uid')) {
27 order.init(); 28 order.init();
28 } 29 }
29 30
  31 +if ($couponUse.data('value') !== orderInfo('couponValue')) {
  32 + orderInfo('couponCode', null);
  33 + orderInfo('couponValue', null);
  34 +}
  35 +
30 function dispacthTapEvt(e) { 36 function dispacthTapEvt(e) {
31 var $cur = $(e.target).closest('li'); 37 var $cur = $(e.target).closest('li');
32 38
@@ -110,10 +116,25 @@ function orderCompute() { @@ -110,10 +116,25 @@ function orderCompute() {
110 } 116 }
111 117
112 function submitOrder() { 118 function submitOrder() {
113 - if (orderInfo('invoice') && !orderInfo('invoiceText')) { 119 + var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
  120 + msg = $('#msg').find('input').val() || orderInfo('msg');
  121 +
  122 + if (orderInfo('invoice')) {
  123 + if (!invoiceText) {
114 tip.show('请输入发票抬头'); 124 tip.show('请输入发票抬头');
115 return; 125 return;
116 } 126 }
  127 + if (invoiceText.length > 30) {
  128 + tip.show('发票抬头不得超过30个汉字');
  129 + return;
  130 + }
  131 + }
  132 + if (msg) {
  133 + if (msg.length > 40) {
  134 + tip.show('留言不得超过40个汉字');
  135 + return;
  136 + }
  137 + }
117 loading.showLoadingMask(); 138 loading.showLoadingMask();
118 $.ajax({ 139 $.ajax({
119 method: 'POST', 140 method: 'POST',
@@ -123,9 +144,9 @@ function submitOrder() { @@ -123,9 +144,9 @@ function submitOrder() {
123 cartType: queryString.cartType || queryString.carttype || 'ordinary', 144 cartType: queryString.cartType || queryString.carttype || 'ordinary',
124 deliveryId: orderInfo('deliveryId'), 145 deliveryId: orderInfo('deliveryId'),
125 deliveryTimeId: orderInfo('deliveryTimeId'), 146 deliveryTimeId: orderInfo('deliveryTimeId'),
126 - invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), 147 + invoiceText: invoiceText,
127 invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'), 148 invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'),
128 - msg: $('#msg').find('input').val() || orderInfo('msg'), 149 + msg: msg,
129 paymentTypeId: orderInfo('paymentTypeId'), 150 paymentTypeId: orderInfo('paymentTypeId'),
130 paymentType: orderInfo('paymentType'), //支付方式 151 paymentType: orderInfo('paymentType'), //支付方式
131 couponCode: orderInfo('couponCode'), 152 couponCode: orderInfo('couponCode'),
@@ -198,7 +219,7 @@ $invoice.find('[name="invoice-title"]').on('blur', function() { @@ -198,7 +219,7 @@ $invoice.find('[name="invoice-title"]').on('blur', function() {
198 orderInfo('invoiceType', $(this).val()); 219 orderInfo('invoiceType', $(this).val());
199 }); 220 });
200 221
201 -$('#msg').find('input').on('blur', function() { 222 +$('#msg').find('textarea').on('blur', function() {
202 orderInfo('msg', $(this).val()); 223 orderInfo('msg', $(this).val());
203 }); 224 });
204 225
@@ -166,7 +166,8 @@ @@ -166,7 +166,8 @@
166 } 166 }
167 } 167 }
168 168
169 - .block input { 169 + .block {
  170 + input, textarea {
170 box-sizing: border-box; 171 box-sizing: border-box;
171 margin: pxToRem(20px) 0; 172 margin: pxToRem(20px) 0;
172 padding: 0 pxToRem(12px); 173 padding: 0 pxToRem(12px);
@@ -180,6 +181,12 @@ @@ -180,6 +181,12 @@
180 border: 0; 181 border: 0;
181 @include border-radius(4px); 182 @include border-radius(4px);
182 } 183 }
  184 + textarea {
  185 + padding: pxToRem(12px);
  186 + height: auto;
  187 + resize: none;
  188 + }
  189 + }
183 190
184 #invoice { 191 #invoice {
185 border-top: 1px solid #f7f7f7; 192 border-top: 1px solid #f7f7f7;
@@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
50 </span> 50 </span>
51 51
52 {{#if value}} 52 {{#if value}}
53 - <span class="used coupon-use"> 53 + <span class="used coupon-use" data-value="{{value}}">
54 {{value}} 54 {{value}}
55 <i class="iconfont">&#xe614;</i> 55 <i class="iconfont">&#xe614;</i>
56 </span> 56 </span>
@@ -77,7 +77,7 @@ @@ -77,7 +77,7 @@
77 <span class="title">发票</span> 77 <span class="title">发票</span>
78 <span class="iconfont checkbox {{#if needInvoice}}icon-cb-checked{{else}}icon-checkbox{{/if}}"></span> 78 <span class="iconfont checkbox {{#if needInvoice}}icon-cb-checked{{else}}icon-checkbox{{/if}}"></span>
79 <form id="invoice"> 79 <form id="invoice">
80 - <input type="text" name="invoice-title" value="{{invoiceText}}" placeholder="发票抬头"> 80 + <input type="text" name="invoice-title" value="{{invoiceText}}" maxlength="30" placeholder="发票抬头">
81 <label> 81 <label>
82 发票类型 82 发票类型
83 <select class="invoice-type" name="invoice-type"> 83 <select class="invoice-type" name="invoice-type">
@@ -92,7 +92,7 @@ @@ -92,7 +92,7 @@
92 </ul> 92 </ul>
93 93
94 <form id="msg" action="" method="post"> 94 <form id="msg" action="" method="post">
95 - <input type="text" name="msg" value="{{msg}}" placeholder="留言"> 95 + <textarea name="msg" rows="2" maxlength="40" placeholder="留言">{{msg}}</textarea>
96 </form> 96 </form>
97 </section> 97 </section>
98 98