Handy_Cao 2 anni fa
parent
commit
b2b6ca154a

+ 9 - 1
src/packages/qxst/main.ts

@@ -14,6 +14,7 @@ import { timerInterceptor } from '@/utils/timer'
 import { useGlobalStore } from '@/stores'
 // import Vconsole from 'vconsole'
 // new Vconsole()
+import eventBus from '@/services/bus'
 
 const app = createApp(App)
 app.use(router)
@@ -28,4 +29,11 @@ document.addEventListener('DOMContentLoaded', () => {
     screenAdapter(true)
     // 监听窗口大小变化
     window.addEventListener('resize', timerInterceptor.setDebounce(() => screenAdapter(true)))
-}, false)
+}, false)
+
+// 监听窗口页面变化
+document.addEventListener('visibilitychange', () => {
+    const state = document.visibilityState
+    // 窗口页面状态通知
+    eventBus.$emit('DocumentVisibilityStateNotify', state)
+})

+ 11 - 6
src/packages/qxst/views/account/certification/components/certification-next/Index.vue

@@ -33,7 +33,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, computed, PropType} from 'vue'
+import { shallowRef, computed, PropType } from 'vue'
 import { CellGroup, Button, Cell, Field, showFailToast, Image } from 'vant'
 import { fullloading, dialog } from '@/utils/vant';
 import { getAQCertificateTypeListName } from "@/constants/account";
@@ -41,10 +41,10 @@ import { useRequest } from '@/hooks/request'
 import { queryUserESignRecord } from '@/services/api/account';
 import { useRequestCreateContractAndAddSigner, useRequestSignCompleted } from '@/business/user/account';
 import plus from '@/utils/h5plus'
+import eventBus from '@/services/bus'
 import { getFileUrl } from '@/filters';
 import AppModal from '@/components/base/modal/index.vue'
 
-const error = shallowRef(false)
 const showModal = shallowRef(true)
 // 是否刷新父组件数据
 const refresh = shallowRef(false)
@@ -55,7 +55,7 @@ const { signCompleted} = useRequestSignCompleted()
 const canAdd = shallowRef(false)
 
 /// 查询
-useRequest(queryUserESignRecord, {
+const { run } = useRequest(queryUserESignRecord, {
     onSuccess: (res) => {
         if (res.data.length != 0) {
             dataList.value = res.data.filter(obj => {
@@ -64,9 +64,6 @@ useRequest(queryUserESignRecord, {
         }
         /// 只有全部签署才可以进行下一步
         canAdd.value = dataList.value.some(obj => { [1, 4].includes(obj.recordstatus) })
-    },
-    onError: () => {
-        error.value = true
     }
 })
 
@@ -149,10 +146,18 @@ const signer = (item: Model.UserESignRecordRsq) => {
     }
 }
 
+// 接收窗口页面状态通知
+const documentVisibilityStateNotify = eventBus.$on('DocumentVisibilityStateNotify', (state) => {
+  if (state === 'visible') {
+    run()
+  }
+})
+
 // 关闭弹窗
 const closed = (isRefresh = false) => {
     refresh.value = isRefresh
     showModal.value = false
+    documentVisibilityStateNotify.cancel()
 }
 
 // 暴露组件属性给父组件调用