|
@@ -33,13 +33,16 @@
|
|
|
:type="livenessReminderType"
|
|
:type="livenessReminderType"
|
|
|
:expire-date-text="livenessExpireDateText"
|
|
:expire-date-text="livenessExpireDateText"
|
|
|
/>
|
|
/>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 国开大合规上岗活动弹窗 -->
|
|
|
|
|
+ <GdComplianceBannerDialog :can-show="canShowGdBanner" />
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { computed, ref } from 'vue'
|
|
|
|
|
|
|
+import { computed, ref, watch } from 'vue'
|
|
|
|
|
|
|
|
-import { onShow } from '@dcloudio/uni-app'
|
|
|
|
|
|
|
+import { onHide, onShow, onUnload } from '@dcloudio/uni-app'
|
|
|
import dayjs from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
@@ -53,6 +56,7 @@ import type { PopupNoticeItem, PopupNoticeType } from '@/services/modules/userIn
|
|
|
|
|
|
|
|
import { useUserStore } from '@/stores/modules/user'
|
|
import { useUserStore } from '@/stores/modules/user'
|
|
|
|
|
|
|
|
|
|
+import GdComplianceBannerDialog from './components/GdComplianceBannerDialog.vue'
|
|
|
import HonestAgreementGate from './components/HonestAgreementGate.vue'
|
|
import HonestAgreementGate from './components/HonestAgreementGate.vue'
|
|
|
import LivenessReminderDialog from './components/LivenessReminderDialog.vue'
|
|
import LivenessReminderDialog from './components/LivenessReminderDialog.vue'
|
|
|
import WorkbenchCard from './components/WorkbenchCard.vue'
|
|
import WorkbenchCard from './components/WorkbenchCard.vue'
|
|
@@ -66,6 +70,11 @@ const isLoggedIn = computed(() => userStore.isLoggedIn)
|
|
|
const waitApprove = ref('0')
|
|
const waitApprove = ref('0')
|
|
|
const onTheWay = ref('0')
|
|
const onTheWay = ref('0')
|
|
|
const isShowingPopupNotice = ref(false)
|
|
const isShowingPopupNotice = ref(false)
|
|
|
|
|
+const isPageActive = ref(false)
|
|
|
|
|
+const isHomePopupFlowReady = ref(false)
|
|
|
|
|
+const shouldResumeAfterLiveness = ref(false)
|
|
|
|
|
+let livenessResumeTimer: ReturnType<typeof setTimeout> | undefined
|
|
|
|
|
+let isCompletingHomePopupFlow = false
|
|
|
|
|
|
|
|
const SUPPORTED_POPUP_NOTICE_TYPES: PopupNoticeType[] = [
|
|
const SUPPORTED_POPUP_NOTICE_TYPES: PopupNoticeType[] = [
|
|
|
'PENDING_SUBMIT',
|
|
'PENDING_SUBMIT',
|
|
@@ -75,6 +84,10 @@ const SUPPORTED_POPUP_NOTICE_TYPES: PopupNoticeType[] = [
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
onShow(async () => {
|
|
onShow(async () => {
|
|
|
|
|
+ isPageActive.value = true
|
|
|
|
|
+ isHomePopupFlowReady.value = false
|
|
|
|
|
+ shouldResumeAfterLiveness.value = false
|
|
|
|
|
+
|
|
|
// 每次进入页面时刷新用户状态
|
|
// 每次进入页面时刷新用户状态
|
|
|
if (!userStore.isLoggedIn) return
|
|
if (!userStore.isLoggedIn) return
|
|
|
|
|
|
|
@@ -100,7 +113,7 @@ onShow(async () => {
|
|
|
|
|
|
|
|
// 超龄提醒
|
|
// 超龄提醒
|
|
|
if (userInfo.ageReminder) {
|
|
if (userInfo.ageReminder) {
|
|
|
- notifyUpcomingAgeLimit()
|
|
|
|
|
|
|
+ await notifyUpcomingAgeLimit()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 平台合规测试
|
|
// 平台合规测试
|
|
@@ -110,20 +123,61 @@ onShow(async () => {
|
|
|
// 活体验证提醒:本次登录只弹一次
|
|
// 活体验证提醒:本次登录只弹一次
|
|
|
const hasOpenedLivenessReminder = checkLivenessReminder(userInfo)
|
|
const hasOpenedLivenessReminder = checkLivenessReminder(userInfo)
|
|
|
if (hasOpenedLivenessReminder) {
|
|
if (hasOpenedLivenessReminder) {
|
|
|
|
|
+ shouldResumeAfterLiveness.value = true
|
|
|
uni.showTabBar()
|
|
uni.showTabBar()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 密码修改提醒
|
|
|
|
|
- const hasNavigatedToResetPassword = await checkLastChangePassword()
|
|
|
|
|
- if (hasNavigatedToResetPassword) return
|
|
|
|
|
|
|
+ await completeHomePopupFlow()
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
- await requestPopupNoticesOnce()
|
|
|
|
|
|
|
+onHide(() => {
|
|
|
|
|
+ isPageActive.value = false
|
|
|
|
|
+ isHomePopupFlowReady.value = false
|
|
|
|
|
+ shouldResumeAfterLiveness.value = false
|
|
|
|
|
+ clearLivenessResumeTimer()
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
- // 兜底处理
|
|
|
|
|
- uni.showTabBar()
|
|
|
|
|
|
|
+onUnload(() => {
|
|
|
|
|
+ clearLivenessResumeTimer()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+const completeHomePopupFlow = async () => {
|
|
|
|
|
+ if (!isPageActive.value || !userStore.isLoggedIn || isCompletingHomePopupFlow) return
|
|
|
|
|
+
|
|
|
|
|
+ isCompletingHomePopupFlow = true
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 密码修改提醒
|
|
|
|
|
+ const hasNavigatedToResetPassword = await checkLastChangePassword()
|
|
|
|
|
+ if (hasNavigatedToResetPassword || !isPageActive.value) return
|
|
|
|
|
+
|
|
|
|
|
+ await requestPopupNoticesOnce()
|
|
|
|
|
+ if (!isPageActive.value) return
|
|
|
|
|
+
|
|
|
|
|
+ isHomePopupFlowReady.value = true
|
|
|
|
|
+
|
|
|
|
|
+ // 兜底处理
|
|
|
|
|
+ uni.showTabBar()
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ isCompletingHomePopupFlow = false
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const scheduleLivenessResume = () => {
|
|
|
|
|
+ clearLivenessResumeTimer()
|
|
|
|
|
+ livenessResumeTimer = setTimeout(() => {
|
|
|
|
|
+ livenessResumeTimer = undefined
|
|
|
|
|
+ void completeHomePopupFlow()
|
|
|
|
|
+ }, 300)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const clearLivenessResumeTimer = () => {
|
|
|
|
|
+ if (!livenessResumeTimer) return
|
|
|
|
|
+ clearTimeout(livenessResumeTimer)
|
|
|
|
|
+ livenessResumeTimer = undefined
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const requestPopupNoticesOnce = async () => {
|
|
const requestPopupNoticesOnce = async () => {
|
|
|
if (!userStore.hasRequestedPopupNotices) {
|
|
if (!userStore.hasRequestedPopupNotices) {
|
|
|
// 发起请求前即标记,避免首页 onShow 并发触发重复请求。
|
|
// 发起请求前即标记,避免首页 onShow 并发触发重复请求。
|
|
@@ -246,9 +300,7 @@ interface PopupNoticeModalOptions {
|
|
|
confirmText: string
|
|
confirmText: string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const openPopupNoticeModal = (
|
|
|
|
|
- options: PopupNoticeModalOptions
|
|
|
|
|
-): Promise<boolean | null> => {
|
|
|
|
|
|
|
+const openPopupNoticeModal = (options: PopupNoticeModalOptions): Promise<boolean | null> => {
|
|
|
return new Promise((resolve) => {
|
|
return new Promise((resolve) => {
|
|
|
let result: boolean | null = null
|
|
let result: boolean | null = null
|
|
|
|
|
|
|
@@ -353,23 +405,28 @@ const isAgeOverLimit = () => {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
// 提前提醒年龄即将超限
|
|
// 提前提醒年龄即将超限
|
|
|
-const notifyUpcomingAgeLimit = () => {
|
|
|
|
|
- uni.showModal({
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- cancelText: '不再提醒',
|
|
|
|
|
- confirmText: '确定',
|
|
|
|
|
- content: userStore?.currentUserInfo?.ageReminderInfo || '',
|
|
|
|
|
- async success(res) {
|
|
|
|
|
- if (res.cancel) {
|
|
|
|
|
- const response = await stopSixtyReminderApi()
|
|
|
|
|
- if (!response.data) return
|
|
|
|
|
-
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '不再弹出年龄提醒',
|
|
|
|
|
- icon: 'none',
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
|
|
+const notifyUpcomingAgeLimit = (): Promise<void> => {
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ cancelText: '不再提醒',
|
|
|
|
|
+ confirmText: '确定',
|
|
|
|
|
+ content: userStore?.currentUserInfo?.ageReminderInfo || '',
|
|
|
|
|
+ async success(res) {
|
|
|
|
|
+ if (res.cancel) {
|
|
|
|
|
+ const response = await stopSixtyReminderApi()
|
|
|
|
|
+ if (!response.data) return
|
|
|
|
|
+
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '不再弹出年龄提醒',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ complete() {
|
|
|
|
|
+ resolve()
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
const getPltQuizResult = async (): Promise<boolean> => {
|
|
const getPltQuizResult = async (): Promise<boolean> => {
|
|
@@ -460,6 +517,24 @@ const isLivenessReminderVisible = ref(false)
|
|
|
const livenessReminderType = ref<LivenessReminderType>('')
|
|
const livenessReminderType = ref<LivenessReminderType>('')
|
|
|
const livenessExpireDateText = ref('')
|
|
const livenessExpireDateText = ref('')
|
|
|
|
|
|
|
|
|
|
+const canShowGdBanner = computed(
|
|
|
|
|
+ () =>
|
|
|
|
|
+ isHomePopupFlowReady.value &&
|
|
|
|
|
+ isPageActive.value &&
|
|
|
|
|
+ userStore.isLoggedIn &&
|
|
|
|
|
+ !isHonestAgreementVisible.value &&
|
|
|
|
|
+ !isLivenessReminderVisible.value &&
|
|
|
|
|
+ !isShowingPopupNotice.value &&
|
|
|
|
|
+ !userStore.currentPopupNotice
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+watch(isLivenessReminderVisible, (visible, wasVisible) => {
|
|
|
|
|
+ if (visible || !wasVisible || !shouldResumeAfterLiveness.value) return
|
|
|
|
|
+
|
|
|
|
|
+ shouldResumeAfterLiveness.value = false
|
|
|
|
|
+ scheduleLivenessResume()
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
const checkLivenessReminder = (userInfo: Record<string, any>): boolean => {
|
|
const checkLivenessReminder = (userInfo: Record<string, any>): boolean => {
|
|
|
if (userStore.hasShownLivenessReminder) return false
|
|
if (userStore.hasShownLivenessReminder) return false
|
|
|
|
|
|