CNLiveMineAuthResultViewController.swift 6.14 KB
//
//  CNLiveMineAuthResultViewController.swift
//  metaCode
//
//  Created by open on 2023/9/12.
//

import Foundation

enum CNLiveMineAuthResultShowType {
    case detail//认证身份详情界面
    case result_success//身份信息结果页成功
    case result_failer//身份信息结果页失败
}

class CNLiveMineAuthResultViewController: CNLiveBaseViewController {
    
    lazy var mainView: UIImageView = {
        let mainView = UIImageView()
        mainView.backgroundColor = .white
        mainView.contentMode = .scaleToFill
        mainView.isHidden = !(_show_type == .result_success || _show_type == .result_failer)
        mainView.image = UIImage(named: (_show_type == .result_success ? "mine_auth_result_header_success" : "mine_auth_result_header_failer"))
        return mainView
    }()
    
    lazy var tipName: UILabel = {
        let tipName = UILabel.init()
        tipName.text = "资料审核中"
        tipName.font = BoldFont_18_Fit
        tipName.textAlignment = .center
        tipName.textColor = .black
        return tipName
    }()
    
    lazy var tipDesc:  UILabel = {
        let tipDesc = UILabel.init()
        tipDesc.text = "请耐心等待,预计一分钟之内完成审核"
        tipDesc.textColor = HexColor("#A9A9A9")
        tipDesc.textAlignment = .center
        tipDesc.font = Font_13
        return tipDesc
    }()
    
    lazy var sendButton: UIButton = {
        let sendButton = UIButton(type: .custom)
        sendButton.setTitle("确  定", for: .normal)
        sendButton.setTitleColor(.white, for: .normal)
        sendButton.titleLabel?.font = BoldFont_16_Fit
        sendButton.layer.cornerRadius = 20
        sendButton.layer.masksToBounds = true
        sendButton.addTarget(self, action: #selector(sendInfoActionMothod), for: .touchUpInside)
        return sendButton
    }()
    
    /// 已认证-身份卡片
    lazy var iDCardView:CNIDCardView = {
        let iDCardView:CNIDCardView = CNIDCardView(frame: CGRect(x: (KSreenWidth - 40)/2, y: get_system_nav_height()+30, width: KSreenWidth - 40, height: (KSreenWidth-40) * 0.64))
        iDCardView.isHidden = true
        return iDCardView
    }()
    
    var _status: UIStatusBarStyle! = .lightContent
    var _listModel:StandListModel!
    var _show_type:CNLiveMineAuthResultShowType!
    init(listModel:StandListModel,show_type:CNLiveMineAuthResultShowType) {
        super.init(nibName:nil, bundle:nil)
        _listModel = listModel
        _show_type = show_type
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        navigationBarHidden = false
        view.backgroundColor = .white
        topNavView.backgroundColor = .clear
        titleName = "添加\(_listModel.name!)"
        titleLabel.textColor = .white
        leftBtnWhite = true
        _status = .lightContent
        setNeedsStatusBarAppearanceUpdate()
        
        
        view.insertSubview(mainView, belowSubview: topNavView)
        mainView.snp.makeConstraints { make in
            make.left.top.right.equalToSuperview()
            make.height.equalTo(346)
        }
        view.addSubview(tipName)
        tipName.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(mainView.snp.bottom).offset(20)
        }
        
        view.addSubview(tipDesc)
        tipDesc.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(tipName.snp.bottom).offset(10)
        }
        
        view.addSubview(sendButton)
        sendButton.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(tipDesc.snp.bottom).offset(50)
            make.height.equalTo(40)
            make.width.equalTo(150)
        }
        view.addSubview(iDCardView)
        iDCardView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(get_system_nav_height()+30)
            make.height.equalTo((KSreenWidth-40) * 0.64)
            make.width.equalTo(KSreenWidth-40)
        }
        sendButton.setGradient(colors: [UIColor(red: 103/255.0, green: 197/255.0, blue: 255/255.0, alpha: 1),UIColor(red: 96/255.0, green: 154/255.0, blue: 255/255.0, alpha: 1)], startPoint: CGPoint(x: 0, y: 0.5), endPoint: CGPoint(x: 1, y: 0.5))
        
        CNLiveMineViewModel.startKeepTimeWithStand(id: "\(_listModel.id)") { [weak self] result, respStatue in
            if respStatue == .success {
                self?.titleLabel.textColor = .black
                self?.leftBtnWhite = false
                self?.mainView.isHidden = true
                self?.iDCardView.isHidden = false
                self?.iDCardView.idModel = self?._listModel
                self?.tipName.text = "恭喜您通过认证"
                self?.tipDesc.text = "您已是中国网公益服务志愿者!"
                self?._status = .default
                self?.setNeedsStatusBarAppearanceUpdate()
            }else{
                self?.iDCardView.isHidden = true
                self?.mainView.image = UIImage(named: "mine_auth_result_header_failer")
                self?.tipName.text = "审核失败"
                self?.tipDesc.text = "请您修改后重新提交"
            }
        }
    }
    
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return _status
    }
    
    @objc func sendInfoActionMothod() {
        if _show_type == .result_failer || _show_type == .result_success {
            let tempArray = NSMutableArray.init()
            self.navigationController?.viewControllers.forEach({ item in
                if (item.isKind(of: CNLiveMineInputViewController.self)) {
                    tempArray.remove(item)
                }else{
                    tempArray.add(item)
                }
            })
            self.navigationController?.viewControllers = tempArray as! [CNLiveBaseViewController]
            self.navigationController?.popViewController(animated: true)
        }
    }
}