|
|
@@ -28,7 +28,7 @@
|
|
|
title="公告"></message-list>
|
|
|
|
|
|
<!-- 消息列表 -->
|
|
|
- <message-list ref="msgListRef" @readMsg="setAllMsgRead" :unReadNum="unReadNum"
|
|
|
+ <message-list ref="msgListRef" @readMsg="setAllMsgRead" :unReadNum="unReadMsgNum"
|
|
|
@clickSegment="getMessageData" @clickItem="handleToMessageDetail" @scrollToBottom="getMessagePage"
|
|
|
:defaultCurrent="1" :pSize="5" :pageNo="1" :anime="true" :open="true"
|
|
|
:segments="{ '全部': '', '未读': '0', '已读': '1' }" title="消息"></message-list>
|
|
|
@@ -49,7 +49,7 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { onBeforeMount, onMounted, onUpdated, ref } from 'vue';
|
|
|
-import { onLoad } from '@dcloudio/uni-app'
|
|
|
+import { onLoad,onShow } from '@dcloudio/uni-app'
|
|
|
import { getMessageList, getNoticeList, getUnReadMessageNum, setMsgIsRead } from '@/api/message.js';
|
|
|
import { getUserProcess, getUnProcessNum } from '@/api/process';
|
|
|
import $tab from '@/plugins/tab.js';
|
|
|
@@ -58,27 +58,29 @@ import processList from '@/components/ygoa/processList.vue'
|
|
|
import messageList from '@/components/ygoa/messageList.vue'
|
|
|
import { useUserStore } from '@/store/user.js'
|
|
|
import { getLoginInfo } from '@/utils/auth';
|
|
|
+
|
|
|
const userStore = useUserStore()
|
|
|
|
|
|
const processListRef = ref(null)
|
|
|
onMounted(() => {
|
|
|
uni.$on('ReloadProcessData', (res) => {
|
|
|
- console.log('res: ', res);
|
|
|
processListRef.value.onClickItem()
|
|
|
})
|
|
|
+ uni.$on('showTabBarBadge', showTabBarBadge)
|
|
|
})
|
|
|
onLoad((options) => {
|
|
|
// 是否跳转打卡页
|
|
|
if (options.to == 'clockIn') toClockIn()
|
|
|
})
|
|
|
+onShow(()=>{
|
|
|
+ showTabBarBadge();
|
|
|
+})
|
|
|
onBeforeMount(() => {
|
|
|
uni.removeTabBarBadge({
|
|
|
index: 0
|
|
|
})
|
|
|
})
|
|
|
-onUpdated(() => {
|
|
|
- showTarBarBadge();
|
|
|
-})
|
|
|
+
|
|
|
// 跳转打卡页
|
|
|
function toClockIn() {
|
|
|
// 确认是否跳转打卡页
|
|
|
@@ -89,53 +91,6 @@ function toClockIn() {
|
|
|
|
|
|
//子组件
|
|
|
const msgListRef = ref(null)
|
|
|
-//设置消息已读
|
|
|
-function setMsgRead() {
|
|
|
- $modal.confirm('是否一键已读').then(res => {
|
|
|
- if (res) {
|
|
|
- const params = {
|
|
|
- currentUser: userStore.user.useId,
|
|
|
- isRead: "0",
|
|
|
- pSize: unReadNum.value,
|
|
|
- type: "",
|
|
|
- p: 1,
|
|
|
- }
|
|
|
- getMessageList(params).then(({ returnParams }) => {
|
|
|
- const unReadMsgIds = returnParams.ids === "" ? "" : returnParams.ids + ",";
|
|
|
- setMsgIsRead(unReadMsgIds).then((res) => {
|
|
|
- if (Number.isInteger(res)) {
|
|
|
- switch (res) {
|
|
|
- case -1:
|
|
|
- $modal.msgError('操作失败')
|
|
|
- break
|
|
|
- case -2:
|
|
|
- case 0:
|
|
|
- $modal.msg('不存在未读消息')
|
|
|
- break
|
|
|
- default:
|
|
|
- $modal.msgSuccess('操作成功')
|
|
|
- //刷新页面
|
|
|
- msgListRef.value.reload();// 调用子组件刷新数据
|
|
|
- // showTarBarBadge();
|
|
|
- }
|
|
|
- } else {
|
|
|
- // $modal.msgError('jssesionid失效')
|
|
|
- $modal.confirm('jssesionid失效,您可以继续留在该页面,或者重新登录?').then(res=>{
|
|
|
- const loginInfo=getLoginInfo();
|
|
|
- userStore.LogOut().then(res=>{
|
|
|
- uni.setStorageSync('loginInfo',loginInfo)
|
|
|
- $tab.reLaunch('/pages/login')
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
|
|
|
// 获取待办消息列表数据
|
|
|
function getProcessData({ pSize, pageNo }, callback) {
|
|
|
@@ -275,10 +230,10 @@ function toClockInBtn() {
|
|
|
//待办流程数
|
|
|
const unProcessNum = ref(0)
|
|
|
//未读消息数
|
|
|
-const unReadNum = ref(0)
|
|
|
-//待阅消息数+待办流程数(用于tarbar导航栏)
|
|
|
const unReadMsgNum = ref(0)
|
|
|
-function showTarBarBadge() {
|
|
|
+//待阅消息数+待办流程数(用于tarbar导航栏)
|
|
|
+const unReadNum = ref(0)
|
|
|
+function showTabBarBadge() {
|
|
|
getUnProcessNum(userStore.user.useId, "").then(res => {
|
|
|
if ("failed" == res.returnMsg) {
|
|
|
$modal.showToast('待办流程数获取失败')
|
|
|
@@ -287,16 +242,16 @@ function showTarBarBadge() {
|
|
|
unProcessNum.value = parseInt(res.returnParams.total, 10);
|
|
|
}
|
|
|
getUnReadMessageNum(userStore.user.useId).then(res => {
|
|
|
- unReadNum.value = parseInt(res.returnParams, 10);
|
|
|
- unReadMsgNum.value = unReadNum.value + unProcessNum.value;
|
|
|
- if (unReadMsgNum.value == 0) {
|
|
|
+ unReadMsgNum.value = parseInt(res.returnParams, 10);
|
|
|
+ unReadNum.value = unReadMsgNum.value + unProcessNum.value;
|
|
|
+ if (unReadNum.value == 0) {
|
|
|
uni.removeTabBarBadge({
|
|
|
index: 0
|
|
|
})
|
|
|
} else {
|
|
|
uni.setTabBarBadge({
|
|
|
index: 0,
|
|
|
- text: unReadMsgNum.value > 99 ? '99+' : String(unReadMsgNum.value)
|
|
|
+ text: unReadNum.value > 99 ? '99+' : String(unReadNum.value)
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
@@ -309,7 +264,7 @@ function setAllMsgRead() {
|
|
|
const params = {
|
|
|
currentUser: userStore.user.useId,
|
|
|
isRead: "0",
|
|
|
- pSize: unReadNum.value,
|
|
|
+ pSize: unReadMsgNum.value,
|
|
|
type: "",
|
|
|
p: 1,
|
|
|
}
|
|
|
@@ -324,12 +279,14 @@ function setAllMsgRead() {
|
|
|
case -2:
|
|
|
case 0:
|
|
|
$modal.msg('不存在未读消息')
|
|
|
+ msgListRef.value.reload();// 调用子组件刷新数据
|
|
|
+ showTabBarBadge()
|
|
|
break
|
|
|
default:
|
|
|
$modal.msgSuccess('操作成功')
|
|
|
//刷新页面
|
|
|
msgListRef.value.reload();// 调用子组件刷新数据
|
|
|
- // showTarBarBadge();
|
|
|
+ showTabBarBadge()
|
|
|
}
|
|
|
} else {
|
|
|
$modal.confirm('登录状态失效,您可以继续留在该页面,或者重新登录?').then(res => {
|