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 networkSettingView from './config/menu/networkSettingView.js'
import wechatBindView from "./wechatBindView.js"
import topView from './topView.js'
import screen from '../screen.js'
const wechatNetView = {}
wechatNetView.init = function () {
    /**************************************************创建屏幕*****************************************************/
    const screenMain = dxui.View.build('wechatNetView', dxui.Utils.LAYER.MAIN)
    wechatNetView.screenMain = screenMain
    screenMain.scroll(false)
    screenMain.bgColor(0xffffff)
 
    screenMain.on(dxui.Utils.ENUM.LV_EVENT_SCREEN_LOADED, () => {
        topView.changeTheme(true)
    })
 
    // 企业微信图标
    const wechatImg = dxui.Image.build('wechatNetImg', screenMain)
    wechatImg.source(screen.resourcePath.imagePath + '/wechat.png')
    wechatImg.align(dxui.Utils.ALIGN.TOP_MID, 0, screen.screenSize.height * (150 / 1024))
 
    // 连接网络提示标签
    const netConfigLbl = dxui.Label.build('netConfigLbl', screenMain)
    wechatNetView.netConfigLbl = netConfigLbl
    netConfigLbl.text('请先连接网络')
    netConfigLbl.textFont(viewUtils.font(30))
    netConfigLbl.align(dxui.Utils.ALIGN.TOP_MID, 0, screen.screenSize.height * (500 / 1024))
    netConfigLbl.dataI18n = 'wechatNetView.netConnect'
 
    // 网络配置按钮
    const netConfigBtn = viewUtils.bottomBtn(screenMain, 'netConfigBtn', 'wechatNetView.netConfig', () => {
        networkSettingView.screenMain.backScreen = wechatNetView.screenMain
        networkSettingView.screenMain.titleBox.backScreen = wechatNetView.screenMain
        netConfigLbl.text('正在连接网络......')
        dxui.loadMain(networkSettingView.screenMain)
    })
    netConfigBtn.btnLbl.text("网络配置")
    netConfigBtn.align(dxui.Utils.ALIGN.TOP_MID, 0, screen.screenSize.height * (550 / 1024))
 
    const wechatNetBox = dxui.View.build('wechatNetBox', screenMain)
    viewUtils._clearStyle(wechatNetBox)
    wechatNetBox.width(screen.screenSize.width)
    wechatNetBox.height(screen.screenSize.height * (70 / 1024))
    wechatNetBox.bgOpa(0)
    wechatNetBox.clickable(false)
    wechatNetBox.flexFlow(dxui.Utils.FLEX_FLOW.ROW)
    wechatNetBox.flexAlign(dxui.Utils.FLEX_ALIGN.SPACE_BETWEEN, dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.CENTER)
    wechatNetBox.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, 0)
 
    // 企业微信SN标签
    const wechatSnBox = dxui.View.build('wechatNetSnBox', wechatNetBox)
    viewUtils._clearStyle(wechatSnBox)
    wechatSnBox.width(screen.screenSize.width / 2)
    wechatSnBox.height(screen.screenSize.height * (70 / 1024))
    wechatSnBox.padLeft(screen.screenSize.width * (38 / 600))
    wechatSnBox.bgOpa(0)
    wechatSnBox.clickable(false)
    wechatSnBox.flexFlow(dxui.Utils.FLEX_FLOW.ROW)
    wechatSnBox.flexAlign(dxui.Utils.FLEX_ALIGN.START, dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.CENTER)
    const wechatSnLbl = dxui.Label.build('wechatNetSnLbl', wechatSnBox)
    wechatSnLbl.textFont(viewUtils.font(20))
    wechatSnLbl.text("SN: " + screen.getConfig()["sys.sn"])
    wechatSnLbl.textColor(0x2e2e2e)
 
    // 企业微信IP标签
    const wechatIpBox = dxui.View.build('wechatNetIpBox', wechatNetBox)
    viewUtils._clearStyle(wechatIpBox)
    wechatIpBox.width(screen.screenSize.width / 2)
    wechatIpBox.height(screen.screenSize.height * (70 / 1024))
    wechatIpBox.padRight(screen.screenSize.width * (23 / 600))
    wechatIpBox.bgOpa(0)
    wechatIpBox.clickable(false)
    wechatIpBox.flexFlow(dxui.Utils.FLEX_FLOW.ROW)
    wechatIpBox.flexAlign(dxui.Utils.FLEX_ALIGN.END, dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.CENTER)
    const wechatIpLbl = dxui.Label.build('wechatNetIpLbl', wechatIpBox)
    wechatNetView.wechatIpLbl = wechatIpLbl
    wechatIpLbl.textFont(viewUtils.font(20))
    wechatIpLbl.text("IP: " + screen.getConfig()["net.ip"])
    wechatIpLbl.textColor(0x2e2e2e)
 
    // 创建定时器
    wechatNetView.timerCreate()
 
    std.setTimeout(() => {
        if(screen.weCom.isWeCom() && screen.weCom.getStatus() === 0){
            topView.changeTheme(true)
        }
    }, 3000)
}
 
// 创建定时器方法
wechatNetView.timerCreate = function () {
    // 启动一个定时器,在跳转到设备绑定页面后删除该定时器
    if (screen.weCom.isWeCom() && screen.weCom.getStatus() === 0) {
        std.setTimeout(() => {
            screen.faceRecgPause()
        }, 10000)
        wechatNetView.timer = std.setInterval(() => {
            // 获取网络状态
            let netIsConnected = screen.driver.net.isConnected()
            if (netIsConnected) {
                wechatNetView.netConfigLbl.text('网络连接成功, 正在跳转设备绑定页面......')
                // 网络连接成功,跳转到设备绑定页面
                std.clearInterval(wechatNetView.timer)
                wechatNetView.timer = null
                wechatBindView.getQrCode()
                dxui.loadMain(wechatBindView.screenMain)
            }
            topView.changeTheme(true)
        }, 500)
    }
}
 
export default wechatNetView