You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.3 KiB
123 lines
3.3 KiB
<template>
|
|
<view>
|
|
<cu-custom bgColor="bg-main-bar" :isBack="true">
|
|
<template #backText></template>
|
|
<template #content>{{title}}</template>
|
|
</cu-custom>
|
|
<view class="cu-bar bg-white search fixed" :style="[{top:CustomBar + 'px'}]">
|
|
<view class="search-form round">
|
|
<text class="cuIcon-search"></text>
|
|
<input type="text" v-model="keywords" placeholder="搜索联系人" confirm-type="search"/>
|
|
</view>
|
|
</view>
|
|
|
|
<view style="margin-top:120rpx">
|
|
<view v-if="type<3 && contacts.length>0">
|
|
<view class="padding">联系人</view>
|
|
<view class="cu-list menu-avatar no-padding">
|
|
<!-- <view class="cu-item" v-for="(items,sub) in contacts" :key="sub" @tap='openDetails(items)'>
|
|
<view class='cu-avatar lg radius mr-15' :style="[{backgroundImage:'url('+items.avatar+')'}]">
|
|
</view>
|
|
<view class="content">
|
|
<view class="c-333">{{items.displayName}}</view>
|
|
</view>
|
|
</view> -->
|
|
<view v-for="(items,sub) in contacts" :key="sub" @tap='openDetails(items)' style="background-color: #fff;padding: 15px;border-bottom: 1px solid #f7f7f7;display: flex;align-items: center;">
|
|
<view class='cu-avatar lg radius mr-15' :style="[{backgroundImage:'url('+items.avatar+')'}]">
|
|
</view>
|
|
<view>
|
|
<view class="c-333 text-overflow" style="width: 240px;">{{items.displayName}}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view v-if="groupList.length>0">
|
|
<view class="padding">群聊</view>
|
|
<view class="cu-list menu-avatar no-padding">
|
|
<view class="cu-item" v-for="(items,sub) in groupList" :key="sub" @tap='openDetails(items)'>
|
|
<view class='cu-avatar lg radius mr-15' :style="[{backgroundImage:'url('+items.avatar+')'}]">
|
|
</view>
|
|
<view class="content">
|
|
<view class="c-333">{{items.displayName}}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view v-if="!groupList.length && !contacts.length">
|
|
<Empty noDatatext="暂无数据" textcolor="#999" ></Empty>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
/**
|
|
* 初始的引导页
|
|
*/
|
|
export default {
|
|
name : "search",
|
|
data() {
|
|
return {
|
|
title:'搜索聊天',
|
|
keywords:'',
|
|
allContacts:[],
|
|
contacts:[],
|
|
groupList:[],
|
|
type:1
|
|
};
|
|
},
|
|
watch:{
|
|
keywords(val){
|
|
this.search();
|
|
}
|
|
},
|
|
onLoad(options){
|
|
this.type=options.type;
|
|
if(this.type==2){
|
|
this.title="搜索联系人";
|
|
}else if(this.type==3){
|
|
this.title="搜索群聊";
|
|
}else{
|
|
this.title="搜索聊天";
|
|
}
|
|
},
|
|
mounted(){
|
|
this.allContacts=uni.getStorageSync('allContacts');
|
|
},
|
|
methods: {
|
|
search(){
|
|
const arr=this.$util.searchObject(this.allContacts,['displayName','name_py','account'],this.keywords);
|
|
const contacts=[];
|
|
const groupList=[];
|
|
arr.forEach((item)=>{
|
|
if(item.is_group==1){
|
|
groupList.push(item);
|
|
}else{
|
|
contacts.push(item);
|
|
}
|
|
})
|
|
this.groupList=groupList;
|
|
this.contacts=contacts;
|
|
},
|
|
// 打开聊天
|
|
openDetails(items){
|
|
if(this.type==2 && items.is_gourp==0){
|
|
uni.navigateTo({
|
|
url:"/pages/contacts/detail?id="+items.id
|
|
})
|
|
}
|
|
uni.navigateTo({
|
|
url:"/pages/message/chat?id="+items.id
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.text-overflow{
|
|
text-overflow: ellipsis;
|
|
overflow: hidden !important;
|
|
white-space: nowrap !important;
|
|
}
|
|
</style>
|