...
This commit is contained in:
@@ -7,8 +7,7 @@
|
||||
"moment": "^2.29.1",
|
||||
"uni-read-pages": "^1.0.5",
|
||||
"uni-simple-router": "^2.0.7",
|
||||
"uview-ui": "^2.0.19",
|
||||
"vuex": "^3.6.2"
|
||||
"uview-ui": "^2.0.27"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
avatarSize: 45,
|
||||
labelSize: 14,
|
||||
iconSize: 14
|
||||
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<template>
|
||||
<view class="sent--text">
|
||||
<input class="input" type="text" :auto-blur="true" @focus="focus" @blur="blur" :focus="focusState" v-model="inputTxt" confirm-type="send"
|
||||
@confirm="sent" cursor-spacing="10" />
|
||||
<!-- <button class="button" size="mini" :disabled="disabled" @click="demo">{{focusState ? '失焦': '聚焦'}}</button> -->
|
||||
<input class="input" type="text" :auto-blur="true" @focus="focus" @blur="blur" :focus="focusState"
|
||||
v-model="inputTxt" confirm-type="send" @confirm="sent" cursor-spacing="10" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -19,10 +18,6 @@
|
||||
targetId: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
inputTxt: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -33,7 +28,7 @@
|
||||
return this.$store.getters.sender
|
||||
}
|
||||
},
|
||||
created() {
|
||||
mounted() {
|
||||
RongIMLib.getTextMessageDraft(this.conversationType, this.targetId, ({
|
||||
draft
|
||||
}) => {
|
||||
@@ -41,31 +36,25 @@
|
||||
})
|
||||
},
|
||||
beforeDestroy() {
|
||||
RongIMLib.saveTextMessageDraft(this.conversationType, this.targetId, this.inputTxt, (res) => {
|
||||
console.log('销毁组件之前,保存草稿信息,但是没有执行', res);
|
||||
})
|
||||
// 保存草稿
|
||||
RongIMLib.saveTextMessageDraft(this.conversationType, this.targetId, this.inputTxt)
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
focusState: false,
|
||||
inputTxt: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 发送文本消息
|
||||
sent() {
|
||||
if (!this.disabled) {
|
||||
RongIMLib.clearTextMessageDraft(this.conversationType, this.targetId)
|
||||
im.sentText(this.conversationType, this.targetId, this.inputTxt, this.sender, () => {
|
||||
RongIMLib.clearTextMessageDraft(this.conversationType, this.targetId)
|
||||
this.$emit('success')
|
||||
this.inputTxt = ''
|
||||
})
|
||||
}
|
||||
},
|
||||
demo(){
|
||||
console.log(this.focusState)
|
||||
|
||||
this.focusState = !this.focusState
|
||||
},
|
||||
focus() {
|
||||
this.$emit('focus')
|
||||
},
|
||||
|
||||
@@ -1,45 +1,83 @@
|
||||
<template>
|
||||
<view class="">
|
||||
<text class="name" v-if="!guest && name">{{ name }}</text>
|
||||
<view class="msg--image" :class="guest ? 'right': 'left'">
|
||||
<image class="img" :src="msg.thumbnail" @click="previewImage" mode="widthFix"></image>
|
||||
<view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
|
||||
<view class="msg--image" :class="isRemote ? 'left': 'right'">
|
||||
<image class="img" :src="content.thumbnail" @click="previewImage" mode="widthFix"></image>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
||||
|
||||
export default {
|
||||
name: 'showImage',
|
||||
props: {
|
||||
msg: {
|
||||
message: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
local: '',
|
||||
remote: '',
|
||||
objectName: '',
|
||||
thumbnail: '',
|
||||
isFull: false
|
||||
}
|
||||
return {}
|
||||
}
|
||||
},
|
||||
guest: {
|
||||
isGroup: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
default: false
|
||||
}
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
default: ''
|
||||
computed: {
|
||||
isRemote() {
|
||||
return this.message.messageDirection == 2
|
||||
},
|
||||
content() {
|
||||
return this.message.content
|
||||
},
|
||||
contact() {
|
||||
return function(targetId) {
|
||||
return this.$store.getters.contactInfo(targetId)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
previewImage() {
|
||||
if (this.content.local) {
|
||||
uni.previewImage({
|
||||
urls: [
|
||||
this.msg.remote
|
||||
this.content.local
|
||||
],
|
||||
current: 1
|
||||
success: (e) => {
|
||||
console.log(e);
|
||||
},
|
||||
fail: (er) => {
|
||||
console.log(er);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
RongIMLib.downloadMediaMessage(this.messageId, {
|
||||
success: (path) => {
|
||||
this.content.local = path
|
||||
uni.previewImage({
|
||||
urls: [
|
||||
path
|
||||
],
|
||||
success: (e) => {
|
||||
console.log(e);
|
||||
},
|
||||
fail: (er) => {
|
||||
console.log(er);
|
||||
}
|
||||
})
|
||||
},
|
||||
progress: (progress, messageId) => {
|
||||
console.log('progress', progress);
|
||||
},
|
||||
cancel: (messageId) => {
|
||||
console.log('cancel', messageId);
|
||||
},
|
||||
error: (errorCode, messageId) => {
|
||||
console.log('errorCode', errorCode);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,27 +86,25 @@
|
||||
<style scoped lang="scss">
|
||||
.name {
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
color: $text-gray-m;
|
||||
padding-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.msg--image {
|
||||
// padding: 20rpx;
|
||||
.img {
|
||||
width: 180rpx;
|
||||
}
|
||||
|
||||
&.left {
|
||||
border-radius: 0 20rpx 20rpx 20rpx;
|
||||
// background: white;
|
||||
.img {
|
||||
border-radius: 0 10rpx 10rpx 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
&.right {
|
||||
border-radius: 20rpx 0 20rpx 20rpx;
|
||||
// background: #34CE98;
|
||||
.img {
|
||||
border-radius: 10rpx 0 10rpx 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.img {
|
||||
width: 150rpx;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,29 +1,65 @@
|
||||
<template>
|
||||
<view class="msg--text">
|
||||
<text class="name" v-if="!guest && name">{{ name }}</text>
|
||||
<view>
|
||||
<text class="im--text" :class="guest ? 'right': 'left'">{{ msg.content }}</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: {
|
||||
msg: {
|
||||
message: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
guest: {
|
||||
isGroup: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
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);
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,23 +67,46 @@
|
||||
|
||||
<style scoped lang="scss">
|
||||
.msg--text {
|
||||
.name {
|
||||
font-size: 26rpx;
|
||||
color: $text-gray-m;
|
||||
display: inline-block;
|
||||
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;
|
||||
}
|
||||
.im--text {
|
||||
max-width: 508rpx;
|
||||
|
||||
.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;
|
||||
display: inline-block;
|
||||
word-break: break-all;
|
||||
|
||||
&.left {
|
||||
border-radius: 0 20rpx 20rpx 20rpx;
|
||||
background: white;
|
||||
}
|
||||
|
||||
&.right {
|
||||
border-radius: 20rpx 0 20rpx 20rpx;
|
||||
background: $main-color;
|
||||
|
||||
@@ -1,63 +1,130 @@
|
||||
<template>
|
||||
<view class="">
|
||||
<text class="name" v-if="!guest && name">{{ name }}</text>
|
||||
<view class="msg--voice" :class="guest ? 'right': 'left'" @click="onPlayMsg">
|
||||
<image v-if="!guest" class="icon" src="@/static/icon/audio_green.png" mode="widthFix"></image>
|
||||
<text class="duration">{{msg.duration}}"</text>
|
||||
<image v-if="guest" class="icon" src="@/static/icon/audio_white.png" mode="widthFix"></image>
|
||||
<view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
|
||||
<view class="msg--voice">
|
||||
<view :class="['voice', isRemote ? 'left': 'right', {'onPlay': onPlay}]" :style="{width: width + 'rpx'}" @click="startPlay">
|
||||
<image v-if="isRemote" class="icon" src="@/static/icon/audio_green.png" mode="widthFix"></image>
|
||||
<image v-else class="icon" src="@/static/icon/audio_white.png" mode="widthFix"></image>
|
||||
<text class="duration">{{ duration }}"</text>
|
||||
</view>
|
||||
<u-badge isDot :show="message.content.local =='' && isRemote" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
||||
|
||||
export default {
|
||||
name: 'showVoice',
|
||||
props: {
|
||||
msg: {
|
||||
message: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
local: '',
|
||||
remote: '',
|
||||
objectName: '',
|
||||
duration: 0
|
||||
}
|
||||
return {}
|
||||
}
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
guest: {
|
||||
isGroup: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
onPlay: false,
|
||||
innerAC: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
duration() {
|
||||
return this.message.content.duration
|
||||
},
|
||||
isRemote() {
|
||||
return this.message.messageDirection == 2
|
||||
},
|
||||
contact() {
|
||||
return function(targetId) {
|
||||
return this.$store.getters.contactInfo(targetId)
|
||||
}
|
||||
},
|
||||
width() {
|
||||
if (this.duration > 3) {
|
||||
return (this.duration * 5) + 150
|
||||
} else {
|
||||
return 120
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 这样能临时解决,但是会一直监听
|
||||
uni.$on('onVoiceMessagePlay', (messageId) => {
|
||||
if (this.message.messageId != messageId) {
|
||||
this.stopPlay()
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
// 播放语音消息
|
||||
onPlayMsg() {
|
||||
uni.downloadFile({
|
||||
url: this.msg.remote,
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
let innerAudioContext = uni.createInnerAudioContext()
|
||||
innerAudioContext.src = res.tempFilePath
|
||||
if (this.audioContextPaused) {
|
||||
innerAudioContext.play()
|
||||
this.audioContextPaused = false
|
||||
startPlay() {
|
||||
// 如果是正在播放的,停止当前播放
|
||||
if (this.onPlay) {
|
||||
this.stopPlay()
|
||||
return
|
||||
}
|
||||
innerAudioContext.stop()
|
||||
innerAudioContext.onStop(resStop => {
|
||||
this.audioContextPaused = true
|
||||
})
|
||||
innerAudioContext.onError(err => {
|
||||
console.log(err);
|
||||
// 如果下载到了本地,那么直接播放,否则调用下载语音消息接口,下载后再播放
|
||||
if (this.message.content.local) {
|
||||
this.playVoice(this.message.content.local)
|
||||
} else {
|
||||
RongIMLib.downloadMediaMessage(this.message.messageId, {
|
||||
success: (path) => {
|
||||
this.message.content.local = path
|
||||
this.playVoice(path)
|
||||
},
|
||||
progress: (progress, messageId) => {},
|
||||
cancel: (messageId) => {},
|
||||
error: (errorCode, messageId) => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '语音播放失败'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
playVoice(path) {
|
||||
console.log('准备播放', this.message.content);
|
||||
this.innerAC = uni.createInnerAudioContext()
|
||||
this.innerAC.src = path
|
||||
this.innerAC.autoplay = false
|
||||
this.innerAC.onCanplay(res => {
|
||||
this.innerAC.play()
|
||||
})
|
||||
this.innerAC.onPlay(res => {
|
||||
this.onPlay = true
|
||||
uni.$emit('onVoiceMessagePlay', this.message.messageId)
|
||||
})
|
||||
this.innerAC.onEnded(res => {
|
||||
this.innerAC.stop()
|
||||
})
|
||||
this.innerAC.onStop(() => {
|
||||
this.onPlay = false
|
||||
this.innerAC.destroy()
|
||||
this.innerAC = null
|
||||
uni.$emit('onVoiceMessageStop', this.message.messageId)
|
||||
})
|
||||
this.innerAC.onError(err => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '语音播放失败'
|
||||
})
|
||||
})
|
||||
},
|
||||
stopPlay() {
|
||||
// 停止播放语音消息
|
||||
if (this.innerAC) {
|
||||
this.innerAC.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -65,17 +132,24 @@
|
||||
<style scoped lang="scss">
|
||||
.name {
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
color: $text-gray-m;
|
||||
}
|
||||
|
||||
.msg--voice {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.u-badge {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.voice {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 79rpx;
|
||||
width: 170rpx;
|
||||
padding: 0 20rpx;
|
||||
height: 84rpx;
|
||||
padding: 0 30rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
.icon {
|
||||
@@ -87,6 +161,10 @@
|
||||
border-radius: 0 20rpx 20rpx 20rpx;
|
||||
background: white;
|
||||
|
||||
&.onPlay {
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
|
||||
.duration {
|
||||
color: #333;
|
||||
font-size: 30rpx;
|
||||
@@ -96,6 +174,11 @@
|
||||
&.right {
|
||||
border-radius: 20rpx 0 20rpx 20rpx;
|
||||
background: $main-color;
|
||||
flex-direction: row-reverse;
|
||||
|
||||
&.onPlay {
|
||||
background-color: darken($main-color, 10);
|
||||
}
|
||||
|
||||
.duration {
|
||||
color: white;
|
||||
@@ -103,4 +186,5 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -10,12 +10,9 @@
|
||||
<u-avatar class="avatar" @click="toUser(item)" :size="avatarSize" shape="square"
|
||||
:src="contact(item.senderUserId).portraitUrl" />
|
||||
<view class="msg">
|
||||
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
||||
:msg="item.content" :name="contact(item.senderUserId).name" />
|
||||
<show-image v-if="item.objectName === 'RC:ImgMsg'" :guest="item.messageDirection == 1"
|
||||
:msg="item.content" :name="contact(item.senderUserId).name" />
|
||||
<show-text v-if="item.objectName === 'RC:TxtMsg'" :guest="item.messageDirection == 1"
|
||||
:msg="item.content" :name="contact(item.senderUserId).name" />
|
||||
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :message="item" isGroup />
|
||||
<show-image v-if="item.objectName === 'RC:ImgMsg'" :message="item" isGroup />
|
||||
<show-text v-if="item.objectName === 'RC:TxtMsg'" :message="item" isGroup />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -80,7 +77,6 @@
|
||||
this.targetId = e.targetId
|
||||
// 获取群成员数量
|
||||
getGroupBase(this.targetId).then(res => {
|
||||
console.log(res);
|
||||
uni.setNavigationBarTitle({
|
||||
title: res.name + `(${res.members})`
|
||||
})
|
||||
@@ -93,6 +89,11 @@
|
||||
this.getNewMessage()
|
||||
}
|
||||
})
|
||||
uni.$on('onReceiptRequested', (msg) => {
|
||||
if (msg.targetId == this.targetId) {
|
||||
console.log('群聊消息是否已读', msg);
|
||||
}
|
||||
})
|
||||
// 清理聊天记录
|
||||
uni.$once('cleanGroupMessage', this.getMessageList)
|
||||
},
|
||||
@@ -141,14 +142,32 @@
|
||||
this.scrollBottom()
|
||||
})
|
||||
},
|
||||
// 发送已读回执
|
||||
sendReadReceiptResponse(messages) {
|
||||
const msgs = messages.map((item) => {
|
||||
if (item.receivedStatus == 0) {
|
||||
return {
|
||||
conversationType: 3,
|
||||
targetId: this.targetId,
|
||||
messageId: item.messageId,
|
||||
messageDirection: item.messageDirection,
|
||||
objectName: item.objectName
|
||||
}
|
||||
}
|
||||
}).filter(Boolean)
|
||||
if (msgs.length) {
|
||||
console.error('发送群聊已读回执', msgs);
|
||||
RongIMLib.sendReadReceiptResponse(3, this.targetId, msgs, (res) => {
|
||||
console.error('发送群聊已读回执成功', res);
|
||||
})
|
||||
}
|
||||
},
|
||||
// 滚动到底部
|
||||
scrollBottom(type) {
|
||||
if (this.latestMessage) {
|
||||
// 清理当前会话,未读消息数量
|
||||
RongIMLib.clearMessagesUnreadStatus(this.conversationType, this.targetId, this.latestMessage
|
||||
.sentTime)
|
||||
// // 发送消息已读状态给对方
|
||||
// RongIMLib.sendReadReceiptMessage(this.conversationType, this.targetId, this.latestMessage.sentTime)
|
||||
// 更新badge提醒数量
|
||||
im.setNotifyBadge()
|
||||
}
|
||||
@@ -178,7 +197,7 @@
|
||||
justify-content: flex-end;
|
||||
|
||||
.cell {
|
||||
padding: 10rpx 30rpx;
|
||||
padding: 10rpx 20rpx;
|
||||
|
||||
.time {
|
||||
text-align: center;
|
||||
@@ -188,7 +207,7 @@
|
||||
|
||||
.cell-item {
|
||||
display: flex;
|
||||
width: 690rpx;
|
||||
width: 710rpx;
|
||||
justify-content: flex-start;
|
||||
|
||||
&.left {
|
||||
@@ -206,20 +225,6 @@
|
||||
|
||||
.msg {
|
||||
margin: 0 20rpx;
|
||||
|
||||
.state {
|
||||
padding-top: 10rpx;
|
||||
|
||||
.state-text {
|
||||
font-size: $title-size-m - 2;
|
||||
color: rgba($color: $main-color, $alpha: 0.3)
|
||||
}
|
||||
|
||||
.state-text-active {
|
||||
font-size: $title-size-m - 2;
|
||||
color: #cecece;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
<block v-if="pendings.length > 0">
|
||||
<view class="reviewed-item" v-for="(item, index) in pendings" :key="index">
|
||||
<u-avatar class="avatar"
|
||||
:src="JSON.parse(item.latestMessage.extra).portraitUrl || require('@/static/user/cover.png')"
|
||||
:src="JSON.parse(item.content.extra).portraitUrl || require('@/static/user/cover.png')"
|
||||
shape="square" size="46" />
|
||||
<view style="flex:1;" v-if="item.latestMessage.operation == 'GroupPending'">
|
||||
<view class="nickname">{{ JSON.parse(item.latestMessage.extra).name }} 申请加入群聊</view>
|
||||
<view> 申请原因:{{ item.latestMessage.message }}</view>
|
||||
<view style="flex:1;" v-if="item.content.operation == 'GroupPending'">
|
||||
<view class="nickname">{{ JSON.parse(item.content.extra).name }} 申请加入群聊</view>
|
||||
<view> 申请原因:{{ item.content.message }}</view>
|
||||
</view>
|
||||
<view style="flex:1;" v-if="item.latestMessage.operation == 'GroupInvite'">
|
||||
<view style="flex:1;" v-if="item.content.operation == 'GroupInvite'">
|
||||
<view class="nickname">
|
||||
<text>{{ contact(item.latestMessage.sourceUserId )}}</text>想邀请<span>{{ JSON.parse(item.latestMessage.extra).name }}</span>加入群聊
|
||||
<text>{{ contact(item.content.sourceUserId).name }}</text>想邀请<span>{{ JSON.parse(item.content.extra).name }}</span>加入群聊
|
||||
</view>
|
||||
</view>
|
||||
<view class="sure" @click="sure(item.latestMessage.targetUserId,item.latestMessageId)"> 通过 </view>
|
||||
<view class="sure" @click="sure(item.content.targetUserId,item.messageId)"> 通过 </view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
@@ -81,11 +81,26 @@
|
||||
})
|
||||
|
||||
}).catch(err => {
|
||||
// uni.showToast({
|
||||
// title: err.message,
|
||||
// icon: 'none',
|
||||
// mask: true,
|
||||
// duration: 2000
|
||||
// })
|
||||
RongIMLib.deleteMessagesByIds([latestMessageId], ({
|
||||
code
|
||||
}) => {
|
||||
console.log('code', code)
|
||||
if (code == 0) {
|
||||
uni.showToast({
|
||||
title:err.message,
|
||||
icon: 'none',
|
||||
mask: true,
|
||||
duration: 2000
|
||||
duration: 500
|
||||
})
|
||||
this.getList()
|
||||
uni.$emit('groupInvitedUser')
|
||||
}
|
||||
})
|
||||
})
|
||||
// 直接调用通过或拒绝的接口
|
||||
|
||||
@@ -11,18 +11,10 @@
|
||||
@click="showUser(item.senderUserId, item.messageDirection)"
|
||||
:src="contact(item.senderUserId).portraitUrl" />
|
||||
<view class="msg">
|
||||
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
||||
:msg="item.content" />
|
||||
<show-image v-if="item.objectName === 'RC:ImgMsg'" :guest="item.messageDirection == 1"
|
||||
:msg="item.content" />
|
||||
<show-text v-if="item.objectName === 'RC:TxtMsg'" :guest="item.messageDirection == 1"
|
||||
:msg="item.content" />
|
||||
<show-call v-if="item.objectName === 'RC:InfoNtf'" :guest="item.messageDirection == 1"
|
||||
:msg="item.content" />
|
||||
<view class="state" v-if="item.messageDirection == 1">
|
||||
<text
|
||||
:class="item.sentStatus === 50?'state-text':'state-text-active'">{{ item.sentStatus == 50 ? '已读': '未读'}}</text>
|
||||
</view>
|
||||
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :message="item" />
|
||||
<show-image v-if="item.objectName === 'RC:ImgMsg'" :message="item" />
|
||||
<show-text v-if="item.objectName === 'RC:TxtMsg'" :message="item" />
|
||||
<show-call v-if="item.objectName === 'RC:InfoNtf'" :message="item" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -180,7 +172,7 @@
|
||||
justify-content: flex-end;
|
||||
|
||||
.cell {
|
||||
padding: 10rpx 30rpx;
|
||||
padding: 10rpx 20rpx;
|
||||
|
||||
.time {
|
||||
text-align: center;
|
||||
@@ -191,7 +183,7 @@
|
||||
|
||||
.cell-item {
|
||||
display: flex;
|
||||
width: 690rpx;
|
||||
width: 710rpx;
|
||||
justify-content: flex-start;
|
||||
|
||||
&.left {
|
||||
@@ -208,20 +200,6 @@
|
||||
|
||||
.msg {
|
||||
margin: 0 20rpx;
|
||||
|
||||
.state {
|
||||
padding-top: 10rpx;
|
||||
|
||||
.state-text {
|
||||
font-size: $title-size-m - 2;
|
||||
color: rgba($color: $main-color, $alpha: 0.3)
|
||||
}
|
||||
|
||||
.state-text-active {
|
||||
font-size: $title-size-m - 2;
|
||||
color: #cecece;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ const notifyMsgTypes = [
|
||||
const imLibListeners = () => {
|
||||
// 添加连接状态监听函数
|
||||
IMLib.addConnectionStatusListener((res) => {
|
||||
console.log('连接状态监听', res.data.status)
|
||||
console.error('连接状态监听', res.data.status)
|
||||
uni.$emit('onConnectionStatusChange', res.data.status)
|
||||
})
|
||||
// 添加消息监听函数
|
||||
@@ -85,13 +85,28 @@ const imLibListeners = () => {
|
||||
uni.$emit('onReceiveMessage', message)
|
||||
}
|
||||
})
|
||||
|
||||
// 监听消息回执
|
||||
// 监听私聊消息已读回执
|
||||
IMLib.addReadReceiptReceivedListener(({
|
||||
data
|
||||
}) => {
|
||||
console.error("监听私聊消息已读回执: ", data);
|
||||
uni.$emit('onReadReceiptReceived', data)
|
||||
})
|
||||
// 监听消息撤回操作
|
||||
IMLib.addRecallMessageListener((res) => {
|
||||
console.error("消息撤回: ", res);
|
||||
})
|
||||
// 监听需要群聊消息回执
|
||||
IMLib.addReceiptRequestListener(({
|
||||
data
|
||||
}) => {
|
||||
console.error('onReceiptRequested', data);
|
||||
uni.$emit('onReceiptRequested', data)
|
||||
})
|
||||
// 群消息已读的回执
|
||||
IMLib.addReceiptResponseListener((res) => {
|
||||
console.error('addReceiptResponseListener', res);
|
||||
})
|
||||
}
|
||||
|
||||
const callLibListeners = () => {
|
||||
@@ -100,7 +115,7 @@ const callLibListeners = () => {
|
||||
CallLib.onCallReceived(({
|
||||
data
|
||||
}) => {
|
||||
console.log('onCallReceived');
|
||||
console.error('onCallReceived');
|
||||
uni.navigateTo({
|
||||
url: '/pages/im/private/call?targetId=' + data.targetId + '&mediaType=' +
|
||||
data.mediaType
|
||||
@@ -112,27 +127,27 @@ const callLibListeners = () => {
|
||||
})
|
||||
// 外呼
|
||||
CallLib.onCallOutgoing((res) => {
|
||||
console.log('onCallOutgoing', res);
|
||||
console.error('onCallOutgoing', res);
|
||||
uni.$emit('onCallOutgoing')
|
||||
})
|
||||
// 远端响铃
|
||||
CallLib.onRemoteUserRinging((res) => {
|
||||
console.log('onRemoteUserRinging', res);
|
||||
console.error('onRemoteUserRinging', res);
|
||||
uni.$emit('onRemoteUserRinging')
|
||||
})
|
||||
// 远端加入
|
||||
CallLib.onRemoteUserJoined((res) => {
|
||||
console.log('远端接听');
|
||||
console.error('远端接听');
|
||||
uni.$emit('onRemoteUserJoined')
|
||||
})
|
||||
// 断开链接
|
||||
CallLib.onCallDisconnected((res) => {
|
||||
console.log('断开链接', res)
|
||||
console.error('断开链接', res)
|
||||
uni.$emit('onCallDisconnected')
|
||||
})
|
||||
// 远端挂断
|
||||
CallLib.onRemoteUserLeft((res) => {
|
||||
console.log('远端离开', res)
|
||||
console.error('远端离开', res)
|
||||
uni.$emit('onRemoteUserLeft')
|
||||
})
|
||||
}
|
||||
|
||||
@@ -60,18 +60,16 @@ const getPendingList = (callback, total) => {
|
||||
|
||||
// 群组申请列表,邀请列表
|
||||
const getGroupPendinglist = (targetId, callback) => {
|
||||
let total = 1000
|
||||
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], total, 0, (res) => {
|
||||
if (res.code === 0) {
|
||||
const pendings = res.conversations.filter((item) => {
|
||||
return item.targetId == targetId &&
|
||||
item.objectName == RongIMLib.ObjectName.ContactNotification &&
|
||||
item.latestMessage.operation === 'GroupPending'
|
||||
})
|
||||
const conversationType = RongIMLib.ConversationType.SYSTEM
|
||||
const objectNames = ['RC:ContactNtf']
|
||||
|
||||
callback(pendings)
|
||||
RongIMLib.getHistoryMessagesByTimestamp(conversationType, targetId, objectNames, 0, 1000, true,
|
||||
({
|
||||
messages
|
||||
}) => {
|
||||
callback(messages)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,6 +95,11 @@ const sentText = (conversationType, targetId, content, user, callback) => {
|
||||
messageId
|
||||
}) => {
|
||||
if (code === 0) {
|
||||
if (conversationType == 3) {
|
||||
RongIMLib.sendReadReceiptRequest(messageId, (res) => {
|
||||
console.log('发送回执请求', res);
|
||||
})
|
||||
}
|
||||
callback(messageId)
|
||||
} else {
|
||||
console.log('发送失败', msg);
|
||||
|
||||
37
yarn.lock
37
yarn.lock
@@ -2,27 +2,22 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"moment@^2.29.1":
|
||||
"integrity" "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
|
||||
"resolved" "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz"
|
||||
"version" "2.29.1"
|
||||
moment@^2.29.1:
|
||||
version "2.29.1"
|
||||
resolved "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz"
|
||||
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==
|
||||
|
||||
"uni-read-pages@^1.0.5":
|
||||
"integrity" "sha512-GkrrZ0LX0vn9R5k6RKEi0Ez3Q3e2vUpjXQ8Z6/K/d28KudI9ajqgt8WEjQFlG5EPm1K6uTArN8LlqmZTEixDUA=="
|
||||
"resolved" "https://registry.npmjs.org/uni-read-pages/-/uni-read-pages-1.0.5.tgz"
|
||||
"version" "1.0.5"
|
||||
uni-read-pages@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.npmjs.org/uni-read-pages/-/uni-read-pages-1.0.5.tgz"
|
||||
integrity sha512-GkrrZ0LX0vn9R5k6RKEi0Ez3Q3e2vUpjXQ8Z6/K/d28KudI9ajqgt8WEjQFlG5EPm1K6uTArN8LlqmZTEixDUA==
|
||||
|
||||
"uni-simple-router@^2.0.7":
|
||||
"integrity" "sha512-8FKv5dw7Eoonm0gkO8udprrxzin0fNUI0+AvIphFkFRH5ZmP5ZWJ2pvnWzb2NiiqQSECTSU5VSB7HhvOSwD5eA=="
|
||||
"resolved" "https://registry.npmjs.org/uni-simple-router/-/uni-simple-router-2.0.7.tgz"
|
||||
"version" "2.0.7"
|
||||
uni-simple-router@^2.0.7:
|
||||
version "2.0.7"
|
||||
resolved "https://registry.npmjs.org/uni-simple-router/-/uni-simple-router-2.0.7.tgz"
|
||||
integrity sha512-8FKv5dw7Eoonm0gkO8udprrxzin0fNUI0+AvIphFkFRH5ZmP5ZWJ2pvnWzb2NiiqQSECTSU5VSB7HhvOSwD5eA==
|
||||
|
||||
"uview-ui@^2.0.19":
|
||||
"integrity" "sha512-ddZiaP7R9wsUxMzAuhuXgh5OswgCm2lKuulTqjnRXFr0uUWsgL1iBifU3GbOwpwP0LtTHKJOo9rYv1LP0WXmzA=="
|
||||
"resolved" "https://registry.npmjs.org/uview-ui/-/uview-ui-2.0.19.tgz"
|
||||
"version" "2.0.19"
|
||||
|
||||
"vuex@^3.6.2":
|
||||
"integrity" "sha512-ETW44IqCgBpVomy520DT5jf8n0zoCac+sxWnn+hMe/CzaSejb/eVw2YToiXYX+Ex/AuHHia28vWTq4goAexFbw=="
|
||||
"resolved" "https://registry.npmjs.org/vuex/-/vuex-3.6.2.tgz"
|
||||
"version" "3.6.2"
|
||||
uview-ui@^2.0.27:
|
||||
version "2.0.27"
|
||||
resolved "https://registry.yarnpkg.com/uview-ui/-/uview-ui-2.0.27.tgz#1a7dde9c6246e851d768f3efd44b5fb26774a2e1"
|
||||
integrity sha512-fl35rlguNPfXnwNoVv0w4zS1blFFxxSPuGR1+9SbpFGC33aiTBaoFWs/4Fppj0foS/kDCqSWcJiymNmQjPBD4g==
|
||||
|
||||
Reference in New Issue
Block a user