|
@@ -24,7 +24,7 @@ import { formatDate } from '@/filters'
|
|
|
import { useLogin } from '@/business/login'
|
|
import { useLogin } from '@/business/login'
|
|
|
import { Language } from '@/constants/language'
|
|
import { Language } from '@/constants/language'
|
|
|
import { useNavigation } from './router/navigation'
|
|
import { useNavigation } from './router/navigation'
|
|
|
-import { i18n, useNoticeStore } from '@/stores'
|
|
|
|
|
|
|
+import { i18n, useNoticeStore, useLoginStore } from '@/stores'
|
|
|
import eventBus from '@/services/bus'
|
|
import eventBus from '@/services/bus'
|
|
|
import plus from '@/utils/h5plus'
|
|
import plus from '@/utils/h5plus'
|
|
|
import Notify from '@mobile/components/base/notify/index.vue'
|
|
import Notify from '@mobile/components/base/notify/index.vue'
|
|
@@ -49,6 +49,7 @@ const props = defineProps({
|
|
|
const { userLogout } = useLogin()
|
|
const { userLogout } = useLogin()
|
|
|
const { backHome } = useNavigation()
|
|
const { backHome } = useNavigation()
|
|
|
|
|
|
|
|
|
|
+const loginStore = useLoginStore()
|
|
|
const noticeStore = useNoticeStore()
|
|
const noticeStore = useNoticeStore()
|
|
|
|
|
|
|
|
// 消息弹窗
|
|
// 消息弹窗
|
|
@@ -57,11 +58,16 @@ const message = reactive({
|
|
|
index: 0
|
|
index: 0
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+// 获取用户阅读状态的唯一键
|
|
|
|
|
+const getUserReadKey = () => {
|
|
|
|
|
+ const today = formatDate(new Date().toISOString(), 'YYYY-MM-DD')
|
|
|
|
|
+ return `${loginStore.loginId}@${today}`
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 消息列表
|
|
// 消息列表
|
|
|
const messageList = computed(() => {
|
|
const messageList = computed(() => {
|
|
|
- const today = formatDate(new Date().toISOString(), 'YYYY-MM-DD')
|
|
|
|
|
- const readDay = localStorage.getItem('readDay')
|
|
|
|
|
- const showUnread = props.showUnread && today !== readDay // 未读消息一天内只会弹框一次
|
|
|
|
|
|
|
+ const readKey = localStorage.getItem('userReadKey')
|
|
|
|
|
+ const showUnread = props.showUnread && getUserReadKey() !== readKey // 未读消息一天内只会弹框一次
|
|
|
|
|
|
|
|
return noticeStore.noticeList.filter((e) => (showUnread && !e.readed) || e.isforcedisplay)
|
|
return noticeStore.noticeList.filter((e) => (showUnread && !e.readed) || e.isforcedisplay)
|
|
|
})
|
|
})
|
|
@@ -139,8 +145,7 @@ watch(() => noticeStore.isInitialized, () => {
|
|
|
const [firstMessage] = messageList.value
|
|
const [firstMessage] = messageList.value
|
|
|
|
|
|
|
|
if (firstMessage) {
|
|
if (firstMessage) {
|
|
|
- const today = formatDate(new Date().toISOString(), 'YYYY-MM-DD')
|
|
|
|
|
- localStorage.setItem('readDay', today) // 记录当前日期
|
|
|
|
|
|
|
+ localStorage.setItem('userReadKey', getUserReadKey()) // 记录用户已读状态
|
|
|
message.index = 0
|
|
message.index = 0
|
|
|
message.show = true
|
|
message.show = true
|
|
|
noticeStore.updateNoticeReaded(firstMessage.autoid)
|
|
noticeStore.updateNoticeReaded(firstMessage.autoid)
|