|
|
|
@ -71,12 +71,13 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup name="messageCenter"> |
|
|
|
import { ref, computed, onMounted } from 'vue'; |
|
|
|
import { ref, computed, onMounted, watch } from 'vue'; |
|
|
|
import { useRouter, useRoute } from 'vue-router'; |
|
|
|
import { showToast } from 'vant'; |
|
|
|
import 'vant/es/toast/style'; |
|
|
|
import FooterBar from '@/components/FooterBar.vue'; |
|
|
|
import { getMessageUnreadCount } from '@/api/enforcement/index'; |
|
|
|
import { pffwCount, zfpjcount, zfygCount, jhtzcount, zfywCount, zfyyCount, setMessageStats } from '@/store/messageState'; |
|
|
|
|
|
|
|
const router = useRouter(); |
|
|
|
const route = useRoute(); |
|
|
|
@ -100,31 +101,11 @@ const todoRefreshing = ref(false); |
|
|
|
const todoPageNum = ref(1); |
|
|
|
const todoPageSize = ref(10); |
|
|
|
|
|
|
|
// ========== 消息统计数据 ========== |
|
|
|
const messageStats = ref({ |
|
|
|
pffwCount: 0, // 普法服务未读数量 |
|
|
|
zfpjcount: 0, // 执法评价未读数量 |
|
|
|
zfygCount: 0, // 执法预告未读数量 |
|
|
|
totalCount: 0, // 未读总数 |
|
|
|
}); |
|
|
|
|
|
|
|
// 未读总数(tabbar 角标) |
|
|
|
const totalUnread = computed(() => { |
|
|
|
const messageUnread = messageList.value.reduce((sum, item) => sum + (item.unreadCount || 0), 0); |
|
|
|
const todoUnread = todoList.value.reduce((sum, item) => sum + (item.unreadCount || 0), 0); |
|
|
|
return messageUnread + todoUnread; |
|
|
|
}); |
|
|
|
|
|
|
|
// ========== 获取消息未读数量 ========== |
|
|
|
const fetchMessageStats = () => { |
|
|
|
getMessageUnreadCount({}, (res) => { |
|
|
|
if (res && res.code === 200 && res.data) { |
|
|
|
messageStats.value = { |
|
|
|
pffwCount: Number(res.data.pffwCount) || 0, // 普法服务未读数量 |
|
|
|
zfpjcount: Number(res.data.zfpjcount) || 0, // 执法评价未读数量 |
|
|
|
zfygCount: Number(res.data.zfygCount) || 0, // 执法预告未读数量 |
|
|
|
totalCount: Number(res.data.totalCount) || 0, // 总未读数量 |
|
|
|
}; |
|
|
|
setMessageStats(res.data); |
|
|
|
initMessageList(); |
|
|
|
initTodoList(); |
|
|
|
} |
|
|
|
@ -143,7 +124,7 @@ const initMessageList = () => { |
|
|
|
time: '', |
|
|
|
icon: 'law', |
|
|
|
iconBg: 'icon-blue', |
|
|
|
unreadCount: messageStats.value.pffwCount, |
|
|
|
unreadCount: pffwCount.value, |
|
|
|
},{ |
|
|
|
id: 3, |
|
|
|
title: '执法评价', |
|
|
|
@ -151,7 +132,7 @@ const initMessageList = () => { |
|
|
|
time: '', |
|
|
|
icon: 'law', |
|
|
|
iconBg: 'icon-blue', |
|
|
|
unreadCount: messageStats.value.zfpjcount, |
|
|
|
unreadCount: zfpjcount.value, |
|
|
|
},{ |
|
|
|
id: 4, |
|
|
|
title: '非现场执法评价', |
|
|
|
@ -159,7 +140,7 @@ const initMessageList = () => { |
|
|
|
time: '', |
|
|
|
icon: 'law', |
|
|
|
iconBg: 'icon-blue', |
|
|
|
unreadCount: messageStats.value.zfpjcount, |
|
|
|
unreadCount: zfpjcount.value, |
|
|
|
},{ |
|
|
|
id: 2, |
|
|
|
title: '计划通知', |
|
|
|
@ -167,7 +148,7 @@ const initMessageList = () => { |
|
|
|
time: '', |
|
|
|
icon: 'law', |
|
|
|
iconBg: 'icon-blue', |
|
|
|
unreadCount: messageStats.value.jhtzcount, |
|
|
|
unreadCount: jhtzcount.value, |
|
|
|
}, |
|
|
|
]; |
|
|
|
}; |
|
|
|
@ -182,7 +163,7 @@ const initTodoList = () => { |
|
|
|
time: '', |
|
|
|
icon: 'check', |
|
|
|
iconBg: 'icon-red', |
|
|
|
unreadCount: messageStats.value.zfygCount, |
|
|
|
unreadCount: zfygCount.value, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 102, |
|
|
|
@ -191,7 +172,7 @@ const initTodoList = () => { |
|
|
|
time: '', |
|
|
|
icon: 'check', |
|
|
|
iconBg: 'icon-red', |
|
|
|
unreadCount: messageStats.value.zfygCount, |
|
|
|
unreadCount: zfywCount.value, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 103, |
|
|
|
@ -200,7 +181,7 @@ const initTodoList = () => { |
|
|
|
time: '', |
|
|
|
icon: 'check', |
|
|
|
iconBg: 'icon-red', |
|
|
|
unreadCount: messageStats.value.zfygCount, |
|
|
|
unreadCount: zfyyCount.value, |
|
|
|
}, |
|
|
|
]; |
|
|
|
}; |
|
|
|
@ -217,7 +198,34 @@ const fetchMessageList = () => { |
|
|
|
time: '2026-04-15 10:07', |
|
|
|
icon: 'law', |
|
|
|
iconBg: 'icon-blue', |
|
|
|
unreadCount: messageStats.value.pffwCount, |
|
|
|
unreadCount: pffwCount.value, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 3, |
|
|
|
title: '执法评价', |
|
|
|
desc: zfpjcount.value > 0 ? `您有${zfpjcount.value}条执法评价,请及时查看` : '暂无执法评价', |
|
|
|
time: '2026-04-15 10:07', |
|
|
|
icon: 'law', |
|
|
|
iconBg: 'icon-blue', |
|
|
|
unreadCount: zfpjcount.value, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 4, |
|
|
|
title: '非现场执法评价', |
|
|
|
desc: zfpjcount.value > 0 ? `您有${zfpjcount.value}条非现场执法评价,请及时查看` : '暂无非现场执法评价', |
|
|
|
time: '2026-04-15 10:07', |
|
|
|
icon: 'law', |
|
|
|
iconBg: 'icon-blue', |
|
|
|
unreadCount: zfpjcount.value, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 2, |
|
|
|
title: '计划通知', |
|
|
|
desc: jhtzcount.value > 0 ? `您有${jhtzcount.value}条计划通知,请及时查看` : '暂无计划通知', |
|
|
|
time: '2026-04-15 10:07', |
|
|
|
icon: 'law', |
|
|
|
iconBg: 'icon-blue', |
|
|
|
unreadCount: jhtzcount.value, |
|
|
|
}, |
|
|
|
]; |
|
|
|
messageRefreshing.value = false; |
|
|
|
@ -235,11 +243,29 @@ const fetchTodoList = () => { |
|
|
|
{ |
|
|
|
id: 101, |
|
|
|
title: '执法预告', |
|
|
|
desc: messageStats.value.zfygCount > 0 ? `您有${messageStats.value.zfygCount}条执法预告,请及时查看` : '暂无执法预告', |
|
|
|
desc: zfygCount.value > 0 ? `您有${zfygCount.value}条执法预告,请及时查看` : '暂无执法预告', |
|
|
|
time: '2026-04-15 09:30', |
|
|
|
icon: 'check', |
|
|
|
iconBg: 'icon-red', |
|
|
|
unreadCount: zfygCount.value, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 102, |
|
|
|
title: '执法任务', |
|
|
|
desc: zfywCount.value > 0 ? `您有${zfywCount.value}条执法任务,请及时查看` : '暂无执法任务', |
|
|
|
time: '2026-04-15 09:30', |
|
|
|
icon: 'check', |
|
|
|
iconBg: 'icon-red', |
|
|
|
unreadCount: zfywCount.value, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 103, |
|
|
|
title: '执法预约', |
|
|
|
desc: zfyyCount.value > 0 ? `您有${zfyyCount.value}条执法预约,请及时查看` : '暂无执法预约', |
|
|
|
time: '2026-04-15 09:30', |
|
|
|
icon: 'check', |
|
|
|
iconBg: 'icon-red', |
|
|
|
unreadCount: messageStats.value.zfygCount, |
|
|
|
unreadCount: zfyyCount.value, |
|
|
|
}, |
|
|
|
]; |
|
|
|
todoRefreshing.value = false; |
|
|
|
@ -335,6 +361,11 @@ const onTodoClick = (item) => { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
watch([pffwCount, zfpjcount, zfygCount, jhtzcount, zfywCount, zfyyCount], () => { |
|
|
|
initMessageList(); |
|
|
|
initTodoList(); |
|
|
|
}); |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
const returnTab = sessionStorage.getItem('messageReturnTab'); |
|
|
|
if (returnTab === '1') { |
|
|
|
@ -351,8 +382,6 @@ onMounted(() => { |
|
|
|
activeTab.value = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
initMessageList(); |
|
|
|
initTodoList(); |
|
|
|
fetchMessageStats(); |
|
|
|
}); |
|
|
|
</script> |
|
|
|
|