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

View File

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

View File

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

View File

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