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