好友管理的基础流程,1.0.5
This commit is contained in:
@@ -2,18 +2,18 @@
|
||||
<view class="content">
|
||||
<!-- 聊天信息 -->
|
||||
<view class="set-user" @click="showFriend">
|
||||
<u-avatar :src="userInfo.portraitUrl" size="48"></u-avatar>
|
||||
<view class="set-user-nickname">{{ userInfo.name }}</view>
|
||||
<u-avatar :src="friend(targetId).portraitUrl" size="48"></u-avatar>
|
||||
<view class="set-user-nickname">{{ friend(targetId).name }}</view>
|
||||
</view>
|
||||
<!-- 聊天设置 -->
|
||||
<view class="set-group">
|
||||
<view class="group-flex">
|
||||
<label>消息免打扰</label>
|
||||
<u-switch activeColor="#34CE98" size="22"></u-switch>
|
||||
<u-switch v-model="status" activeColor="#34CE98" size="22" @change="setStatus"></u-switch>
|
||||
</view>
|
||||
<view class="group-flex">
|
||||
<label>置顶会话</label>
|
||||
<u-switch v-model="isTop" activeColor="#34CE98" size="22"></u-switch>
|
||||
<label>消息置顶</label>
|
||||
<u-switch v-model="isTop" activeColor="#34CE98" size="22" @change="setTop"></u-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="set-group">
|
||||
@@ -35,22 +35,26 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userInfo: {},
|
||||
eventChannel: null,
|
||||
targetId: '',
|
||||
conversationType: 1,
|
||||
isTop: false,
|
||||
status: 0 // 0 是免打扰,1是正常通知
|
||||
status: false // 0 是免打扰,1是正常通知
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
friend() {
|
||||
return function(targetId) {
|
||||
return this.$store.getters.userInfo(targetId)
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad(e) {
|
||||
this.eventChannel = this.$scope.eventChannel
|
||||
|
||||
this.targetId = e.targetId
|
||||
this.conversationType = e.conversationType
|
||||
|
||||
getUserInfo(e.targetId).then(res => {
|
||||
console.log(res);
|
||||
this.userInfo = res
|
||||
})
|
||||
|
||||
RongIMLib.getConversation(this.conversationType, this.targetId, ({
|
||||
conversation
|
||||
}) => {
|
||||
@@ -60,29 +64,27 @@
|
||||
RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({
|
||||
status
|
||||
}) => {
|
||||
this.status = status
|
||||
this.status = !Boolean(status)
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
showFriend() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/im/friends/info?targetId=' + this.targetId
|
||||
})
|
||||
methods: {
|
||||
showFriend() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/im/friends/info?targetId=' + this.targetId
|
||||
})
|
||||
},
|
||||
setStatus() {
|
||||
RongIMLib.setConversationNotificationStatus(this.conversationType, this.targetId, this.status, ({
|
||||
status
|
||||
}) => {
|
||||
this.status = status
|
||||
this.status = !Boolean(status)
|
||||
})
|
||||
},
|
||||
setTop() {
|
||||
RongIMLib.setConversationToTop(this.conversationType, this.targetId, !this.isTop, (res) => {
|
||||
console.log(res);
|
||||
RongIMLib.setConversationToTop(this.conversationType, this.targetId, this.isTop, (res) => {
|
||||
RongIMLib.getConversation(this.conversationType, this.targetId, ({
|
||||
conversation
|
||||
}) => {
|
||||
console.log(conversation.isTop);
|
||||
this.isTop = conversation.isTop
|
||||
})
|
||||
})
|
||||
@@ -97,6 +99,7 @@
|
||||
code
|
||||
}) => {
|
||||
if (code === 0) {
|
||||
this.eventChannel.emit('messageClear')
|
||||
uni.showToast({
|
||||
title: '聊天记录已清空'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user