| | |
| | | <div class="voiceCallContainer" :style="{ paddingTop: topMargin + 'px' }"> |
| | | <!-- 顶部搜索栏 --> |
| | | <div class="searchBar"> |
| | | <up-search placeholder="请输入关键字搜索" v-model="defaultParam.friendNickName" :animation="true" :show-action="false" @confirm="onSearch" @search="onSearch" @clear="handleClear"></up-search> |
| | | <up-search placeholder="请输入关键字搜索" v-model="defaultParam.nickName" :animation="true" :show-action="false" @confirm="onSearch" @search="onSearch" @clear="handleClear"></up-search> |
| | | </div> |
| | | |
| | | <!-- 联系人列表 --> |
| | |
| | | |
| | | <script setup> |
| | | import { getStatusBarHeight } from '@/utils/common'; |
| | | |
| | | import { useUserStore } from "@/store/index.js" |
| | | const topMargin = getStatusBarHeight() |
| | | import { getPhoneBookListApi } from '@/api/voiceCall/index.js' |
| | | import { onShow } from '@dcloudio/uni-app' |
| | | import defaultAvatar from '/static/images/defaultAvatar.svg' |
| | | const userStore = useUserStore() |
| | | const userId = userStore.userInfo.new_userInfo.userId |
| | | // 联系人数据 |
| | | const contacts = ref([]) |
| | | const defaultParam = ref({ |
| | | current: 1, |
| | | size: 10, |
| | | friendNickName: '' |
| | | nickName: '' |
| | | }) |
| | | |
| | | // 加载状态 |
| | |
| | | const params = { |
| | | current: defaultParam.value.current, |
| | | size: defaultParam.value.size, |
| | | friendNickName: defaultParam.value.friendNickName |
| | | nickName: defaultParam.value.nickName |
| | | } |
| | | |
| | | getPhoneBookListApi(params).then(res => { |
| | | const response = res.data.data |
| | | // 过滤掉与当前登录用户userId一致的联系人 |
| | | const filteredRecords = response.records.filter(contact => { |
| | | return contact.userId && String(contact.userId) !== String(userId) |
| | | }) |
| | | if (defaultParam.value.current === 1) { |
| | | contacts.value = response.records |
| | | contacts.value = filteredRecords |
| | | } else { |
| | | contacts.value = [...contacts.value, ...response.records] |
| | | contacts.value = [...contacts.value, ...filteredRecords] |
| | | } |
| | | |
| | | // 判断是否还有更多数据 |
| | | if (response.records.length < defaultParam.value.size || response.current >= response.pages) { |
| | | if (filteredRecords.length < defaultParam.value.size || response.current >= response.pages) { |
| | | hasMore.value = false |
| | | } else { |
| | | hasMore.value = true |
| | |
| | | |
| | | } |
| | | const handleClear = () => { |
| | | defaultParam.value.friendNickName = '' |
| | | defaultParam.value.nickName = '' |
| | | defaultParam.value.current = 1 |
| | | hasMore.value = true |
| | | getPhoneBookList() |