CNLiveMineAuthFormViewController.swift 4.76 KB
//
//  CNLiveMineAuthFormViewController.swift
//  metaCode
//
//  Created by open on 2024/1/23.
//

import Foundation
import UIKit

class CNLiveMineAuthFormViewController: CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource {
    
    let kMIneBodyAuthFormViewCellIdentifier = "kMIneBodyAuthFormViewCellIdentifier"
    lazy var tableView: UITableView = {
        let tableView = UITableView.init(frame: .zero, style: .grouped)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.backgroundColor = .clear
        tableView.separatorStyle = .none
        tableView.showsVerticalScrollIndicator = false
        tableView.showsHorizontalScrollIndicator = false
        tableView.register(MineAuthFormTableViewCell.self, forCellReuseIdentifier: kMIneBodyAuthFormViewCellIdentifier)
        return tableView
    }()
    
    var _listModel: StandListModel!
    
    init(listModel:StandListModel) {
        super.init(nibName:nil, bundle:nil)
        _listModel = listModel
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationBarHidden = false
        titleName = "元码官方认证"
        
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.top.equalTo(KNavigationHeight)
            make.left.right.equalToSuperview()
            make.bottom.equalToSuperview().offset(get_system_tabbar_height() - get_system_tabbar_ui_height())
        }
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 2
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return section == 0 ? 1 : 2
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        guard let cell = tableView.dequeueReusableCell(withIdentifier: kMIneBodyAuthFormViewCellIdentifier) as? MineAuthFormTableViewCell else {
            return MineAuthFormTableViewCell()
        }
        if indexPath.section == 0 && indexPath.row == 1 {
            cell.mainView.image = UIImage(named: "mine_form_auth_btn_persion")
        }
        if indexPath.section == 1 {
            cell.mainView.image = UIImage(named: "mine_form_auth_btn")
        }
        return cell
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return adapt_length(length: 190)
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return adapt_length(length: 10)
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return adapt_length(length: 10)
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//        if indexPath.section == 0 {
//            self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _listModel, authType: .person), animated: true)
//        }
//        if indexPath.section == 1 {
//            self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _listModel, authType: .enterprise), animated: true)
//        }
//        if indexPath.section == 2 {
//            self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _listModel, authType: .agency), animated: true)
//        }
    }
}

class MineAuthFormTableViewCell: UITableViewCell {
    
    lazy var mainView: UIImageView = {
        let view = UIImageView.init()
        view.backgroundColor = .white
        view.contentMode = .scaleAspectFill
        view.layer.cornerRadius = adapt_length(length: 10)
        view.layer.masksToBounds = true
        return view
    }()
    
    lazy var whiteView: UIView = {
        let view = UIView.init()
        view.backgroundColor = .white
        view.layer.masksToBounds = true
        view.layer.cornerRadius = adapt_length(length: 10)
        return view
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = .clear
        backgroundColor = .clear
        selectionStyle = .none
        
        contentView.addSubview(mainView)
        mainView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.top.left.equalToSuperview().offset(10)
            make.bottom.right.equalToSuperview().offset(-10)
        }
        
        contentView.addSubview(whiteView)
        whiteView.snp.makeConstraints { make in
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}