Commit 8711ef40 by huangqy

1111

parent b0be70a5
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"swiper": "^6.3.5", "swiper": "^6.3.5",
"speak-tts": "^2.0.8",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-awesome-swiper": "^3.1.3", "vue-awesome-swiper": "^3.1.3",
"vue-calendar-component": "^2.8.2", "vue-calendar-component": "^2.8.2",
......
...@@ -246,11 +246,13 @@ export default { ...@@ -246,11 +246,13 @@ export default {
this.tagCheck(backMessObj.Data.Data) this.tagCheck(backMessObj.Data.Data)
} }
else if (backMessObj.Cmd === 5){ else if (backMessObj.Cmd === 5){
let str = backMessObj.Data.replace(/\n/g, ',') // let str = backMessObj.Data.replace(/\n/g, ',')
var obj = str.substr(0, str.length -1) // var obj = str.substr(0, str.length -1)
var index = obj.lastIndexOf("编") // var index = obj.lastIndexOf("编")
obj = obj.substring(index+3, obj.length) // obj = obj.substring(index+3, obj.length)
var sendObj = { Uid: this.uid, Data: obj } // var sendObj = { Uid: this.uid, Data: obj }
var sendObj = { Uid: this.uid, Data: backMessObj.Code }
console.log(JSON.stringify({Cmd: 3, Data: sendObj}))
this.websock.send(JSON.stringify({Cmd: 3, Data: sendObj})) this.websock.send(JSON.stringify({Cmd: 3, Data: sendObj}))
} }
else if (backMessObj.Cmd === 254) { else if (backMessObj.Cmd === 254) {
......
...@@ -199,6 +199,24 @@ ...@@ -199,6 +199,24 @@
<script> <script>
import initData from '../../mixins/initData' import initData from '../../mixins/initData'
import Speech from 'speak-tts'
const speech = new Speech() // will throw an exception if not browser supported
if(speech.hasBrowserSupport()) { // returns a boolean
console.log("speech synthesis supported")
}
speech.init({
'volume': 1,
'lang': 'zh-CN',
'rate': 1,
'pitch': 1,
'voice':'Google 普通话(中国大陆)',
'splitSentences': true,
'listeners': {
'onvoiceschanged': (voices) => {
console.log("Event voiceschanged", voices)
}
}
})
export default { export default {
mixins: [initData], mixins: [initData],
data () { data () {
...@@ -226,6 +244,31 @@ export default { ...@@ -226,6 +244,31 @@ export default {
}, },
methods: { methods: {
speak(text) {
console.log(text)
speech.speak({
text: text,
queue: true, // current speech will be interrupted,
listeners: {
onstart: () => {
console.log("Start utterance")
},
onend: () => {
console.log("End utterance")
},
onresume: () => {
console.log("Resume utterance")
},
onboundary: (event) => {
console.log(event.name + ' boundary reached after ' + event.elapsedTime + ' milliseconds.')
}
}
}).then(() => {
console.log("Success !")
}).catch(e => {
console.error("An error occurred :", e)
})
},
beforeInit() { beforeInit() {
this.url = '/api/batch/page' this.url = '/api/batch/page'
return true return true
...@@ -352,7 +395,6 @@ export default { ...@@ -352,7 +395,6 @@ export default {
console.log(backMessObj) console.log(backMessObj)
this.loading = false this.loading = false
if (backMessObj.Cmd == 2) { if (backMessObj.Cmd == 2) {
// this.logList.unshift({time: this.parseTime(new Date()), log: '数据加密成功:' + JSON.stringify(backMessObj.Data) })
this.updateContent(backMessObj.Data.Access, backMessObj.Data.Data) this.updateContent(backMessObj.Data.Access, backMessObj.Data.Data)
} else if (backMessObj.Cmd === 1){ } else if (backMessObj.Cmd === 1){
if (this.oldUid !== this.newUid) { if (this.oldUid !== this.newUid) {
...@@ -361,6 +403,7 @@ export default { ...@@ -361,6 +403,7 @@ export default {
this.updateUid(backMessObj.Data) this.updateUid(backMessObj.Data)
} }
else if (backMessObj.Cmd === 4){ else if (backMessObj.Cmd === 4){
this.speak('D')
this.logList.unshift({time: this.parseTime(new Date()), log: '标签成功写入生产数据' }) this.logList.unshift({time: this.parseTime(new Date()), log: '标签成功写入生产数据' })
this.bindForm.doneNum ++ this.bindForm.doneNum ++
this.oldUid = this.newUid this.oldUid = this.newUid
...@@ -375,6 +418,7 @@ export default { ...@@ -375,6 +418,7 @@ export default {
}, 1000) }, 1000)
} else { } else {
this.logList.unshift({time: this.parseTime(new Date()), log: backMessObj.Data.Message }) this.logList.unshift({time: this.parseTime(new Date()), log: backMessObj.Data.Message })
this.speak(backMessObj.Data.Message + ',请重新绑定')
} }
} }
}, },
...@@ -394,7 +438,7 @@ export default { ...@@ -394,7 +438,7 @@ export default {
async updateContent(password, ciphertext) { async updateContent(password, ciphertext) {
const { data: res } = await this.$axios.post('/api/tag/updateContent', {tagId: this.bindForm.tagId, password: password, ciphertext: ciphertext}) const { data: res } = await this.$axios.post('/api/tag/updateContent', {tagId: this.bindForm.tagId, password: password, ciphertext: ciphertext})
if (!res.data) return this.$message.error(res.message) if (!res.data) return this.$message.error(res.message)
this.websock.send(JSON.stringify({Cmd: 4, Data: {Access: password, Data: res.data.content} })) this.websock.send(JSON.stringify({Cmd: 4, Data: {Access: password, Data: res.data.content, Code: res.data.productCode } }))
}, },
bindBatch() { bindBatch() {
this.loading = true this.loading = true
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论