This commit is contained in:
2022-02-18 11:50:29 +08:00
5 changed files with 72 additions and 65 deletions

View File

@@ -6,11 +6,12 @@
</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" :draft="item.draft"
:conversationType="item.conversationType" :user="item.latestMessage.userInfo" />
</view>
</view>
</template>
@@ -26,6 +27,9 @@
return {}
}
}
},
mounted() {
console.log(this.item);
},
computed: {
contact() {
@@ -58,7 +62,7 @@
box-sizing: border-box;
position: relative;
flex: 1;
border-bottom-width: 0.5px !important;
border-color: #f9f9f9 !important;

View File

@@ -1,32 +1,37 @@
<template>
<view>
<view class="preview" v-if="msg.objectName=='RC:TxtMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>{{ msg.content || '' }}
</view>
<view class="preview" v-if="msg.objectName=='RC:HQVCMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[语音]
</view>
<view class="preview" v-if="msg.objectName=='RC:ImgMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[图片]
</view>
<view class="preview" v-if="msg.objectName=='RC:GIFMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[表情]
</view>
<view class="preview" v-if="msg.objectName=='RC:FileMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[文件]
</view>
<view class="preview" v-if="msg.objectName=='RC:LBSMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[位置]
</view>
<view class="preview" v-if="msg.objectName=='RC:AudioMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[语音通话]
</view>
<view class="preview" v-if="msg.objectName=='RC:VideoMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[视频通话]
<view>
<view class="preview" v-if="draft">
<text class="draft">[草稿]</text> {{ draft }}
</view>
<view class="preview" v-if="msg.objectName=='RC:GrpNtf'">
[{{ msg.message }}]
</view>
<block v-else>
<view class="preview" v-if="msg.objectName=='RC:TxtMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>{{ msg.content || '' }}
</view>
<view class="preview" v-if="msg.objectName=='RC:HQVCMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[语音]
</view>
<view class="preview" v-if="msg.objectName=='RC:ImgMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[图片]
</view>
<view class="preview" v-if="msg.objectName=='RC:GIFMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[表情]
</view>
<view class="preview" v-if="msg.objectName=='RC:FileMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[文件]
</view>
<view class="preview" v-if="msg.objectName=='RC:LBSMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[位置]
</view>
<view class="preview" v-if="msg.objectName=='RC:AudioMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[语音通话]
</view>
<view class="preview" v-if="msg.objectName=='RC:VideoMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[视频通话]
</view>
<view class="preview" v-if="msg.objectName=='RC:GrpNtf'">
[{{ msg.message }}]
</view>
</block>
</view>
</template>
@@ -36,10 +41,14 @@
msg: {
type: Object,
default: {}
},
conversationType: {
type: Number,
default: 0
},
conversationType: {
type: Number,
default: 0
},
draft: {
type: String,
default: ''
},
user: {
type: Object,
@@ -63,6 +72,11 @@
height: 32rpx;
line-height: 32rpx;
width: 520rpx;
@extend .nowrap;
@extend .nowrap;
.draft {
color: $text-price;
padding-right: 10rpx;
}
}
</style>

View File

@@ -1,9 +1,9 @@
<template>
<view class="chat">
<!-- chat -->
<scroll-view class="body" scroll-y>
<view class="cell" v-for="(item, index) in messages" :key="index">
<view class="time">{{ customCN(item.sentTime) }}</view>
<view class="body">
<view class="cell" v-for="(item, index) in messages" :key="index">
<view class="time">{{ item.sentTime|timeCustomCN }}</view>
<view :class="['cell-item', item.messageDirection == 1 ? 'right' : 'left']">
<u-avatar class="avatar" size="40" shape="square" @click="showUser(targetId, item.messageDirection)"
:src="contact(item.senderUserId).portraitUrl" />
@@ -21,16 +21,12 @@
</view>
</view>
</view>
<view class="cell-footer" ref="chatBottom"></view>
</scroll-view>
</view>
<sent-message-bar :conversationType="conversationType" :targetId="targetId" @onSuccess="getNewMessage()" />
</view>
</template>
<script>
import {
timeCustomCN
} from '@/utils/filters.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import im from '@/utils/im/index.js'
import showVoice from '../components/showVoice'
@@ -38,8 +34,6 @@
import showText from '../components/showText'
import sentMessageBar from '../components/sentMessageBar'
const ChatList = uni.requireNativePlugin('dom')
export default {
components: {
sentMessageBar,
@@ -106,9 +100,6 @@
uni.$off('onReadReceiptReceived')
},
methods: {
customCN(val) {
return timeCustomCN(val)
},
getNewMessage() {
im.getMessageList(
this.conversationType,
@@ -116,10 +107,9 @@
this.latestMessage.sentTime || 0,
1,
false,
(messages) => {
console.log(messages);
this.messages = this.messages.concat(messages)
this.scrollBottom()
(messages) => {
this.messages.unshift(...messages)
// this.scrollBottom()
})
},
// 获取消息列表
@@ -131,9 +121,8 @@
100,
true,
(messages) => {
console.log(messages);
this.messages = messages.reverse()
this.scrollBottom()
this.messages = messages
// this.scrollBottom()
})
},
// 展示好友信息, type 1 是自己, 2 是对方
@@ -174,12 +163,15 @@
display: flex;
flex-direction: column;
.body {
flex: 1;
overflow: scroll;
.body {
flex: 1;
overflow-y: scroll;
display: flex;
flex-direction: column-reverse;
justify-content: flex-end;
.cell {
padding: 10rpx 30rpx;
padding: 10rpx 30rpx;
.time {
text-align: center;