/* This is a UI file (.ui.qml) that is intended to be edited in Qt Design Studio only. It is supposed to be strictly declarative and only uses a subset of QML. If you edit this file manually, you might introduce QML code that is not supported by Qt Design Studio. Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files. */ import QtQuick 6.5 import QtQuick.Controls 6.5 import QtQuick.VirtualKeyboard import com.lock 1.0 // 导入 C++ 类 // import com.InteractiveCore 1.0 import com.InteractiveTask 1.0 Item { id: login property string cardID : "" property int errorNoticeTimeout: 3 property int enterSet: 0 property int enterSetTimeout: 5 signal signal_login(int type, string username, string password) signal signal_fingerWork(bool stat) onVisibleChanged: { if (visible) { proThread.getError(get_error_callback); proThread.moveCursorTo(0, 0); } if (visible === true) { interactiveHand.setFingerImageAppearCallBack( (url)=>{ waitPromptBox.show(); // visible = false; interactiveHand.fingerImageStop(); interactiveCore.appendTask( InteractiveTask.TypeHttpPost_loginByFingerprintDat, null, (json)=>{ waitPromptBox.hide(); var jsonObjRoot = JSON.parse(json); var stat = jsonObjRoot["stat"]; var str = jsonObjRoot["str"]; var name = jsonObjRoot["name"]; var outh = jsonObjRoot["outh"]; if (stat === 0) { mainScreen.login_return_param(name, outh); loginScreen.login_return_stat(stat, str); proThread.slot_feature_login(); } else { loginScreen.login_return_stat(stat, str); interactiveHand.fingerImagePlay(); } }); }); interactiveHand.fingerImagePlay(); } else { interactiveHand.fingerImageStop(); } } function set_cardID(value) { switch(value) { case Qt.Key_0:cardID = cardID + "0";break; case Qt.Key_1:cardID = cardID + "1";break; case Qt.Key_2:cardID = cardID + "2";break; case Qt.Key_3:cardID = cardID + "3";break; case Qt.Key_4:cardID = cardID + "4";break; case Qt.Key_5:cardID = cardID + "5";break; case Qt.Key_6:cardID = cardID + "6";break; case Qt.Key_7:cardID = cardID + "7";break; case Qt.Key_8:cardID = cardID + "8";break; case Qt.Key_9:cardID = cardID + "9";break; case Qt.Key_A:cardID = cardID + "A";break; case Qt.Key_B:cardID = cardID + "B";break; case Qt.Key_C:cardID = cardID + "C";break; case Qt.Key_D:cardID = cardID + "D";break; case Qt.Key_E:cardID = cardID + "E";break; case Qt.Key_F:cardID = cardID + "F";break; case Qt.Key_Return:{ console.log("card:" + cardID); card_login() cardID = ""; } } } focus: true // 确保 Rectangle 能够接收键盘事件 // 强制保持焦点 onFocusChanged: { if(cardInput.visible === true) { if (!focus) { forceActiveFocus() } } } Keys.onPressed: { console.log("key:" + event.key); if(visible === true) { set_cardID(event.key) } } function get_error_callback(isError) { login_toolbutton_error.visible = isError; } Image { id: logoImage x: 73 y: 61 width: 200 height: 50 source: "qrc:/png/bozz.png" fillMode: Image.PreserveAspectFit MouseArea { anchors.fill: parent // 让MouseArea覆盖整个Image区域 onClicked: { enterSetTimeout = 5; if(enterSet >= 4) { enterSet = 0 setView.load_configParam(true) setView.fingerVisible = false setView.visible = true } else{ enterSet++ } } } } Label { id: loginNotice x:0 y:900 width: 1920 color: "#ffffff" text: qsTr("您可以通过刷卡或者指纹直接登录系统") font.pixelSize: 42 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font.bold: true visible: true } ToolButton { id: login_toolbutton_error x: 1572 y: 49 width: 300 height: 110 enabled: false // 不可点击 display: AbstractButton.TextBesideIcon // 文字在图标旁边 visible: false icon.source: "qrc:/png/exception_handle.png" icon.width: 81 icon.height: 72 text: "物资错放" palette.buttonText: "#ff0000" font { pixelSize: 40 // bold: true } background: Rectangle { color: "#00ffffff" border.color: "#ff0000" border.width: 2 // 边框宽度 radius: 20 // 可选,设置圆角 } } Label { id: label1 x: 720 y: 181 color: "#ddffffff" text: qsTr("物资管理系统") font.pixelSize: 80 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font.bold: true } Rectangle { id: rectangle1 x: 227 y: 342 width: 1466 height: 512 color: "#00ffffff" // 人脸登录 Button { id: face_sel x: 103 y: 56 width: 300 height: 400 background: Rectangle { id: face_sel_background color: "#982b7ae9" border.color: "#4c2b7ae9" border.width: 2 // 边框宽度 radius: 20 // 可选,设置圆角 } icon.height: 150 icon.width: 120 display: AbstractButton.TextUnderIcon icon.source: "qrc:/png/face.png" icon.color: "#00ffffff" text: qsTr("人脸登录") font.pixelSize: 40 spacing: 20 palette.buttonText: "#7fffffff" // 设置字体颜色为绿 activeFocusOnTab: false Connections { target: face_sel onClicked: { cardInput.visible = false; passLogin_rec.visible = false; fingerInput.visible = false; faceInput.visible = true; } } } // 工卡登录 Button { id: card_sel x: 423 y: 56 width: 300 height: 400 background: Rectangle { id: card_sel_background color: "#982b7ae9" border.color: "#4c2b7ae9" border.width: 2 // 边框宽度 radius: 20 // 可选,设置圆角 } icon.height: 150 icon.width: 120 display: AbstractButton.TextUnderIcon icon.source: "qrc:/png/card.png" icon.color: "#00ffffff" text: qsTr("工卡登录") font.pixelSize: 40 spacing: 20 palette.buttonText: "#7fffffff" // 设置字体颜色为绿 activeFocusOnTab: false Connections { target: card_sel onClicked: { passLogin_rec.visible = false; password_sel.enabled = true; fingerInput.visible = false; faceInput.visible = false; cardInput.visible = true; cardID = ""; } } } Button { id: password_sel x: 743 y: 56 width: 300 height: 400 background: Rectangle { id: password_sel_background color: "#982b7ae9" border.color: "#4c2b7ae9" border.width: 2 // 边框宽度 radius: 20 // 可选,设置圆角 } icon.height: 150 icon.width: 120 display: AbstractButton.TextUnderIcon icon.source: "qrc:/png/user.png" icon.color: "#00ffffff" text: qsTr("用户名登录") font.pixelSize: 40 spacing: 20 palette.buttonText: "#7fffffff" // 设置字体颜色为绿 activeFocusOnTab: false Connections { target: password_sel onClicked: { cardInput.visible = false; faceInput.visible = false; fingerInput.visible = false; passLogin_rec.visible = true password_sel.enabled = false usernameText.text = "" passwordText.text = "" } } } Button { id: finger_sel x: 1063 y: 56 width: 300 height: 400 background: Rectangle { id: finger_sel_background color: "#982b7ae9" border.color: "#4c2b7ae9" border.width: 2 // 边框宽度 radius: 20 // 可选,设置圆角 } icon.height: 150 icon.width: 120 display: AbstractButton.TextUnderIcon icon.source: "qrc:/png/finger.png" icon.color: "#00ffffff" text: qsTr("指纹登录") font.pixelSize: 40 spacing: 20 palette.buttonText: "#7fffffff" // 设置字体颜色为绿 activeFocusOnTab: false Connections { target: finger_sel onClicked: { cardInput.visible = false; passLogin_rec.visible = false; password_sel.enabled = true; fingerInput.visible = true; faceInput.visible = false; } } } } Rectangle { id: passLogin_rec x: 711 y: 371 width: 497 height: 438 visible: false color: "#980e57ea" radius: 20 Column { id: column x: 0 y: 0 width: 497 height: 438 visible: true spacing: 30 padding: 0 topPadding: 46 Rectangle { x: 72 width: 353 height: 68 color: "#00ffffff" border.color: "#a3ffffff" border.width: 3 radius: 10 TextField { id: usernameText anchors.fill: parent anchors.margins: 2 font.pointSize: 15 focus: false color: "#a3ffffff" background: Rectangle { color: "transparent" // 使TextField背景透明 } placeholderText: qsTr("请输入用户名") font.pixelSize: 30 horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter wrapMode: Text.NoWrap selectionColor: "#a300aaff" placeholderTextColor: "#60ffffff" bottomPadding: 5 topPadding: 5 rightPadding: 20 leftPadding: 20 renderType: Text.QtRendering font.styleName: "Regular" } } Rectangle { x: 72 width: 353 height: 68 color: "#00ffffff" border.color: "#a3ffffff" border.width: 3 radius: 10 TextField { id: passwordText anchors.fill: parent anchors.margins: 2 font.pointSize: 15 focus: false color: "#a3ffffff" background: Rectangle { color: "transparent" // 使TextField背景透明 } placeholderText: qsTr("请输入密码") echoMode: TextInput.Password // 设置echoMode为Password font.pixelSize: 30 selectionColor: "#a300aaff" horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter wrapMode: Text.NoWrap placeholderTextColor: "#60ffffff" bottomPadding: 5 topPadding: 5 rightPadding: 20 leftPadding: 20 renderType: Text.QtRendering font.styleName: "Regular" } } Button { id: button_enter x: 72 width: 353 height: 68 text: qsTr("登录") contentItem: Label { id: label3 text: parent.text font.pixelSize: 30 color: "#a3ffffff" // 设置字体颜色 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } background: Rectangle { color: "#a300aaff" radius: 10 // 设置圆角半径 } Connections { target: button_enter onClicked: { username_login() } } } Button { id: button_cancel x: 72 width: 353 height: 68 text: qsTr("取消") contentItem: Label { text: parent.text font.pixelSize: 30 color: "#a3ffffff" // 设置字体颜色 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } background: Rectangle { color: "#00ffffff" border.color: "#a3ffffff" border.width: 3 radius: 10 // 设置圆角半径 } Connections { target: button_cancel onClicked: { console.log("username return:"); passLogin_rec.visible = false password_sel.enabled = true usernameText.text = "" passwordText.text = "" } } } } } Rectangle { id: faceInput x: (mainScreen.width - width) / 2 - parent.x y: 420 width: 350 height: 350 visible: false color: "#980e57ea" radius: 20 onVisibleChanged: { if (faceInput.visible === true) { interactiveFace.setCallBackFaceStatus( (status)=>{ if (!status) { loginScreen.login_return_stat(-1, "未检测到人脸"); } } ); interactiveFace.setCameraImageCallBack( null, (url)=>{ waitPromptBox.show(); // interactiveFace.cameraImageStop(); faceInput.visible = false; interactiveCore.appendTask( InteractiveTask.TypeHttpPost_loginByFace, null, (json)=>{ waitPromptBox.hide(); var jsonObjRoot = JSON.parse(json); var stat = jsonObjRoot["stat"]; var str = jsonObjRoot["str"]; var name = jsonObjRoot["name"]; var outh = jsonObjRoot["outh"]; if (stat === 0) { mainScreen.login_return_param(name, outh); loginScreen.login_return_stat(stat, str); proThread.slot_feature_login(); } else { loginScreen.login_return_stat(stat, str); // interactiveFace.cameraImagePlay(); } }); }, null); interactiveFace.cameraImagePlay(); } else { interactiveFace.setCallBackFaceStatus(null); interactiveFace.cameraImageStop(); proThread.moveCursorTo(0, 0); } } Column { x: 0 y: 0 width: 350 height: 350 visible: true spacing: 30 padding: 0 topPadding: 46 Image { width: 200 height: 200 opacity: 0.5 anchors.horizontalCenter: parent.horizontalCenter source: "qrc:/png/faceNotice.png" } Label { id: cardNotice anchors.horizontalCenter: parent.horizontalCenter color: "#9affffff" text: qsTr("请刷人脸") font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font.bold: true } } } Rectangle { id: cardInput x: (mainScreen.width - width) / 2 - parent.x y: 420 width: 350 height: 350 visible: false color: "#980e57ea" radius: 20 Column { x: 0 y: 0 width: 350 height: 350 visible: true spacing: 30 padding: 0 topPadding: 46 Image { width: 200 height: 200 opacity: 0.5 anchors.horizontalCenter: parent.horizontalCenter source: "qrc:/png/cardNotice.png" } Label { id: faceNotice anchors.horizontalCenter: parent.horizontalCenter color: "#9affffff" text: qsTr("请刷工卡") font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font.bold: true } } } Rectangle { id: fingerInput x: (mainScreen.width - width) / 2 - parent.x y: 420 width: 350 height: 350 visible: false color: "#980e57ea" radius: 20 Column { x: 0 y: 0 width: 350 height: 350 visible: true spacing: 30 padding: 0 topPadding: 46 Image { width: 200 height: 200 opacity: 0.5 anchors.horizontalCenter: parent.horizontalCenter source: "qrc:/png/fingerNotice.png" } Label { id: fingerNotice anchors.horizontalCenter: parent.horizontalCenter color: "#9affffff" text: qsTr("请刷指纹") font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font.bold: true } } onVisibleChanged: { // signal_fingerWork(visible) } } Rectangle { id: errorLogin x: 785 y: 415 width: 350 height: 350 visible: false color: "#66ea3a0e" radius: 20 onVisibleChanged: { errorNotice.visible = errorLogin.visible } Column { x: 0 y: 0 width: 350 height: 350 visible: true spacing: 30 padding: 0 topPadding: 46 Image { width: 200 height: 200 opacity: 0.5 anchors.horizontalCenter: parent.horizontalCenter source: "qrc:/png/error.png" } Label { id: errorNotice_old anchors.horizontalCenter: parent.horizontalCenter color: "#9affffff" text: qsTr("登录失败") font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font.bold: true } } } Label { id: errorNotice y:835 anchors.horizontalCenter: errorLogin.horizontalCenter color: "#9affffff" text: qsTr("用户名密码错误") font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font.bold: true visible: false } Timer { interval: 1000 running: true repeat: true onTriggered: { if(errorNoticeTimeout > 0) { errorNoticeTimeout--; } else{ errorLogin.visible = false; } if(enterSetTimeout > 0) { enterSetTimeout--; } } } function username_login() { var username = usernameText.text; var password = passwordText.text; if(username.length > 0) { signal_login(0, username, password); } else{ login_return_stat(-99, "请输入用户名"); } } function card_login() { if(cardID.length > 0) { signal_login(1, cardID, cardID); } } function login_return_stat(stat, notice) { if(stat === 0) { // 获取http 异常类型字典值 interactiveCore.appendTask( InteractiveTask.TypeHttpGet_exception_type, null, null); // 获取http 严重等级字典值 interactiveCore.appendTask( InteractiveTask.TypeHttpGet_severity_level, null, null); // 通过物资Code获取物资柜ID interactiveCore.appendTask( InteractiveTask.TypeHttpGet_selectIsMaterialsCabinetByCode, null, null); // 获取用户登录信息 interactiveCore.appendTask( InteractiveTask.TypeHttpGet_getInfo, null, null); interactiveCore.appendTask( InteractiveTask.TypeDataCacheRefresh, null, null); usernameText.text = ""; passwordText.text = ""; passLogin_rec.visible = false; password_sel.enabled = true; cardInput.visible = false; fingerInput.visible = false; loginScreen.visible = false; mainScreen.resetLogin_timeout(); mainScreen.visible = true; materialSelmodel.visible = true; } else { passwordText.text = ""; errorNotice.text = qsTr(notice); errorLogin.visible = true errorNoticeTimeout = 3 } } Item { id: __materialLibrary__ } states: [ State { name: "clicked" } ] }