Commit aaf5f6662bbe36211ce090693d02fb37f4ac2607

Authored by lxf
1 parent 9289d6f9

fix: 优化下单loading

Showing 1 changed file with 7 additions and 2 deletions   Show diff stats
pages/order/add.vue
@@ -136,7 +136,7 @@ @@ -136,7 +136,7 @@
136 </u-form> 136 </u-form>
137 </template> 137 </template>
138 <template #footer> 138 <template #footer>
139 - <u-button type="primary" @tap="submitAddFun">下单并指派</u-button> 139 + <u-button :loading="loading" type="primary" @tap="submitAddFun">下单并指派</u-button>
140 </template> 140 </template>
141 <u-toast ref="uToast"></u-toast> 141 <u-toast ref="uToast"></u-toast>
142 <u-modal :show="showModal" title="粘贴识别司机车辆信息" :showCancelButton="true" @cancel="cliCancel" @confirm="cliSubmit" confirmText="确定"> 142 <u-modal :show="showModal" title="粘贴识别司机车辆信息" :showCancelButton="true" @cancel="cliCancel" @confirm="cliSubmit" confirmText="确定">
@@ -156,6 +156,7 @@ export default { @@ -156,6 +156,7 @@ export default {
156 components: { UTextarea, PopupPlatenumber, payee }, 156 components: { UTextarea, PopupPlatenumber, payee },
157 data() { 157 data() {
158 return { 158 return {
  159 + loading: false,
159 showModal: '', 160 showModal: '',
160 content: '', 161 content: '',
161 carNumber: '', 162 carNumber: '',
@@ -233,7 +234,6 @@ export default { @@ -233,7 +234,6 @@ export default {
233 if (trailer && trailer.input) { 234 if (trailer && trailer.input) {
234 cliTrailer = trailer[0]; 235 cliTrailer = trailer[0];
235 } 236 }
236 - console.info(cliMobile, cliVehicle, cliTrailer);  
237 if (cliMobile || cliVehicle || cliTrailer) { 237 if (cliMobile || cliVehicle || cliTrailer) {
238 this.form = { 238 this.form = {
239 ...this.form, 239 ...this.form,
@@ -453,17 +453,22 @@ export default { @@ -453,17 +453,22 @@ export default {
453 }); 453 });
454 }, 454 },
455 submitAddFun() { 455 submitAddFun() {
  456 + if (this.loading) return;
  457 + this.loading = true;
456 let totalAmount = Number(this.form.paidAmount || 0) + Number(this.form.serviceAmount || 0) + Number(this.form.securityServiceAmount || 0); 458 let totalAmount = Number(this.form.paidAmount || 0) + Number(this.form.serviceAmount || 0) + Number(this.form.securityServiceAmount || 0);
457 uni.$u.api.freightOrder 459 uni.$u.api.freightOrder
458 .add({ ...this.form, totalAmount, payeeId: this.payeeModel.driverId }) 460 .add({ ...this.form, totalAmount, payeeId: this.payeeModel.driverId })
459 .then(res => { 461 .then(res => {
460 if (res.success) { 462 if (res.success) {
  463 + this.form = {};
461 uni.showToast({ title: '下单成功', icon: 'none' }); 464 uni.showToast({ title: '下单成功', icon: 'none' });
462 this.getOpenerEventChannel().emit('refreshData'); 465 this.getOpenerEventChannel().emit('refreshData');
463 setTimeout(() => uni.navigateBack(), 500); 466 setTimeout(() => uni.navigateBack(), 500);
464 } 467 }
  468 + this.loading = false;
465 }) 469 })
466 .catch(e => { 470 .catch(e => {
  471 + this.loading = false;
467 this.$refs.uToast.show({ 472 this.$refs.uToast.show({
468 type: 'default', 473 type: 'default',
469 message: e, 474 message: e,