| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862 |
- /*
- 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"
- }
- ]
- }
|