|
|
|
@ -14,24 +14,22 @@ import {getAction, putAction} from "@api/manage"; |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
speech: null, |
|
|
|
|
locale: zhCN, |
|
|
|
|
// 本次定时获取到到语言播报消息列表id |
|
|
|
|
messageIds: [], |
|
|
|
|
// 定时器ID |
|
|
|
|
timer: null, |
|
|
|
|
// 定时器周期 |
|
|
|
|
millisec: 10000, |
|
|
|
|
url: { |
|
|
|
|
list: "/org.jeecg.modules.message/zySpeechMessage/list", |
|
|
|
|
edit: "/org.jeecg.modules.message/zySpeechMessage/edit", |
|
|
|
|
}, |
|
|
|
|
/* 数据源 */ |
|
|
|
|
dataSource: [], |
|
|
|
|
|
|
|
|
|
// speech: null, |
|
|
|
|
// // 定时器ID |
|
|
|
|
// timer: null, |
|
|
|
|
// // 定时器周期 |
|
|
|
|
// millisec: 3000, |
|
|
|
|
// url: { |
|
|
|
|
// list: "/org.jeecg.modules.message/zySpeechMessage/list", |
|
|
|
|
// edit: "/org.jeecg.modules.message/zySpeechMessage/edit", |
|
|
|
|
// }, |
|
|
|
|
// // 本次定时获取到到语言播报消息列表id |
|
|
|
|
// messageList: [], |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
created() { |
|
|
|
|
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> App is init") |
|
|
|
|
let that = this |
|
|
|
|
enquireScreen(deviceType => { |
|
|
|
|
// tablet |
|
|
|
@ -51,119 +49,119 @@ export default { |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
mounted() { |
|
|
|
|
this.speechInit(); |
|
|
|
|
this.openTimer() |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
methods: { |
|
|
|
|
speechInit() { |
|
|
|
|
this.speech = new Speech(); |
|
|
|
|
if (this.speech.hasBrowserSupport()) { // returns a boolean |
|
|
|
|
console.log("this browser,supported TTS") |
|
|
|
|
} else { |
|
|
|
|
console.log("sorry,this browser,not supported TTS!!!") |
|
|
|
|
} |
|
|
|
|
this.speech.init({ |
|
|
|
|
'volume': 1, |
|
|
|
|
'lang': 'zh-CN', |
|
|
|
|
'rate': 1, |
|
|
|
|
'pitch': 1, |
|
|
|
|
'splitSentences': true, |
|
|
|
|
}).then((conf) => { |
|
|
|
|
console.log('语音播报初始化完成...,Speech配置参数:', conf) |
|
|
|
|
}).catch(e => { |
|
|
|
|
console.error("An error occured while init : ", e) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
//语音播报 |
|
|
|
|
MySpeak(obj) { |
|
|
|
|
let mess = obj['message']; |
|
|
|
|
console.log("----------speak()接受到的消息-----------【" + mess + "】"); |
|
|
|
|
this.speech.speak({ |
|
|
|
|
text: mess, |
|
|
|
|
listeners: { |
|
|
|
|
//开始播放 |
|
|
|
|
onstart: () => { |
|
|
|
|
console.log("Start utterance") |
|
|
|
|
}, |
|
|
|
|
//判断播放是否完毕 |
|
|
|
|
onend: () => { |
|
|
|
|
// console.log("End utterance"); |
|
|
|
|
console.log("------------delete----------【" + mess + "】消息播报完成,删除该消息") |
|
|
|
|
this.updateMessageStatus(obj['id']); |
|
|
|
|
}, |
|
|
|
|
//恢复播放 |
|
|
|
|
onresume: () => { |
|
|
|
|
console.log("Resume utterance") |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}).then(() => { |
|
|
|
|
// console.log("消息" + obj['id'] + "播报完成") |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getMessageList() { |
|
|
|
|
let parma = { |
|
|
|
|
"status": '0', |
|
|
|
|
} |
|
|
|
|
getAction(this.url.list, parma).then((res) => { |
|
|
|
|
if (res.success) { |
|
|
|
|
console.log("------------getMessageList----------文字转语音消息列表>>>:" + JSON.stringify(res.result.records)); |
|
|
|
|
this.dataSource = res.result.records; |
|
|
|
|
this.dataSource.forEach(obj => { |
|
|
|
|
if (obj['status'] === '0') { |
|
|
|
|
this.MySpeak(obj); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.$message.warning(res.message) |
|
|
|
|
} |
|
|
|
|
}).finally(() => { |
|
|
|
|
// this.loading = false |
|
|
|
|
// this.loadData(); |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
updateMessageStatus(id) { |
|
|
|
|
// console.log("删除已播报消息:" + id); |
|
|
|
|
let parma = { |
|
|
|
|
"id": id, |
|
|
|
|
"status": '1', |
|
|
|
|
} |
|
|
|
|
putAction(this.url.edit, parma).then((res) => { |
|
|
|
|
if (res.success) { |
|
|
|
|
for (let i = 0; i < this.dataSource.length; i++) { |
|
|
|
|
if (this.dataSource[i].id === id) { |
|
|
|
|
this.dataSource.splice(i, 1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
this.$message.warning(res.message) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
openTimer() { |
|
|
|
|
this.closeTimer() |
|
|
|
|
console.log("timer初始化完成:" + new Date().toLocaleString()) |
|
|
|
|
//上次播报列表播报完后,再获取新数据 |
|
|
|
|
this.timer = setInterval(() => { |
|
|
|
|
console.log("---未播报消息数量:", this.dataSource.length) |
|
|
|
|
if (this.dataSource.length === 0) { |
|
|
|
|
console.log("--------timer is exec,the current time:" + new Date().toLocaleString()) |
|
|
|
|
this.getMessageList(); |
|
|
|
|
} else { |
|
|
|
|
console.log("-------上次消息列表未处理完---HOLD DOWN") |
|
|
|
|
} |
|
|
|
|
}, this.millisec) |
|
|
|
|
}, |
|
|
|
|
// mounted() { |
|
|
|
|
// this.speechInit(); |
|
|
|
|
// this.openTimer() |
|
|
|
|
// }, |
|
|
|
|
|
|
|
|
|
/** 关闭定时器 */ |
|
|
|
|
closeTimer() { |
|
|
|
|
if (this.timer) clearInterval(this.timer) |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
// methods: { |
|
|
|
|
// speechInit() { |
|
|
|
|
// this.speech = new Speech(); |
|
|
|
|
// if (this.speech.hasBrowserSupport()) { // returns a boolean |
|
|
|
|
// console.log("this browser,supported TTS") |
|
|
|
|
// } else { |
|
|
|
|
// console.log("sorry,this browser,not supported TTS!!!") |
|
|
|
|
// } |
|
|
|
|
// this.speech.init({ |
|
|
|
|
// 'volume': 1, |
|
|
|
|
// 'lang': 'zh-CN', |
|
|
|
|
// 'rate': 1, |
|
|
|
|
// 'pitch': 1, |
|
|
|
|
// 'splitSentences': true, |
|
|
|
|
// }).then((conf) => { |
|
|
|
|
// console.log('语音播报初始化完成...,Speech配置参数:', conf) |
|
|
|
|
// }).catch(e => { |
|
|
|
|
// console.error("An error occured while init : ", e) |
|
|
|
|
// }) |
|
|
|
|
// }, |
|
|
|
|
// //语音播报 |
|
|
|
|
// MySpeak(obj) { |
|
|
|
|
// let mess = obj['message']; |
|
|
|
|
// console.log("----------speak()接受到的消息-----------【" + mess + "】"); |
|
|
|
|
// this.speech.speak({ |
|
|
|
|
// text: mess, |
|
|
|
|
// listeners: { |
|
|
|
|
// //开始播放 |
|
|
|
|
// onstart: () => { |
|
|
|
|
// console.log("Start utterance") |
|
|
|
|
// }, |
|
|
|
|
// //判断播放是否完毕 |
|
|
|
|
// onend: () => { |
|
|
|
|
// // console.log("End utterance"); |
|
|
|
|
// console.log("------------delete----------【" + mess + "】消息播报完成,删除该消息") |
|
|
|
|
// this.updateMessageStatus(obj['id']); |
|
|
|
|
// }, |
|
|
|
|
// //恢复播放 |
|
|
|
|
// onresume: () => { |
|
|
|
|
// console.log("Resume utterance") |
|
|
|
|
// }, |
|
|
|
|
// }, |
|
|
|
|
// }).then(() => { |
|
|
|
|
// // console.log("消息" + obj['id'] + "播报完成") |
|
|
|
|
// }) |
|
|
|
|
// }, |
|
|
|
|
// |
|
|
|
|
// getMessageList() { |
|
|
|
|
// let parma = { |
|
|
|
|
// "status": '0', |
|
|
|
|
// } |
|
|
|
|
// getAction(this.url.list, parma).then((res) => { |
|
|
|
|
// if (res.success) { |
|
|
|
|
// console.log("------------getMessageList----------文字转语音消息列表>>>:" + JSON.stringify(res.result.records)); |
|
|
|
|
// this.messageList = res.result.records; |
|
|
|
|
// this.messageList.forEach(obj => { |
|
|
|
|
// if (obj['status'] === '0') { |
|
|
|
|
// this.MySpeak(obj); |
|
|
|
|
// } |
|
|
|
|
// }) |
|
|
|
|
// } else { |
|
|
|
|
// this.$message.warning(res.message) |
|
|
|
|
// } |
|
|
|
|
// }).finally(() => { |
|
|
|
|
// // this.loading = false |
|
|
|
|
// // this.loadData(); |
|
|
|
|
// }) |
|
|
|
|
// }, |
|
|
|
|
// |
|
|
|
|
// updateMessageStatus(id) { |
|
|
|
|
// // console.log("删除已播报消息:" + id); |
|
|
|
|
// let parma = { |
|
|
|
|
// "id": id, |
|
|
|
|
// "status": '1', |
|
|
|
|
// } |
|
|
|
|
// putAction(this.url.edit, parma).then((res) => { |
|
|
|
|
// if (res.success) { |
|
|
|
|
// for (let i = 0; i < this.messageList.length; i++) { |
|
|
|
|
// if (this.messageList[i].id === id) { |
|
|
|
|
// this.messageList.splice(i, 1); |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// } else { |
|
|
|
|
// this.$message.warning(res.message) |
|
|
|
|
// } |
|
|
|
|
// }) |
|
|
|
|
// }, |
|
|
|
|
// |
|
|
|
|
// openTimer() { |
|
|
|
|
// this.closeTimer() |
|
|
|
|
// console.log(">>>timer初始化完成【" + new Date().toLocaleString() + "】,---执行周期: " + this.millisec+" 毫秒") |
|
|
|
|
// //上次播报列表播报完后,再获取新数据 |
|
|
|
|
// this.timer = setInterval(() => { |
|
|
|
|
// console.log("---未播报消息数量:", this.messageList.length) |
|
|
|
|
// if (this.messageList.length === 0) { |
|
|
|
|
// console.log("--------timer is exec,the current time:" + new Date().toLocaleString()) |
|
|
|
|
// this.getMessageList(); |
|
|
|
|
// } else { |
|
|
|
|
// console.log("-------上次消息列表未处理完---HOLD DOWN") |
|
|
|
|
// } |
|
|
|
|
// }, this.millisec) |
|
|
|
|
// }, |
|
|
|
|
// |
|
|
|
|
// /** 关闭定时器 */ |
|
|
|
|
// closeTimer() { |
|
|
|
|
// if (this.timer) clearInterval(this.timer) |
|
|
|
|
// }, |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
<style> |
|
|
|
|