提交 7ae1ce1d 编写于 作者: DCloud_JSON's avatar DCloud_JSON

更新 查找好友页面不再显示当前用户自己

上级 4e7b062b
......@@ -25,16 +25,9 @@
:avatar="item.avatar_file?.url || '/uni_modules/uni-im/static/avatarUrl.png'"
>
<text v-if="item.isFriend" class="chat-custom-right grey">已添加</text>
<text v-else-if="item._id === currentUser._id" class="chat-custom-right grey">不能加自己</text>
<text v-else @click="addUser(index)" class="chat-custom-right">加为好友</text>
</uni-im-info-card>
<!--
v-if="keyword.length"
<template v-else>
<uni-list-item v-for="(tab,index) in tabs" :key="index"
class="tab-item" :title="tab.title"
:to="tab.url" showArrow :border="false"
></uni-list-item>
</template> -->
</view>
<uni-im-load-state v-else :status="loading?'loading':(hasMore?'hasMore':'noMore')"></uni-im-load-state>
</view>
......@@ -96,6 +89,7 @@ import uniIm from '@/uni_modules/uni-im/sdk/index.js';
}
},
computed: {
...uniIm.mapState(['currentUser']),
usersList() {
let friendList = uniIm.friend.dataList
return this.usersData.map(item => {
......@@ -140,7 +134,7 @@ import uniIm from '@/uni_modules/uni-im/sdk/index.js';
const limit = 100
const skip = this.groupData.length/limit
const res = await db.collection('uni-im-group')
.where(`"user_id" != "${uniIm.currentUser._id}"`)
.where(`"user_id" != "${this.currentUser._id}"`)
.field('_id,name,avatar_file')
.orderBy('create_date', 'desc')
.skip(skip)
......@@ -156,6 +150,7 @@ import uniIm from '@/uni_modules/uni-im/sdk/index.js';
async getUserList(){
try{
let res = await db.collection('uni-id-users')
.where(`"_id" != "${this.currentUser._id}"`)
.field('_id,nickname,avatar_file')
.get()
let data = res.result.data
......@@ -166,26 +161,26 @@ import uniIm from '@/uni_modules/uni-im/sdk/index.js';
this.usersData = data
}
}catch(e){
console.log(e);
console.error(e);
}
},
back() {
uni.navigateBack()
},
async doSearch(e){
if(!this.keyword){
return this.activeIndex === 0 ? this.getUserList() : this.getGroupsList()
}
// console.log("doSearch: ",e,this.keyword);
uni.showLoading({
title: '搜索中'
})
if(this.activeIndex){
let where = {};
if(this.keyword){
where = `
const where = `
/${this.keyword}/.test(name) ||
"_id" == "${this.keyword}"
`
}
let res = await db.collection('uni-im-group')
const res = await db.collection('uni-im-group')
.where(where)
.get()
// console.log(res);
......@@ -199,7 +194,7 @@ import uniIm from '@/uni_modules/uni-im/sdk/index.js';
"mobile"
].map(item => `"${item}" == "${this.keyword}"`).join(' || ')
// console.log('whereString',whereString);
let res = await db.collection('uni-id-users')
const res = await db.collection('uni-id-users')
.where(whereString)
.field('_id,nickname,avatar_file')
.get()
......@@ -308,14 +303,10 @@ import uniIm from '@/uni_modules/uni-im/sdk/index.js';
.background{
background-color: #f5f5f5;
}
.grey{
color: #ddd;
}
.chat-custom-right {
width:70px;
height:30px;
line-height: 30px;
padding: 0 10px;
color: #666;
font-size: 12px;
text-align: center;
......@@ -325,6 +316,9 @@ import uniIm from '@/uni_modules/uni-im/sdk/index.js';
/* #endif */
border-radius: 100px;
}
.grey{
color: #aaa;
}
.border{
border: #ddd solid 1px;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册