| | |
| | | <div class="voiceCallContainer" :style="{ paddingTop: topMargin + 'px' }"> |
| | | <!-- 顶部搜索栏 --> |
| | | <div class="searchBar"> |
| | | <up-search placeholder="请输入关键字搜索" :animation="true" :show-action="false"></up-search> |
| | | <up-search placeholder="请输入关键字搜索" v-model="searchKeyword" :animation="true" :show-action="false"></up-search> |
| | | </div> |
| | | |
| | | <!-- 联系人列表 --> |
| | | <div class="contactList"> |
| | | <div |
| | | class="contactItem" |
| | | v-for="(contact, index) in filteredContacts" |
| | | :key="index" |
| | | > |
| | | <div class="itemBox"> |
| | | <!-- 头像 --> |
| | | <div class="contactAvatar"> |
| | | <image :src="contact.avatar" mode="aspectFill" /> |
| | | </div> |
| | | <div class="contactList"> |
| | | <div |
| | | class="contactItem" |
| | | v-for="(contact, index) in contacts" |
| | | :key="index" |
| | | > |
| | | <div class="itemBox"> |
| | | <!-- 头像 --> |
| | | <div class="contactAvatar"> |
| | | <image :src="contact.avatar" mode="aspectFill" /> |
| | | </div> |
| | | |
| | | <!-- 联系人信息 --> |
| | | <div class="contactInfo"> |
| | | <div class="contactName">{{ contact.name }}</div> |
| | | <div class="contactDept">{{ contact.dept }}</div> |
| | | </div> |
| | | <!-- 联系人信息 --> |
| | | <div class="contactInfo"> |
| | | <div class="contactName">{{ contact.friendNickName }}</div> |
| | | <div class="contactDept">{{ contact.dept }}</div> |
| | | </div> |
| | | |
| | | <!-- 电话按钮 --> |
| | | <div class="callButton" @click="makeCall(contact)"> |
| | | <image src="@/static/images/voiceVal/phoneVal.svg" mode="aspectFit" /> |
| | | </div> |
| | | </div> |
| | | <!-- 电话按钮 --> |
| | | <div class="callButton" @click="makeCall(contact)"> |
| | | <image src="@/static/images/voiceVal/phoneVal.svg" mode="aspectFit" /> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { getStatusBarHeight } from '@/utils/common'; |
| | | const topMargin = getStatusBarHeight() |
| | | |
| | | import { getPhoneBookListApi } from '@/api/voiceCall/index.js' |
| | | import { onShow } from '@dcloudio/uni-app' |
| | | // 搜索关键字 |
| | | const searchKeyword = ref('') |
| | | |
| | |
| | | { name: '张晓晓', dept: '吉州区应急部门', avatar: '/static/images/tabbar/icon_me.png' }, |
| | | ]) |
| | | |
| | | // 过滤后的联系人列表 |
| | | const filteredContacts = computed(() => { |
| | | if (!searchKeyword.value) { |
| | | return contacts.value |
| | | // 获取通讯录 |
| | | const getPhoneBookList = () => { |
| | | // 添加分页参数 |
| | | const params = { |
| | | pageNum: 1, |
| | | pageSize: 100 |
| | | } |
| | | return contacts.value.filter(contact => { |
| | | return contact.name.includes(searchKeyword.value) || |
| | | contact.dept.includes(searchKeyword.value) |
| | | getPhoneBookListApi(params).then(res => { |
| | | const response = res.data.data |
| | | console.log('通讯录', response) |
| | | contacts.value = response.records |
| | | }).catch(err => { |
| | | console.error('获取通讯录失败:', err) |
| | | const errorMsg = err.msg || err.message || '获取通讯录失败' |
| | | uni.showToast({ |
| | | title: errorMsg, |
| | | icon: 'none', |
| | | duration: 3000 |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | |
| | | // 拨打电话方法 |
| | | const makeCall = (contact) => { |
| | |
| | | icon: 'none' |
| | | }) |
| | | } |
| | | onShow(() => { |
| | | getPhoneBookList() |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | |
| | | .contactList { |
| | | margin: 0 24rpx; |
| | | background: #fff; |
| | | border-radius: 12rpx ; |
| | | border-radius: 12rpx; |
| | | overflow-y: auto; |
| | | height: 0; |
| | | flex-grow: 1; |
| | |
| | | .contactItem { |
| | | display: flex; |
| | | align-items: center; |
| | | padding:0 24rpx; |
| | | padding: 0 24rpx; |
| | | |
| | | } |
| | | |
| | | .itemBox { |
| | | display: flex; |
| | | align-items: center; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | width:100%; |
| | | width: 100%; |
| | | height: 98rpx; |
| | | border-bottom: 1rpx solid #EBEBEB; |
| | | } |
| | | |
| | | .contactAvatar { |
| | | width: 80rpx; |
| | | height: 80rpx; |