好友列表调整

This commit is contained in:
2022-02-09 13:16:12 +08:00
parent 1678fd6e80
commit 699c178bd7
4 changed files with 65 additions and 38 deletions

View File

@@ -1,37 +1,32 @@
<template>
<view>
<view class="friend-flex u-border-bottom" @click="toPending">
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_01.png')"></u-avatar>
<u-badge max="99" absolute :offset="[23, 20]" :value="pendingCount" />
<view class="name">新的朋友</view>
</view>
<view class="friend-flex" @click="showToast">
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_00.png')"></u-avatar>
<view class="name">我的群聊</view>
</view>
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<view class="friend-flex u-border-bottom" @click="toPending">
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_01.png')"></u-avatar>
<u-badge max="99" absolute :offset="[23, 20]" :value="pendingCount" />
<view class="info">新的朋友</view>
</view>
<view class="friend-flex" @click="showToast">
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_00.png')"></u-avatar>
<view class="info">我的群聊</view>
</view>
<block v-if="friends.length > 0">
<template v-for="(item, fkey) in friends">
<!-- #ifdef APP-NVUE -->
<u-index-item v-for="(item, fkey) in friends" :key="fkey">
<u-index-anchor :text="indexs[fkey]" bgColor="#F3F6FB" height="20" size="12" color="#666">
</u-index-anchor>
<!-- #endif -->
<u-index-item>
<!-- #ifndef APP-NVUE -->
<u-index-anchor :text="indexs[fkey]" bgColor="#F3F6FB" height="20" size="12" color="#666">
</u-index-anchor>
<!-- #endif -->
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex u-border-bottom"
@click="toFriend(friendItem.userId)">
<u-avatar size="40" shape="square" :src="friend(friendItem.userId).portraitUrl" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex u-border-bottom"
@click="toFriend(friendItem.userId)">
<u-avatar size="40" shape="square" :src="friend(friendItem.userId).portraitUrl" />
<view class="info">
<view class="name">{{ friend(friendItem.userId).name }}</view>
<view class="address">{{ friendItem.address }}</view>
</view>
</u-index-item>
</template>
</view>
</u-index-item>
</block>
<block v-else>
<u-empty class="pages-null" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" text="暂无好友">
<u-empty class="pages-null" mode="data" text="暂无好友">
</u-empty>
</block>
</u-index-list>
@@ -42,8 +37,8 @@
import {
getFriendsLetter
} from '@/apis/interfaces/im';
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
export default {
data() {
return {
@@ -60,17 +55,23 @@
}
},
onLoad() {
uni.$on('onContactNotification', this.checkNewFriendPending)
this.getFriendList()
this.checkNewFriendPending()
getFriendsLetter().then(res => {
this.indexs = res.indexList
this.friends = res.itemArr
uni.$on('onContactNotification', () => {
this.checkNewFriendPending()
this.getFriendList()
})
},
onUnload() {
uni.$off('onContactNotification')
},
methods: {
getFriendList() {
getFriendsLetter().then(res => {
this.indexs = res.indexList
this.friends = res.itemArr
})
},
checkNewFriendPending() {
// 获取是否有新的好友申请
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], 1000, 0, (res) => {
@@ -121,13 +122,22 @@
flex-direction: row;
align-items: center;
.name {
.info {
flex: 1;
padding-left: $padding;
font-size: $title-size + 2;
font-size: $title-size + 2;
color: #454545 !important;
@extend .nowrap;
margin-left: $padding;
.name {
font-size: $title-size + 2;
font-size: $title-size + 2;
color: #454545 !important;
@extend .nowrap;
}
.address {
color: $text-gray-m;
font-size: $title-size-m - 5;
}
}
}
</style>

View File

@@ -158,7 +158,8 @@
content: '确认删除后不可恢复',
success: e => {
if (e.confirm) {
deleteFriend(this.targetId).then(res => {
deleteFriend(this.targetId).then(res => {
uni.$emit('onContactNotification')
// 删除聊天记录
RongIMLib.deleteMessages(1, this.targetId);
RongIMLib.removeConversation(1, this.targetId);