视频通话时长转换
This commit is contained in:
@@ -22,10 +22,10 @@
|
|||||||
<view class="preview" v-if="msg.objectName=='RC:LBSMsg'">
|
<view class="preview" v-if="msg.objectName=='RC:LBSMsg'">
|
||||||
<text v-if="conversationType == 3">{{ user.name }}:</text>[位置]
|
<text v-if="conversationType == 3">{{ user.name }}:</text>[位置]
|
||||||
</view>
|
</view>
|
||||||
<view class="preview" v-if="msg.objectName=='RC:InfoNtf' && JSON.parse(msg.message).mediaType=='0'">
|
<view class="preview" v-if="msg.objectName=='RC:InfoNtf' && JSON.parse(msg.message).mediaType==0">
|
||||||
<text v-if="conversationType == 3">{{ user.name }}:</text>[语音通话]
|
<text v-if="conversationType == 3">{{ user.name }}:</text>[语音通话]
|
||||||
</view>
|
</view>
|
||||||
<view class="preview" v-if="msg.objectName=='RC:InfoNtf' && JSON.parse(msg.message).mediaType=='1'">
|
<view class="preview" v-if="msg.objectName=='RC:InfoNtf' && JSON.parse(msg.message).mediaType==1">
|
||||||
<text v-if="conversationType == 3">{{ user.name }}:</text>[视频通话]
|
<text v-if="conversationType == 3">{{ user.name }}:</text>[视频通话]
|
||||||
</view>
|
</view>
|
||||||
<view class="preview" v-if="msg.objectName=='RC:GrpNtf'">
|
<view class="preview" v-if="msg.objectName=='RC:GrpNtf'">
|
||||||
|
|||||||
@@ -1,29 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="msg--text">
|
<view class="msg--call">
|
||||||
<text class="name" v-if="!guest && name">{{ name }}</text>
|
<view class="name" v-if="!guest && name">{{ name }}</view>
|
||||||
<view>
|
<view class="im--text" :class="guest ? 'right': 'left'">
|
||||||
<text class="im--text" :class="guest ? 'right': 'left'" v-if="message.mediaType == '1'">
|
<u-icon name="camera" size="22" v-if="message.mediaType == 1"
|
||||||
<u-icon name="camera" /> {{ message.connected ? '通话时长' + message.duration : '未接通' }}
|
:label="message.connected ? '通话时长:' + duration : '未接通'" />
|
||||||
</text>
|
<u-icon name="phone" size="22" v-else :label="message.connected ? '通话时长:' + duration : '未接通'" />
|
||||||
<text class="im--text" :class="guest ? 'right': 'left'" v-else>
|
|
||||||
<u-icon name="phone" /> {{ message.connected ? '通话时长' + message.duration : '未接通' }}
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<!-- msg
|
|
||||||
{
|
|
||||||
"message": "1",
|
|
||||||
"objectName": "RC:InfoNtf",
|
|
||||||
"userInfo": {
|
|
||||||
"userId": "10051",
|
|
||||||
"name": "Jason.电信",
|
|
||||||
"extra": "",
|
|
||||||
"portraitUrl": "http://storage.zh.shangkelian.cn/uploads/2022/02/16/29b13f5301694721ad7acd8b8b67bbd9.jpg"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-->
|
|
||||||
<script>
|
<script>
|
||||||
|
import utils from '@/utils/index.js'
|
||||||
|
import moment from 'moment'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'showText',
|
name: 'showText',
|
||||||
props: {
|
props: {
|
||||||
@@ -45,16 +34,20 @@
|
|||||||
computed: {
|
computed: {
|
||||||
message() {
|
message() {
|
||||||
return JSON.parse(this.msg.message)
|
return JSON.parse(this.msg.message)
|
||||||
}
|
|
||||||
},
|
},
|
||||||
mounted() {
|
duration() {
|
||||||
console.log(this.message);
|
if (this.message.duration > 3600) {
|
||||||
|
return moment.utc(this.message.duration * 1000).format('HH:mm:ss')
|
||||||
|
} else {
|
||||||
|
return moment.utc(this.message.duration * 1000).format('mm:ss')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.msg--text {
|
.msg--call {
|
||||||
.name {
|
.name {
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: $text-gray-m;
|
color: $text-gray-m;
|
||||||
@@ -67,8 +60,8 @@
|
|||||||
line-height: 46rpx;
|
line-height: 46rpx;
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: $text-color;
|
color: $text-color;
|
||||||
display: inline-block;
|
display: flex;
|
||||||
word-break: break-all;
|
flex-direction: row;
|
||||||
|
|
||||||
&.left {
|
&.left {
|
||||||
border-radius: 0 20rpx 20rpx 20rpx;
|
border-radius: 0 20rpx 20rpx 20rpx;
|
||||||
@@ -79,6 +72,10 @@
|
|||||||
border-radius: 20rpx 0 20rpx 20rpx;
|
border-radius: 20rpx 0 20rpx 20rpx;
|
||||||
background: $main-color;
|
background: $main-color;
|
||||||
color: white;
|
color: white;
|
||||||
|
|
||||||
|
.u-icon {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,8 @@
|
|||||||
// 关闭扬声器
|
// 关闭扬声器
|
||||||
volumeOff: false,
|
volumeOff: false,
|
||||||
// 通话时长
|
// 通话时长
|
||||||
duration: 0
|
duration: 0,
|
||||||
|
interval: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
@@ -86,7 +87,7 @@
|
|||||||
// 进入页面开启外呼
|
// 进入页面开启外呼
|
||||||
if (this.isCall) {
|
if (this.isCall) {
|
||||||
CallLib.startSingleCall(this.targetId, this.mediaType, '');
|
CallLib.startSingleCall(this.targetId, this.mediaType, '');
|
||||||
if (this.mediaType == '1') {
|
if (this.mediaType == 1) {
|
||||||
const session = CallLib.getCurrentCallSession()
|
const session = CallLib.getCurrentCallSession()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
CallLib.setVideoView(session.mine.userId, this.$refs.bigVideoView.ref, 0, false)
|
CallLib.setVideoView(session.mine.userId, this.$refs.bigVideoView.ref, 0, false)
|
||||||
@@ -107,7 +108,6 @@
|
|||||||
this.bigVideoStyle = {
|
this.bigVideoStyle = {
|
||||||
width: this.windowWidth + 'px',
|
width: this.windowWidth + 'px',
|
||||||
height: this.windowHeight + 'px',
|
height: this.windowHeight + 'px',
|
||||||
// backgroundImage: `url("${this.contact(this.targetId).portraitUrl}")`
|
|
||||||
}
|
}
|
||||||
this.movableAreaStyle = {
|
this.movableAreaStyle = {
|
||||||
width: this.windowWidth + 'px',
|
width: this.windowWidth + 'px',
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
afterHangup() {
|
afterHangup() {
|
||||||
const conversationType = IMLib.ConversationType.PRIVATE // 会话类型
|
clearInterval(this.interval)
|
||||||
const targetId = this.targetId
|
const targetId = this.targetId
|
||||||
const sentStatus = 30
|
const sentStatus = 30
|
||||||
const messageContent = {
|
const messageContent = {
|
||||||
@@ -144,19 +144,12 @@
|
|||||||
duration: this.duration
|
duration: this.duration
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const sentTime = 0 // 消息的发送时间
|
const sentTime = 0
|
||||||
IMLib.insertOutgoingMessage(conversationType, targetId, sentStatus, messageContent, sentTime,
|
if (this.isCall) {
|
||||||
({
|
IMLib.insertOutgoingMessage(1, targetId, sentStatus, messageContent, sentTime)
|
||||||
code,
|
} else {
|
||||||
message
|
IMLib.insertIncomingMessage(1, targetId, targetId, sentStatus, messageContent, sentTime)
|
||||||
}) => {
|
|
||||||
console.log(code);
|
|
||||||
// 插入消息成功
|
|
||||||
if (code === 0) {
|
|
||||||
console.log(message)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
uni.$emit('onReceiveMessage', {
|
uni.$emit('onReceiveMessage', {
|
||||||
targetId: this.targetId
|
targetId: this.targetId
|
||||||
})
|
})
|
||||||
@@ -180,34 +173,37 @@
|
|||||||
// 设置链接状态
|
// 设置链接状态
|
||||||
this.connected = true
|
this.connected = true
|
||||||
// 视频通话,才开摄像头
|
// 视频通话,才开摄像头
|
||||||
if (this.mediaType == '1') {
|
if (this.mediaType == 1) {
|
||||||
const session = CallLib.getCurrentCallSession()
|
const session = CallLib.getCurrentCallSession()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
CallLib.setVideoView(session.targetId, this.$refs.bigVideoView.ref, 0, false)
|
CallLib.setVideoView(session.targetId, this.$refs.bigVideoView.ref, 0, false)
|
||||||
CallLib.setVideoView(session.mine.userId, this.$refs.smallVideoView.ref, 0, true)
|
CallLib.setVideoView(session.mine.userId, this.$refs.smallVideoView.ref, 0, true)
|
||||||
}, 200)
|
}, 200)
|
||||||
}
|
}
|
||||||
|
this.interval = setInterval(() => {
|
||||||
|
this.duration++
|
||||||
|
}, 1000)
|
||||||
},
|
},
|
||||||
// 切换主屏显示人
|
// 切换主屏显示人
|
||||||
changeMine() {
|
changeMine() {
|
||||||
if (this.isCall) {
|
// if (this.isCall) {
|
||||||
const session = CallLib.getCurrentCallSession()
|
// const session = CallLib.getCurrentCallSession()
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
CallLib.setVideoView(session.targetId, this.$refs.bigVideoView.ref, 0, false)
|
// CallLib.setVideoView(session.targetId, this.$refs.bigVideoView.ref, 0, false)
|
||||||
CallLib.setVideoView(session.mine.userId, this.$refs.smallVideoView.ref, 0, true)
|
// CallLib.setVideoView(session.mine.userId, this.$refs.smallVideoView.ref, 0, true)
|
||||||
}, 200)
|
// }, 200)
|
||||||
} else {
|
// } else {
|
||||||
const session = CallLib.getCurrentCallSession()
|
// const session = CallLib.getCurrentCallSession()
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
CallLib.setVideoView(session.targetId, this.$refs.smallVideoView.ref, 0, true)
|
// CallLib.setVideoView(session.targetId, this.$refs.smallVideoView.ref, 0, true)
|
||||||
CallLib.setVideoView(session.mine.userId, this.$refs.bigVideoView.ref, 0, false)
|
// CallLib.setVideoView(session.mine.userId, this.$refs.bigVideoView.ref, 0, false)
|
||||||
}, 200)
|
// }, 200)
|
||||||
}
|
// }
|
||||||
this.isCall = !this.isCall
|
// this.isCall = !this.isCall
|
||||||
},
|
},
|
||||||
hangup() {
|
hangup() {
|
||||||
this.afterHangup()
|
|
||||||
CallLib.hangup()
|
CallLib.hangup()
|
||||||
|
this.afterHangup()
|
||||||
this.stopRing()
|
this.stopRing()
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user