feat(消息): 添加未读消息红点显示功能
在TabBar和消息页面添加未读消息红点显示 更新用户状态管理以支持消息计数 调整搜索栏提示文本和红点样式大小
Showing
4 changed files
with
22 additions
and
11 deletions
| ... | @@ -34,8 +34,15 @@ | ... | @@ -34,8 +34,15 @@ |
| 34 | <view | 34 | <view |
| 35 | @click="navigateTo('/pages/messages/index')" | 35 | @click="navigateTo('/pages/messages/index')" |
| 36 | :class="getTabClass('messages')" | 36 | :class="getTabClass('messages')" |
| 37 | + class="relative" | ||
| 37 | > | 38 | > |
| 38 | <Message size="20" :color="getIconColor('messages')" /> | 39 | <Message size="20" :color="getIconColor('messages')" /> |
| 40 | + <!-- 未读消息红点 --> | ||
| 41 | + <div | ||
| 42 | + v-if="unreadCount > 0" | ||
| 43 | + class="absolute top-0 right-0 bg-red-500 rounded-full w-2 h-2" | ||
| 44 | + > | ||
| 45 | + </div> | ||
| 39 | <span class="text-xs mt-1">消息</span> | 46 | <span class="text-xs mt-1">消息</span> |
| 40 | </view> | 47 | </view> |
| 41 | 48 | ||
| ... | @@ -53,7 +60,7 @@ | ... | @@ -53,7 +60,7 @@ |
| 53 | </template> | 60 | </template> |
| 54 | 61 | ||
| 55 | <script setup> | 62 | <script setup> |
| 56 | -import { ref, onMounted } from 'vue' | 63 | +import { ref, onMounted, computed } from 'vue' |
| 57 | import Taro from '@tarojs/taro' | 64 | import Taro from '@tarojs/taro' |
| 58 | import { Home, Category, Message, My } from '@nutui/icons-vue-taro' | 65 | import { Home, Category, Message, My } from '@nutui/icons-vue-taro' |
| 59 | import { useUserStore } from '@/stores/user' | 66 | import { useUserStore } from '@/stores/user' |
| ... | @@ -63,6 +70,8 @@ import { checkPermission, PERMISSION_TYPES } from '@/utils/permission' | ... | @@ -63,6 +70,8 @@ import { checkPermission, PERMISSION_TYPES } from '@/utils/permission' |
| 63 | const activeTab = ref('') | 70 | const activeTab = ref('') |
| 64 | // 用户状态管理 | 71 | // 用户状态管理 |
| 65 | const userStore = useUserStore() | 72 | const userStore = useUserStore() |
| 73 | +// 未读消息数量 | ||
| 74 | +const unreadCount = computed(() => userStore.userInfo.message_count) | ||
| 66 | 75 | ||
| 67 | /** | 76 | /** |
| 68 | * 获取当前页面路径并设置激活状态 | 77 | * 获取当前页面路径并设置激活状态 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-19 14:11:06 | 2 | * @Date: 2022-09-19 14:11:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-07-23 14:51:20 | 4 | + * @LastEditTime: 2025-07-23 16:00:30 |
| 5 | * @FilePath: /jgdl/src/pages/auth/index.vue | 5 | * @FilePath: /jgdl/src/pages/auth/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -91,8 +91,8 @@ export default { | ... | @@ -91,8 +91,8 @@ export default { |
| 91 | // 测试环境下传递openid,正式环境不传递 | 91 | // 测试环境下传递openid,正式环境不传递 |
| 92 | if (process.env.NODE_ENV === 'development') { | 92 | if (process.env.NODE_ENV === 'development') { |
| 93 | // requestData.openid = 'h-008'; | 93 | // requestData.openid = 'h-008'; |
| 94 | - requestData.openid = 'h-009'; | 94 | + // requestData.openid = 'h-009'; |
| 95 | - // requestData.openid = 'oWbdFvkD5VtloC50wSNR9IWiU2q8'; | 95 | + requestData.openid = 'oWbdFvkD5VtloC50wSNR9IWiU2q8'; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | request.post('/srv/?a=openid', requestData) | 98 | request.post('/srv/?a=openid', requestData) | ... | ... |
| ... | @@ -8,7 +8,7 @@ | ... | @@ -8,7 +8,7 @@ |
| 8 | </nut-col> --> | 8 | </nut-col> --> |
| 9 | <nut-col span="24"> | 9 | <nut-col span="24"> |
| 10 | <!-- Search Bar --> | 10 | <!-- Search Bar --> |
| 11 | - <nut-searchbar v-model="searchValue" placeholder="搜索消息" @blur="onBlurSearch" @clear="onBlurSearch" shape="round" | 11 | + <nut-searchbar v-model="searchValue" placeholder="按联系人名字/系统通知内容搜索" @blur="onBlurSearch" @clear="onBlurSearch" shape="round" |
| 12 | background="transparent" input-background="#ffffff"> | 12 | background="transparent" input-background="#ffffff"> |
| 13 | <template #leftin> | 13 | <template #leftin> |
| 14 | <Search2 /> | 14 | <Search2 /> |
| ... | @@ -58,7 +58,7 @@ | ... | @@ -58,7 +58,7 @@ |
| 58 | <text class="font-medium truncate flex-1 mr-2">{{ conversation.name }}</text> | 58 | <text class="font-medium truncate flex-1 mr-2">{{ conversation.name }}</text> |
| 59 | <view class="flex items-center flex-shrink-0"> | 59 | <view class="flex items-center flex-shrink-0"> |
| 60 | <text class="text-xs text-gray-500">{{ conversation.time }}</text> | 60 | <text class="text-xs text-gray-500">{{ conversation.time }}</text> |
| 61 | - <view v-if="conversation.unread" class="ml-1 w-2 h-2 bg-red-500 rounded-full"> | 61 | + <view v-if="conversation.unread" class="ml-1 bg-red-500 rounded-full w-2 h-2"> |
| 62 | </view> | 62 | </view> |
| 63 | </view> | 63 | </view> |
| 64 | </view> | 64 | </view> |
| ... | @@ -584,11 +584,11 @@ onUnmounted(() => { | ... | @@ -584,11 +584,11 @@ onUnmounted(() => { |
| 584 | } | 584 | } |
| 585 | 585 | ||
| 586 | .w-2 { | 586 | .w-2 { |
| 587 | - width: 8rpx; | 587 | + width: 16rpx; |
| 588 | } | 588 | } |
| 589 | 589 | ||
| 590 | .h-2 { | 590 | .h-2 { |
| 591 | - height: 8rpx; | 591 | + height: 16rpx; |
| 592 | } | 592 | } |
| 593 | 593 | ||
| 594 | // .rounded-full { | 594 | // .rounded-full { | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2025-01-08 18:00:00 | 2 | * @Date: 2025-01-08 18:00:00 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-07-09 11:22:03 | 4 | + * @LastEditTime: 2025-07-24 10:52:42 |
| 5 | * @FilePath: /jgdl/src/stores/user.js | 5 | * @FilePath: /jgdl/src/stores/user.js |
| 6 | * @Description: 用户状态管理 | 6 | * @Description: 用户状态管理 |
| 7 | */ | 7 | */ |
| ... | @@ -22,7 +22,8 @@ export const useUserStore = defineStore('user', { | ... | @@ -22,7 +22,8 @@ export const useUserStore = defineStore('user', { |
| 22 | avatar_url: '', | 22 | avatar_url: '', |
| 23 | follower_count: 0, | 23 | follower_count: 0, |
| 24 | order_count: 0, | 24 | order_count: 0, |
| 25 | - favorite_count: 0 | 25 | + favorite_count: 0, |
| 26 | + message_count: 0, | ||
| 26 | }, | 27 | }, |
| 27 | isAuthenticated: false, | 28 | isAuthenticated: false, |
| 28 | isLoading: false | 29 | isLoading: false |
| ... | @@ -99,7 +100,8 @@ export const useUserStore = defineStore('user', { | ... | @@ -99,7 +100,8 @@ export const useUserStore = defineStore('user', { |
| 99 | avatar_url: '', | 100 | avatar_url: '', |
| 100 | follower_count: 0, | 101 | follower_count: 0, |
| 101 | order_count: 0, | 102 | order_count: 0, |
| 102 | - favorite_count: 0 | 103 | + favorite_count: 0, |
| 104 | + message_count: 0, | ||
| 103 | } | 105 | } |
| 104 | this.isAuthenticated = false | 106 | this.isAuthenticated = false |
| 105 | }, | 107 | }, | ... | ... |
-
Please register or login to post a comment