<template>
<div class="bxgd">
<!-- 导航栏 -->
<!-- <div class="nav">
<div class="user"
@click="goback">
<img src="./../../../../static/images/fh_btn@2x.png" />
</div>
<div class="navTitle">通讯录</div>
<div class="tips">
</div>
</div> -->
<!-- 搜索 -->
<div class="filter">
<van-search v-model="query.data.searchStr"
shape="round"
background="#fff"
@search="handleChange">
</van-search>
<div class="search-icon"
@click="handleChange"></div>
</div>
<!-- 主体 -->
<div class="main">
<!-- 列表 -->
<div class="list">
<van-index-bar v-if="!query.data.searchStr"
:index-list="indexList">
<div v-for="(item,index) in mailData"
:key="index">
<van-index-anchor :index="item.ch" />
<van-cell v-for="(item2,index2) in item.data"
:key="index2"
@click="showDia(item2.personnelPhone,item2.personnelName)">
{{item2.departmentName}}-{{item2.personnelName}}
</van-cell>
</div>
</van-index-bar>
<div v-else>
<van-cell v-for="(item2,index2) in allData"
:key="index2"
@click="showDia(item2.personnelPhone,item2.personnelName)">
{{item2.departmentName}}-{{item2.personnelName}}
</van-cell>
</div>
</div>
</div>
<van-popup v-model="showphoneDia"
position="bottom"
round
:style="{ height: '35%' }">
<PhoneDia :ToPhone='ToPhone'
:ToName='ToName'></PhoneDia>
<div class="popup-close"
@click="showphoneDia=false">取消</div>
</van-popup>
</div>
</template>
记得加indexList 就从mailData里面提取ch的数组 不然可能点击跳转不对
<script>
import { http } from "../../api/index";
import PinyinMatch from "pinyin-match";
import PhoneDia from "@/components/PhoneDia"; //电话弹框
export default {
components: {
PhoneDia
},
data () {
return {
showphoneDia: false,
ToPhone: '',
ToName: '',
query: {
data: {
searchStr: '',
},
},
allData: [],
indexList: [],
mailData: [
{ "ch": "A", "data": [{ "personnelPhone": "13600000000", "departmentName": "暗淡" }] },
{ "ch": "B", "data": [{ "personnelPhone": "13600000000", "departmentName": "包子" }] },
{ "ch": "C", "data": [{ "personnelPhone": "13600000000", "departmentName": "重庆" }] },
{ "ch": "D", "data": [{ "personnelPhone": "13600000000", "departmentName": "地方" }] },
{ "ch": "E", "data": [{ "personnelPhone": "13600000000", "departmentName": "二期" }] },
{ "ch": "F", "data": [{ "personnelPhone": "13600000000", "departmentName": "发货" }] },
{ "ch": "Z", "data": [{ "personnelPhone": "13600000000", "departmentName": "周岩" }] },
{ "ch": "T", "data": [{ "personnelPhone": "13600000000", "departmentName": "田松" }] },
{ "ch": "D", "data": [{ "personnelPhone": "13600000000", "departmentName": "玳瑁猫" }] },
{ "ch": "J", "data": [{ "personnelPhone": "13600000000", "departmentName": "加菲猫" }, { "personnelPhone": "13600000000", "departmentName": "金渐层" }, { "personnelPhone": "13600000000", "departmentName": "橘猫" }] },
{ "ch": "L", "data": [{ "personnelPhone": "13600000000", "departmentName": "蓝白猫" }, { "personnelPhone": "13600000000", "departmentName": "蓝猫" }, { "personnelPhone": "13600000000", "departmentName": "狸花猫" }, { "personnelPhone": "13600000000", "label": "狸花猫" }] }],
isRefreshing: false, //是否处于刷新状态
loading: false, //数据是否处于加载状态
finished: true, //数据是否加载完毕
listData: [],
//列表数据
activeNames: [0],
activeNames2: [0],
activeNames3: [0],
activeNames4: [0],
}
},
watch: {
'query.data.searchStr' (val) {
if (val) {
let dataList = []
// let mark = ''
this.mailData.forEach(item => {
if (item.data !== undefined) {
item.data.forEach(i => {
const a = `${i.personnelName}${i.departmentName}`
if (PinyinMatch.match(a, val)) {
dataList.push({ personnelPhone: i.personnelPhone, personnelName: i.personnelName, departmentName: i.departmentName })
// mark = item.ch
// console.log('dataList', dataList);
}
})
}
})
this.allData = dataList
}
}
},
mounted () {
// this.txlsearch();
this.onLoadData()
},
filters: {
formdataeg (val) {
var resultPhone = val.replace(/^(\d{3})\d{4}(\d+)/, "$1****$2");
return resultPhone
},
},
methods: {
showDia (phone, name) {
this.ToPhone = phone
this.ToName = name
this.$nextTick(() => {
this.showphoneDia = true
})
},
//触发事件
handleEvent (event) {
switch (event) {
//下拉刷新数据
case "refresh":
this.finished = false;
this.loading = true;
this.txlsearch();
break;
//上拉加载数据
case "load":
this.txlsearch();
break;
}
},
getnewchildren (item) {
if (item.state == 0) {
let formdata = new FormData()
formdata.append('orgId', item.id)
http.post(this.$api.sipingrivers.floodList, formdata).then(res => {
if (res.data.code == 200) {
// console.log(this.listData);
console.log(item);
this.addchildren(this.listData, item.id, res.data.data)
// console.log(res.data.data);
}
})
} else {
return
}
},
addchildren (arr, id, data) {
console.log(arr, id, data);
arr[0].children.map(item => {
if (item.id == id) {
item.children = data
}
})
console.log(arr);
},
//返回到上一页
goback () {
// this.$router.push({
// path: "/fxyjment"
// });
},
handleChange (name, index) {
console.log(name);
console.log('mailData', this.mailData);
// this.listData = [];
// this.txlsearch();
},
txlsearch () {
if (this.isRefreshing) {
this.listData = [];
this.query.current = 1;
this.isRefreshing = false;
}
http.post(this.$api.sipingrivers.getAddressList).then(res => {
if (res.data.code === 200) {
console.log(res.data.data);
this.listData = res.data.data
this.loading = false;
this.finished = true;
} else {
this.loading = false;
this.finished = true;
this.$toast({
message: res.data.message,
type: "fail"
});
}
}).catch(() => {
this.loading = false;
this.finished = true;
});
},
//请求数据
onLoadData () {
this.indexList = []
this.mailData = []
http.post(this.$api.floodprevention.getAddressList).then(res => {
if (res.data.code === 200) {
console.log(res.data.data);
this.mailData = res.data.data
res.data.data.map(item => {
this.indexList.push(item.ch)
})
} else {
this.loading = false;
this.finished = true;
this.$toast({
message: res.data.message,
type: "fail"
});
}
})
.catch(() => {
this.loading = false;
this.finished = true;
});
},
}
}
</script>
<style lang="scss" scoped>
/deep/ .van-field__left-icon {
display: none;
}
.bxgd {
width: 100%;
height: 100%;
overflow: hidden;
}
.main {
width: 100%;
height: calc(100% - 0.44rem);
overflow-y: auto;
.list {
width: 100%;
height: 100%;
/deep/ .van-pull-refresh {
overflow-y: auto;
height: 100%;
}
}
}
.bxgd .filter {
height: 0.44rem;
position: relative;
padding-top: 0;
overflow: hidden;
z-index: 99;
}
.search-icon {
position: absolute;
right: 23px;
top: 50%;
transform: translateY(-50%);
width: 24px;
height: 24px;
background: url("../../../static/images/newfxhj/gwmap/search.png") no-repeat;
background-size: 100% 100%;
}
.bxgd .list-item_field {
height: 100%;
min-height: 0.25rem;
display: flex;
justify-content: space-between;
.label {
display: flex;
min-width: 67%;
}
.text {
color: #000;
font-size: 0.1225rem;
font-weight: bold;
margin-right: 0.0625rem;
min-width: 0.425rem;
text-align: center;
}
.personnelPhone {
color: #999999;
// max-width: 60%;
}
.icon {
width: 20px;
height: 20px;
background: url("../../../static/images/newfxhj/messagecx/tel.png")
no-repeat;
background-size: 100% 100%;
}
}
.yiji {
font-size: 0.125rem;
font-weight: bold;
}
/deep/ .dierji {
.van-cell {
// background-color: #f3f8ff;
font-weight: bold;
padding: 10px 0;
}
}
/deep/.van-search {
padding-right: 52px;
}
.bxgd .bigheight {
min-height: 0.4rem;
align-items: center;
}
#phone2 {
display: block;
width: 100%;
}
.popup-close {
padding: 15px 0;
text-align: center;
font-size: 0.1575rem;
}
</style>
下面为弹框组件 多页面复制传值即可调用 因为新增了融云语音和视频功能所以需要区分开来
<template>
<div id="PhoneDia">
<div>
<div class="popup-title">呼叫 {{ToName}}</div>
<div class="tonghua-item"
@click="chaxunstatus(1)">
<div class="svg-pix">
<img :src="yuyin">
</div>
<div>语音通话</div>
</div>
<div class="tonghua-item"
@click="chaxunstatus(2)">
<div class="svg-pix">
<img :src="shipin">
</div>
<div>视频通话</div>
</div>
<div class="tonghua-item">
<div class="svg-pix">
<img :src="putong">
</div>
<a :href="'tel:'+ToPhone"
id="phone2">
普通电话
</a>
</div>
<div class="popup-jianju"></div>
</div>
</div>
</template>
<script>
import { http } from "@/api/index";
export default {
props: {
ToPhone: {
type: String
},
ToName: {
type: String
}
},
data () {
return {
LoginPhone: JSON.parse(localStorage.getItem("userinfo")).phone,
yuyin: require('../../static/images/address/yyth.svg'),
shipin: require('../../static/images/address/spth.svg'),
putong: require('../../static/images/address/ptdh.svg'),
};
},
mounted () {
},
methods: {
// 查询当前用户是否在线
chaxunstatus (type) {
let prams = {
phone: this.ToPhone
}
http.post(this.$api.floodprevention.getUserStatus, prams).then(res => {
if (res.data.code == 200) {
let data = JSON.parse(res.data.data)
if (data.status == 1) {
// 1为在线
switch (type) {
case 1:
this.setrongphone()
break;
case 2:
this.setrongvideo()
break;
}
} else {
this.$toast({
message: '当前呼叫人员不在线,请使用普通电话联系'
});
}
}
})
},
// 融云电话
setrongphone () {
console.log(this.LoginPhone, this.ToPhone);
window.android.setrongphone(this.LoginPhone, this.ToPhone)
},
//融云视频
setrongvideo () {
console.log(this.LoginPhone, this.ToPhone);
window.android.setrongvideo(this.LoginPhone, this.ToPhone)
},
}
};
</script>
<style lang="scss" scoped>
.popup-title {
text-align: center;
font-size: 0.1275rem;
padding: 0.125rem;
color: #969799;
}
.popup-jianju {
height: 8px;
width: 100%;
background: #f2f1f6;
}
.tonghua-item {
padding: 10px;
display: flex;
align-items: center;
font-size: 0.1475rem;
border-top: 1px solid #efefef;
}
.svg-pix {
margin-right: 10px;
height: 30px;
width: 20px;
img {
width: 100%;
height: 100%;
fill: #000;
}
}
#phone2 {
display: block;
width: 100%;
}
</style>
仿照钉钉写的一个弹框(右侧为钉钉)