CNLiveDigitalSecCell.swift 18.3 KB
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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
//
//  CNLiveDigitalSecCell.swift
//  metaCode
//
//  Created by zx on 2024/6/17.
//  数字资产-身份cell

import Foundation
import Kingfisher
import SnapKit

class CNLiveDigitalSecCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource {
        
    lazy var whiteView :UIView = {
        let whiteView = UIView(frame: CGRect(x: 15, y:adapt_length(length: 15), width: KSreenWidth-30, height: adapt_length(length: 838)))
        whiteView.backgroundColor = .white
        whiteView.layer.cornerRadius = 12
        whiteView.clipsToBounds = true
        return whiteView
    }()
    
    lazy var myIdentityTitleLabel: UILabel = {
        let titleLabel = UILabel()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.textAlignment = .center
        titleLabel.text = "我的身份"
        titleLabel.font = BoldFont_16
        return titleLabel
    }()
    
    let kCNLiveDigitalSecCollectCellID = "kCNLiveDigitalSecCollectCellID"
    lazy var threeCollectionView: UICollectionView = {
        let layout = UICollectionViewFlowLayout()
        layout.itemSize = CGSizeMake(adapt_length(length: 60), adapt_length(length: 60+3+17))
        layout.minimumLineSpacing = 22
        layout.scrollDirection = .horizontal
        let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.backgroundColor = .white
        collectionView.register(CNLiveDigitalSecCollectionCell.self, forCellWithReuseIdentifier: kCNLiveDigitalSecCollectCellID)
        return collectionView
    }()
    var currSeleIndex = 0

    var _digitalListModels : [MineAuthListModel]?
    var digitalListModels : [MineAuthListModel]? {
        get{
            _digitalListModels
        }
        set{
            _digitalListModels = newValue!
            setupNewUI(models: _digitalListModels!)
        }
    }
    
    //关联证书
    lazy var zhengshuView :UIView = {
        let bottomNavView = UIView(frame: CGRect(x: 15, y: self.threeCollectionView.bottom+17, width: self.width-30, height: 231))
        bottomNavView.backgroundColor = HexColor("#F9F9F9")
        bottomNavView.layer.cornerRadius = 9
        bottomNavView.clipsToBounds = true
        return bottomNavView
    }()
    lazy var zhengshuTitleLabel: UILabel = {
        let titleLabel = UILabel()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.textAlignment = .center
        titleLabel.text = "关联证书"
        titleLabel.font = BoldFont_16
        return titleLabel
    }()
    lazy var zhengshuDescTitleLabel: UILabel = {
        let titleLabel = UILabel()
        titleLabel.textColor = HexColor("#999999")
        titleLabel.textAlignment = .left
        titleLabel.text = "关联技能证书或身份证书,见证你的实力"
        titleLabel.font = Font_12
        return titleLabel
    }()
    lazy var zhengshuImgView :UIImageView = {
        let iconImgView = UIImageView()
        iconImgView.image = UIImage(named: "auth_zhengshu")
        return iconImgView
    }()
    lazy var zhengshuBtn: UIButton = {
        let  closeBtn = UIButton(type: .custom)
        closeBtn.setTitle("关联证书", for: .normal)
        closeBtn.setTitleColor(HexColor("#999999"), for: .normal)
        closeBtn.titleLabel?.font = BoldFont_14
        closeBtn.layer.borderColor = HexColor("#999999")?.cgColor
        closeBtn.layer.borderWidth = 0.5
        closeBtn.layer.cornerRadius = 6
        closeBtn.clipsToBounds = true
        closeBtn.addTarget(self, action: #selector(zhengshuBtnAction), for: .touchUpInside)
        return closeBtn
    }()

    //关联工作记录
    lazy var gongzuoView :UIView = {
        let bottomNavView = UIView(frame: CGRect(x: 15, y: self.zhengshuView.bottom+15, width: self.width-30, height: 131))
        bottomNavView.backgroundColor = HexColor("#F9F9F9")
        bottomNavView.layer.cornerRadius = 9
        bottomNavView.clipsToBounds = true
        return bottomNavView
    }()
    lazy var gongzuoTitleLabel: UILabel = {
        let titleLabel = UILabel()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.textAlignment = .center
        titleLabel.text = "关联工作记录"
        titleLabel.font = BoldFont_16
        return titleLabel
    }()
    lazy var gongzuoDescTitleLabel: UILabel = {
        let titleLabel = UILabel()
        titleLabel.textColor = HexColor("#999999")
        titleLabel.textAlignment = .left
        titleLabel.text = "关联工作记录,见证你的专业经验"
        titleLabel.font = Font_12
        return titleLabel
    }()
    lazy var gongzuoBtn: UIButton = {
        let  closeBtn = UIButton(type: .custom)
        closeBtn.setTitle("关联工作记录", for: .normal)
        closeBtn.setTitleColor(HexColor("#999999"), for: .normal)
        closeBtn.titleLabel?.font = BoldFont_14
        closeBtn.layer.borderColor = HexColor("#999999")?.cgColor
        closeBtn.layer.borderWidth = 0.5
        closeBtn.layer.cornerRadius = 6
        closeBtn.clipsToBounds = true
        closeBtn.addTarget(self, action: #selector(gongzuoBtnAction), for: .touchUpInside)
        return closeBtn
    }()
    
    //关联社团经历
    lazy var shetuanView :UIView = {
        let bottomNavView = UIView(frame: CGRect(x: 15, y: self.gongzuoView.bottom+15, width: self.width-30, height: 131))
        bottomNavView.backgroundColor = HexColor("#F9F9F9")
        bottomNavView.layer.cornerRadius = 9
        bottomNavView.clipsToBounds = true
        return bottomNavView
    }()
    lazy var shetuanTitleLabel: UILabel = {
        let titleLabel = UILabel()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.textAlignment = .center
        titleLabel.text = "关联社团经历"
        titleLabel.font = BoldFont_16
        return titleLabel
    }()
    lazy var shetuanDescTitleLabel: UILabel = {
        let titleLabel = UILabel()
        titleLabel.textColor = HexColor("#999999")
        titleLabel.textAlignment = .left
        titleLabel.text = "关联社团经历,见证全面成长与技能发展"
        titleLabel.font = Font_12
        return titleLabel
    }()
    lazy var shetuanBtn: UIButton = {
        let  closeBtn = UIButton(type: .custom)
        closeBtn.setTitle("关联社团经历", for: .normal)
        closeBtn.setTitleColor(HexColor("#999999"), for: .normal)
        closeBtn.titleLabel?.font = BoldFont_14
        closeBtn.layer.borderColor = HexColor("#999999")?.cgColor
        closeBtn.layer.borderWidth = 0.5
        closeBtn.layer.cornerRadius = 6
        closeBtn.clipsToBounds = true
        closeBtn.addTarget(self, action: #selector(shetuanBtnAction), for: .touchUpInside)
        return closeBtn
    }()
    
    //关联获奖情况
    lazy var huojiangView :UIView = {
        let bottomNavView = UIView(frame: CGRect(x: 15, y: self.gongzuoView.bottom+15, width: self.width-30, height: 131))
        bottomNavView.backgroundColor = HexColor("#F9F9F9")
        bottomNavView.layer.cornerRadius = 9
        bottomNavView.clipsToBounds = true
        return bottomNavView
    }()
    lazy var huojiangTitleLabel: UILabel = {
        let titleLabel = UILabel()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.textAlignment = .center
        titleLabel.text = "关联获奖情况"
        titleLabel.font = BoldFont_16
        return titleLabel
    }()
    lazy var huojiangDescTitleLabel: UILabel = {
        let titleLabel = UILabel()
        titleLabel.textColor = HexColor("#999999")
        titleLabel.textAlignment = .left
        titleLabel.text = "关联获奖情况,见证全面成长与技能发展"
        titleLabel.font = Font_12
        return titleLabel
    }()
    lazy var huojiangBtn: UIButton = {
        let  closeBtn = UIButton(type: .custom)
        closeBtn.setTitle("关联获奖情况", for: .normal)
        closeBtn.setTitleColor(HexColor("#999999"), for: .normal)
        closeBtn.titleLabel?.font = BoldFont_14
        closeBtn.layer.borderColor = HexColor("#999999")?.cgColor
        closeBtn.layer.borderWidth = 0.5
        closeBtn.layer.cornerRadius = 6
        closeBtn.clipsToBounds = true
        closeBtn.addTarget(self, action: #selector(huojiangBtnAction), for: .touchUpInside)
        return closeBtn
    }()
    let delegate = UIApplication.shared.delegate as! AppDelegate
    /// 未认证-inputType17时弹窗背景图
    lazy var alertBgImgView:UIImageView = {
        let alertBgImgView:UIImageView = UIImageView()
        alertBgImgView.tag = 20001
        alertBgImgView.isUserInteractionEnabled = true
        let ges = UITapGestureRecognizer(target: self, action: #selector(alertBgImgViewClickAction))
        alertBgImgView.addGestureRecognizer(ges)

        return alertBgImgView
    }()
    lazy var alertBgView:UIView = {
        let alertBgView:UIView = UIView(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: KSreenHeight))
        alertBgView.backgroundColor = HexColor("#000000")
        alertBgView.alpha = 0.6
        alertBgView.isUserInteractionEnabled = true
        alertBgView.tag = 20000
        
        let ges = UITapGestureRecognizer(target: self, action: #selector(alertBgViewClickAction))
        alertBgView.addGestureRecognizer(ges)

        return alertBgView
    }()

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.backgroundColor = .clear
        self.backgroundColor = .clear
        self.selectionStyle = .none
        self.contentView.addSubview(self.whiteView)
        self.whiteView.addSubview(self.myIdentityTitleLabel)
        self.myIdentityTitleLabel.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(adapt_length(length: 15))
            make.left.equalTo(adapt_length(length: 15))
        }
        
        self.whiteView.addSubview(self.threeCollectionView)
        self.threeCollectionView.snp.makeConstraints { make in
            make.left.right.equalToSuperview().offset(adapt_length(length: 18))
            make.top.equalTo(adapt_length(length: 53))
            make.height.equalTo(adapt_length(length: 60+7+17))
            make.width.equalToSuperview().offset(adapt_length(length: -36))
        }
        
        self.whiteView.addSubview(self.zhengshuView)
        self.zhengshuView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.right.equalToSuperview().offset(adapt_length(length: -15))
            make.top.equalTo(self.threeCollectionView.snp.bottom).offset(adapt_length(length: 17))
            make.height.equalTo(adapt_length(length: 231))
        }
        self.zhengshuView.addSubview(self.zhengshuTitleLabel)
        self.zhengshuTitleLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.top.equalToSuperview().offset(adapt_length(length: 15))
        }
        self.zhengshuView.addSubview(self.zhengshuDescTitleLabel)
        self.zhengshuDescTitleLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.top.equalTo(self.zhengshuTitleLabel.snp.bottom).offset(adapt_length(length: 3))
        }
        self.zhengshuView.addSubview(self.zhengshuImgView)
        self.zhengshuImgView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(self.zhengshuDescTitleLabel.snp.bottom).offset(adapt_length(length: 20))
            make.width.equalTo(adapt_length(length: 125))
            make.height.equalTo(adapt_length(length: 85))
        }
        self.zhengshuView.addSubview(self.zhengshuBtn)
        self.zhengshuBtn.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(self.zhengshuImgView.snp.bottom).offset(adapt_length(length: 15))
            make.width.equalTo(adapt_length(length: 86))
            make.height.equalTo(adapt_length(length: 34))
        }
        
        self.whiteView.addSubview(self.gongzuoView)
        self.gongzuoView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.right.equalToSuperview().offset(adapt_length(length: -15))
            make.top.equalTo(self.zhengshuView.snp.bottom).offset(adapt_length(length: 15))
            make.height.equalTo(adapt_length(length: 131))
        }
        self.gongzuoView.addSubview(self.gongzuoTitleLabel)
        self.gongzuoTitleLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.top.equalToSuperview().offset(adapt_length(length: 15))
        }
        self.gongzuoView.addSubview(self.gongzuoDescTitleLabel)
        self.gongzuoDescTitleLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.top.equalTo(self.gongzuoTitleLabel.snp.bottom).offset(adapt_length(length: 3))
        }
        self.gongzuoView.addSubview(self.gongzuoBtn)
        self.gongzuoBtn.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(self.gongzuoDescTitleLabel.snp.bottom).offset(adapt_length(length: 20))
            make.width.equalTo(adapt_length(length: 86))
            make.height.equalTo(adapt_length(length: 34))
        }
        
        self.whiteView.addSubview(self.shetuanView)
        self.shetuanView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.right.equalToSuperview().offset(adapt_length(length: -15))
            make.top.equalTo(self.gongzuoView.snp.bottom).offset(adapt_length(length: 15))
            make.height.equalTo(adapt_length(length: 131))
        }
        self.shetuanView.addSubview(self.shetuanTitleLabel)
        self.shetuanTitleLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.top.equalToSuperview().offset(adapt_length(length: 15))
        }
        self.shetuanView.addSubview(self.shetuanDescTitleLabel)
        self.shetuanDescTitleLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.top.equalTo(self.shetuanTitleLabel.snp.bottom).offset(adapt_length(length: 3))
        }
        self.shetuanView.addSubview(self.shetuanBtn)
        self.shetuanBtn.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(self.shetuanDescTitleLabel.snp.bottom).offset(adapt_length(length: 20))
            make.width.equalTo(adapt_length(length: 86))
            make.height.equalTo(adapt_length(length: 34))
        }
        
        self.whiteView.addSubview(self.huojiangView)
        self.huojiangView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.right.equalToSuperview().offset(adapt_length(length: -15))
            make.top.equalTo(self.shetuanView.snp.bottom).offset(adapt_length(length: 15))
            make.height.equalTo(adapt_length(length: 131))
        }
        self.huojiangView.addSubview(self.huojiangTitleLabel)
        self.huojiangTitleLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.top.equalToSuperview().offset(adapt_length(length: 15))
        }
        self.huojiangView.addSubview(self.huojiangDescTitleLabel)
        self.huojiangDescTitleLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.top.equalTo(self.huojiangTitleLabel.snp.bottom).offset(adapt_length(length: 3))
        }
        self.huojiangView.addSubview(self.huojiangBtn)
        self.huojiangBtn.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(self.huojiangDescTitleLabel.snp.bottom).offset(adapt_length(length: 20))
            make.width.equalTo(adapt_length(length: 86))
            make.height.equalTo(adapt_length(length: 34))
        }
        
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func zhengshuBtnAction(){
        self.show17Alert()
    }
    @objc func gongzuoBtnAction(){
        self.show17Alert()
    }
    @objc func shetuanBtnAction(){
        self.show17Alert()
    }
    @objc func huojiangBtnAction(){
        self.show17Alert()
    }
    
    // MARK: - 点击弹窗,按类型跳转
    @objc func alertBgImgViewClickAction() {
        self.hiden17Alert()
    }
    @objc func alertBgViewClickAction() {
        //点击蒙版隐藏view
        self.hiden17Alert()
    }
    
    //弹出弹窗
    func show17Alert(){
        
        delegate.window?.addSubview(self.alertBgView)
        delegate.window?.addSubview(self.alertBgImgView)
        alertBgImgView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.centerY.equalToSuperview()
            make.width.equalTo(KSreenWidth-80)
            make.height.equalTo((KSreenWidth-80)*170.5/295)
        }
        
        self.alertBgImgView.image = UIImage(named: "auth_alert_unOpen")
    }
    func hiden17Alert(){
        delegate.window?.subviews.forEach({ view in
            if view.tag >= 20000{
                view.removeFromSuperview()
            }
        })
    }
    
    
    func setupNewUI(models:[MineAuthListModel]){

        self.threeCollectionView.reloadData()
    }
   
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        self.digitalListModels?.count ?? 0
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCNLiveDigitalSecCollectCellID, for: indexPath) as! CNLiveDigitalSecCollectionCell
        cell.authListModel = self.digitalListModels?[indexPath.row]
        if indexPath.row == currSeleIndex
        {//
            cell.cellIsSelected = true
        }else{
        //
            cell.cellIsSelected = false
        }
        return cell
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        self.currSeleIndex = indexPath.row
        self.threeCollectionView.reloadData()
    }
}