同步数据

This commit is contained in:
2022-02-18 10:51:01 +08:00
parent b7cc4d05a0
commit d6974e9a8b
5 changed files with 109 additions and 76 deletions

View File

@@ -2,22 +2,24 @@
<view>
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<view class="search">
<u--input class="search-input" placeholder="搜索" border="none" prefixIcon="search" v-model="searchTxt" :disabled="friends.length>0" disabledColor="#Fff"
prefixIconStyle="font-size: 22px;color: #909399" />
<u--input class="search-input" placeholder="搜索" border="none" prefixIcon="search" v-model="searchTxt"
disabledColor="#Fff" prefixIconStyle="font-size: 22px;color: #909399" />
</view>
<block v-if="friends.length > 0">
<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" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
@click="toFriend(friendItem.targetId)">
<u-avatar class="avatar-img" size="40" shape="square"
:src="contact(friendItem.targetId).portraitUrl" />
<view class="info">
<view class="name">{{ contact(friendItem.targetId).name }}</view>
<u-checkbox-group v-model="checkboxValue" placement="column" @change="checkboxChange">
<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" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
@click="selectFriend(friendItem.targetId)">
<u-checkbox :customStyle="{marginBottom: '8px'}" :name="friendItem.targetId" />
<u-avatar class="avatar-img" size="40" shape="square" :src="contact(friendItem.targetId).portraitUrl" />
<view class="info">
<view class="name">{{ contact(friendItem.targetId).name }}</view>
</view>
</view>
</view>
</u-index-item>
</u-index-item>
</u-checkbox-group>
</block>
<view class="no-lists" v-else>
<u-image class="cover" radius="4" width="400rpx" height="400rpx"
@@ -41,7 +43,8 @@
indexs: [],
friends: [],
pendingCount: 0,
searchTxt: ''
searchTxt: '',
checkboxValue: [],
};
},
computed: {
@@ -57,56 +60,33 @@
uni.$on('onContactNotification', this.checkNewFriendPending)
},
methods: {
// group事件
checkboxChange(n) {
console.log('change', n);
},
getFriendList() {
getFriendsLetter().then(res => {
console.log(res)
this.indexs = res.indexList
this.friends = res.itemArr
})
},
checkNewFriendPending() {
// 获取是否有新的好友申请
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], 1000, 0, (res) => {
if (res.code === 0) {
this.pendingCount = res.conversations.filter((item) => {
return item.objectName == RongIMLib.ObjectName.ContactNotification
}).length
}
})
},
toGroup() {
uni.navigateTo({
url: '/pages/im/group/index',
fail(err) {
console.log(err);
}
})
},
toFriend(targetId) {
// uni.navigateTo({
// url: '/pages/im/friends/info?targetId=' + targetId
// })
console.log('奥克兰打开')
},
// 新朋友
toPending() {
if (this.pendingCount > 0) {
uni.navigateTo({
url: '/pages/im/friends/pending'
});
} else {
uni.showToast({
title: ` 暂无好友申请 ~ `,
icon: "none",
mask: true,
duration: 3000
})
selectFriend(targetId) {
console.log(targetId,typeof targetId)
let arr = this.checkboxValue
let index = arr.findIndex(item => item === targetId)
if(index>0){
console.log('选择了再次点击清除数据le')
}else{
console.log('没有选择过,添加数据')
}
}
},
onNavigationBarButtonTap(e) {
uni.navigateTo({
url: '/pages/im/friends/search'
});
console.log(this.checkboxValue,index)
console.log('奥克兰打开',targetId)
},
}
};
</script>