调整聊天窗口

This commit is contained in:
唐明明
2022-01-28 14:57:39 +08:00
17 changed files with 1524 additions and 1129 deletions

View File

@@ -4,7 +4,9 @@
<view>
<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>
<view class="name">新的朋友</view>
<view class="name">
新的朋友 ({{ pendingCount }})
</view>
</view>
<view class="friend-flex" @click="showToast">
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_00.png')"></u-avatar>
@@ -22,7 +24,8 @@
<u-index-anchor :text="indexs[friend]" bgColor="#F3F6FB" height="20" size="12" color="#666">
</u-index-anchor>
<!-- #endif -->
<view v-for="(friendItem, index) in item" :key="friendItem.userId" class="friend-flex u-border-bottom"
<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 } })">
<block v-if="friendItem.portraitUrl != ''">
<u-avatar class="cover" size="40" shape="square" :src="friendItem.portraitUrl || ''"
@@ -47,24 +50,29 @@
<script>
import {
getFriends
getFriends,
getPendingCount
} from '@/apis/interfaces/im';
export default {
data() {
return {
indexs: [],
friends: []
friends: [],
pendingCount: 0
};
},
onShow() {
getFriends().then(res => {
this.indexs = res.indexList;
this.friends = res.itemArr;
});
this.indexs = res.indexList
this.friends = res.itemArr
})
getPendingCount().then(res => {
console.log(res);
this.pendingCount = res
})
},
computed: {},
methods: {
// 扫码提示
showToast() {
uni.showToast({
title: '群聊功能暂未开放,敬请期待',
@@ -104,7 +112,9 @@
.name {
flex: 1;
padding-left: $padding;
font-size: $title-size;
font-size: $title-size + 2;
font-size: $title-size + 2;
color: #454545 !important;
@extend .nowrap;
}
}

View File

@@ -2,7 +2,7 @@
<view class="content">
<!-- 用户信息 -->
<view class="info-flex">
<u-avatar :src="userInfo.portraitUrl" shape="square" size="50" bg-color="#fff"></u-avatar>
<u-avatar :src="userInfo.portraitUrl || require('@/static/user/cover.png')" shape="square" size="50" bg-color="#fff"></u-avatar>
<view class="info-text">
<view class="nickname">{{userInfo.name}}</view>
<view class="address" @longpress="copyAddress">地址{{userInfo.address}}</view>
@@ -22,11 +22,11 @@
<view class="info-btns">
<view class="item u-border-bottom" @click="setRemark">
<label>设置备注</label>
<u-icon name="arrow-right" color="#999" size="16"></u-icon>
<u-icon name="arrow-right" color="#eee" size="16" />
</view>
<view class="item u-border-bottom" @click="setRemark">
<label>设置标签</label>
<u-icon name="arrow-right" color="#999" size="16"></u-icon>
<u-icon name="arrow-right" color="#eee" size="16" />
</view>
<view class="item u-border-bottom">
<label>聊天免打扰</label>
@@ -40,21 +40,21 @@
<view class="footer">
<view class="footer-item" @click="deleteFriend">
<view class="icon">
<u-icon class="icon-u" name="close-circle-fill" color="#fff" size="26"></u-icon>
<u-icon class="icon-u" name="close-circle-fill" color="#fff" size="30" />
</view>
<view class="text">删除好友</view>
</view>
<view class="footer-item" @click="toPrivate">
<view class="icon">
<u-icon class="icon-u" name="chat-fill" color="#fff" size="26"></u-icon>
<view class="icon ">
<u-icon class="icon-u" name="chat-fill" color="#fff" size="30" />
</view>
<view class="text">发送消息</view>
</view>
<view class="footer-item" @click="callShow = true">
<view class="icon">
<u-icon class="icon-u" name="camera-fill" color="#fff" size="26"></u-icon>
<u-icon class="icon-u" name="camera-fill" color="#fff" size="30" />
</view>
<view class="text">视频通话</view>
<view class="text">/视频通话</view>
</view>
</view>
</block>
@@ -62,7 +62,7 @@
<view class="footer">
<view class="footer-item" @click="toBeFriend">
<view class="icon">
<u-icon class="icon-u" name="plus-people-fill" color="#fff" size="26"></u-icon>
<u-icon class="icon-u" name="plus-people-fill" color="#fff" size="30" />
</view>
<view class="text">申请好友</view>
</view>
@@ -104,7 +104,8 @@
callShow: false
}
},
onLoad(e) {
onLoad(e) {
console.log(e);
this.targetId = e.targetId
getFriendInfo(e.targetId).then(res => {
this.userInfo = res
@@ -126,123 +127,99 @@
}
});
},
toPrivate() {
uni.redirectTo({
url: '/pages/im/private/index?conversationType=1&targetId=' + this.targetId
});
},
setRemark() {
uni.showToast({
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'
});
}
});
});
}
methods: {
copyAddress() {
uni.setClipboardData({
data: this.userInfo.address,
success: () => {
uni.showToast({
icon: 'none',
title: '复制成功'
})
},
toPrivate() {
uni.redirectTo({
url: '/pages/im/private/index?conversationType=1&targetId=' + this.targetId
})
},
setRemark() {
uni.showToast({
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({
url: '/pages/im/private/chat?conversationType=1&targetId=' + this.targetId
});
},
setRemark() {
uni.showToast({
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'
})
}
})
}
})
}
})
},
setStatus() {
RongIMLib.setConversationNotificationStatus(this.conversationType, this.targetId, this.status, ({
}
})
},
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
})
},
setTop() {
RongIMLib.setConversationToTop(this.conversationType, this.targetId, this.isTop, (res) => {
RongIMLib.getConversation(this.conversationType, this.targetId, ({
conversation
}) => {
this.isTop = conversation.isTop
})
},
// 申请好友
toBeFriend() {
pedingFriend(this.targetId).then(res => {
uni.showToast({
title: '申请成功',
icon: 'none'
});
})
},
// 申请好友
toBeFriend() {
pedingFriend(this.targetId).then(res => {
uni.showToast({
title: '申请成功',
icon: 'none'
});
})
.catch(err => {
uni.showToast({
icon: 'error',
title: err.message,
duration: 2000
})
})
},
singleCall(e) {
CallLib.startSingleCall(this.targetId, e.type, '');
uni.redirectTo({
url: '/pages/im/private/call',
success: (err) => {
console.log('跳转视频通话成功');
},
fail: (err) => {
console.log('跳转视频页失败', err);
}
})
},
.catch(err => {
uni.showToast({
icon: 'error',
title: err.message,
duration: 2000
})
})
},
singleCall(e) {
uni.showToast({
icon: 'none',
title: '功能正在开发中'
})
// CallLib.startSingleCall(this.targetId, e.type, '');
// uni.redirectTo({
// url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type
// })
}
}
}
};
</script>
<style lang="scss" scoped>
@@ -269,7 +246,7 @@
.nickname {
line-height: 30px;
font-size: $title-size + 6;
color: $text-color;
color: #454545;
text-align: left;
}
@@ -296,26 +273,36 @@
.footer-item {
margin: 0 $margin/2;
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
.icon {
background: $main-color;
width: 88rpx;
height: 88rpx;
line-height: 88rpx;
display: inline-block;
// line-height: 88rpx;
// display: inline-block;
border-radius: 50%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
.icon-u {
margin-top: calc((88rpx/2) - 13px);
margin-left: calc((88rpx/2) - 13px);
// margin-top: calc((88rpx/2) - 13px);
// margin-left: calc((88rpx/2) - 13px);
}
}
.text {
color: $main-color;
font-size: $title-size-m;
font-size: $title-size-m - 2;
text-align: center;
padding-top: 10rpx;
padding-top: 16rpx;
}
}
}
@@ -326,12 +313,14 @@
background: white;
margin: $margin;
border-radius: $radius;
.u-border-bottom{
border-bottom: solid 1rpx #f9f9f9 !important;
}
.item {
line-height: 100rpx;
display: flex;
align-items: center;
padding: 0 $padding;
padding:10rpx $padding;
justify-content: space-between;
font-size: $title-size-lg;

View File

@@ -1,183 +1,191 @@
<template>
<view class="content">
<!-- 用户信息 -->
<view class="info-flex">
<u-avatar
:src="infoObj.portraitUrl"
shape="square"
size="50"
bg-color="#fff"
></u-avatar>
<view class="info-text">
<view class="nickname">{{infoObj.name}}</view>
<view class="address">地址{{infoObj.address}}</view>
</view>
</view>
<!-- 用户身份 -->
<view class="info-btns">
<view class="item">
<label>性别</label>
<view class="text" v-if="infoObj.gender === 0">保密</view>
<view class="text" v-if="infoObj.gender === 1"></view>
<view class="text" v-if="infoObj.gender === 2"></view>
</view>
<view class="item">
<label>HASH</label>
<view class="text">{{infoObj.hash}}</view>
</view>
</view>
<!-- 二维码 -->
<view class="info-code">
<uqrcode class="info-code-src" :size="198" ref="uQRCode" text="qrContent" />
<view class="info-code-text">
<view>ZH-HEALTH扫一扫上面的二维码</view>
<view>添加我的好友</view>
</view>
</view>
</view>
</template>
<script>
import { getUserInfo } from '@/apis/interfaces/im'
export default{
data(){
return{
infoObj: {
userId : '',
username : '',
name : '',
address : '',
portraitUrl : '',
gender : 0,
hash : ''
},
qrContent: 'ADDFRIEND|'
}
},
onLoad(e){
console.log(e)
},
mounted() {
getUserInfo(this.$Route.query.targetId).then(res => {
this.infoObj = res
this.qrContent += res.userId
console.log(this.infoObj)
})
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.content{
background: $window-color;
min-height: 100vh;
padding-top: $padding;
box-sizing: border-box;
.info-code{
background: white;
margin: 0 $margin;
border-radius: $radius;
padding: $padding*3 $padding $padding;
text-align: center;
&-src{
display: inline-block;
}
&-text{
text-align: center;
color: $text-gray;
font-size: $title-size-sm;
line-height: 40rpx;
padding: $padding 0;
}
}
// 用户信息
.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;
.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{
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: $padding*2 $padding;
display: flex;
justify-content: space-around;
.footer-item{
margin: 0 $margin/2;
.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;
padding-top: 10rpx;
}
}
}
// btns
.info-btns{
background: white;
margin: $margin;
border-radius: $radius;
.item{
line-height: 100rpx;
border-bottom: solid 1rpx $border-color;
display: flex;
padding: 0 $padding;
justify-content: space-between;
font-size: $title-size-lg;
&:last-child{
border-bottom: none;
}
label{
width: 200rpx;
}
.text{
width: calc(100% - 200rpx);
color: $text-gray-m;
text-align: right;
@extend .nowrap;
}
}
}
<template>
<view class="content">
<!-- 用户信息 -->
<view class="info-flex">
<u-avatar :src="infoObj.portraitUrl" shape="square" size="50" bg-color="#fff"></u-avatar>
<view class="info-text">
<view class="nickname">{{infoObj.name}}</view>
<view class="address">地址{{infoObj.address}}</view>
</view>
</view>
<!-- 用户身份 -->
<view class="info-btns">
<view class="item">
<label>性别</label>
<view class="text" v-if="infoObj.gender === 0">保密</view>
<view class="text" v-if="infoObj.gender === 1"></view>
<view class="text" v-if="infoObj.gender === 2"></view>
</view>
<view class="item">
<label>HASH</label>
<view class="text">{{infoObj.hash}}</view>
</view>
</view>
<!-- 二维码 -->
<view class="info-code">
<uqrcode class="info-code-src" :size="198" ref="uQRCode" :text="qrContent" />
<view class="info-code-text">
<view>ZH-HEALTH扫一扫上面的二维码</view>
<view>添加我的好友</view>
</view>
</view>
</view>
</template>
<script>
import {
getUserInfo
} from '@/apis/interfaces/im'
export default {
data() {
return {
infoObj: {
userId: '',
username: '',
name: '',
address: '',
portraitUrl: '',
gender: 0,
hash: ''
},
qrContent: 'ADDFRIEND|'
}
},
onLoad(e) {},
mounted() {
getUserInfo(this.$Route.query.targetId).then(res => {
this.infoObj = res
this.qrContent += res.userId
})
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.content {
background: $window-color;
min-height: 100vh;
padding-top: $padding;
box-sizing: border-box;
.info-code {
background: white;
margin: 0 $margin;
border-radius: $radius;
padding: $padding*3 $padding $padding;
text-align: center;
&-src {
display: inline-block;
}
&-text {
text-align: center;
color: $text-gray;
font-size: $title-size-sm;
line-height: 40rpx;
padding: $padding 0;
}
}
// 用户信息
.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;
.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 {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: $padding*2 $padding;
display: flex;
justify-content: space-around;
.footer-item {
margin: 0 $margin/2;
.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;
padding-top: 10rpx;
}
}
}
// btns
.info-btns {
background: white;
margin: $margin;
border-radius: $radius;
.item {
line-height: 100rpx;
border-bottom: solid 1rpx $border-color;
display: flex;
padding: 0 $padding;
justify-content: space-between;
font-size: $title-size-lg;
&:last-child {
border-bottom: none;
}
label {
width: 200rpx;
}
.text {
width: calc(100% - 200rpx);
color: $text-gray-m;
text-align: right;
@extend .nowrap;
}
}
}
}
</style>