From e491cdb48129752324c4e3764f99bd9203c56dec Mon Sep 17 00:00:00 2001
From: lgq <1015864684@qq.com>
Date: 星期二, 31 三月 2026 09:48:44 +0800
Subject: [PATCH] 1.新增VF205门禁机代码
---
vf205_access/src/view/topView.js | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 170 insertions(+), 0 deletions(-)
diff --git a/vf205_access/src/view/topView.js b/vf205_access/src/view/topView.js
new file mode 100644
index 0000000..db0f041
--- /dev/null
+++ b/vf205_access/src/view/topView.js
@@ -0,0 +1,170 @@
+import dxui from '../../dxmodules/dxUi.js'
+import std from '../../dxmodules/dxStd.js'
+import viewUtils from './viewUtils.js'
+import screen from '../screen.js'
+import newPwdView from './config/newPwdView.js'
+import logger from '../../dxmodules/dxLogger.js'
+
+// 涓昏鏄剧ず绯荤粺鏃堕棿鍜岀姸鎬佸浘鏍�
+const topView = {}
+topView.init = function () {
+ const screenMain = dxui.View.build('topView', dxui.Utils.LAYER.TOP)
+ topView.screenMain = screenMain
+ viewUtils._clearStyle(screenMain)
+ screenMain.scroll(false)
+ screenMain.width(screen.screenSize.width)
+ screenMain.height(screen.screenSize.height)
+ screenMain.bgOpa(0)
+ screenMain.clickable(false)
+
+ const topBox = dxui.View.build('topBox', screenMain)
+ viewUtils._clearStyle(topBox)
+ topBox.width(screen.screenSize.width)
+ topBox.height(70)
+ topBox.bgOpa(0)
+ topBox.clickable(false)
+
+ topBox.flexFlow(dxui.Utils.FLEX_FLOW.ROW)
+ topBox.flexAlign(dxui.Utils.FLEX_ALIGN.SPACE_BETWEEN, dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.CENTER)
+
+ const topBoxLeft = dxui.View.build('topBoxLeft', topBox)
+ viewUtils._clearStyle(topBoxLeft)
+ topBoxLeft.width(400)
+ topBoxLeft.height(70)
+ topBoxLeft.padLeft(38)
+ topBoxLeft.bgOpa(0)
+ topBoxLeft.clickable(false)
+
+ const topBoxRight = dxui.View.build('topBoxRight', topBox)
+ viewUtils._clearStyle(topBoxRight)
+ topBoxRight.width(400)
+ topBoxRight.height(70)
+ topBoxRight.padRight(38)
+ topBoxRight.bgOpa(0)
+ topBoxRight.clickable(false)
+ topBoxRight.flexFlow(dxui.Utils.FLEX_FLOW.ROW)
+ topBoxRight.flexAlign(dxui.Utils.FLEX_ALIGN.END, dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.CENTER)
+
+ const ethShow = dxui.Image.build('ethShow', topBoxRight)
+ topView.ethShow = ethShow
+ ethShow.source('/app/code/resource/image/ethernet.png')
+ ethShow.clickable(false)
+ ethShow.hide()
+
+ const wifiShow = dxui.Image.build('wifiShow', topBoxRight)
+ topView.wifiShow = wifiShow
+ wifiShow.source('/app/code/resource/image/wifi.png')
+ wifiShow.clickable(false)
+ wifiShow.hide()
+
+ const _4gShow = dxui.Image.build('4gShow', topBoxRight)
+ topView._4gShow = _4gShow
+ _4gShow.source('/app/code/resource/image/4g.png')
+ _4gShow.clickable(false)
+ _4gShow.hide()
+
+ const mqttShow = dxui.Image.build('mqttShow', topBoxRight)
+ topView.mqttShow = mqttShow
+ mqttShow.source('/app/code/resource/image/mqtt.png')
+ mqttShow.clickable(false)
+ mqttShow.hide()
+
+ // 娣诲姞闀挎寜杩涘叆绠$悊椤甸潰鐨勫尯鍩�
+ const adminArea = dxui.View.build('adminArea', screenMain)
+ viewUtils._clearStyle(adminArea)
+ adminArea.setSize(120, 120)
+ adminArea.align(dxui.Utils.ALIGN.TOP_RIGHT, 0, 0)
+ adminArea.bgOpa(0)
+ adminArea.clickable(true)
+
+ logger.info('[topView]: 闀挎寜鍖哄煙宸插垱寤猴紝浣嶇疆锛氬彸涓婅')
+
+ let pressStartTime = 0
+ let isPressing = false
+ let longPressTimer = null
+
+ // 浣跨敤PRESSING浜嬩欢妫�娴嬫寜浣忕姸鎬�
+ adminArea.on(dxui.Utils.EVENT.PRESSING, () => {
+ if (!isPressing) {
+ // 绗竴娆℃娴嬪埌鎸変綇
+ isPressing = true
+ pressStartTime = Date.now()
+ logger.info('[topView]: 寮�濮嬫寜浣�')
+
+ // 鍚姩闀挎寜璁℃椂鍣�
+ longPressTimer = std.setTimeout(() => {
+ const pressDuration = Date.now() - pressStartTime
+ logger.info(`[topView]: 鎸変綇涓嶆斁${pressDuration}ms鎴愬姛锛岃繘鍏ョ鐞嗛〉闈)
+ dxui.loadMain(newPwdView.screenMain)
+ longPressTimer = null
+ }, 3000)
+ }
+ })
+
+ // 浣跨敤CLICK浜嬩欢妫�娴嬮噴鏀撅紙褰撶敤鎴烽噴鏀炬椂锛孭RESSING浜嬩欢浼氬仠姝級
+ adminArea.on(dxui.Utils.EVENT.CLICK, () => {
+ if (isPressing) {
+ const pressDuration = Date.now() - pressStartTime
+ logger.info(`[topView]: 鎸変綇鏃堕棿${pressDuration}ms锛岄噴鏀綻)
+
+ // 娓呴櫎璁℃椂鍣�
+ if (longPressTimer) {
+ std.clearTimeout(longPressTimer)
+ longPressTimer = null
+ }
+
+ isPressing = false
+ } else {
+ logger.info('[topView]: 闀挎寜鍖哄煙妫�娴嬪埌鐐瑰嚮浜嬩欢')
+ }
+ })
+
+}
+
+// 鍒囨崲涓婚锛屼袱濂楀浘鏍囷紝涓�濂楃櫧鑹诧紝涓�濂楅粦鑹�
+topView.changeTheme = function (dark) {
+ if (dark) {
+ topView.ethShow.source('/app/code/resource/image/ethernet_dark.png')
+ topView.mqttShow.source('/app/code/resource/image/mqtt_dark.png')
+ topView.wifiShow.source('/app/code/resource/image/wifi_dark.png')
+ topView._4gShow.source('/app/code/resource/image/4g_dark.png')
+ } else {
+ topView.ethShow.source('/app/code/resource/image/ethernet.png')
+ topView.mqttShow.source('/app/code/resource/image/mqtt.png')
+ topView.wifiShow.source('/app/code/resource/image/wifi.png')
+ topView._4gShow.source('/app/code/resource/image/4g.png')
+ }
+}
+
+// mqtt杩炴帴鐘舵��
+topView.mqttConnectState = function (connected) {
+ if (connected) {
+ topView.mqttShow.show()
+ } else {
+ topView.mqttShow.hide()
+ }
+}
+
+// eth杩炴帴鐘舵��
+topView.ethConnectState = function (connected, type) {
+ if (connected) {
+ if (type == 1) {
+ topView.ethShow.show()
+ topView.wifiShow.hide()
+ topView._4gShow.hide()
+ } else if (type == 2) {
+ topView.wifiShow.show()
+ topView.ethShow.hide()
+ topView._4gShow.hide()
+ } else if (type == 4) {
+ topView._4gShow.show()
+ topView.ethShow.hide()
+ topView.wifiShow.hide()
+ }
+ } else {
+ topView.ethShow.hide()
+ topView.wifiShow.hide()
+ topView._4gShow.hide()
+ }
+}
+export default topView
--
Gitblit v1.9.3