This commit is contained in:
2022-11-22 18:12:30 +08:00
parent adc0a0fad3
commit 4d91cde705
4 changed files with 18 additions and 22 deletions

View File

@@ -357,23 +357,19 @@ export default {
this.speech.init().then(() => {}) this.speech.init().then(() => {})
}, },
// 播放函数 // 播放函数
play (textContent, id, needcast, i, len) { play (textContent, id, needcast) {
if (needcast === '0') {
return
}
this.speech.speak({ this.speech.speak({
text: textContent, // 播放的文本内容 text: needcast === '1' ? textContent : '', // 播放的文本内容
listeners: { listeners: {
// 开始播放 // 开始播放
onstart: () => { onstart: () => {
this.pkId = id this.pkId = needcast === '1' ? id : ''
}, },
// 判断播放是否完毕 // 判断播放是否完毕
onend: () => { onend: () => {
this.pkId = '' this.pkId = ''
this.ids.push(id) if (needcast === '1') {
if (i === len - 1) { this._updateWarnTime([id])
this._updateWarnTime()
} }
}, },
// 恢复播放 // 恢复播放
@@ -875,16 +871,16 @@ export default {
if (res.code === '1') { if (res.code === '1') {
this.gridArr5 = [...res.srb.device_group_arr] this.gridArr5 = [...res.srb.device_group_arr]
if (this.gridArr5.length > 0) { if (this.gridArr5.length > 0) {
this.gridArr5.map((el, i) => { this.gridArr5.map((e, i) => {
this.play(el.fault_desc, el.id, el.needcast, i, this.gridArr5.length) this.play(e.fault_desc, e.id, e.needcast)
}) })
} }
} else { } else {
this.Dialog(res.desc) this.Dialog(res.desc)
} }
}, },
async _updateWarnTime () { async _updateWarnTime (id) {
let res = await updateWarnTime(this.ids) let res = await updateWarnTime(id)
if (res.code === '1') { if (res.code === '1') {
// this.toast(res.desc) // this.toast(res.desc)
} else { } else {

View File

@@ -28,7 +28,7 @@
<input type="text" class="inputStyle" v-model="baseUrl"> <input type="text" class="inputStyle" v-model="baseUrl">
</div> </div>
<div class="inputOuter"> <div class="inputOuter">
<label>刷新时间</label> <label>刷新时间()</label>
<input type="number" class="inputStyle" v-model="setTime"> <input type="number" class="inputStyle" v-model="setTime">
</div> </div>
<!-- <div class="inputOuter"> <!-- <div class="inputOuter">
@@ -78,7 +78,7 @@ export default {
password: '', password: '',
drift: 0, drift: 0,
baseUrl: this.$store.getters.baseUrl, baseUrl: this.$store.getters.baseUrl,
setTime: this.$store.getters.setTime, setTime: this.$store.getters.setTime / 1000,
fullscreen: false, fullscreen: false,
heightLimit: false, heightLimit: false,
option: [], option: [],
@@ -135,7 +135,7 @@ export default {
_config () { _config () {
let obj = { let obj = {
baseUrl: this.baseUrl, baseUrl: this.baseUrl,
setTime: this.setTime setTime: this.setTime * 1000
} }
this.$store.dispatch('setConfig', obj) this.$store.dispatch('setConfig', obj)
this.$router.push('/DeviceManage') this.$router.push('/DeviceManage')
@@ -214,7 +214,7 @@ export default {
width 100% width 100%
margin-bottom 12px margin-bottom 12px
.inputStyle, select .inputStyle, select
width 260px width 240px
font-size 16px font-size 16px
float right float right
background none background none

View File

@@ -1,5 +1,8 @@
<template> <template>
<button @click="play('播放')">播放语音</button> <section>
<button @click="play('播放联芳街道垃圾分类鸡蛋放了解了解')">播放语音</button>
<button @click="play('收到了放假了')">播放语音</button>
</section>
</template> </template>
<script> <script>
import Speech from 'speak-tts' import Speech from 'speak-tts'
@@ -11,9 +14,6 @@ export default {
}, },
mounted () { mounted () {
this.SpeechInit() // 需要初始化 this.SpeechInit() // 需要初始化
setInterval(() => {
this.play('播放')
}, 5000)
}, },
methods: { methods: {
SpeechInit () { SpeechInit () {

View File

@@ -15,7 +15,7 @@ const state = {
toastMsg: '退出登录', toastMsg: '退出登录',
alertMsg: '操作成功', alertMsg: '操作成功',
baseUrl: getStore('baseUrl') || baseUrl, baseUrl: getStore('baseUrl') || baseUrl,
setTime: getStore('setTime') || 5000, setTime: getStore('setTime') || '5000',
equipId: getStore('equipId') || '' equipId: getStore('equipId') || ''
} }