59 lines
1.2 KiB
Vue
59 lines
1.2 KiB
Vue
<template>
|
|
<div style="position:relative;" class="cursor-pointer" @click="handleClick">
|
|
<div class="num" v-show="num">{{ num }}</div>
|
|
<el-icon :size="30">
|
|
<Bell />
|
|
</el-icon>
|
|
</div>
|
|
</template>
|
|
<script setup>
|
|
import { Bell } from '@element-plus/icons-vue'
|
|
import Notifce from './../../../../utils/Notifce.js'
|
|
import { apiOaMsgNums } from '@/api/oa_message'
|
|
import { useRouter } from "vue-router"
|
|
|
|
const router = useRouter()
|
|
|
|
const handleClick = () => {
|
|
num.value = 0
|
|
router.push("/works/oa_message")
|
|
}
|
|
|
|
const num = ref(0)
|
|
|
|
const getNums = async () => {
|
|
let res = await apiOaMsgNums()
|
|
if (res.message_count == 0) {
|
|
return num.value = 0
|
|
}
|
|
if (res.message_count != num.value) {
|
|
Notifce.info("你有新的消息")
|
|
num.value = res.message_count
|
|
}
|
|
|
|
}
|
|
|
|
// setInterval(() => {
|
|
// getNums()
|
|
// }, 10000);
|
|
getNums()
|
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
.num {
|
|
position: absolute;
|
|
top: -5px;
|
|
right: -5px;
|
|
width: 20px;
|
|
height: 20px;
|
|
background: red;
|
|
border-radius: 50%;
|
|
color: #fff;
|
|
text-align: center;
|
|
line-height: 20px;
|
|
font-size: 12px;
|
|
z-index: 100;
|
|
}
|
|
</style> |