118 lines
3.3 KiB
Vue
118 lines
3.3 KiB
Vue
<template>
|
|
<view class="msg--text">
|
|
<view class="state" v-if="!isGroup && !isRemote">
|
|
<!-- 已发送 -->
|
|
<u-icon name="checkbox-mark" class="sent" :color="message.sentStatus >= 30 ? '#34CE98' : '#999999' " />
|
|
<!-- 已阅读 -->
|
|
<u-icon name="checkbox-mark" class="receive" :color="message.sentStatus >= 50 ? '#34CE98' : '#999999' " />
|
|
</view>
|
|
<view class="">
|
|
<view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
|
|
<view @longpress="backMessage" :class="['text', isRemote ? 'left': 'right']">{{ content }}</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
|
|
|
export default {
|
|
name: 'showText',
|
|
props: {
|
|
message: {
|
|
type: Object,
|
|
default: () => {
|
|
return {}
|
|
}
|
|
},
|
|
isGroup: {
|
|
type: Boolean,
|
|
default: false
|
|
}
|
|
},
|
|
computed: {
|
|
isRemote() {
|
|
return this.message.messageDirection == 2
|
|
},
|
|
content() {
|
|
return this.message.content.content
|
|
},
|
|
contact() {
|
|
return function(targetId) {
|
|
return this.$store.getters.contactInfo(targetId)
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
// 撤回消息测试
|
|
backMessage() {
|
|
console.log('撤回消息');
|
|
const pushContent = '推送内容'
|
|
RongIMLib.recallMessage(this.message.messageId, pushContent,
|
|
({
|
|
code,
|
|
message
|
|
}) => {
|
|
console.error(code);
|
|
// 撤回消息成功
|
|
if (code === 0) {
|
|
console.error(message);
|
|
}
|
|
}
|
|
)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.msg--text {
|
|
display: flex;
|
|
align-items: flex-end;
|
|
|
|
.state {
|
|
padding: 10rpx;
|
|
border-radius: 30rpx;
|
|
width: 40rpx;
|
|
background-color: #ddd;
|
|
display: flex;
|
|
margin-right: 10rpx;
|
|
|
|
.sent {
|
|
z-index: 2;
|
|
}
|
|
|
|
.receive {
|
|
z-index: 1;
|
|
margin-left: -20rpx;
|
|
}
|
|
}
|
|
|
|
.name {
|
|
font-size: 24rpx;
|
|
color: $text-gray-m;
|
|
}
|
|
|
|
.text {
|
|
box-sizing: border-box;
|
|
max-width: 502rpx;
|
|
padding: 20rpx;
|
|
line-height: 46rpx;
|
|
font-size: 32rpx;
|
|
color: $text-color;
|
|
word-break: break-all;
|
|
|
|
&.left {
|
|
border-radius: 0 20rpx 20rpx 20rpx;
|
|
background: white;
|
|
}
|
|
|
|
&.right {
|
|
border-radius: 20rpx 0 20rpx 20rpx;
|
|
background: $main-color;
|
|
color: white;
|
|
}
|
|
}
|
|
}
|
|
</style>
|