lgq
3 天以前 081f12a52906abe6c2d139fdc144135978681009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import dxui from '../../../../../dxmodules/dxUi.js'
import std from '../../../../../dxmodules/dxStd.js'
import viewUtils from "../../../viewUtils.js"
import topView from "../../../topView.js"
import screen from '../../../../screen.js'
import log from '../../../../../dxmodules/dxLogger.js'
import fingerEnterView from './fingerEnterView.js'
import mainView from '../../../mainView.js'
 
const fingerApplyView = {}
 
fingerApplyView.payload = null
 
fingerApplyView.init = function () {
    /**************************************************创建屏幕*****************************************************/
    const screenMain = dxui.View.build('fingerApplyView', dxui.Utils.LAYER.MAIN)
    fingerApplyView.screenMain = screenMain
    screenMain.scroll(false)
    screenMain.bgColor(0xffffff)
 
    screenMain.on(dxui.Utils.ENUM.LV_EVENT_SCREEN_LOADED, () => {
        topView.changeTheme(true)
        // fingerApplyView.screenMain.show()
    })
 
    const titleBox = viewUtils.title(screenMain, mainView.screenMain, 'fingerApplyViewTitle', 'fingerApplyView.title', fingerApplyView.backCb)
    titleBox.align(dxui.Utils.ALIGN.TOP_MID, 0, screen.screenSize.height * (50 / 1024))
 
    // 指纹录入申请Label
    const fingerApplyLbl = dxui.Label.build('fingerApplyLbl', screenMain)
    fingerApplyLbl.align(dxui.Utils.ALIGN.TOP_MID, 0, screen.screenSize.height * (240 / 1024))
    fingerApplyLbl.textFont(viewUtils.font(28))
    fingerApplyLbl.dataI18n = "fingerApplyView.apply"
 
    // 申请人姓名Label
    const fingerNameLbl = dxui.Label.build('fingerNameLbl', screenMain)
    fingerNameLbl.align(dxui.Utils.ALIGN.TOP_MID, 0, screen.screenSize.height * (380 / 1024))
    fingerNameLbl.textFont(viewUtils.font(28))
    fingerNameLbl.text("")
    fingerApplyView.fingerNameLbl = fingerNameLbl
 
    // 申请时间Label
    const fingerTimeLbl = dxui.Label.build('fingerTimeLbl', screenMain)
    fingerTimeLbl.align(dxui.Utils.ALIGN.TOP_MID, 0, screen.screenSize.height * (460 / 1024))
    fingerTimeLbl.textFont(viewUtils.font(20))
    fingerTimeLbl.text("")
    fingerApplyView.fingerTimeLbl = fingerTimeLbl
 
    // 重复录入情况下-重新录入按钮 默认隐藏
    const fingerInputBtn = dxui.Button.build('fingerInputBtn', screenMain)
    fingerInputBtn.setSize(screen.screenSize.width * (210 / 600), screen.screenSize.height * (50 / 1024))
    fingerInputBtn.align(dxui.Utils.ALIGN.TOP_RIGHT, -screen.screenSize.width * (195 / 600), screen.screenSize.height * (700 / 1024))
    fingerInputBtn.bgColor(0x000000)
    fingerInputBtn.radius(30)
    fingerInputBtn.on(dxui.Utils.EVENT.CLICK, () => {
        log.info("开始远程录入")
 
        fingerEnterView.enrollFinger(fingerApplyView.payload)
        dxui.loadMain(fingerEnterView.screenMain)
        // fingerApplyView.screenMain.hide()
    })
    fingerApplyView.fingerInputBtn = fingerInputBtn
 
    const fingerResetBtnLbl = dxui.Label.build('fingerInputBtnLbl', fingerInputBtn)
    fingerResetBtnLbl.dataI18n = 'fingerApplyView.input'
    fingerResetBtnLbl.textFont(viewUtils.font(26))
    fingerResetBtnLbl.align(dxui.Utils.ALIGN.CENTER, 0, 0)
}
 
fingerApplyView.applyFinger = function(payload){
    // fingerApplyView.screenMain.show()
    fingerApplyView.payload = payload
    if(payload.data.extra && payload.data.extra.userId){
        fingerEnterView.userId = payload.data.extra.userId
        let user = screen.getUserById(fingerEnterView.userId)
        fingerApplyView.fingerNameLbl.text((user && user.name) ? user.name : "welcome")
    } else {
        fingerApplyView.fingerNameLbl.text("welcome")
    }
 
    // 更新名称、更新时间
    const t = new Date();
    // 补零函数
    const pad = (n) => n < 10 ? `0${n}` : n;
    fingerApplyView.fingerTimeLbl.text(`${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())} ${pad(t.getHours())}:${pad(t.getMinutes())}:${pad(t.getSeconds())}`)
 
    // 自动超时 120秒后回退到主页面
    fingerApplyView.timeOut = std.setTimeout(() => {
        dxui.loadMain(mainView.screenMain)
    }, 60000)
}
 
// 中断指纹采集
fingerApplyView.interruptFinger = function () {
    fingerApplyView.backCb()
    fingerEnterView.backCb()
    dxui.loadMain(mainView.screenMain)
}
 
fingerApplyView.backCb = function () {
    // fingerApplyView.screenMain.hide()
    // 如果退出指纹远程录入页面,返回录入失败
    if(fingerEnterView.userId){
        screen.cacheFingerChar(fingerEnterView.userId, null)
        fingerEnterView.userId = null
    }
    // 更新名称、更新时间
    fingerApplyView.fingerNameLbl.text("welcome")
    fingerApplyView.fingerTimeLbl.text("1970-01-01 00:00:00")
 
    if(fingerApplyView.timeOut){
        std.clearTimeout(fingerApplyView.timeOut)
    }
    fingerApplyView.timeOut = null
}
 
export default fingerApplyView