JLChen
2021-04-30 a5247b61d585627a1a7b1e1f35f34de9f0af9fba
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
118
119
120
121
//
//  Copyright © 2018年 Zhejiang Dahua Technology Co.,Ltd. All rights reserved.
//    SoftAP:非PaaS接入的设备,进入指示灯选择界面
 
import UIKit
 
class DHApP2PTypeDoneViewController: DHGuideBaseViewController {
 
    public var devicePassword: String = "admin"
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.baseAddOMSIntroductionObserver()
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    // MARK: DHAddBaseVCProtocol
    override func rightActionType() -> [DHAddBaseRightAction] {
        return [.restart]
    }
    
    override func leftActionType() -> DHAddBaseLeftAction {
        return .quit
    }
    
    override func isLeftActionShowAlert() -> Bool {
        return true
    }
    
    // MARK: DHAddBaseVCProtocol(OMS Introduction)
    override func needUpdateCurrentOMSIntroduction() {
        LCProgressHUD.hideAllHuds(self.view)
        if let imageUrl = DHAddDeviceManager.sharedInstance.getIntroductionParser()?.doneInfo.guideImageUrl {
            self.guideView.topImageView.lc_setImage(withUrl: imageUrl, placeholderImage: DHOMSSoftAPDoneDefault.imagename, toDisk: true)
        }
    }
    
    // MARK: DHGuideBaseVCProtocol
    override func tipText() -> String? {
        let introductionParser = DHAddDeviceManager.sharedInstance.getIntroductionParser()
        return introductionParser?.doneInfo.content ?? DHOMSSoftAPDoneDefault.content
    }
    
    override func tipImageName() -> String? {
        return DHOMSSoftAPDoneDefault.imagename
    }
    
    override func tipImageUrl() -> String? {
        let introductionParser = DHAddDeviceManager.sharedInstance.getIntroductionParser()
        return introductionParser?.doneInfo.guideImageUrl
    }
    
    override func checkText() -> String? {
        let introductionParser = DHAddDeviceManager.sharedInstance.getIntroductionParser()
        return introductionParser?.doneInfo.guide ?? DHOMSSoftAPDoneDefault.guide
    }
    
    override func detailImageUrl() -> String? {
        return nil
    }
    
    override func isCheckHidden() -> Bool {
        return false
    }
    
    override func isDetailHidden() -> Bool {
        return true
    }
    
    override func nextStepText() -> String? {
        return "add_device_done".lc_T
    }
    
    override func doNext() {
        //添加设备
        LCProgressHUD.show(on: self.view)
        DHAddDeviceManager.sharedInstance.bindDevice(devicePassword: devicePassword, success: {
            self.baseExitAddDevice(showAlert: false, backToMain: true)
            LCProgressHUD.hideAllHuds(self.view)
        }) { (error) in
            
            LCProgressHUD.hideAllHuds(self.view)
#if DEBUG
            //调试时打印具体错误
            error.showTips("Failed to bind...")
#endif
            
            self.pushToConnectFailureView()
        }
    }
    
    private func pushToConnectFailureView() {
        let controller = DHConnectCloudTimeoutViewController()
        controller.failureType = .overseasDoorbell
        self.navigationController?.pushViewController(controller, animated: true)
    }
}
 
/// 绑定容器(UIViewController)需要实现的协议
extension DHApP2PTypeDoneViewController: DHBindContainerProtocol {
    
    func navigationVC() -> UINavigationController? {
        return self.navigationController
    }
    
    func mainView() -> UIView {
        return self.view
    }
    
    func mainController() -> UIViewController {
        return self
    }
    
    func retry() {
        
    }
}