好友删除,扫码加好友
This commit is contained in:
@@ -23,6 +23,14 @@ const getImToken = () => {
|
|||||||
}, true)
|
}, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除好友
|
||||||
|
const deleteFriend = (targetId) => {
|
||||||
|
return request({
|
||||||
|
method: 'DELETE',
|
||||||
|
url: 'im/friends/' + targetId,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
const getUserInfo = (targetId) => {
|
const getUserInfo = (targetId) => {
|
||||||
return request({
|
return request({
|
||||||
@@ -79,6 +87,7 @@ const pedingFriend = (recipient) => {
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
getImToken,
|
getImToken,
|
||||||
|
deleteFriend,
|
||||||
getFriends,
|
getFriends,
|
||||||
getUserInfo,
|
getUserInfo,
|
||||||
getFriendInfo,
|
getFriendInfo,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<view>
|
<view>
|
||||||
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
|
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
|
||||||
<view>
|
<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>
|
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_01.png')"></u-avatar>
|
||||||
<view class="name">新的朋友</view>
|
<view class="name">新的朋友</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<u-index-anchor :text="indexs[friend]" bgColor="#F3F6FB" height="20" size="12" color="#666">
|
<u-index-anchor :text="indexs[friend]" bgColor="#F3F6FB" height="20" size="12" color="#666">
|
||||||
</u-index-anchor>
|
</u-index-anchor>
|
||||||
<!-- #endif -->
|
<!-- #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 } })">
|
@click="$Router.push({ name: 'imFriendsInfo', params: { targetId: friendItem.userId } })">
|
||||||
<block v-if="friendItem.portraitUrl != ''">
|
<block v-if="friendItem.portraitUrl != ''">
|
||||||
<u-avatar class="cover" size="40" shape="square" :src="friendItem.portraitUrl || ''"
|
<u-avatar class="cover" size="40" shape="square" :src="friendItem.portraitUrl || ''"
|
||||||
@@ -108,19 +108,5 @@
|
|||||||
font-size: $title-size;
|
font-size: $title-size;
|
||||||
@extend .nowrap;
|
@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>
|
</style>
|
||||||
|
|||||||
@@ -58,7 +58,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
getFriendInfo,
|
getFriendInfo,
|
||||||
pedingFriend
|
pedingFriend,
|
||||||
|
deleteFriend
|
||||||
} from '@/apis/interfaces/im.js'
|
} from '@/apis/interfaces/im.js'
|
||||||
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
|
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
|
||||||
|
|
||||||
@@ -71,11 +72,10 @@
|
|||||||
isTop: false,
|
isTop: false,
|
||||||
block: false,
|
block: false,
|
||||||
conversationType: 1
|
conversationType: 1
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
this.targetId = e.targetId
|
this.targetId = e.targetId
|
||||||
console.log(this.targetId);
|
|
||||||
getFriendInfo(e.targetId).then(res => {
|
getFriendInfo(e.targetId).then(res => {
|
||||||
this.userInfo = res
|
this.userInfo = res
|
||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
@@ -125,9 +125,19 @@
|
|||||||
content: '确认删除后不可恢复',
|
content: '确认删除后不可恢复',
|
||||||
success: (e) => {
|
success: (e) => {
|
||||||
if (e.confirm) {
|
if (e.confirm) {
|
||||||
|
deleteFriend(this.targetId).then(res => {
|
||||||
|
// 删除聊天记录
|
||||||
|
RongIMLib.deleteMessages(1, this.targetId)
|
||||||
|
RongIMLib.removeConversation(1, this.targetId)
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: '开发中'
|
title: '好友删除成功',
|
||||||
|
success() {
|
||||||
|
uni.switchTab({
|
||||||
|
url: '/pages/im/index'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,14 +164,12 @@
|
|||||||
},
|
},
|
||||||
// 申请好友
|
// 申请好友
|
||||||
toBeFriend() {
|
toBeFriend() {
|
||||||
pedingFriend(this.targetId)
|
pedingFriend(this.targetId).then(res => {
|
||||||
.then(res => {
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '申请成功',
|
title: '申请成功',
|
||||||
icon: "none"
|
icon: "none"
|
||||||
})
|
})
|
||||||
})
|
}).catch(err => {
|
||||||
.catch(err => {
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
title: err.message,
|
title: err.message,
|
||||||
|
|||||||
Reference in New Issue
Block a user