|
@@ -0,0 +1,67 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-button @click="shotPicture">拍照</el-button>
|
|
|
+ <el-button @click="openDoor">开锁</el-button>
|
|
|
+ <el-button @click="lockDoor">锁门</el-button>
|
|
|
+ <el-button @click="addVisit">下发人证基本信息</el-button>
|
|
|
+ <el-button @click="addUser">添加人员</el-button>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { DeviceUrl } from '@/utils/domain'
|
|
|
+export default {
|
|
|
+ name: 'Index',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ websock: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.initWebSocket()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ initWebSocket: function() {
|
|
|
+ var stockbase = DeviceUrl.replace('http', 'ws')
|
|
|
+ this.websock = new WebSocket(stockbase + '/entraceguard')
|
|
|
+ this.websock.onopen = this.websocketonopen
|
|
|
+ this.websock.onerror = this.websocketonerror
|
|
|
+ this.websock.onmessage = this.websocketonmessage
|
|
|
+ this.websock.onclose = this.websocketclose
|
|
|
+ },
|
|
|
+ websocketonopen: function() {
|
|
|
+ this.$message.success('服务正常,可自动发现新看板')
|
|
|
+ this.websock.send(JSON.stringify({ 'cmd': 'web_clinet', 'id': this.$store.getters.uuid }))
|
|
|
+ console.log('WebSocket连接成功')
|
|
|
+ },
|
|
|
+ websocketonerror: function(e) {
|
|
|
+ console.log('WebSocket连接发生错误')
|
|
|
+ },
|
|
|
+ websocketonmessage: function(e) {
|
|
|
+ console.log(e)
|
|
|
+ },
|
|
|
+ websocketclose: function(e) {
|
|
|
+ console.log('connection closed (' + e.code + ')')
|
|
|
+ },
|
|
|
+ shotPicture() {
|
|
|
+ this.websock.send(JSON.stringify({ 'cmd': 'shotpicture', 'from': this.$store.getters.uuid, 'to': 'RLM-00112935' }))
|
|
|
+ },
|
|
|
+ openDoor() {
|
|
|
+ this.websock.send(JSON.stringify({ 'cmd': 'open_door', 'from': this.$store.getters.uuid, 'to': 'RLM-00112935' }))
|
|
|
+ },
|
|
|
+ lockDoor() {
|
|
|
+ this.websock.send(JSON.stringify({ 'cmd': 'lock_door', 'from': this.$store.getters.uuid, 'to': 'RLM-00112935' }))
|
|
|
+ },
|
|
|
+ addVisit() {
|
|
|
+ this.websock.send(JSON.stringify({ 'cmd': 'add_visit', 'from': this.$store.getters.uuid, 'to': 'RLM-00112935' }))
|
|
|
+ },
|
|
|
+ addUser() {
|
|
|
+ this.websock.send(JSON.stringify({ 'cmd': 'add_user', 'from': this.$store.getters.uuid, 'to': 'RLM-00112935' }))
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|