This commit is contained in:
2022-02-18 15:12:51 +08:00
parent 5b2c15f380
commit 0deef8bc6a
2 changed files with 49 additions and 17 deletions

View File

@@ -2,18 +2,18 @@
<view class="invite">
<view class="search">
<u--input class="search-input" placeholder="搜索" border="none" prefixIcon="search" v-model="searchTxt"
disabledColor="#Fff" prefixIconStyle="font-size: 22px;color: #909399" />
disabledColor="#Fff" prefixIconStyle="font-size: 22px;color: #909399" @change="onSearch" />
</view>
<block v-if="friends.length > 0">
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<u-checkbox-group v-if="friends.length > 0" v-model="checkboxValue" placement="column">
<u-index-item v-for="(item, fkey) in friends" :key="fkey">
<u-index-anchor :text="indexs[fkey]" bgColor="#ededed" height="20" size="12" color="#666"
style="padding:10rpx 30rpx" />
<u-index-anchor :text="indexs[fkey]" v-if="indexs[fkey]" bgColor="#ededed" height="20" size="12"
color="#666" style="padding:10rpx 30rpx" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
@click="addContact(friendItem.targetId)">
<u-checkbox :name="friendItem.targetId" shape="square" activeColor="#34ce98"
style="margin-right: 20rpx;" />
<u-checkbox :name="friendItem.targetId" shape="circle" activeColor="#34ce98"
style="margin-right: 20rpx;" :disabled="canSelect(friendItem.targetId)" />
<u-avatar class="avatar-img" size="40" shape="square"
:src="contact(friendItem.targetId).portraitUrl" />
<view class="info">
@@ -43,6 +43,8 @@
inviteGroupUser,
getGroupUsers
} from '@/apis/interfaces/im';
import utils from '@/utils/index.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
export default {
@@ -51,9 +53,11 @@
searchTxt: '',
targetId: '',
indexs: [],
orignalIndexs: [],
friends: [],
orignalFriends: [],
checkboxValue: [],
selectValue:[]
selectValue: []
};
},
computed: {
@@ -68,15 +72,44 @@
this.getFriendList()
},
methods: {
onSearch(val) {
if (val) {
var ix = []
this.friends = this.orignalFriends.map((list, index) => {
const resList = list.filter(item => item.name.indexOf(val) > 0)
if (resList.length > 0) {
this.indexs.filter((t, i) => i == index)
}
// if (resList.length > 0) {
// ix = this.orignalIndexs.map((t, i) => {
// if (i == index) {
// return t
// }
// }).filter(Boolean)
// }
return resList
})
console.log( this.indexs);
} else {
this.friends = this.orignalFriends
this.indexs = this.orignalIndexs
}
},
canSelect(targetId) {
return utils.inArray(targetId, this.selectValue)
},
getFriendList() {
getFriendsLetter().then(res => {
this.indexs = res.indexList
this.friends = res.itemArr
this.orignalFriends = res.itemArr
this.orignalIndexs = res.indexList
})
getGroupUsers(this.targetId).then(res => {
res.map(res => {
this.checkboxValue.push(res.targetId + "")
this.selectValue.push(res.targetId+"")
this.checkboxValue.push(String(res.targetId))
this.selectValue.push(String(res.targetId))
})
})
},
@@ -91,7 +124,7 @@
},
onInvite() {
inviteGroupUser(this.targetId, this.checkboxValue).then(res => {
console.log(res,'res')
console.log(res, 'res')
uni.navigateBack({
delta: 1,
animationType: 'pop-out',