调整语音组件
This commit is contained in:
@@ -101,6 +101,7 @@
|
|||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.send--voice {
|
.send--voice {
|
||||||
.voice {
|
.voice {
|
||||||
|
display: flex;
|
||||||
background: $window-color;
|
background: $window-color;
|
||||||
height: 70rpx;
|
height: 70rpx;
|
||||||
line-height: 70rpx;
|
line-height: 70rpx;
|
||||||
@@ -109,7 +110,6 @@
|
|||||||
width: 500rpx;
|
width: 500rpx;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
margin-right: 15rpx;
|
margin-right: 15rpx;
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
color: #333;
|
color: #333;
|
||||||
@@ -117,6 +117,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.modal {
|
.modal {
|
||||||
|
display: flex;
|
||||||
background: rgba(0, 0, 0, .6);
|
background: rgba(0, 0, 0, .6);
|
||||||
position: fixed;
|
position: fixed;
|
||||||
height: 200rpx;
|
height: 200rpx;
|
||||||
@@ -128,7 +129,6 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
width: 88rpx;
|
width: 88rpx;
|
||||||
height: 88rpx;
|
height: 88rpx;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
<view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
|
<view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
|
||||||
<view class="msg--voice">
|
<view class="msg--voice">
|
||||||
<view :class="['voice', isRemote ? 'left': 'right', {'onPlay': onPlay}]" :style="{width: width + 'rpx'}" @click="startPlay">
|
<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-if="isRemote" class="icon" :class="{ 'videoFlicker' : onPlay && msgId == message.messageId }" src="@/static/icon/audio_green.png" mode="widthFix"></image>
|
||||||
<image v-else class="icon" src="@/static/icon/audio_white.png" mode="widthFix"></image>
|
<image v-else class="icon" :class="{ 'videoFlicker' : onPlay && msgId == message.messageId }" src="@/static/icon/audio_white.png" mode="widthFix"></image>
|
||||||
<text class="duration">{{ duration }}"</text>
|
<text class="duration">{{ duration }}"</text>
|
||||||
</view>
|
</view>
|
||||||
<u-badge isDot :show="message.content.local =='' && isRemote" />
|
<u-badge isDot :show="message.content.local =='' && isRemote" />
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
return {
|
return {
|
||||||
onPlay: false,
|
onPlay: false,
|
||||||
innerAC: null,
|
innerAC: null,
|
||||||
|
msgId : null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -63,6 +64,11 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
console.log(this.message.messageId)
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
// 播放语音消息
|
// 播放语音消息
|
||||||
startPlay() {
|
startPlay() {
|
||||||
@@ -96,9 +102,11 @@
|
|||||||
this.innerAC = uni.createInnerAudioContext()
|
this.innerAC = uni.createInnerAudioContext()
|
||||||
this.innerAC.src = path
|
this.innerAC.src = path
|
||||||
this.innerAC.autoplay = false
|
this.innerAC.autoplay = false
|
||||||
|
this.msgId = this.message.messageId
|
||||||
this.innerAC.onCanplay(res => {
|
this.innerAC.onCanplay(res => {
|
||||||
this.innerAC.play()
|
this.innerAC.play()
|
||||||
})
|
})
|
||||||
|
|
||||||
this.innerAC.onPlay(res => {
|
this.innerAC.onPlay(res => {
|
||||||
this.onPlay = true
|
this.onPlay = true
|
||||||
uni.$emit('onVoiceMessagePlay', this.message.messageId)
|
uni.$emit('onVoiceMessagePlay', this.message.messageId)
|
||||||
@@ -110,6 +118,7 @@
|
|||||||
this.onPlay = false
|
this.onPlay = false
|
||||||
this.innerAC.destroy()
|
this.innerAC.destroy()
|
||||||
this.innerAC = null
|
this.innerAC = null
|
||||||
|
this.msgId = null
|
||||||
uni.$emit('onVoiceMessageStop', this.message.messageId)
|
uni.$emit('onVoiceMessageStop', this.message.messageId)
|
||||||
})
|
})
|
||||||
this.innerAC.onError(err => {
|
this.innerAC.onError(err => {
|
||||||
@@ -129,6 +138,24 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@keyframes playFlicker{
|
||||||
|
0%{
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
50%{
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
100%{
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.videoFlicker{
|
||||||
|
animation: playFlicker 1s infinite;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.name {
|
.name {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<u-avatar class="avatar" @click="toUser(item)" :size="avatarSize" shape="square"
|
<u-avatar class="avatar" @click="toUser(item)" :size="avatarSize" shape="square"
|
||||||
:src="contact(item.senderUserId).portraitUrl" />
|
:src="contact(item.senderUserId).portraitUrl" />
|
||||||
<view class="msg">
|
<view class="msg">
|
||||||
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :message="item" isGroup />
|
<show-voice ref="voice" v-if="item.objectName === 'RC:HQVCMsg'" :message="item" isGroup />
|
||||||
<show-image v-if="item.objectName === 'RC:ImgMsg'" :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 />
|
<show-text v-if="item.objectName === 'RC:TxtMsg'" :message="item" isGroup />
|
||||||
</view>
|
</view>
|
||||||
@@ -150,6 +150,10 @@
|
|||||||
im.setNotifyBadge()
|
im.setNotifyBadge()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
onHide() {
|
||||||
|
// console.log(JSON.stringify(this.$refs))
|
||||||
|
this.$refs.voice.stopPlay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user