吉安感知网项目-前端
张含笑
2026-01-12 7a0c71deb14c997e51f37a43728a933a97a707d8
feat:通讯录搜索
1 files modified
42 ■■■■■ changed files
uniapps/work-app/src/pages/voiceCall/index.vue 42 ●●●●● patch | view | raw | blame | history
uniapps/work-app/src/pages/voiceCall/index.vue
@@ -2,7 +2,7 @@
  <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>
    <!-- 联系人列表 -->
@@ -43,16 +43,17 @@
<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: ''
})
// 加载状态
@@ -62,19 +63,16 @@
// 获取通讯录
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 {
@@ -108,7 +106,18 @@
  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 || '未知联系人'
@@ -224,12 +233,13 @@
  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>