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

View File

@@ -1,32 +1,37 @@
<template> <template>
<view> <view>
<view class="preview" v-if="msg.objectName=='RC:TxtMsg'"> <view class="preview" v-if="draft">
<text v-if="conversationType == 3">{{ user.name }}</text>{{ msg.content || '' }} <text class="draft">[草稿]</text> {{ draft }}
</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>
<view class="preview" v-if="msg.objectName=='RC:GrpNtf'"> <block v-else>
[{{ msg.message }}] <view class="preview" v-if="msg.objectName=='RC:TxtMsg'">
</view> <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> </view>
</template> </template>
@@ -36,10 +41,14 @@
msg: { msg: {
type: Object, type: Object,
default: {} default: {}
}, },
conversationType: { conversationType: {
type: Number, type: Number,
default: 0 default: 0
},
draft: {
type: String,
default: ''
}, },
user: { user: {
type: Object, type: Object,
@@ -63,6 +72,11 @@
height: 32rpx; height: 32rpx;
line-height: 32rpx; line-height: 32rpx;
width: 520rpx; width: 520rpx;
@extend .nowrap; @extend .nowrap;
.draft {
color: $text-price;
padding-right: 10rpx;
}
} }
</style> </style>

View File

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

View File

@@ -9,10 +9,6 @@ import store from '@/store/index'
// #ifdef APP-NVUE // #ifdef APP-NVUE
const ROUTES = [{ const ROUTES = [{
"path": "/pages/im/private/call" "path": "/pages/im/private/call"
}, {
"path": "/pages/im/private/chat"
}, {
"path": "/pages/im/group/chat"
}]; }];
// #endif // #endif

View File

@@ -115,7 +115,8 @@ const callLibListeners = () => {
uni.$emit('onCallOutgoing') uni.$emit('onCallOutgoing')
}) })
// 远端响铃 // 远端响铃
CallLib.onRemoteUserRinging((res) => { CallLib.onRemoteUserRinging((res) => {
console.log('onRemoteUserRinging', res);
uni.$emit('onRemoteUserRinging') uni.$emit('onRemoteUserRinging')
}) })
// 远端加入 // 远端加入