This commit is contained in:
BianLzhaoMin 2025-08-21 10:46:35 +08:00
parent c17eaf593e
commit 86108ff4e9
1 changed files with 39 additions and 1 deletions

View File

@ -631,7 +631,7 @@ export default {
return { return {
// //
idCardReaderForm: { idCardReaderForm: {
idCardReaderAddress: '127.0.0.1:8080', // idCardReaderAddress: 'ws://127.0.0.1:24011', //
}, },
// //
idCardInfoForm: { idCardInfoForm: {
@ -931,6 +931,7 @@ export default {
editUploadFileList: [], // editUploadFileList: [], //
isEditContract: false, // isEditContract: false, //
webSocket: null, // websocket
} }
}, },
methods: { methods: {
@ -1439,6 +1440,36 @@ export default {
const age = new Date().getFullYear() - birthday.slice(0, 4) const age = new Date().getFullYear() - birthday.slice(0, 4)
this.idCardInfoForm.age = age this.idCardInfoForm.age = age
}, },
// websocket
createWebSocket() {
this.webSocket = new WebSocket(
this.idCardReaderForm.idCardReaderAddress,
)
this.webSocket.onopen = function (evt) {
console.log('建立连接成功', evt)
}
this.webSocket.onclose = function (evt) {
console.log('断开连接', evt)
}
this.webSocket.onmessage = function (evt) {
console.log('收到消息', evt)
}
this.webSocket.onerror = function (evt) {
console.log('错误', evt)
}
},
// websocket
closeWebSocket() {
this.webSocket.close()
},
//
downloadIdCardReaderDriver() {
// window.open(this.idCardReaderForm.idCardReaderAddress)
},
}, },
async created() { async created() {
@ -1451,6 +1482,13 @@ export default {
}) })
this.getLotProjectSelectList() this.getLotProjectSelectList()
this.createWebSocket()
},
beforeDestroy() {
if (this.webSocket) {
this.closeWebSocket()
}
}, },
watch: { watch: {