| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- <template>
- <view class="page-workbench">
- <view class="workbench-header">
- <wd-navbar fixed placeholder :bordered="false" safeAreaInsetTop customClass="navbar">
- <template #title>
- <view class="navbar-title"> 要易小助手</view>
- </template>
- </wd-navbar>
- <WorkbenchCard
- :is-login="isLoggedIn"
- :on-the-way="onTheWay"
- :wait-approve="waitApprove"
- @go-task="goTask"
- @open-history="taskHistory"
- @open-status="handleOpenStatus"
- />
- </view>
- <view class="workbench-notice">
- <wd-notice-bar
- text="任务包即将完成时,请不要做积分较高的任务,避免浪费积分哦~"
- prefix="warn-bold"
- type="info "
- color="#f90"
- background-color="#fdf6ec "
- />
- </view>
- <WorkbenchTaskSection @select-task="handleSelectTask" />
- <!--廉洁协议 -->
- <HonestAgreementGate v-model="isHonestAgreementVisible" />
- </view>
- </template>
- <script setup lang="ts">
- import { computed, ref } from 'vue'
- import { onShow } from '@dcloudio/uni-app'
- import {
- getQuizPltTestResultApi,
- resetPasswordApi,
- stopSixtyReminderApi,
- } from '@/services/modules/userInfo'
- import { useUserStore } from '@/stores/modules/user'
- import HonestAgreementGate from './components/HonestAgreementGate.vue'
- import WorkbenchCard from './components/WorkbenchCard.vue'
- import WorkbenchTaskSection from './components/WorkbenchTaskSection.vue'
- const userStore = useUserStore()
- const isLoggedIn = computed(() => userStore.isLoggedIn)
- const waitApprove = computed(() => userStore.currentUserInfo?.waitApprove ?? 0)
- const onTheWay = computed(() => userStore.currentUserInfo?.onTheWay ?? 0)
- onShow(async () => {
- // 每次进入页面时刷新用户状态
- if (!userStore.isLoggedIn) return
- const userInfo = await userStore.getUserInfoByCode()
- if (!userInfo) return
- // 未签署廉洁协议
- if (!userInfo.signedAgreement?.includes('HONEST_AGREEMENT_V2')) {
- uni.hideTabBar()
- openHonestAgreementGate()
- return
- }
- // 超龄退出
- if (userInfo.ageLimit) {
- isAgeOverLimit()
- }
- // 超龄提醒
- if (userInfo.ageReminder) {
- notifyUpcomingAgeLimit()
- }
- // 平台合规测试
- const res = await getPltQuizResult()
- if (!res) return
- // 密码修改提醒
- checkLastChangePassword()
- // 兜底处理
- uni.showTabBar()
- })
- const ensureCanOperate = (): boolean => {
- if (!userStore.isLoggedIn) {
- uni.showToast({
- icon: 'none',
- title: '请先登录',
- })
- setTimeout(() => {
- uni.navigateTo({ url: '/pages/login/index' })
- }, 1500)
- return false
- }
- if (userStore.hasBlacklistRisk) {
- uni.showModal({
- title: '提示',
- content: '该账号存在风险,请联系管理员',
- showCancel: false,
- })
- return false
- }
- return true
- }
- const goTask = () => {
- if (!ensureCanOperate()) return
- console.log('去领包')
- }
- const taskHistory = () => {
- if (!ensureCanOperate()) return
- console.log('领包记录')
- }
- const handleOpenStatus = (type: 'on-the-way' | 'wait-approve') => {
- if (!ensureCanOperate()) return
- // 领包记录
- console.log('type', type)
- }
- const handleSelectTask = (item: any) => {
- if (!ensureCanOperate()) return
- // 统一处理跳转 / 权限校验
- }
- // 业务判断
- // 显示签署廉洁协议弹窗
- const isHonestAgreementVisible = ref(false)
- const openHonestAgreementGate = () => {
- isHonestAgreementVisible.value = true
- }
- // 年龄已超限
- const isAgeOverLimit = () => {
- uni.showModal({
- title: '提示',
- showCancel: false,
- content: userStore?.currentUserInfo?.ageReminderInfo || '',
- success() {
- userStore.logout()
- uni.reLaunch({
- url: '/pages/login/index',
- })
- },
- })
- }
- // 提前提醒年龄即将超限
- const notifyUpcomingAgeLimit = () => {
- uni.showModal({
- title: '提示',
- cancelText: '不再提醒',
- confirmText: '确定',
- content: userStore?.currentUserInfo?.ageReminderInfo || '',
- async success(res) {
- if (res.cancel) {
- const res = await stopSixtyReminderApi()
- if (res.code === 0 && res.data) {
- uni.showToast({
- title: '不再弹出年龄提醒',
- icon: 'none',
- })
- }
- }
- },
- })
- }
- const getPltQuizResult = async (): Promise<boolean> => {
- const res = await getQuizPltTestResultApi()
- if (res.code === 0) {
- const { required, testResults } = res.data
- const hasInvalidResult = testResults.some((item) => !item.valid)
- const flag = required && hasInvalidResult
- if (flag) {
- uni.showModal({
- title: '提示',
- cancelText: '暂不处理',
- confirmText: '去测试',
- content: '因平台合规升级,现需要您完成风险评估测试,请您认真作答。感谢您的配合!',
- async success(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/quiz-plt-test/index',
- })
- }
- if (res.cancel) {
- userStore.logout()
- uni.reLaunch({
- url: '/pages/login/index',
- })
- }
- },
- })
- return false
- }
- }
- return true
- }
- // 是否修改过密码
- const checkLastChangePassword = async () => {
- const userInfo = userStore.currentUserInfo
- if (!userInfo) return
- const latestChangePwdTime = userInfo.latestChangePwdTime
- const now = Date.now()
- const ninetyDaysAgo = now - 90 * 24 * 60 * 60 * 1000
- const lastChangeTime = new Date(latestChangePwdTime).getTime()
- if (lastChangeTime < ninetyDaysAgo) {
- uni.showModal({
- title: '提示',
- content: '您的登录密码长时间未修改,为保障账号安全,建议您及时修改密码!',
- confirmText: '去修改',
- cancelText: '暂不修改',
- success: async (res) => {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/reset-password/index',
- })
- } else if (res.cancel) {
- resetPasswordApi(userInfo.userId)
- }
- },
- })
- }
- }
- </script>
- <style lang="scss" scoped>
- .page-workbench {
- .workbench-header {
- position: relative;
- background-image: var(--workbench-bg);
- background-size: 100% 100%;
- height: 400rpx;
- width: 750rpx;
- :deep(.navbar) {
- background-color: transparent;
- }
- .navbar-title {
- color: #fff;
- font-weight: bold;
- }
- }
- .workbench-notice {
- padding: 0 30rpx;
- margin: 150rpx auto 0;
- }
- }
- </style>
|