From 8e68e6e9743168d1092fd0f1bd5faeb16ca132ce Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 29 Nov 2023 17:24:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E6=8F=90=E7=A4=BA=E9=9F=B3?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E4=B9=8B=E5=89=8D=E7=94=B5=E8=AF=9D=E9=93=83?= =?UTF-8?q?=E5=A3=B0=E3=80=81=E8=AF=AD=E9=9F=B3=E6=92=AD=E5=AE=8C=E5=86=8D?= =?UTF-8?q?=E6=92=AD=E5=8F=A6=E4=B8=80=E4=B8=AA=E3=80=81=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../newMap/display/newChat/chatContent.vue | 44 +++++++++++++------ src/views/newMap/display/newChat/index.vue | 9 ++-- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/views/newMap/display/newChat/chatContent.vue b/src/views/newMap/display/newChat/chatContent.vue index 97e2ecdbb..44d25cb52 100644 --- a/src/views/newMap/display/newChat/chatContent.vue +++ b/src/views/newMap/display/newChat/chatContent.vue @@ -123,12 +123,7 @@ export default { } }, id() { - this.currentAudioList = []; - this.messageList.forEach(item => { - this.$set(item, 'activeAuto', false); - }); - const audioDom = document.querySelector('#audioPlay'); - audioDom && audioDom.pause(); + this.stopNoReadPlay(); this.cancelRecording(); } }, @@ -146,12 +141,29 @@ export default { this.contentDom = ''; }, methods: { + stopNoReadPlay() { + this.currentAudioList = []; + this.messageList.forEach(item => { + this.$set(item, 'activeAuto', false); + }); + const audioDom = document.querySelector('#audioPlay'); + audioDom && audioDom.pause(); + }, playNoReadMessage() { if (!this.id && !this.privateChatId) return; const list = this.getNoReadVoiceList(); - if (list.length) { - this.currentAudioList = list; - this.playAllAudio(); + if (this.play) { + const filterList = list.filter(item => { + return !this.currentAudioList.find(ii => { + return ii.id == item.id; + }); + }); + this.currentAudioList.push(...filterList); + } else { + if (list.length) { + this.currentAudioList = list; + this.playAllAudio(); + } } }, getNoReadVoiceList() { @@ -160,12 +172,12 @@ export default { }); return filter; }, - setActiveAutoFalse(ms) { + setActiveAutoStatus(ms, s = false) { const findIndex = this.messageList.findIndex(item => { return item.id == ms.id; }); if (findIndex > -1) { - this.messageList.splice(findIndex, 1, {...this.messageList[findIndex], 'activeAuto': false}); + this.$set(this.messageList[findIndex], 'activeAuto', s); } }, setIsBottomFn() { @@ -192,10 +204,11 @@ export default { document.querySelector('#audioPlay').src = this.currentMessage.audioPath; document.querySelector('#audioPlay').play(); this.$set(this.currentMessage, 'activeAuto', true); + this.setActiveAutoStatus(this.currentMessage, true); this.play = true; document.querySelector('#audioPlay').onended = () => { this.$set(this.currentMessage, 'activeAuto', false); - this.setActiveAutoFalse(this.currentMessage); + this.setActiveAutoStatus(this.currentMessage); if (!this.currentAudioList || !this.currentAudioList.length) { this.play = false; } else { @@ -205,8 +218,7 @@ export default { }); }, playAudio(audioPath, data) { - this.$set(this.currentMessage, 'activeAuto', false); - this.currentAudioList = []; + this.stopNoReadPlay(); this.currentMessage = data; this.play = true; document.querySelector('#audioPlay').src = audioPath; @@ -263,6 +275,10 @@ export default { }, // 停止录制 发送语音 stopRecording() { + if (this.seconds < 1) { + this.$message.info('录制语音时间太短!'); + return; + } this.audioPlay = true; clearInterval(this.inter); this.seconds = 0; diff --git a/src/views/newMap/display/newChat/index.vue b/src/views/newMap/display/newChat/index.vue index 0b898ba4b..381ee1c1b 100644 --- a/src/views/newMap/display/newChat/index.vue +++ b/src/views/newMap/display/newChat/index.vue @@ -16,7 +16,7 @@ import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler'; // import {UserOperationType} from '@/scripts/ConstDic'; import chatDialog from './chatDialog'; -import BuzzerAudio from '@/assets/buzzer.mp3'; +import teleRing from '@/assets/teleRing.mp3'; export default { name: 'ChatBox', components: { @@ -25,7 +25,7 @@ export default { data() { return { totalUnreadNum: 0, - buzzerAudio: BuzzerAudio + buzzerAudio: teleRing }; }, computed:{ @@ -53,7 +53,10 @@ export default { methods: { playBuzzer() { const audioDom = document.querySelector('#chatBuzzer'); - audioDom && audioDom.play(); + if (audioDom) { + audioDom.currentTime = 0; + audioDom.play(); + } }, pauseBuzzer() { const audioDom = document.querySelector('#chatBuzzer');