[同步数据]

This commit is contained in:
2022-01-27 17:40:41 +08:00
parent 4d5d595329
commit e147e1c09c

View File

@@ -2,15 +2,10 @@
<view class="content"> <view class="content">
<!-- 用户信息 --> <!-- 用户信息 -->
<view class="info-flex"> <view class="info-flex">
<u-avatar <u-avatar :src="userInfo.portraitUrl" shape="square" size="50" bg-color="#fff" />
:src="userInfo.portraitUrl"
shape="square"
size="50"
bg-color="#fff"
></u-avatar>
<view class="info-text"> <view class="info-text">
<view class="nickname">{{userInfo.name}}</view> <view class="nickname">{{ userInfo.name }}</view>
<view class="address" @longpress="copyAddress">地址{{userInfo.address}}</view> <view class="address" @longpress="copyAddress">地址{{ userInfo.address }}</view>
</view> </view>
</view> </view>
<!-- 用户资料 --> <!-- 用户资料 -->
@@ -27,11 +22,11 @@
<view class="info-btns"> <view class="info-btns">
<view class="item" @click="setRemark"> <view class="item" @click="setRemark">
<label>设置备注</label> <label>设置备注</label>
<u-icon name="arrow-right" color="#999" size="16"></u-icon> <u-icon name="arrow-right" color="#999" size="16" />
</view> </view>
<view class="item" @click="setRemark"> <view class="item" @click="setRemark">
<label>设置标签</label> <label>设置标签</label>
<u-icon name="arrow-right" color="#999" size="16"></u-icon> <u-icon name="arrow-right" color="#999" size="16" />
</view> </view>
<view class="item"> <view class="item">
<label>聊天免打扰</label> <label>聊天免打扰</label>
@@ -44,21 +39,15 @@
</view> </view>
<view class="footer"> <view class="footer">
<view class="footer-item" @click="deleteFriend"> <view class="footer-item" @click="deleteFriend">
<view class="icon"> <view class="icon"><u-icon class="icon-u" name="close-circle-fill" color="#fff" size="26" /></view>
<u-icon class="icon-u" name="close-circle-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">删除好友</view> <view class="text">删除好友</view>
</view> </view>
<view class="footer-item" @click="toPrivate"> <view class="footer-item" @click="toPrivate">
<view class="icon"> <view class="icon"><u-icon class="icon-u" name="chat-fill" color="#fff" size="26" /></view>
<u-icon class="icon-u" name="chat-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">发送消息</view> <view class="text">发送消息</view>
</view> </view>
<view class="footer-item" @click="toPrivate"> <view class="footer-item" @click="toPrivate">
<view class="icon"> <view class="icon"><u-icon class="icon-u" name="camera-fill" color="#fff" size="26" /></view>
<u-icon class="icon-u" name="camera-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">视频通话</view> <view class="text">视频通话</view>
</view> </view>
</view> </view>
@@ -66,9 +55,7 @@
<block v-else> <block v-else>
<view class="footer"> <view class="footer">
<view class="footer-item" @click="toBeFriend"> <view class="footer-item" @click="toBeFriend">
<view class="icon"> <view class="icon"><u-icon class="icon-u" name="plus-people-fill" color="#fff" size="26" /></view>
<u-icon class="icon-u" name="plus-people-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">申请好友</view> <view class="text">申请好友</view>
</view> </view>
</view> </view>
@@ -77,226 +64,212 @@
</template> </template>
<script> <script>
import { import { getFriendInfo, pedingFriend, deleteFriend } from '@/apis/interfaces/im.js';
getFriendInfo, import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index';
pedingFriend,
deleteFriend
} from '@/apis/interfaces/im.js'
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
export default { export default {
data() { data() {
return { return {
targetId: '', targetId: '',
userInfo: {}, userInfo: {},
status: false, // 0 是免打扰1是正常通知 status: false, // 0 是免打扰1是正常通知
isTop: false, isTop: false,
block: false, block: false,
conversationType: 1 conversationType: 1
};
},
onLoad(e) {
this.targetId = e.targetId;
getFriendInfo(e.targetId).then(res => {
this.userInfo = res;
uni.setNavigationBarTitle({
title: res.name
});
});
RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({ status }) => {
this.status = !Boolean(status);
});
RongIMLib.getConversation(this.conversationType, this.targetId, ({ code, conversation }) => {
if (code == 0) {
this.isTop = conversation.isTop;
} }
}, });
onLoad(e) { },
this.targetId = e.targetId methods: {
getFriendInfo(e.targetId).then(res => { copyAddress() {
this.userInfo = res uni.setClipboardData({
uni.setNavigationBarTitle({ data: this.userInfo.address,
title: res.name success: () => {
}) uni.showToast({
}) icon: 'none',
RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({ title: '复制区块链成功'
status });
}) => {
this.status = !Boolean(status)
})
RongIMLib.getConversation(this.conversationType, this.targetId, ({
code,
conversation
}) => {
if (code == 0) {
this.isTop = conversation.isTop
} }
}) });
}, },
methods: { toPrivate() {
copyAddress() { uni.redirectTo({
uni.setClipboardData({ url: '/pages/im/private/index?conversationType=1&targetId=' + this.targetId
data: this.userInfo.address, });
success: () => { },
uni.showToast({ setRemark() {
icon: 'none', uni.showToast({
title: '复制区块链成功' title: '开发中',
}) icon: 'none'
});
},
deleteFriend() {
uni.showModal({
title: '删除确认',
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: '好友删除成功',
success() {
uni.switchTab({
url: '/pages/im/index'
});
}
});
});
} }
}) }
}, });
toPrivate() { },
uni.redirectTo({ setStatus() {
url: '/pages/im/private/index?conversationType=1&targetId=' + this.targetId RongIMLib.setConversationNotificationStatus(this.conversationType, this.targetId, this.status, ({ status }) => {
}) this.status = !Boolean(status);
}, });
setRemark() { },
uni.showToast({ setTop() {
title: '开发中', RongIMLib.setConversationToTop(this.conversationType, this.targetId, this.isTop, res => {
icon : 'none' RongIMLib.getConversation(this.conversationType, this.targetId, ({ conversation }) => {
}) this.isTop = conversation.isTop;
}, });
deleteFriend() { });
uni.showModal({ },
title: '删除确认', setBlock() {},
content: '确认删除后不可恢复', // 申请好友
success: (e) => { toBeFriend() {
if (e.confirm) { pedingFriend(this.targetId)
deleteFriend(this.targetId).then(res => { .then(res => {
// 删除聊天记录
RongIMLib.deleteMessages(1, this.targetId)
RongIMLib.removeConversation(1, this.targetId)
uni.showToast({
icon: 'none',
title: '好友删除成功',
success() {
uni.switchTab({
url: '/pages/im/index'
})
}
})
})
}
}
})
},
setStatus() {
RongIMLib.setConversationNotificationStatus(this.conversationType, this.targetId, this.status, ({
status
}) => {
this.status = !Boolean(status)
})
},
setTop() {
RongIMLib.setConversationToTop(this.conversationType, this.targetId, this.isTop, (res) => {
RongIMLib.getConversation(this.conversationType, this.targetId, ({
conversation
}) => {
this.isTop = conversation.isTop
})
})
},
setBlock() {
},
// 申请好友
toBeFriend() {
pedingFriend(this.targetId).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,
duration: 2000 duration: 2000
}) });
}) });
}
} }
}; }
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.content { .content {
min-height: 100vh; min-height: 100vh;
background: $window-color; background: $window-color;
padding-top: $padding; padding-top: $padding;
box-sizing: border-box;
}
// 用户信息
.info-flex {
padding: $padding;
margin: 0 $margin;
display: flex;
background: white;
border-radius: $radius;
.info-text {
width: calc(100% - 50px);
padding-left: $padding;
box-sizing: border-box; box-sizing: border-box;
} .nickname {
line-height: 30px;
// 用户信息 font-size: $title-size + 6;
.info-flex{ color: $text-color;
padding: $padding; text-align: left;
margin: 0 $margin; }
display: flex; .address {
background: white; line-height: 20px;
border-radius: $radius; font-size: $title-size-sm;
.info-text{ color: $text-gray;
width: calc(100% - 50px); text-align: left;
padding-left: $padding; @extend .nowrap;
box-sizing: border-box;
.nickname{
line-height: 30px;
font-size: $title-size + 6;
color: $text-color;
text-align: left;
}
.address{
line-height: 20px;
font-size: $title-size-sm;
color: $text-gray;
text-align: left;
@extend .nowrap;
}
} }
} }
}
// footer // footer
.footer{ .footer {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
padding: $padding*2 $padding; padding: $padding * 2 $padding;
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
.footer-item{ .footer-item {
margin: 0 $margin/2; margin: 0 $margin/2;
text-align: center;
.icon {
background: $main-color;
width: 88rpx;
height: 88rpx;
line-height: 88rpx;
display: inline-block;
border-radius: 50%;
.icon-u {
margin-top: calc((88rpx / 2) - 13px);
margin-left: calc((88rpx / 2) - 13px);
}
}
.text {
color: $main-color;
font-size: $title-size-m;
text-align: center; text-align: center;
.icon{ padding-top: 10rpx;
background: $main-color;
width: 88rpx;
height: 88rpx;
line-height: 88rpx;
display: inline-block;
border-radius: 50%;
.icon-u{
margin-top: calc((88rpx/2) - 13px);
margin-left: calc((88rpx/2) - 13px);
}
}
.text{
color: $main-color;
font-size: $title-size-m;
text-align: center;
padding-top: 10rpx;
}
} }
} }
}
// btns // btns
.info-btns{ .info-btns {
background: white; background: white;
margin: $margin; margin: $margin;
border-radius: $radius; border-radius: $radius;
.item{ .item {
line-height: 100rpx; line-height: 100rpx;
border-bottom: solid 1rpx $border-color; border-bottom: solid 1rpx $border-color;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 $padding; padding: 0 $padding;
justify-content: space-between; justify-content: space-between;
font-size: $title-size-lg; font-size: $title-size-lg;
&:last-child{ &:last-child {
border-bottom: none; border-bottom: none;
} }
label{ label {
width: 200rpx; width: 200rpx;
} }
.text{ .text {
width: calc(100% - 200rpx); width: calc(100% - 200rpx);
color: $text-gray-m; color: $text-gray-m;
text-align: right; text-align: right;
@extend .nowrap; @extend .nowrap;
}
} }
} }
}
</style> </style>