|
|
@@ -1,5 +1,5 @@
|
|
|
import { ref, reactive } from 'vue'
|
|
|
-import { useRouter } from 'vue-router'
|
|
|
+import { useRouter, useRoute } from 'vue-router'
|
|
|
import { showToast, showSuccessToast } from 'vant'
|
|
|
import { getStatusApi, submitInvoiceApplyApi } from '@/services/modules/invoiceInformation'
|
|
|
import type { PushRecordIdRequest } from '@/services/modules/invoiceInformation/type.d.ts'
|
|
|
@@ -23,6 +23,8 @@ export function useInvoice() {
|
|
|
const userStore = useUserStore()
|
|
|
const router = useRouter()
|
|
|
|
|
|
+ const route = useRoute()
|
|
|
+
|
|
|
// state
|
|
|
const btnDisabled = ref(false)
|
|
|
const statusMap = ref<ToStatus>({})
|
|
|
@@ -73,20 +75,31 @@ export function useInvoice() {
|
|
|
*/
|
|
|
const submitInvoiceApply = async () => {
|
|
|
try {
|
|
|
+ // 1. 提交流程
|
|
|
const res = await submitInvoiceApplyApi(params)
|
|
|
+ // 2. 成功逻辑
|
|
|
if (res.code === 0 && res.data) {
|
|
|
showSuccessToast('提交成功')
|
|
|
setTimeout(() => {
|
|
|
userStore.LogOut()
|
|
|
router.replace({ path: '/success' })
|
|
|
}, 800)
|
|
|
- } else {
|
|
|
- showToast(res.msg)
|
|
|
+ return
|
|
|
}
|
|
|
+ // 3. 失败逻辑(接口返回的错误)
|
|
|
+ showToast(res.msg)
|
|
|
} catch (err: any) {
|
|
|
+ // 4. 异常逻辑
|
|
|
console.error('提交失败', err)
|
|
|
showToast(err.message)
|
|
|
}
|
|
|
+
|
|
|
+ // 5. 失败后统一处理 —— 判断当前页面是否需要跳转
|
|
|
+ if (route.path !== '/h5/invoice-information/index') {
|
|
|
+ setTimeout(() => {
|
|
|
+ router.replace('/h5/invoice-information/index')
|
|
|
+ }, 1800)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return {
|