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/emergencyPwdView.js |  140 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 140 insertions(+), 0 deletions(-)

diff --git a/vf205_access/src/view/emergencyPwdView.js b/vf205_access/src/view/emergencyPwdView.js
new file mode 100644
index 0000000..01704cc
--- /dev/null
+++ b/vf205_access/src/view/emergencyPwdView.js
@@ -0,0 +1,140 @@
+import dxui from '../../dxmodules/dxUi.js'
+import std from '../../dxmodules/dxStd.js'
+import viewUtils from "./viewUtils.js"
+import topView from './topView.js'
+import mainView from './mainView.js'
+import screen from '../screen.js'
+import logger from '../../dxmodules/dxLogger.js'
+import driver from '../driver.js'
+import config from '../../dxmodules/dxConfig.js'
+
+const emergencyPwdView = {}
+emergencyPwdView.init = function () {
+    /**************************************************鍒涘缓灞忓箷*****************************************************/
+    const screenMain = dxui.View.build('emergencyPwdView', dxui.Utils.LAYER.MAIN)
+    emergencyPwdView.screenMain = screenMain
+    screenMain.scroll(false)
+    screenMain.bgColor(0xffffff)
+    screenMain.on(dxui.Utils.ENUM.LV_EVENT_SCREEN_LOADED, () => {
+        topView.changeTheme(true)
+
+        // 鎾斁搴旀�ラ�氳璇煶鎻愮ず
+        try {
+            driver.alsa.play(`/app/code/resource/${config.get("base.language") == "CN" ? "CN" : "EN"}/wav/emergency.wav`)
+            logger.info('[emergencyPwdView]: 鎾斁搴旀�ラ�氳璇煶鎻愮ず')
+        } catch (error) {
+            logger.error('[emergencyPwdView]: 鎾斁璇煶鎻愮ず澶辫触: ' + error.message)
+        }
+
+        emergencyPwdView.timer = std.setInterval(() => {
+            let count = dxui.Utils.GG.NativeDisp.lvDispGetInactiveTime()
+            if (count > 15 * 1000) {
+                std.clearInterval(emergencyPwdView.timer)
+                emergencyPwdView.timer = null
+                dxui.loadMain(mainView.screenMain)
+            }
+        }, 1000)
+
+        pwdInput.send(dxui.Utils.EVENT.CLICK)
+        pwdInput.send(dxui.Utils.EVENT.FOCUSED)
+    })
+    screenMain.on(dxui.Utils.ENUM.LV_EVENT_SCREEN_UNLOADED, () => {
+        if (emergencyPwdView.timer) {
+            std.clearInterval(emergencyPwdView.timer)
+        }
+        // 娓呯┖楠岃瘉缁撴灉鎻愮ず
+        if (emergencyPwdView.resultLbl) {
+            emergencyPwdView.resultLbl.text(' ')
+        }
+    })
+
+    const titleBox = viewUtils.title(screenMain, mainView.screenMain, 'emergencyPwdViewTitle', '搴旀�ュ瘑鐮侀�氳')
+    titleBox.align(dxui.Utils.ALIGN.TOP_MID, 0, 70)
+
+    const pwdInput = viewUtils.input(screenMain, 'emergencyPwdInput', 2, undefined, '璇疯緭鍏ュ簲鎬ュ瘑鐮�')
+    pwdInput.align(dxui.Utils.ALIGN.TOP_MID, 0, 211)
+    pwdInput.setPasswordMode(true)
+
+    const eyeFill = viewUtils.imageBtn(screenMain, screenMain.id + 'eye_fill', '/app/code/resource/image/eye-fill.png')
+    eyeFill.alignTo(pwdInput, dxui.Utils.ALIGN.RIGHT_MID, 0, 0)
+    eyeFill.on(dxui.Utils.EVENT.CLICK, () => {
+        pwdInput.setPasswordMode(true)
+        eyeFill.hide()
+        eyeOff.show()
+    })
+    eyeFill.hide()
+
+    const eyeOff = viewUtils.imageBtn(screenMain, screenMain.id + 'eye_off', '/app/code/resource/image/eye-off.png')
+    eyeOff.alignTo(pwdInput, dxui.Utils.ALIGN.RIGHT_MID, 0, 0)
+    eyeOff.on(dxui.Utils.EVENT.CLICK, () => {
+        pwdInput.setPasswordMode(false)
+        eyeFill.show()
+        eyeOff.hide()
+    })
+
+    // 娣诲姞鎻愮ず鏂囨湰
+    const hintText1 = dxui.Label.build('hintText1', screenMain)
+    hintText1.text('1.搴旀�ュ紑闂ㄦ棤瑙嗕粨鍐呮皵浣撴祿搴︽槸鍚﹁揪鏍�,璇疯嚜琛岀‘淇濆紑闂ㄥ叆浠撳畨鍏ㄣ��')
+    hintText1.textFont(viewUtils.font(24))
+    hintText1.textColor(0xff0000)
+    hintText1.align(dxui.Utils.ALIGN.TOP_MID, 0, 350)
+    hintText1.longMode(dxui.Utils.LABEL_LONG_MODE.BREAK)
+    hintText1.width(680)
+
+    const hintText2 = dxui.Label.build('hintText2', screenMain)
+    hintText2.text('2.姘旇皟浠撴垨鐔忚捀浠撹鍔″繀浣╂埓涓撲笟璁惧,纭繚鍏ヤ粨瀹夊叏銆�')
+    hintText2.textFont(viewUtils.font(24))
+    hintText2.textColor(0xff0000)
+    hintText2.align(dxui.Utils.ALIGN.TOP_MID, 0, 400)
+    hintText2.longMode(dxui.Utils.LABEL_LONG_MODE.BREAK)
+    hintText2.width(680)
+
+    // 楠岃瘉缁撴灉鎻愮ず
+    const resultLbl = dxui.Label.build('resultLbl', screenMain)
+    resultLbl.text(' ')
+    resultLbl.textFont(viewUtils.font(32))
+    resultLbl.textColor(0x000000)
+    resultLbl.align(dxui.Utils.ALIGN.TOP_MID, 0, 480)
+    emergencyPwdView.resultLbl = resultLbl
+
+    const emergencyAccessBtn = viewUtils.bottomBtn(screenMain, 'emergencyAccessBtn', '搴旀�ュ瘑鐮侀�氳', () => {
+        // 纭瀵嗙爜
+        const pwd = pwdInput.text()
+        const result = screen.pwdAccess(pwd)
+        
+        if (result) {
+            // 瀵嗙爜楠岃瘉閫氳繃
+            logger.info('[emergencyPwdView]: 搴旀�ュ瘑鐮侀獙璇侀�氳繃')
+            resultLbl.text('搴旀�ュ瘑鐮侀獙璇侀�氳繃锛屾鍦ㄥ紑浠�...')
+            resultLbl.textColor(0x008000)
+            
+            // 寮�缁х數鍣�
+            try {
+                driver.gpio.open() // 鎵撳紑缁х數鍣ㄥ苟鍦ㄦ寚瀹氭椂闂村悗鑷姩鍏抽棴
+                logger.info(`[emergencyPwdView]: 鎵撳紑缁х數鍣ㄦ垚鍔焋)
+                resultLbl.text('搴旀�ュ瘑鐮侀獙璇侀�氳繃锛屽凡寮�浠擄紒')
+            } catch (error) {
+                logger.error(`[emergencyPwdView]: 鎵撳紑缁х數鍣ㄥけ璐�: ${error.message}`)
+            }
+            
+            // 璇煶鎻愮ず
+            driver.alsa.play(`/app/code/resource/${config.get("base.language") == "CN" ? "CN" : "EN"}/wav/emergency_s.wav`)
+            
+            // 寤惰繜杩斿洖涓荤晫闈�
+            std.setTimeout(() => {
+                dxui.loadMain(mainView.screenMain)
+            }, 3000)
+        } else {
+            // 瀵嗙爜楠岃瘉澶辫触
+            logger.info('[emergencyPwdView]: 搴旀�ュ瘑鐮侀獙璇佸け璐�')
+            resultLbl.text('搴旀�ュ瘑鐮侀敊璇紝璇烽噸鏂拌緭鍏�')
+            resultLbl.textColor(0xff0000)
+            
+            // 璇煶鎻愮ず
+            driver.alsa.play(`/app/code/resource/${config.get("base.language") == "CN" ? "CN" : "EN"}/wav/emergency_f.wav`)
+        }
+    })
+    emergencyAccessBtn.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, -83)
+}
+
+export default emergencyPwdView
\ No newline at end of file

--
Gitblit v1.9.3