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

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

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