feat: connect user message notification
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<view class="chat-nav__btn" @tap="goBack">
|
||||
<u-icon name="arrow-left" size="34" color="#111827" />
|
||||
</view>
|
||||
<text class="chat-nav__title">私聊消息</text>
|
||||
<text class="chat-nav__title">消息通知</text>
|
||||
<view class="chat-nav__btn" @tap="loadSessions(true)">
|
||||
<u-icon name="reload" size="30" color="#111827" />
|
||||
</view>
|
||||
|
||||
@@ -82,7 +82,12 @@
|
||||
<view class="user-list">
|
||||
<view v-for="item in contentMenus" :key="item.key" class="user-list__item"
|
||||
@tap="handleMenuTap(item)">
|
||||
<view class="user-list__icon"><u-icon :name="item.icon" color="#1468f5" size="30" /></view>
|
||||
<view class="user-list__icon">
|
||||
<u-icon :name="item.icon" color="#1468f5" size="30" />
|
||||
<view v-if="item.key === 'notice' && stats.chat_unread_count > 0" class="user-list__badge">
|
||||
<text>{{ stats.chat_unread_count > 99 ? '99+' : stats.chat_unread_count }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="user-list__label">{{ item.label }}</text>
|
||||
<u-icon name="arrow-right" color="#9aa0a8" size="22" />
|
||||
</view>
|
||||
@@ -130,14 +135,15 @@ const stats = reactive({
|
||||
follow_count: 0,
|
||||
fans_count: 0,
|
||||
collect_count: 0,
|
||||
user_points: 0
|
||||
user_points: 0,
|
||||
chat_unread_count: 0
|
||||
})
|
||||
|
||||
const contentMenus = [
|
||||
{ key: 'posts', label: '我的帖子', icon: 'file-text', url: '/pages/my_posts/my_posts' },
|
||||
{ key: 'comments', label: '我的评论', icon: 'chat', url: '/pages/my_comments/my_comments' },
|
||||
{ key: 'collection', label: '我的收藏', icon: 'star', url: '/pages/collection/collection' },
|
||||
{ key: 'notice', label: '消息通知', icon: 'bell', toast: '消息通知功能即将上线' }
|
||||
{ key: 'notice', label: '消息通知', icon: 'bell', url: '/pages/private_chat/list' }
|
||||
]
|
||||
|
||||
const accountMenus = [
|
||||
@@ -207,6 +213,7 @@ const fetchStats = async () => {
|
||||
stats.fans_count = res.data.fans_count || 0
|
||||
stats.collect_count = res.data.collect_count || 0
|
||||
stats.user_points = res.data.user_points || 0
|
||||
stats.chat_unread_count = Number(res.data.chat_unread_count) || 0
|
||||
}
|
||||
} catch (e) {
|
||||
// 静默处理
|
||||
@@ -238,6 +245,10 @@ const openProfile = () => {
|
||||
}
|
||||
|
||||
const handleMenuTap = (item: any) => {
|
||||
if (item.key === 'notice' && !isLogin.value) {
|
||||
goPage('/pages/login/login')
|
||||
return
|
||||
}
|
||||
if (item.url) {
|
||||
goPage(item.url)
|
||||
return
|
||||
@@ -551,12 +562,35 @@ const handleMenuTap = (item: any) => {
|
||||
}
|
||||
|
||||
&__icon {
|
||||
position: relative;
|
||||
width: 36rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__badge {
|
||||
position: absolute;
|
||||
top: -8rpx;
|
||||
right: -18rpx;
|
||||
min-width: 26rpx;
|
||||
height: 26rpx;
|
||||
padding: 0 6rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 2rpx solid #fff;
|
||||
border-radius: 16rpx;
|
||||
background: #ef4444;
|
||||
box-sizing: border-box;
|
||||
|
||||
text {
|
||||
color: #fff;
|
||||
font-size: 16rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
&__label {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
Reference in New Issue
Block a user