diff --git a/src/components/search/ResultItem/ContactItem.vue b/src/components/search/ResultItem/ContactItem.vue index ce06b2a..1fcfab2 100644 --- a/src/components/search/ResultItem/ContactItem.vue +++ b/src/components/search/ResultItem/ContactItem.vue @@ -1,30 +1,30 @@ - {{ props.user.nickName }} - {{ props.user.account }} + {{ props.contactInfo.nickName }} + {{ props.contactInfo.account }} - 部门: {{ props.user.organization || '-' }} + 部门: {{ props.contactInfo.organization || '-' }} diff --git a/src/components/search/SearchBox.vue b/src/components/search/SearchBox.vue index 5ee246a..320fb46 100644 --- a/src/components/search/SearchBox.vue +++ b/src/components/search/SearchBox.vue @@ -5,6 +5,8 @@ import ContactItem from './ResultItem/ContactItem.vue' import { userQueryService, userQueryByNickService } from '@/api/user' import { searchStore } from '@/stores' +const emit = defineEmits(['showContactCard']) + const searchData = searchStore() const inputRef = ref() const keyWords = ref('') @@ -37,6 +39,10 @@ const onOpen = () => { }) } +const onShowContactCard = (contactInfo) => { + emit('showContactCard', contactInfo) +} + // 1.失去焦点或按Enter时触发查询 // 2.延时+防抖查询 // TODO 如果缓存有值,且keywords没有改变就不重新查了 @@ -53,7 +59,6 @@ const onQuery = () => { console.log('all 待完成,搜索关键字:', keyWordsTrim.value) break case 'contact': - console.log('contact 待完成,搜索关键字:', keyWordsTrim.value) response = await userQueryByNickService({ nickNameKeyWords: keyWordsTrim.value }) response.data.data?.forEach((element) => { result[element.account] = element @@ -132,7 +137,8 @@ watch(searchTab, () => { diff --git a/src/components/user/UserCard.vue b/src/components/user/UserCard.vue index fa370cb..4a1cc82 100644 --- a/src/components/user/UserCard.vue +++ b/src/components/user/UserCard.vue @@ -23,7 +23,8 @@ const closeCardIfOutside = (event) => { if ( !event.target.closest('.user-card') && !event.target.closest('.avatar-session-box') && - !event.target.closest('.avatar-message-item') + !event.target.closest('.avatar-message-item') && + !event.target.closest('.avatar-contact-item') ) { onClose() } diff --git a/src/views/message/MessageLayout.vue b/src/views/message/MessageLayout.vue index 8ada365..54f7f24 100644 --- a/src/views/message/MessageLayout.vue +++ b/src/views/message/MessageLayout.vue @@ -417,6 +417,12 @@ const onShowUserCard = async ({ sessionId, account }) => { isShowUserCard.value = true } +const onShowContactCard = (contactInfo) => { + userInfo.value = contactInfo + isShowGroupCard.value = false + isShowUserCard.value = true +} + // TODO const onShowGroupCard = () => { isShowUserCard.value = false @@ -457,7 +463,7 @@ watch(() => msgRecords.value, (oldValue) => { - +