From a95c91f64079d7a0583321781fcca08c58eeb26a Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 29 Nov 2023 10:15:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=94=B6=E5=88=B0=E6=96=B0=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=B7=BB=E5=8A=A0=E9=93=83=E5=A3=B0=E6=8F=90=E9=86=92?= =?UTF-8?q?=E3=80=81=E5=BD=93=E5=89=8D=E4=BC=9A=E8=AF=9D=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E5=88=B0=E6=96=B0=E8=AF=AD=E9=9F=B3=E7=9B=B4=E6=8E=A5=E6=92=AD?= =?UTF-8?q?=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../newMap/display/newChat/chatContent.vue | 33 +++++++++++++++++-- .../newMap/display/newChat/chatDialog.vue | 5 ++- src/views/newMap/display/newChat/index.vue | 21 +++++++++++- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/views/newMap/display/newChat/chatContent.vue b/src/views/newMap/display/newChat/chatContent.vue index f5af5dd84..97e2ecdbb 100644 --- a/src/views/newMap/display/newChat/chatContent.vue +++ b/src/views/newMap/display/newChat/chatContent.vue @@ -123,6 +123,12 @@ export default { } }, id() { + this.currentAudioList = []; + this.messageList.forEach(item => { + this.$set(item, 'activeAuto', false); + }); + const audioDom = document.querySelector('#audioPlay'); + audioDom && audioDom.pause(); this.cancelRecording(); } }, @@ -140,6 +146,28 @@ export default { this.contentDom = ''; }, methods: { + playNoReadMessage() { + if (!this.id && !this.privateChatId) return; + const list = this.getNoReadVoiceList(); + if (list.length) { + this.currentAudioList = list; + this.playAllAudio(); + } + }, + getNoReadVoiceList() { + const filter = this.messageList.filter(item => { + return item.type == 'Voice' && !item.allRead && !item.readerSet.includes(this.myMemberId) && this.myMemberId != item.memberId; + }); + return filter; + }, + setActiveAutoFalse(ms) { + const findIndex = this.messageList.findIndex(item => { + return item.id == ms.id; + }); + if (findIndex > -1) { + this.messageList.splice(findIndex, 1, {...this.messageList[findIndex], 'activeAuto': false}); + } + }, setIsBottomFn() { const scrollTop = this.contentDom.scrollHeight - this.contentDom.clientHeight; if (scrollTop == 0 || this.contentDom.scrollTop >= scrollTop) { @@ -157,16 +185,17 @@ export default { }, playAllAudio() { this.$nextTick(function() { - this.currentMessage = this.currentAudioList.shift(); - if (this.currentMessage.type === 'Text') { + if (!this.currentAudioList || !this.currentAudioList[0] || this.currentAudioList[0].type === 'Text') { return; } + this.currentMessage = this.currentAudioList.shift(); document.querySelector('#audioPlay').src = this.currentMessage.audioPath; document.querySelector('#audioPlay').play(); this.$set(this.currentMessage, 'activeAuto', true); this.play = true; document.querySelector('#audioPlay').onended = () => { this.$set(this.currentMessage, 'activeAuto', false); + this.setActiveAutoFalse(this.currentMessage); if (!this.currentAudioList || !this.currentAudioList.length) { this.play = false; } else { diff --git a/src/views/newMap/display/newChat/chatDialog.vue b/src/views/newMap/display/newChat/chatDialog.vue index f009174eb..45e029543 100644 --- a/src/views/newMap/display/newChat/chatDialog.vue +++ b/src/views/newMap/display/newChat/chatDialog.vue @@ -56,7 +56,7 @@
- +
@@ -591,6 +591,9 @@ export default { this.getMessageStatus(obj); }); }); + this.$nextTick(() => { + this.$refs.chatContentRef && this.$refs.chatContentRef.playNoReadMessage(); + }); }, handleClose() { this.$store.dispatch('training/setChatBoxMin', true); diff --git a/src/views/newMap/display/newChat/index.vue b/src/views/newMap/display/newChat/index.vue index 4301c4bb5..0b898ba4b 100644 --- a/src/views/newMap/display/newChat/index.vue +++ b/src/views/newMap/display/newChat/index.vue @@ -6,6 +6,9 @@
+ @@ -13,6 +16,7 @@ import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler'; // import {UserOperationType} from '@/scripts/ConstDic'; import chatDialog from './chatDialog'; +import BuzzerAudio from '@/assets/buzzer.mp3'; export default { name: 'ChatBox', components: { @@ -20,7 +24,8 @@ export default { }, data() { return { - totalUnreadNum: 0 + totalUnreadNum: 0, + buzzerAudio: BuzzerAudio }; }, computed:{ @@ -36,11 +41,24 @@ export default { this.$nextTick(() => { this.$store.dispatch('training/emitTipFresh'); }); + }, + totalUnreadNum(val) { + if (val && !this.$refs.chatDialog.dialogVisible) { + this.playBuzzer(); + } } }, mounted() { }, methods: { + playBuzzer() { + const audioDom = document.querySelector('#chatBuzzer'); + audioDom && audioDom.play(); + }, + pauseBuzzer() { + const audioDom = document.querySelector('#chatBuzzer'); + audioDom && audioDom.pause(); + }, setTotalUnread(val) { this.totalUnreadNum = val; }, @@ -52,6 +70,7 @@ export default { // }; this.$store.dispatch('training/setChatBoxMin', false); this.$refs.chatDialog.dialogVisible = true; + this.pauseBuzzer(); // if (this.$store.state.trainingNew.trainingSwitch) { // this.$nextTick(() => { // this.$store.dispatch('trainingNew/next', operate); 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 2/2] =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E9=9F=B3=E6=94=B9=E4=B8=BA=E4=B9=8B=E5=89=8D=E7=94=B5=E8=AF=9D?= =?UTF-8?q?=E9=93=83=E5=A3=B0=E3=80=81=E8=AF=AD=E9=9F=B3=E6=92=AD=E5=AE=8C?= =?UTF-8?q?=E5=86=8D=E6=92=AD=E5=8F=A6=E4=B8=80=E4=B8=AA=E3=80=81=E5=85=B6?= =?UTF-8?q?=E4=BB=96=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');