提交
This commit is contained in:
parent
73063d1faf
commit
23415808bb
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed, onMounted, watch } from 'vue'
|
import { ref, computed, onMounted, watch } from 'vue'
|
||||||
import { ServeGetContacts } from '@/api/contact'
|
import { ServeGetTalkList } from '@/api/chat.js'
|
||||||
import { ServeGetGroups } from '@/api/group'
|
import { ServeGetGroups } from '@/api/group'
|
||||||
import XNModal from '@/components/x-naive-ui/x-n-modal/index.vue'
|
import XNModal from '@/components/x-naive-ui/x-n-modal/index.vue'
|
||||||
const emit = defineEmits(['close', 'on-submit'])
|
const emit = defineEmits(['close', 'on-submit'])
|
||||||
@ -26,7 +26,7 @@ const loadGroupStatus = ref(false)
|
|||||||
// 搜索过滤器:不再按类型过滤,将好友和群组融合在一起
|
// 搜索过滤器:不再按类型过滤,将好友和群组融合在一起
|
||||||
const searchFilter = computed(() => {
|
const searchFilter = computed(() => {
|
||||||
return items.value.filter((item: Item) => {
|
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 = () => {
|
const onLoad = () => {
|
||||||
onLoadContact()
|
onLoadContact()
|
||||||
onLoadGroup()
|
// onLoadGroup()
|
||||||
}
|
}
|
||||||
|
|
||||||
const onLoadContact = () => {
|
const onLoadContact = () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
ServeGetContacts()
|
ServeGetTalkList()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
let list = res.data.items || []
|
let list = res.data.items || []
|
||||||
|
|
||||||
items.value = list.map((item: any) => {
|
items.value = list.map((item: any) => {
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
...item,
|
||||||
avatar: item.avatar,
|
|
||||||
type: 1,
|
|
||||||
name: item.remark || item.nickname,
|
|
||||||
keyword: (item.remark || '') + item.nickname,
|
|
||||||
remark: item.remark,
|
|
||||||
checked: false
|
checked: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -68,35 +63,35 @@ const onLoadContact = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const onLoadGroup = async () => {
|
// const onLoadGroup = async () => {
|
||||||
if (loadGroupStatus.value) {
|
// if (loadGroupStatus.value) {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
loading.value = true
|
// loading.value = true
|
||||||
let { code, data } = await ServeGetGroups()
|
// let { code, data } = await ServeGetGroups()
|
||||||
if (code != 200) {
|
// if (code != 200) {
|
||||||
loading.value = false
|
// loading.value = false
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
let list = data.items.map((item: any) => {
|
// let list = data.items.map((item: any) => {
|
||||||
return {
|
// return {
|
||||||
id: item.id,
|
// id: item.id,
|
||||||
avatar: item.avatar,
|
// avatar: item.avatar,
|
||||||
type: 2,
|
// type: 2,
|
||||||
name: item.group_name,
|
// name: item.group_name,
|
||||||
keyword: item.group_name,
|
// keyword: item.group_name,
|
||||||
remark: '',
|
// remark: '',
|
||||||
checked: false
|
// checked: false
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
|
|
||||||
items.value.push(...list)
|
// items.value.push(...list)
|
||||||
|
|
||||||
loading.value = false
|
// loading.value = false
|
||||||
loadGroupStatus.value = true
|
// loadGroupStatus.value = true
|
||||||
}
|
// }
|
||||||
|
|
||||||
const onMaskClick = () => {
|
const onMaskClick = () => {
|
||||||
emit('close')
|
emit('close')
|
||||||
@ -151,7 +146,13 @@ const changeSelectType = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad()
|
watch(()=>{
|
||||||
|
return isShowBox.value
|
||||||
|
},(newVal)=>{
|
||||||
|
if(newVal){
|
||||||
|
onLoad()
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -183,7 +184,12 @@ onLoad()
|
|||||||
<n-checkbox v-else :checked="item.checked" />
|
<n-checkbox v-else :checked="item.checked" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mr-10px">
|
<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>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<span class="text-ellipsis">{{ item.name }}</span>
|
<span class="text-ellipsis">{{ item.name }}</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user