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

chore: 消息增加未读统计

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