Commit 5d676393 by lijiabin

【需求 21402】 feat: 完成私信相关的功能

parent 674789ad
...@@ -5,6 +5,7 @@ import type { ...@@ -5,6 +5,7 @@ import type {
ConversationResponseDto, ConversationResponseDto,
GetMessageDetailListDto, GetMessageDetailListDto,
MessageDetailListItem, MessageDetailListItem,
DeleteMessageDto,
} from './types' } from './types'
// 关于私信的相关接口 // 关于私信的相关接口
...@@ -37,3 +38,12 @@ export const getMessageDetailList = (data: GetMessageDetailListDto) => { ...@@ -37,3 +38,12 @@ export const getMessageDetailList = (data: GetMessageDetailListDto) => {
data, data,
}) })
} }
// 删除某个私信
export const deleteMessage = (data: DeleteMessageDto) => {
return service.request({
url: '/api/cultureDialog/deleteMessage',
method: 'POST',
data,
})
}
...@@ -78,3 +78,13 @@ export interface MessageDetailListItem { ...@@ -78,3 +78,13 @@ export interface MessageDetailListItem {
is_self: boolean is_self: boolean
image_list: string[] image_list: string[]
} }
/** 删除私信:会话或单条消息 */
export type DeleteCultureMessageKind = 'user' | 'message'
export interface DeleteMessageDto {
/** user:按会话删除;message:按消息删除 */
type: DeleteCultureMessageKind
/** 会话 id 列表或消息 id 列表 */
idList: number[]
}
...@@ -112,6 +112,12 @@ ...@@ -112,6 +112,12 @@
<component :is="item.icon" /> <component :is="item.icon" />
</el-icon> </el-icon>
<span class="text-sm">{{ item.label }}</span> <span class="text-sm">{{ item.label }}</span>
<el-badge
v-if="item.tab === '我的私信'"
:value="privateMessageUnreadDisplay > 99 ? '99+' : privateMessageUnreadDisplay"
:hidden="privateMessageUnreadDisplay <= 0"
class="ml-auto"
/>
</div> </div>
</div> </div>
<!-- 左侧菜单 —— 官方账号菜单 审核操作等 --> <!-- 左侧菜单 —— 官方账号菜单 审核操作等 -->
...@@ -164,7 +170,7 @@ ...@@ -164,7 +170,7 @@
<script lang="tsx" setup> <script lang="tsx" setup>
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import EditUserInfo from './components/editUserInfo.vue' import EditUserInfo from './components/editUserInfo.vue'
import { generateLoginKey, hasOfficialAccount } from '@/api' import { generateLoginKey, hasOfficialAccount, getMessageList } from '@/api'
import type { OfficialAccountItemDto } from '@/api/user/types' import type { OfficialAccountItemDto } from '@/api/user/types'
import { wxLogin } from '@/utils/wxUtil' import { wxLogin } from '@/utils/wxUtil'
import type { RouteLocationNormalizedLoadedGeneric } from 'vue-router' import type { RouteLocationNormalizedLoadedGeneric } from 'vue-router'
...@@ -198,6 +204,8 @@ const componentRef = useTemplateRef<{ ...@@ -198,6 +204,8 @@ const componentRef = useTemplateRef<{
const editUserInfoRef = useTemplateRef<InstanceType<typeof EditUserInfo>>('editUserInfoRef') const editUserInfoRef = useTemplateRef<InstanceType<typeof EditUserInfo>>('editUserInfoRef')
const userStore = useUserStore() const userStore = useUserStore()
const { userInfo } = storeToRefs(userStore) const { userInfo } = storeToRefs(userStore)
const anonymousUnreadCount = ref(0)
const realUnreadCount = ref(0)
// 左侧普通用户菜单 // 左侧普通用户菜单
const menuUserItems = [ const menuUserItems = [
...@@ -281,6 +289,11 @@ const menuOfficialItems = [ ...@@ -281,6 +289,11 @@ const menuOfficialItems = [
const isReal = ref<BooleanFlag>(BooleanFlag.NO) const isReal = ref<BooleanFlag>(BooleanFlag.NO)
/** 与私信页一致:实名 → realUnreadCount,匿名 → anonymousUnreadCount */
const privateMessageUnreadDisplay = computed(() =>
isReal.value === BooleanFlag.YES ? realUnreadCount.value : anonymousUnreadCount.value,
)
provide(IS_REAL_KEY, isReal) provide(IS_REAL_KEY, isReal)
watch(isReal, () => { watch(isReal, () => {
...@@ -321,6 +334,17 @@ const getIsOfficial = async () => { ...@@ -321,6 +334,17 @@ const getIsOfficial = async () => {
officialAccountList.value = data officialAccountList.value = data
} }
const getSelfMessageUnreadCount = async () => {
try {
const { data } = await getMessageList({})
anonymousUnreadCount.value = data?.anonymousUnreadCount ?? 0
realUnreadCount.value = data?.realUnreadCount ?? 0
} catch {
anonymousUnreadCount.value = 0
realUnreadCount.value = 0
}
}
const handleSwitchAccount = async () => { const handleSwitchAccount = async () => {
const selectedEmail = ref('') const selectedEmail = ref('')
ElMessageBox({ ElMessageBox({
...@@ -429,6 +453,10 @@ const handleClearCache = async () => { ...@@ -429,6 +453,10 @@ const handleClearCache = async () => {
onMounted(() => { onMounted(() => {
getIsOfficial() getIsOfficial()
}) })
onActivated(() => {
getSelfMessageUnreadCount()
})
</script> </script>
<style scoped> <style scoped>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment