This commit is contained in:
Phoenix 2025-05-19 16:56:52 +08:00
parent 73063d1faf
commit 23415808bb

View File

@ -1,6 +1,6 @@
<script lang="ts" setup>
import { ref, computed, onMounted, watch } from 'vue'
import { ServeGetContacts } from '@/api/contact'
import { ServeGetTalkList } from '@/api/chat.js'
import { ServeGetGroups } from '@/api/group'
import XNModal from '@/components/x-naive-ui/x-n-modal/index.vue'
const emit = defineEmits(['close', 'on-submit'])
@ -26,7 +26,7 @@ const loadGroupStatus = ref(false)
//
const searchFilter = computed(() => {
return items.value.filter((item: Item) => {
return item.keyword.toLowerCase().includes(keywords.value.toLowerCase())
return item.name.toLowerCase().includes(keywords.value.toLowerCase())
})
})
@ -40,24 +40,19 @@ const isCanSubmit = computed(() => {
const onLoad = () => {
onLoadContact()
onLoadGroup()
// onLoadGroup()
}
const onLoadContact = () => {
loading.value = true
ServeGetContacts()
ServeGetTalkList()
.then((res) => {
if (res.code == 200) {
let list = res.data.items || []
items.value = list.map((item: any) => {
return {
id: item.id,
avatar: item.avatar,
type: 1,
name: item.remark || item.nickname,
keyword: (item.remark || '') + item.nickname,
remark: item.remark,
...item,
checked: false
}
})
@ -68,35 +63,35 @@ const onLoadContact = () => {
})
}
const onLoadGroup = async () => {
if (loadGroupStatus.value) {
return
}
// const onLoadGroup = async () => {
// if (loadGroupStatus.value) {
// return
// }
loading.value = true
let { code, data } = await ServeGetGroups()
if (code != 200) {
loading.value = false
return
}
// loading.value = true
// let { code, data } = await ServeGetGroups()
// if (code != 200) {
// loading.value = false
// return
// }
let list = data.items.map((item: any) => {
return {
id: item.id,
avatar: item.avatar,
type: 2,
name: item.group_name,
keyword: item.group_name,
remark: '',
checked: false
}
})
// let list = data.items.map((item: any) => {
// return {
// id: item.id,
// avatar: item.avatar,
// type: 2,
// name: item.group_name,
// keyword: item.group_name,
// remark: '',
// checked: false
// }
// })
items.value.push(...list)
// items.value.push(...list)
loading.value = false
loadGroupStatus.value = true
}
// loading.value = false
// loadGroupStatus.value = true
// }
const onMaskClick = () => {
emit('close')
@ -151,7 +146,13 @@ const changeSelectType = () => {
})
}
onLoad()
watch(()=>{
return isShowBox.value
},(newVal)=>{
if(newVal){
onLoad()
}
})
</script>
<template>
@ -183,7 +184,12 @@ onLoad()
<n-checkbox v-else :checked="item.checked" />
</div>
<div class="mr-10px">
<n-image class="w-42px h-42px rounded-full" :src="item.avatar" />
<avatarModule class="mr-10px" :mode="item.talk_type"
:avatar="item.avatar"
:groupType="item.group_type"
:customStyle="{width:'42px',height:'42px'}"></avatarModule>
<!-- <n-image class="w-42px h-42px rounded-full" :src="item.avatar" /> -->
</div>
<div class="flex items-center">
<span class="text-ellipsis">{{ item.name }}</span>