好友删除,扫码加好友

This commit is contained in:
2022-01-26 14:25:54 +08:00
parent b24d2a4906
commit c786af8179
3 changed files with 38 additions and 35 deletions

View File

@@ -23,6 +23,14 @@ const getImToken = () => {
}, true)
}
// 删除好友
const deleteFriend = (targetId) => {
return request({
method: 'DELETE',
url: 'im/friends/' + targetId,
})
}
// 获取用户信息
const getUserInfo = (targetId) => {
return request({
@@ -79,6 +87,7 @@ const pedingFriend = (recipient) => {
export {
getImToken,
deleteFriend,
getFriends,
getUserInfo,
getFriendInfo,

View File

@@ -2,7 +2,7 @@
<view>
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<view>
<view class="friend-flex" @click="toPending">
<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>
<view class="name">新的朋友</view>
</view>
@@ -22,7 +22,7 @@
<u-index-anchor :text="indexs[friend]" bgColor="#F3F6FB" height="20" size="12" color="#666">
</u-index-anchor>
<!-- #endif -->
<view v-for="(friendItem, index) in item" :key="friendItem.userId" class="friend-flex"
<view v-for="(friendItem, index) in item" :key="friendItem.userId" class="friend-flex u-border-bottom"
@click="$Router.push({ name: 'imFriendsInfo', params: { targetId: friendItem.userId } })">
<block v-if="friendItem.portraitUrl != ''">
<u-avatar class="cover" size="40" shape="square" :src="friendItem.portraitUrl || ''"
@@ -108,19 +108,5 @@
font-size: $title-size;
@extend .nowrap;
}
&::after {
position: absolute;
height: 1rpx;
background: $border-color;
left: calc(40px + #{$padding * 2});
right: 0;
bottom: 0;
content: ' ';
}
&:last-child::after {
display: none;
}
}
</style>

View File

@@ -58,7 +58,8 @@
<script>
import {
getFriendInfo,
pedingFriend
pedingFriend,
deleteFriend
} from '@/apis/interfaces/im.js'
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
@@ -71,11 +72,10 @@
isTop: false,
block: false,
conversationType: 1
};
}
},
onLoad(e) {
this.targetId = e.targetId
console.log(this.targetId);
getFriendInfo(e.targetId).then(res => {
this.userInfo = res
uni.setNavigationBarTitle({
@@ -125,9 +125,19 @@
content: '确认删除后不可恢复',
success: (e) => {
if (e.confirm) {
deleteFriend(this.targetId).then(res => {
// 删除聊天记录
RongIMLib.deleteMessages(1, this.targetId)
RongIMLib.removeConversation(1, this.targetId)
uni.showToast({
icon: 'none',
title: '开发中'
title: '好友删除成功',
success() {
uni.switchTab({
url: '/pages/im/index'
})
}
})
})
}
}
@@ -154,14 +164,12 @@
},
// 申请好友
toBeFriend() {
pedingFriend(this.targetId)
.then(res => {
pedingFriend(this.targetId).then(res => {
uni.showToast({
title: '申请成功',
icon: "none"
})
})
.catch(err => {
}).catch(err => {
uni.showToast({
icon: 'error',
title: err.message,