From 07322857495b30e1331bda017fcd4c4e65967bcc Mon Sep 17 00:00:00 2001 From: lxf Date: Mon, 28 Jul 2025 16:28:55 +0800 Subject: [PATCH] fix: 下单加保险 --- pages/order/index.vue | 29 ++++++----------------------- pages/order/insurance.vue | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/pages/order/index.vue b/pages/order/index.vue index d144325..b8d8008 100644 --- a/pages/order/index.vue +++ b/pages/order/index.vue @@ -319,30 +319,13 @@ export default { }); }, buyInsurance(code, data) { - uni.$once('buy-insurance', insuranceForm => { - uni.showLoading(); - if (insuranceForm.insuranceProgramCode) { - uni.$u.api.freightOrder - .insure({ - orderCode: code, - ...insuranceForm, - }) - .then(res => { - uni.hideLoading(); - uni.navigateBack(); - this.onSearch(); - }) - .catch(() => { - setTimeout(() => { - uni.hideLoading(); - }, 2000); - }); - } else { - uni.navigateBack(); - } - }); uni.navigateTo({ - url: `/pages/order/insurance?paidAmount=${data.paidAmount}`, + url: `/pages/order/insurance?paidAmount=${data.paidAmount}&orderCode=${code}`, + events: { + refreshData: () => { + this.onSearch(); + }, + }, }); }, }, diff --git a/pages/order/insurance.vue b/pages/order/insurance.vue index 904219b..70c7d64 100644 --- a/pages/order/insurance.vue +++ b/pages/order/insurance.vue @@ -50,7 +50,7 @@ @@ -67,6 +67,8 @@ export default { }, data() { return { + loading: false, // 下单之后购买-使用 + orderCode: '', // 下单之后购买 pdfFile0: 'https://zeyi-tms-product.oss-cn-hangzhou.aliyuncs.com/file/tms/a15401e7-3d44-41ab-9302-39c6574a1233.pdf', pdfFile: 'https://zeyi-tms-product.oss-cn-hangzhou.aliyuncs.com/file/tms/71c2d1ff-0ea1-491b-b387-d2f18de0b19d.html', paidAmount: '', @@ -91,6 +93,7 @@ export default { }, onLoad(option) { this.paidAmount = option.paidAmount; + this.orderCode = option.orderCode || ''; this.initData(); }, methods: { @@ -145,7 +148,11 @@ export default { insuranceProgramCode: '', coverageLimit: '', }; - uni.$emit('buy-insurance', form); + if (this.orderCode) { + uni.navigateBack(); + } else { + uni.$emit('buy-insurance', form); + } }, submitInsurance() { if (!this.form.startDate) { @@ -154,7 +161,27 @@ export default { if (!this.form.insuranceProgramCode) { return uni.showToast({ title: '请选择方案', icon: 'none' }); } - uni.$emit('buy-insurance', { ...this.form, programName: this.choseScheme.programName }); + if (this.orderCode) { + this.buyAfterOrder(this.form); + } else { + uni.$emit('buy-insurance', { ...this.form, programName: this.choseScheme.programName }); + } + }, + buyAfterOrder(insuranceForm) { + if (this.loading) return; + this.loading = true; + uni.$u.api.freightOrder + .insure({ + orderCode: this.orderCode, + ...insuranceForm, + }) + .then(res => { + this.getOpenerEventChannel().emit('refreshData'); + setTimeout(() => uni.navigateBack(), 500); + }) + .finally(() => { + this.loading = false; + }); }, getReceiveInsuranceAmount(choseScheme, paidAmount) { if (!paidAmount || !choseScheme) return ''; -- libgit2 0.21.0