好友删除,扫码加好友
This commit is contained in:
@@ -22,6 +22,14 @@ const getImToken = () => {
|
||||
url: 'im/token',
|
||||
}, true)
|
||||
}
|
||||
|
||||
// 删除好友
|
||||
const deleteFriend = (targetId) => {
|
||||
return request({
|
||||
method: 'DELETE',
|
||||
url: 'im/friends/' + targetId,
|
||||
})
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
const getUserInfo = (targetId) => {
|
||||
@@ -78,7 +86,8 @@ const pedingFriend = (recipient) => {
|
||||
}
|
||||
|
||||
export {
|
||||
getImToken,
|
||||
getImToken,
|
||||
deleteFriend,
|
||||
getFriends,
|
||||
getUserInfo,
|
||||
getFriendInfo,
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '开发中'
|
||||
deleteFriend(this.targetId).then(res => {
|
||||
// 删除聊天记录
|
||||
RongIMLib.deleteMessages(1, this.targetId)
|
||||
RongIMLib.removeConversation(1, this.targetId)
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '好友删除成功',
|
||||
success() {
|
||||
uni.switchTab({
|
||||
url: '/pages/im/index'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -154,20 +164,18 @@
|
||||
},
|
||||
// 申请好友
|
||||
toBeFriend() {
|
||||
pedingFriend(this.targetId)
|
||||
.then(res => {
|
||||
uni.showToast({
|
||||
title: '申请成功',
|
||||
icon: "none"
|
||||
})
|
||||
pedingFriend(this.targetId).then(res => {
|
||||
uni.showToast({
|
||||
title: '申请成功',
|
||||
icon: "none"
|
||||
})
|
||||
.catch(err => {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: err.message,
|
||||
duration: 2000
|
||||
})
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: err.message,
|
||||
duration: 2000
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user