| | |
| | | <div class="voiceCallContainer" :style="{ paddingTop: topMargin + 'px' }"> |
| | | <!-- 顶部搜索栏 --> |
| | | <div class="searchBar"> |
| | | <up-search placeholder="请输入关键字搜索" v-model="defaultParam.searchKeyword" :animation="true" :show-action="false"></up-search> |
| | | <up-search placeholder="请输入关键字搜索" v-model="defaultParam.friendNickName" :animation="true" :show-action="false" @confirm="onSearch" @search="onSearch" @clear="handleClear"></up-search> |
| | | </div> |
| | | |
| | | <!-- 联系人列表 --> |
| | |
| | | |
| | | <script setup> |
| | | import { getStatusBarHeight } from '@/utils/common'; |
| | | |
| | | const topMargin = getStatusBarHeight() |
| | | import { getPhoneBookListApi } from '@/api/voiceCall/index.js' |
| | | import { onShow } from '@dcloudio/uni-app' |
| | | import defaultAvatar from '/static/images/defaultAvatar.svg' |
| | | import defaultAvatar from '/static/images/defaultAvatar.svg' |
| | | // 联系人数据 |
| | | const contacts = ref([]) |
| | | const defaultParam =ref( { |
| | | const defaultParam = ref({ |
| | | current: 1, |
| | | size: 10, |
| | | searchKeyword:'' |
| | | friendNickName: '' |
| | | }) |
| | | |
| | | // 加载状态 |
| | |
| | | // 获取通讯录 |
| | | const getPhoneBookList = () => { |
| | | if (loading.value || !hasMore.value) return |
| | | |
| | | loading.value = true |
| | | // 添加分页参数 |
| | | const params = { |
| | | current: defaultParam.value.current, |
| | | size: defaultParam.value.size, |
| | | searchKeyword: defaultParam.value.searchKeyword |
| | | friendNickName: defaultParam.value.friendNickName |
| | | } |
| | | |
| | | getPhoneBookListApi(params).then(res => { |
| | | const response = res.data.data |
| | | console.log('通讯录', response) |
| | | |
| | | if (defaultParam.value.current === 1) { |
| | | contacts.value = response.records |
| | | } else { |
| | |
| | | defaultParam.value.current++ |
| | | getPhoneBookList() |
| | | } |
| | | const onSearch = () => { |
| | | defaultParam.value.current = 1 |
| | | hasMore.value = true |
| | | getPhoneBookList() |
| | | |
| | | } |
| | | const handleClear = () => { |
| | | defaultParam.value.friendNickName = '' |
| | | defaultParam.value.current = 1 |
| | | hasMore.value = true |
| | | getPhoneBookList() |
| | | } |
| | | // 拨打电话方法 |
| | | const makeCall = (contact) => { |
| | | const contactName = contact.friendNickName || '未知联系人' |
| | |
| | | height: 60rpx; |
| | | |
| | | } |
| | | .loadingMore { |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | height: 80rpx; |
| | | font-size: 28rpx; |
| | | color: #999; |
| | | } |
| | | |
| | | .loadingMore { |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | height: 80rpx; |
| | | font-size: 28rpx; |
| | | color: #999; |
| | | } |
| | | </style> |