Commit 07322857495b30e1331bda017fcd4c4e65967bcc
1 parent
b07c981d
Exists in
master
and in
1 other branch
fix: 下单加保险
Showing
2 changed files
with
36 additions
and
26 deletions
Show diff stats
pages/order/index.vue
| ... | ... | @@ -319,30 +319,13 @@ export default { |
| 319 | 319 | }); |
| 320 | 320 | }, |
| 321 | 321 | buyInsurance(code, data) { |
| 322 | - uni.$once('buy-insurance', insuranceForm => { | |
| 323 | - uni.showLoading(); | |
| 324 | - if (insuranceForm.insuranceProgramCode) { | |
| 325 | - uni.$u.api.freightOrder | |
| 326 | - .insure({ | |
| 327 | - orderCode: code, | |
| 328 | - ...insuranceForm, | |
| 329 | - }) | |
| 330 | - .then(res => { | |
| 331 | - uni.hideLoading(); | |
| 332 | - uni.navigateBack(); | |
| 333 | - this.onSearch(); | |
| 334 | - }) | |
| 335 | - .catch(() => { | |
| 336 | - setTimeout(() => { | |
| 337 | - uni.hideLoading(); | |
| 338 | - }, 2000); | |
| 339 | - }); | |
| 340 | - } else { | |
| 341 | - uni.navigateBack(); | |
| 342 | - } | |
| 343 | - }); | |
| 344 | 322 | uni.navigateTo({ |
| 345 | - url: `/pages/order/insurance?paidAmount=${data.paidAmount}`, | |
| 323 | + url: `/pages/order/insurance?paidAmount=${data.paidAmount}&orderCode=${code}`, | |
| 324 | + events: { | |
| 325 | + refreshData: () => { | |
| 326 | + this.onSearch(); | |
| 327 | + }, | |
| 328 | + }, | |
| 346 | 329 | }); |
| 347 | 330 | }, |
| 348 | 331 | }, | ... | ... |
pages/order/insurance.vue
| ... | ... | @@ -50,7 +50,7 @@ |
| 50 | 50 | <template #footer> |
| 51 | 51 | <view style="display: flex; align-items: center; gap: 20rpx"> |
| 52 | 52 | <u-button type="primary" plain custom-style="flex:1" @click="cancelInsurance">取消投保</u-button> |
| 53 | - <u-button type="primary" custom-style="flex:2" @click="submitInsurance" :disabled="checkboxValue.length === 0">确定投保</u-button> | |
| 53 | + <u-button type="primary" custom-style="flex:2" @click="submitInsurance" :loading="loading" :disabled="checkboxValue.length === 0">确定投保</u-button> | |
| 54 | 54 | </view> |
| 55 | 55 | </template> |
| 56 | 56 | </Page> |
| ... | ... | @@ -67,6 +67,8 @@ export default { |
| 67 | 67 | }, |
| 68 | 68 | data() { |
| 69 | 69 | return { |
| 70 | + loading: false, // 下单之后购买-使用 | |
| 71 | + orderCode: '', // 下单之后购买 | |
| 70 | 72 | pdfFile0: 'https://zeyi-tms-product.oss-cn-hangzhou.aliyuncs.com/file/tms/a15401e7-3d44-41ab-9302-39c6574a1233.pdf', |
| 71 | 73 | pdfFile: 'https://zeyi-tms-product.oss-cn-hangzhou.aliyuncs.com/file/tms/71c2d1ff-0ea1-491b-b387-d2f18de0b19d.html', |
| 72 | 74 | paidAmount: '', |
| ... | ... | @@ -91,6 +93,7 @@ export default { |
| 91 | 93 | }, |
| 92 | 94 | onLoad(option) { |
| 93 | 95 | this.paidAmount = option.paidAmount; |
| 96 | + this.orderCode = option.orderCode || ''; | |
| 94 | 97 | this.initData(); |
| 95 | 98 | }, |
| 96 | 99 | methods: { |
| ... | ... | @@ -145,7 +148,11 @@ export default { |
| 145 | 148 | insuranceProgramCode: '', |
| 146 | 149 | coverageLimit: '', |
| 147 | 150 | }; |
| 148 | - uni.$emit('buy-insurance', form); | |
| 151 | + if (this.orderCode) { | |
| 152 | + uni.navigateBack(); | |
| 153 | + } else { | |
| 154 | + uni.$emit('buy-insurance', form); | |
| 155 | + } | |
| 149 | 156 | }, |
| 150 | 157 | submitInsurance() { |
| 151 | 158 | if (!this.form.startDate) { |
| ... | ... | @@ -154,7 +161,27 @@ export default { |
| 154 | 161 | if (!this.form.insuranceProgramCode) { |
| 155 | 162 | return uni.showToast({ title: '请选择方案', icon: 'none' }); |
| 156 | 163 | } |
| 157 | - uni.$emit('buy-insurance', { ...this.form, programName: this.choseScheme.programName }); | |
| 164 | + if (this.orderCode) { | |
| 165 | + this.buyAfterOrder(this.form); | |
| 166 | + } else { | |
| 167 | + uni.$emit('buy-insurance', { ...this.form, programName: this.choseScheme.programName }); | |
| 168 | + } | |
| 169 | + }, | |
| 170 | + buyAfterOrder(insuranceForm) { | |
| 171 | + if (this.loading) return; | |
| 172 | + this.loading = true; | |
| 173 | + uni.$u.api.freightOrder | |
| 174 | + .insure({ | |
| 175 | + orderCode: this.orderCode, | |
| 176 | + ...insuranceForm, | |
| 177 | + }) | |
| 178 | + .then(res => { | |
| 179 | + this.getOpenerEventChannel().emit('refreshData'); | |
| 180 | + setTimeout(() => uni.navigateBack(), 500); | |
| 181 | + }) | |
| 182 | + .finally(() => { | |
| 183 | + this.loading = false; | |
| 184 | + }); | |
| 158 | 185 | }, |
| 159 | 186 | getReceiveInsuranceAmount(choseScheme, paidAmount) { |
| 160 | 187 | if (!paidAmount || !choseScheme) return ''; | ... | ... |