Files
ZhHealth/pages/im/friends/info.vue
2022-01-26 11:01:42 +08:00

210 lines
6.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="content">
<!-- 用户信息 -->
<view class="user-info">
<u-avatar :src="userInfo.portraitUrl" size="100" />
<view class="nickname">{{ userInfo.username }}</view>
<view class="gender">
<u-tag text="保密" v-if="userInfo.gender === 0" color="#fff" borderColor="#999" size="mini"
bgColor="#999"></u-tag>
<u-tag text="男" v-if="userInfo.gender === 1" color="#fff" borderColor="#5db6ee" size="mini" icon="man"
bgColor="#5db6ee"></u-tag>
<u-tag text="女" v-if="userInfo.gender === 2" color="#fff" borderColor="#e4867a" size="mini" icon="woman"
bgColor="#e4867a"></u-tag>
</view>
<view class="address">{{ userInfo.address }}</view>
</view>
<view class="actions">
<u-cell-group>
<u-cell isLink title="设置备注" @click="setRemark"></u-cell>
<u-cell isLink title="设置标签" @click="setRemark"></u-cell>
<u-cell title="聊天免打扰">
<u-switch slot="value" size="18" v-model="status" activeColor="#34CE98" @change="setStatus">
</u-switch>
</u-cell>
<u-cell title="聊天置顶">
<u-switch slot="value" size="18" v-model="isTop" activeColor="#34CE98" @change="setTop">
</u-switch>
</u-cell>
<!-- <u-cell title="加入黑名单">
<u-switch slot="value" size="18" v-model="block" activeColor="#34CE98" @change="setBlock"></u-switch>
</u-cell> -->
<u-cell isLink titleStyle="color: red" title="删除好友" @click="deleteFriend"></u-cell>
</u-cell-group>
</view>
<view class="footer">
<u-button @click="toPrivate()">
<u-icon name="chat" size="20" /> 发送消息
</u-button>
<u-button @click="toPrivate()">
<u-icon name="mic" size="20" /> 音视频通话
</u-button>
</view>
</view>
</template>
<script>
import {
getUserInfo
} from '@/apis/interfaces/im.js'
import * as RongIMLib from '@rongcloud/imlib-uni'
export default {
data() {
return {
targetId: '',
userInfo: {},
status: false, // 0 是免打扰1是正常通知
isTop: false,
block: false,
conversationType: 1
};
},
onLoad(e) {
this.targetId = e.targetId
getUserInfo(e.targetId).then(res => {
console.log(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, ({
conversation
}) => {
this.isTop = conversation.isTop
})
},
methods: {
toPrivate() {
uni.redirectTo({
url: '/pages/im/private/index?conversationType=1&targetId=' + this.targetId
})
},
setRemark() {
uni.showToast({
icon: 'none',
title: '开发中'
})
},
deleteFriend() {
uni.showModal({
title: '删除确认',
content: '确认删除后不可恢复',
success: (e) => {
if (e.confirm) {
uni.showToast({
icon: 'none',
title: '开发中'
})
}
}
})
},
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() {
}
}
};
</script>
<style lang="scss" scoped>
.content {
min-height: 100vh;
background: $window-color;
}
.actions {
background: white;
margin-top: $padding / 2;
}
// 用户信息
.user-info {
padding: $padding 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: white;
.nickname {
font-size: 42rpx;
padding-top: $padding;
}
.address {
line-height: 64rpx;
font-size: 26rpx;
color: $text-gray;
}
.gender {
padding-top: $padding/2;
text {
font-size: $title-size-sm;
background: #303133;
padding: 0 10rpx;
color: white;
border-radius: $radius-m;
line-height: 30rpx;
display: inline-block;
}
}
}
.user-lists {
margin-top: $margin;
background: white;
.user-lists-item {
padding: 0 $padding;
display: flex;
justify-content: space-between;
line-height: 90rpx;
font-size: $title-size-lg;
label {
color: $text-color;
}
text {
color: $text-gray;
}
}
}
.footer {
padding: $padding / 2;
.u-button {
margin-top: $padding / 2;
}
}
</style>