还有搜索好友申请模块处理
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="apply--cell u-border-bottom">
|
||||
<view class="avatar">
|
||||
<u-avatar :src="user.portraitUrl" shape="square" size="46" />
|
||||
<u-avatar :src="user.portraitUrl || require('@/static/user/cover.png')" shape="square" size="46" />
|
||||
</view>
|
||||
<view class="info">
|
||||
<view class="name">
|
||||
|
||||
138
pages/im/components/friendSearchList.vue
Normal file
138
pages/im/components/friendSearchList.vue
Normal file
@@ -0,0 +1,138 @@
|
||||
<template>
|
||||
<view class="friend-apply">
|
||||
<block v-for="(item, index) in lists" v-if="lists.length > 0" :key="index">
|
||||
<view class="lists">
|
||||
<view class="" style="width: 100rpx;height: 100rpx;">
|
||||
<u-avatar :src="item.portraitUrl || require('@/static/user/cover.png')" shape="square" size="44" />
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="title">
|
||||
<view class="name">{{ item.name }}</view>
|
||||
<view class="des">{{ item.address }}</view>
|
||||
</view>
|
||||
<view class="agress-btn">
|
||||
<span v-if="isApply && item.friendship !=='accepted'" @click="action('apply', item)">查看</span>
|
||||
<span class="isFri" v-if="isApply && item.friendship ==='accepted'" @click="action('isFriend', item)">已是好友</span>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'friend-apply-reject-agree',
|
||||
props: {
|
||||
lists: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
isAgree: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isReject: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isApply: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
console.log(this.lists);
|
||||
},
|
||||
methods: {
|
||||
action(type, item) {
|
||||
if (type === 'isFriend') {
|
||||
// ,后期可以跳转到信息介绍页面,先留在这里
|
||||
return uni.showToast({
|
||||
title: '已是好友,无需重复添加',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
this.$emit('action', {
|
||||
type,
|
||||
item
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.lists {
|
||||
padding: 0 $padding;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
box-sizing: border-box;
|
||||
font-size: $title-size;
|
||||
color: $text-gray;
|
||||
|
||||
.cover {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.right {
|
||||
width: 570rpx;
|
||||
margin-left: $margin - 10;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: $padding 0;
|
||||
border-bottom: solid 1rpx #f9f9f9;
|
||||
|
||||
.title {
|
||||
width: 370rpx;
|
||||
|
||||
.name {
|
||||
width: 100%;
|
||||
color: $text-color;
|
||||
font-size: $title-size + 2;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.des {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: $title-size-m;
|
||||
margin-top: $margin - 10;
|
||||
color: $text-gray-m;
|
||||
}
|
||||
}
|
||||
|
||||
.agress-btn {
|
||||
display: flex;
|
||||
color: #fff;
|
||||
|
||||
span {
|
||||
display: inline-block;
|
||||
padding: 6rpx 14rpx;
|
||||
background-color: $text-price;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
span:nth-child(1) {
|
||||
background-color: $main-color;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.isFri {
|
||||
background-color: #f9f9f9 !important;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -6,12 +6,10 @@
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="header">
|
||||
<view class="name">{{ contact(item.targetId).name }} <text v-if="item.conversationType === 3"
|
||||
class='qun'>[群]</text></view>
|
||||
<view class="name">{{ contact(item.targetId).name }} <text v-if="item.conversationType === 3" class='qun'>[群]</text></view>
|
||||
<view class="time">{{ item.sentTime|timeCustomCN }}</view>
|
||||
</view>
|
||||
<message-preview class="preview" :msg="item.latestMessage" :conversationType="item.conversationType"
|
||||
:user="item.latestMessage.userInfo" />
|
||||
<message-preview class="preview" :msg="item.latestMessage" :conversationType="item.conversationType" :user="item.latestMessage.userInfo" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -19,6 +17,10 @@
|
||||
<script>
|
||||
import messagePreview from './messagePreview'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export default {
|
||||
props: {
|
||||
item: {
|
||||
|
||||
@@ -12,15 +12,14 @@
|
||||
</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="#F3F6FB" height="20" size="12" color="#666">
|
||||
</u-index-anchor>
|
||||
<u-index-anchor :text="indexs[fkey]" bgColor="#F9F9F9" height="20" size="12" color="#666" />
|
||||
|
||||
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex u-border-bottom"
|
||||
@click="toFriend(friendItem.targetId)">
|
||||
<u-avatar size="40" shape="square" :src="contact(friendItem.targetId).portraitUrl" />
|
||||
<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 class="address">{{ friendItem.address }}</view>
|
||||
<view class="address">hash:{{ friendItem.address }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-index-item>
|
||||
@@ -119,10 +118,13 @@
|
||||
// 好友列表
|
||||
.friend-flex {
|
||||
position: relative;
|
||||
padding: 20rpx $padding;
|
||||
padding: 24rpx $padding;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
.avatar-img{
|
||||
box-shadow: 0 0 20rpx rgba($color: $main-color, $alpha: 0.2);
|
||||
}
|
||||
|
||||
.info {
|
||||
flex: 1;
|
||||
@@ -137,7 +139,8 @@
|
||||
|
||||
.address {
|
||||
color: $text-gray-m;
|
||||
font-size: $title-size-m - 5;
|
||||
font-size: $title-size-m - 3;
|
||||
padding-top: 10rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
bg-color="#fff"></u-avatar>
|
||||
<view class="info-text">
|
||||
<view class="nickname">{{ userInfo.name }}</view>
|
||||
<view class="address" @longpress="copyAddress">地址:{{ userInfo.address }}</view>
|
||||
<view class="address" @longpress="copyAddress">Hash:{{ userInfo.address }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 用户资料 -->
|
||||
@@ -19,7 +19,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<block v-if="userInfo.is_friend">
|
||||
<block v-if="userInfo.friendship ==='accepted'">
|
||||
<view class="info-btns">
|
||||
<view class="item u-border-bottom" @click="setRemark">
|
||||
<label>设置备注</label>
|
||||
@@ -83,7 +83,11 @@
|
||||
} from '@/apis/interfaces/im.js'
|
||||
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
||||
import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index'
|
||||
|
||||
// friendship: '' 没有好友关系
|
||||
// accepted 好友
|
||||
// pending 申请中
|
||||
// denied 拒绝
|
||||
// blocked 黑名单
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -105,9 +109,10 @@
|
||||
callShow: false
|
||||
}
|
||||
},
|
||||
onLoad(e) {
|
||||
onLoad(e) {
|
||||
this.targetId = e.targetId
|
||||
getFriendInfo(e.targetId).then(res => {
|
||||
console.log(res, "获取朋友的信息")
|
||||
this.userInfo = res
|
||||
// 获取到用户信息之后,去检查一下要不要更新
|
||||
this.$store.dispatch('updateContact', res)
|
||||
@@ -158,7 +163,7 @@
|
||||
content: '确认删除后不可恢复',
|
||||
success: e => {
|
||||
if (e.confirm) {
|
||||
deleteFriend(this.targetId).then(res => {
|
||||
deleteFriend(this.targetId).then(res => {
|
||||
uni.$emit('onContactNotification')
|
||||
// 删除聊天记录
|
||||
RongIMLib.deleteMessages(1, this.targetId);
|
||||
@@ -198,17 +203,23 @@
|
||||
toBeFriend() {
|
||||
pedingFriend(this.targetId).then(res => {
|
||||
uni.showToast({
|
||||
title: '申请成功',
|
||||
icon: 'none'
|
||||
title: ` 申请成功,等待审核 `,
|
||||
icon: 'none',
|
||||
duration: 3000,
|
||||
mask: true
|
||||
});
|
||||
|
||||
})
|
||||
.catch(err => {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: err.message,
|
||||
duration: 2000
|
||||
})
|
||||
// if(err.status_code === 6001){
|
||||
// this.userInfo.friendship = 'accepted'
|
||||
// }else{
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: err.message,
|
||||
duration: 2000,
|
||||
mask: true
|
||||
})
|
||||
// }
|
||||
})
|
||||
},
|
||||
singleCall(e) {
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
searchFriend,
|
||||
pedingFriend
|
||||
} from '@/apis/interfaces/im.js';
|
||||
import applyFriend from '../components/friendApplyList.vue';
|
||||
import applyFriend from '../components/friendSearchList.vue';
|
||||
export default {
|
||||
components: {
|
||||
applyFriend
|
||||
@@ -45,9 +45,15 @@
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
// friendship: '' 没有好友关系
|
||||
// accepted 好友
|
||||
// pending 申请中
|
||||
// denied 拒绝
|
||||
// blocked 黑名单
|
||||
searchFriend(this.searchValue)
|
||||
.then(res => {
|
||||
this.searchResult = res;
|
||||
console.log(res)
|
||||
})
|
||||
.catch(err => {
|
||||
uni.showToast({
|
||||
@@ -56,9 +62,10 @@
|
||||
});
|
||||
});
|
||||
},
|
||||
action(e) {
|
||||
action(e) {
|
||||
|
||||
uni.navigateTo({
|
||||
url: '/pages/im/friends/info?targetId=' + e.item.userId
|
||||
url: '/pages/im/friends/info?targetId=' + e.item.targetId
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user