|
@@ -13,19 +13,25 @@ const tabCountList = ref([0, 0, 0, 0, 0])
|
|
|
const curTabCount = ref([])
|
|
const curTabCount = ref([])
|
|
|
|
|
|
|
|
const handleCount = (count: number) => {
|
|
const handleCount = (count: number) => {
|
|
|
- if (!count) return ''
|
|
|
|
|
|
|
+ if (!count || count < 0) return ''
|
|
|
return count > 99 ? '99+' : count
|
|
return count > 99 ? '99+' : count
|
|
|
}
|
|
}
|
|
|
|
|
+// 计算未读卡片数量
|
|
|
|
|
+const unreadCardCount = computed(() => {
|
|
|
|
|
+ const curEventNotificationIndex = navList.findIndex((navItem) => {
|
|
|
|
|
+ return navItem === activeCardTypeName.value
|
|
|
|
|
+ })
|
|
|
|
|
+ return tabCountList.value[curEventNotificationIndex] - notificationMsgStore.readCardMap.length
|
|
|
|
|
+})
|
|
|
const handleShowCount = (typeName: string, index: number) => {
|
|
const handleShowCount = (typeName: string, index: number) => {
|
|
|
// 在切换type类型时,防止点击的类型值为点击之前类型的值
|
|
// 在切换type类型时,防止点击的类型值为点击之前类型的值
|
|
|
if (curTabCount.value?.[index] > -1) {
|
|
if (curTabCount.value?.[index] > -1) {
|
|
|
return curTabCount.value[index]
|
|
return curTabCount.value[index]
|
|
|
}
|
|
}
|
|
|
- const count = tabCountList.value[index]
|
|
|
|
|
if (typeName === activeCardTypeName.value) {
|
|
if (typeName === activeCardTypeName.value) {
|
|
|
- return handleCount(unreadNotificationList.value.length)
|
|
|
|
|
|
|
+ return handleCount(unreadCardCount.value)
|
|
|
}
|
|
}
|
|
|
- return handleCount(count)
|
|
|
|
|
|
|
+ return handleCount(tabCountList.value[index])
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const navList = [
|
|
const navList = [
|
|
@@ -52,6 +58,10 @@ const setActiveItem = (item: string) => {
|
|
|
tabCountList.value.length - 1
|
|
tabCountList.value.length - 1
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ // 滚动到顶部
|
|
|
|
|
+ if (notificationMessageCardRef.value) {
|
|
|
|
|
+ notificationMessageCardRef.value.scrollContainerRef.scrollTo(0, 0)
|
|
|
|
|
+ }
|
|
|
activeCardTypeName.value = item
|
|
activeCardTypeName.value = item
|
|
|
sessionStorage.setItem('activeCardTypeName', item)
|
|
sessionStorage.setItem('activeCardTypeName', item)
|
|
|
activeTabName.value = 'All Notifications'
|
|
activeTabName.value = 'All Notifications'
|
|
@@ -61,40 +71,72 @@ const setActiveItem = (item: string) => {
|
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
|
const notificationList = ref<any[]>([])
|
|
const notificationList = ref<any[]>([])
|
|
|
|
|
|
|
|
-const unreadNotificationList = computed(() => {
|
|
|
|
|
- return notificationList.value.filter((item) => !item.info.isRead)
|
|
|
|
|
-})
|
|
|
|
|
-const readNotificationList = computed(() => {
|
|
|
|
|
- return notificationList.value.filter((item) => item.info.isRead)
|
|
|
|
|
|
|
+// const unreadNotificationList = computed(() => {
|
|
|
|
|
+// return notificationList.value.filter((item) => !item.info.isRead)
|
|
|
|
|
+// })
|
|
|
|
|
+const unreadNotificationList = ref<any[]>([])
|
|
|
|
|
+// const readNotificationList = computed(() => {
|
|
|
|
|
+// return notificationList.value.filter((item) => item.info.isRead)
|
|
|
|
|
+// })
|
|
|
|
|
+const readNotificationList = ref<any[]>([])
|
|
|
|
|
+const pageInfo = ref({
|
|
|
|
|
+ cp: 1,
|
|
|
|
|
+ ps: 5
|
|
|
})
|
|
})
|
|
|
-const getNotificationList = async () => {
|
|
|
|
|
|
|
+const getNotificationList = async (tabType: string = 'All Notification') => {
|
|
|
loading.value = true
|
|
loading.value = true
|
|
|
const rulesType = Object.entries(notificationTypeList.value).find(
|
|
const rulesType = Object.entries(notificationTypeList.value).find(
|
|
|
(item) => item[1] === activeCardTypeName.value
|
|
(item) => item[1] === activeCardTypeName.value
|
|
|
)?.[0]
|
|
)?.[0]
|
|
|
|
|
+ let info_type: string | boolean = ''
|
|
|
|
|
+ if (tabType === 'All Notification') {
|
|
|
|
|
+ info_type = ''
|
|
|
|
|
+ } else if (tabType === 'Unread') {
|
|
|
|
|
+ info_type = true
|
|
|
|
|
+ } else {
|
|
|
|
|
+ info_type = false
|
|
|
|
|
+ }
|
|
|
try {
|
|
try {
|
|
|
await notificationMsgStore.markMessageAsRead()
|
|
await notificationMsgStore.markMessageAsRead()
|
|
|
$api
|
|
$api
|
|
|
.getSystemMessageData({
|
|
.getSystemMessageData({
|
|
|
- rules_type: rulesType
|
|
|
|
|
|
|
+ rules_type: rulesType,
|
|
|
|
|
+ cp: pageInfo.value.cp,
|
|
|
|
|
+ ps: pageInfo.value.ps,
|
|
|
|
|
+ info_type
|
|
|
})
|
|
})
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
|
const data = res.data
|
|
const data = res.data
|
|
|
- notificationList.value = data.cardList
|
|
|
|
|
- tabCountList.value = data.countList
|
|
|
|
|
|
|
+ notificationList.value = [...notificationList.value, ...data.cardList]
|
|
|
|
|
+ // tabCountList.value = data.countList
|
|
|
|
|
+ !data?.cardList?.length && (notificationMessageCardRef.value.finished = true)
|
|
|
|
|
+ if (tabType === 'All Notification') {
|
|
|
|
|
+ tabCountList.value = data.countList
|
|
|
|
|
+ notificationList.value = [...notificationList.value, ...data.cardList]
|
|
|
|
|
+ } else if (tabType === 'Unread') {
|
|
|
|
|
+ unreadNotificationList.value = [...unreadNotificationList.value, ...data.cardList]
|
|
|
|
|
+ } else {
|
|
|
|
|
+ readNotificationList.value = [...readNotificationList.value, ...data.cardList]
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
.finally(() => {
|
|
.finally(() => {
|
|
|
loading.value = false
|
|
loading.value = false
|
|
|
curTabCount.value = []
|
|
curTabCount.value = []
|
|
|
|
|
+ notificationMessageCardRef.value.loading = false
|
|
|
|
|
+ pageInfo.value.cp += 1
|
|
|
})
|
|
})
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- console.error(error)
|
|
|
|
|
loading.value = false
|
|
loading.value = false
|
|
|
curTabCount.value = []
|
|
curTabCount.value = []
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+const notificationMessageCardRef = ref()
|
|
|
|
|
+const handleMessageLoading = async () => {
|
|
|
|
|
+ pageInfo.value.cp += 1
|
|
|
|
|
+ await getNotificationList()
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
const changeCardRead = () => {
|
|
const changeCardRead = () => {
|
|
|
const readCardMap = notificationMsgStore.readCardMap
|
|
const readCardMap = notificationMsgStore.readCardMap
|
|
@@ -108,12 +150,13 @@ const changeCardRead = () => {
|
|
|
const activeTabName = ref('All Notifications')
|
|
const activeTabName = ref('All Notifications')
|
|
|
const handleTabChange = () => {
|
|
const handleTabChange = () => {
|
|
|
// 当前tab页切换时,更新数据
|
|
// 当前tab页切换时,更新数据
|
|
|
- const readCardMap = notificationMsgStore.readCardMap
|
|
|
|
|
- notificationList.value.forEach((item) => {
|
|
|
|
|
- if (readCardMap.includes(item.info.id)) {
|
|
|
|
|
- item.info.isRead = true
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // const readCardMap = notificationMsgStore.readCardMap
|
|
|
|
|
+ // notificationList.value.forEach((item) => {
|
|
|
|
|
+ // if (readCardMap.includes(item.info.id)) {
|
|
|
|
|
+ // item.info.isRead = true
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
|
|
+ getNotificationList(activeTabName.value)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
@@ -174,10 +217,12 @@ onMounted(() => {
|
|
|
<NotificationMessageCard
|
|
<NotificationMessageCard
|
|
|
v-if="activeTabName === 'All Notifications'"
|
|
v-if="activeTabName === 'All Notifications'"
|
|
|
:data="notificationList"
|
|
:data="notificationList"
|
|
|
- @hasCardRead="changeCardRead"
|
|
|
|
|
:isScrollPadding="true"
|
|
:isScrollPadding="true"
|
|
|
:isShowInsertionTime="true"
|
|
:isShowInsertionTime="true"
|
|
|
:updateReadCardsOnChange="false"
|
|
:updateReadCardsOnChange="false"
|
|
|
|
|
+ @hasCardRead="changeCardRead"
|
|
|
|
|
+ @loading="getNotificationList('All Notifications')"
|
|
|
|
|
+ ref="notificationMessageCardRef"
|
|
|
></NotificationMessageCard>
|
|
></NotificationMessageCard>
|
|
|
</div>
|
|
</div>
|
|
|
</el-tab-pane>
|
|
</el-tab-pane>
|
|
@@ -187,9 +232,11 @@ onMounted(() => {
|
|
|
<div
|
|
<div
|
|
|
class="count"
|
|
class="count"
|
|
|
:style="{ 'padding-top': isMac ? 0 : '1px' }"
|
|
:style="{ 'padding-top': isMac ? 0 : '1px' }"
|
|
|
- v-if="unreadNotificationList.length"
|
|
|
|
|
|
|
+ v-if="unreadNotificationList.length > 0 || unreadCardCount > 0"
|
|
|
>
|
|
>
|
|
|
- <span>{{ handleCount(unreadNotificationList.length) }}</span>
|
|
|
|
|
|
|
+ <span>{{
|
|
|
|
|
+ handleCount(unreadNotificationList.length) || handleCount(unreadCardCount)
|
|
|
|
|
+ }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
<div style="padding-bottom: 20px" v-if="activeTabName === 'Unread'">
|
|
<div style="padding-bottom: 20px" v-if="activeTabName === 'Unread'">
|
|
@@ -199,6 +246,7 @@ onMounted(() => {
|
|
|
:isScrollPadding="true"
|
|
:isScrollPadding="true"
|
|
|
:isShowInsertionTime="true"
|
|
:isShowInsertionTime="true"
|
|
|
:updateReadCardsOnChange="false"
|
|
:updateReadCardsOnChange="false"
|
|
|
|
|
+ @loading="getNotificationList('Unread')"
|
|
|
></NotificationMessageCard>
|
|
></NotificationMessageCard>
|
|
|
</div>
|
|
</div>
|
|
|
</el-tab-pane>
|
|
</el-tab-pane>
|
|
@@ -211,6 +259,7 @@ onMounted(() => {
|
|
|
:isScrollPadding="true"
|
|
:isScrollPadding="true"
|
|
|
:isShowInsertionTime="true"
|
|
:isShowInsertionTime="true"
|
|
|
:data="readNotificationList"
|
|
:data="readNotificationList"
|
|
|
|
|
+ @loading="getNotificationList('Read')"
|
|
|
>
|
|
>
|
|
|
</NotificationMessageCard>
|
|
</NotificationMessageCard>
|
|
|
</div>
|
|
</div>
|