From 7ae1ce1d1cfef5f282b4220b243ca3d4f96c4ce7 Mon Sep 17 00:00:00 2001 From: linju Date: Mon, 11 Nov 2024 20:32:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E5=A5=BD=E5=8F=8B=E9=A1=B5=E9=9D=A2=E4=B8=8D=E5=86=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7=E8=87=AA=E5=B7=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addPeopleGroups/addPeopleGroups.vue | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/pages/contacts/addPeopleGroups/addPeopleGroups.vue b/pages/contacts/addPeopleGroups/addPeopleGroups.vue index b282577..e8aea51 100644 --- a/pages/contacts/addPeopleGroups/addPeopleGroups.vue +++ b/pages/contacts/addPeopleGroups/addPeopleGroups.vue @@ -25,16 +25,9 @@ :avatar="item.avatar_file?.url || '/uni_modules/uni-im/static/avatarUrl.png'" > 已添加 + 不能加自己 加为好友 - @@ -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; } -- GitLab