提交 b4e70605 authored 作者: 王鹏飞's avatar 王鹏飞

chore: 消息增加未读统计

上级 340bba26
......@@ -34,5 +34,5 @@ export function sendResetPasswordCode(data) {
}
// 登出
export function logout() {
return httpRequest.get('/api/passport/rest/logout')
return httpRequest.post('/api/alumni/site/logout')
}
......@@ -240,6 +240,11 @@ export function updateActivityStatus(id, data) {
return httpRequest.post(`/api/alumni/v1/activities2/check/${id}`, data)
}
// 获取未读消息
export function getUnreadMessage() {
return httpRequest.get('/api/alumni/v1/student/unread')
}
// 获取消息列表
export function getMessageList(params) {
return httpRequest.get('/api/alumni/v1/student/messages', { params })
......
......@@ -2,14 +2,14 @@ import axios from 'axios'
import qs from 'qs'
import { Notify } from 'vant'
import router from '@/router'
import { logout } from '@/api/account'
// import { logout } from '@/api/account'
const httpRequest = axios.create({
baseURL: process.env.VUE_APP_BASE_API,
timeout: 60000,
withCredentials: true,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
tenant: 'sofia'
'Content-Type': 'application/x-www-form-urlencoded'
// tenant: 'sofia'
}
})
......@@ -39,12 +39,12 @@ httpRequest.interceptors.response.use(
if (status === 400) {
Notify(message)
} else if (status === 403) {
logout().then(() => {
// logout().then(() => {
// })
router.replace({
path: '/login',
query: { redirect_uri: encodeURIComponent(window.location.href) }
})
})
}
} else {
Notify(error)
......
......@@ -8,6 +8,7 @@
<div class="message-card-content">
<h4>系统消息</h4>
<!-- <p>紫荆官方发布了一条新消息,点击查看</p> -->
<span class="num" v-if="total.system">{{ total.system }}</span>
</div>
</div>
<div class="message-card" @click="onClick('1')">
......@@ -17,6 +18,7 @@
<div class="message-card-content">
<h4>组织消息</h4>
<!-- <p>您创建的组织有新的人员加入请求</p> -->
<span class="num" v-if="total.group">{{ total.group }}</span>
</div>
</div>
<div class="message-card" @click="onClick('2')">
......@@ -26,6 +28,7 @@
<div class="message-card-content">
<h4>活动消息</h4>
<!-- <p>您创建的活动有新的人员加入请求</p> -->
<span class="num" v-if="total.activity">{{ total.activity }}</span>
</div>
</div>
</card>
......@@ -34,16 +37,39 @@
<script>
import Card from '@/components/Card'
import * as api from '@/api'
export default {
name: 'MessageIndex',
components: { Card },
data() {
return {}
return {
unreadList: []
}
},
computed: {
total() {
return this.unreadList.reduce(
(result, item) => {
const map = { 1: 'group', 2: 'activity', 3: 'system' }
result[map[item.type]] = item.sum
return result
},
{ activity: 0, system: 0, group: 0 }
)
}
},
methods: {
onClick(type) {
this.$router.push({ name: 'messageList', params: { type } })
},
getUnreadMessage() {
api.getUnreadMessage().then(response => {
this.unreadList = response
})
}
},
beforeMount() {
this.getUnreadMessage()
}
}
</script>
......@@ -65,6 +91,8 @@ export default {
}
}
.message-card-content {
position: relative;
flex: 1;
margin-left: 10px;
h4 {
font-size: 14px;
......@@ -76,5 +104,20 @@ export default {
font-size: 12px;
color: #999;
}
.num {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
width: 20px;
height: 20px;
font-size: 12px;
color: #fff;
line-height: 20px;
text-align: center;
background-color: #ff6767;
border-radius: 50%;
overflow: hidden;
}
}
</style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论