CNLiveMineBodyListView.swift 37.7 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 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027
//
//  CNLiveMineBodyListView.swift
//  metaCode
//
//  Created by open on 2023/6/7.
//

import Foundation
import Kingfisher
import APButton
import QMUIKit

let CNLiveMineSettingISKipBeginAndEndKey = "CNLiveMineSettingISKipBeginAndEndKey"//默认开启
let CNLiveMineSettingSkipBeginAndEndFirstSettingKey = "CNLiveMineSettingSkipBeginAndEndFirstSettingKey"//是否设置过跳过片头片尾


class MineBodyOneListViewCell : UITableViewCell {
    
    lazy var nameLabel: UILabel = {
        let nameLabel = UILabel.init()
        nameLabel.textColor = .black
        nameLabel.font = BoldFont_16_Fit
        nameLabel.backgroundColor = .clear
        nameLabel.text = "我的身份"
        return nameLabel
    }()
    
    lazy var headerView: UIImageView = {
        let headerView = UIImageView.init()
        headerView.image = UIImage(named: "mine_header_icon_identity")
        headerView.backgroundColor = .clear
        headerView.contentMode = .scaleToFill
        return headerView
    }()
    
    lazy var mainView: UIView = {
        let mainView = UIView.init()
        mainView.backgroundColor = .white
        mainView.layer.cornerRadius = 8
        mainView.layer.masksToBounds = true
        return mainView
    }()
    
    lazy var lookBtn: UIButton = {
        let lookBtn = UIButton.init(type: .custom)
        lookBtn.setTitle("  去查看  ", for: .normal)
        lookBtn.setTitleColor(.white, for: .normal)
        lookBtn.titleLabel?.font = BoldFont_14
        lookBtn.layer.masksToBounds = true
        lookBtn.isUserInteractionEnabled = false
        lookBtn.layer.cornerRadius = 15
        return lookBtn
    }()
    
    lazy var tipLabel: UILabel = {
        let tipLabel = UILabel.init()
        tipLabel.textColor = HexColor("#999999")
        tipLabel.text = "您暂未进行身份认证"
        tipLabel.font = Font_15
        return tipLabel
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        addSubview(mainView)
        mainView.addSubview(headerView)
        headerView.addSubview(nameLabel)
        mainView.addSubview(tipLabel)
        mainView.addSubview(lookBtn)
        setupConstraints()
    }
    
    public func reloadWithData() {
        let tempArray = StandSortManager.sortMyListData(auths: CNLiveSaveAuthDB.shared.searchAllObject() as NSArray) as! [MineAuthListModel]
        if tempArray.count == 0 {
            tipLabel.text = "您暂未进行身份认证"
        }else{
            tipLabel.text = "您已认证\(tempArray.count)个身份"
//            for (index, item) in tempArray.enumerated() {
//                setupWithIconsView(authModel: item, index: index)
//            }
        }
    }
    
    private func setupWithIconsView(authModel: MineAuthListModel,index: NSInteger) {
        
        let iconView = UIImageView.init()
        iconView.layer.cornerRadius = 20
        iconView.layer.masksToBounds = true
        iconView.clipsToBounds = true
        iconView.contentMode = .scaleToFill
        iconView.backgroundColor = .white
        iconView.kf.indicatorType = .activity
        iconView.kf.setImage(with: URL(string: authModel.icon ?? ""), placeholder: UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSize(width: 40, height: 40)))
        mainView.addSubview(iconView)
        iconView.snp.makeConstraints { make in
            make.centerY.equalToSuperview().offset(20)
            make.left.equalToSuperview().offset(10+(40 * index) - (index > 0 ? 10 : 0))
            make.size.equalTo(40)
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupConstraints() {
        mainView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.top.bottom.equalToSuperview()
        }
        headerView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.left.right.equalToSuperview()
            make.height.equalTo(40)
        }
        nameLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(15)
        }
        tipLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview().offset(20)
            make.left.equalToSuperview().offset(20)
        }
        lookBtn.snp.makeConstraints { make in
            make.centerY.equalToSuperview().offset(20)
            make.right.equalToSuperview().offset(-15)
            make.width.equalTo(80)
            make.height.equalTo(30)
        }

        lookBtn.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))
    }
}

class MineBodyTwoListViewCell : UITableViewCell {
    
    lazy var mainView: UIView = {
        let mainView = UIView.init()
        mainView.backgroundColor = .white
        mainView.layer.cornerRadius = 15
        mainView.layer.masksToBounds = true
        return mainView
    }()
    lazy var nameLabel: UILabel = {
        let nameLabel = UILabel.init()
        nameLabel.textColor = .black
        nameLabel.font = BoldFont_16_Fit
        nameLabel.backgroundColor = .clear
        return nameLabel
    }()
    lazy var headerView: UIImageView = {
        let headerView = UIImageView.init()
        headerView.backgroundColor = .clear
        headerView.contentMode = .scaleToFill
        return headerView
    }()
    lazy var avatarView: UIImageView = {
        let avatarView = UIImageView.init()
        avatarView.backgroundColor = .clear
        avatarView.contentMode = .scaleAspectFill
        avatarView.layer.cornerRadius = 30
        avatarView.layer.masksToBounds = true
        avatarView.clipsToBounds = true
        avatarView.isHidden = true
        return avatarView
    }()
    lazy var moreBtn: UIButton = {
        let moreBtn = UIButton.init(type: .custom)
        moreBtn.setImage(UIImage(named: "mine_list_icon_right_more"), for: .normal)
        moreBtn.layer.masksToBounds = true
        moreBtn.layer.cornerRadius = 15
        moreBtn.isUserInteractionEnabled = false
        return moreBtn
    }()
    lazy var descLabel: UILabel = {
        let descLabel = UILabel.init()
        descLabel.textColor = HexColor("#999999")
        descLabel.font = Font_11_Fit
        descLabel.backgroundColor = .white
        descLabel.isHidden = true
        return descLabel
    }()
    lazy var moreLabel: UILabel = {
        let moreLabel = UILabel.init()
        moreLabel.textColor = HexColor("#999999")
        moreLabel.font = Font_11_Fit
        moreLabel.textAlignment = .right
        moreLabel.backgroundColor = .white
        moreLabel.isHidden = true
        return moreLabel
    }()
    lazy var skipSwitch: UISwitch = {
        let showSwitch = UISwitch.init()
        showSwitch.addTarget(self, action: #selector(switchInAction), for: .valueChanged)
        showSwitch.isHidden = true
        return showSwitch
    }()
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        addSubview(mainView)
        mainView.addSubview(headerView)
        headerView.addSubview(nameLabel)
        mainView.addSubview(moreBtn)
        mainView.addSubview(descLabel)
        mainView.addSubview(moreLabel)
        mainView.addSubview(skipSwitch)
        mainView.addSubview(avatarView)
        
        setupConstraints()
        
    }
    
    private func setupConstraints() {
        mainView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.top.bottom.equalToSuperview()
        }
        headerView.snp.makeConstraints { make in
            make.centerY.equalTo(mainView)
            make.left.equalTo(15)
            make.size.equalTo(20)
        }
        nameLabel.snp.makeConstraints { make in
            make.centerY.equalTo(headerView)
            make.left.equalTo(headerView.snp.right).offset(7)
        }
        moreBtn.snp.makeConstraints { make in
            make.centerY.equalTo(headerView)
            make.right.equalToSuperview().offset(-15)
            make.height.equalTo(30)
            make.width.equalTo(15)
        }
        skipSwitch.snp.makeConstraints { make in
            make.centerY.equalTo(headerView)
            make.right.equalToSuperview().offset(-15)
        }
        descLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview().offset(15)
            make.left.equalTo(headerView.snp.right).offset(7)
        }
        moreLabel.snp.makeConstraints { make in
            make.centerY.equalTo(headerView)
            make.right.equalTo(moreBtn.snp.left)
        }
        
        avatarView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalTo(moreBtn.snp.left).offset(-10)
            make.size.equalTo(60)
        }
    }
    
    public func setupWithDataSource(show_type: ListShowType,dict : Dictionary<String, Any>) {
        let image = dict["icon"] as! String
        if image == "" {
            headerView.snp.updateConstraints { make in
                make.centerY.equalToSuperview()
                make.left.equalTo(15)
                make.size.equalTo(0.01)
            }
        }else {
            headerView.image = UIImage(named: image)
        }
        if dict.keys.contains("desc") {
            descLabel.isHidden = false
            descLabel.text = "\(dict["desc"] ?? "")"
            headerView.snp.updateConstraints { make in
                make.centerY.equalTo(mainView).offset(-10)
                make.left.equalTo(15)
                make.size.equalTo(20)
            }
        }
        if dict.keys.contains("more") {
            moreLabel.isHidden =  false
            if show_type == .info {
                moreLabel.font = Font_15_Fit
            }
            var more = "\(dict["more"] ?? "")"
            if (more == "m") {
                more = "男"
            }
            if (more == "f") {
                more = "女"
            }
            moreLabel.text = more
        }
        if (dict.keys.contains("avatar") && (dict["avatar"] as! String).count > 0) {
            avatarView.isHidden = false
            avatarView.kf.indicatorType = .activity
            avatarView.kf.setImage(with: URL(string: "\(dict["avatar"] ?? "")"), placeholder: UIImage(named: "mine_header_icon_defult_ava"))
        }else{
            avatarView.isHidden = true
        }
        nameLabel.text = "\(dict["name"] ?? "")"
        
        if show_type == .setting {
            if let name = dict["name"] as? String{
                if name == "剧集视频跳过片头片尾"{
                    moreBtn.isHidden = true
                    skipSwitch.isHidden = false
                    let is_skip = UserDefaults.standard.bool(forKey: CNLiveMineSettingISKipBeginAndEndKey)
                    skipSwitch.isOn = is_skip
                }else{
                    moreBtn.isHidden = false
                    skipSwitch.isHidden = true
                }
            }
            
        }
    }
    
    @objc func switchInAction(sender: UISwitch) {
        print("11111111switch\(sender.isOn)")
        UserDefaults.standard.setValue(sender.isOn, forKey: CNLiveMineSettingISKipBeginAndEndKey)
        UserDefaults.standard.setValue(true, forKey: CNLiveMineSettingSkipBeginAndEndFirstSettingKey)
        UserDefaults.standard.synchronize()
        
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


class MineBodyThreeViewCell: UITableViewCell {
    
    lazy var mainView: UIImageView = {
        let mainView = UIImageView.init()
        mainView.backgroundColor = .clear
        mainView.contentMode = .scaleToFill
        mainView.isUserInteractionEnabled = true
        mainView.image = UIImage(named: "mine_header_point_back")
        return mainView
    }()
    
    lazy var moreView : UIImageView = {
        let moreView = UIImageView.init()
        moreView.image = UIImage(named: "mine_header_message_glod_more")
        moreView.contentMode = .scaleToFill
        moreView.backgroundColor = .clear
        return moreView
    }()
    
    lazy var pointButton: UIButton = {
        let pointButton  = UIButton.init(type: .custom)
        pointButton.backgroundColor = .clear
        pointButton.setTitle("  去赚积分", for: .normal)
        pointButton.titleLabel?.font = Font_12
        pointButton.imageView?.contentMode = .scaleToFill
        pointButton.setTitleColor(HexColor("#FFE4C4"), for: .normal)
        pointButton.setImage(UIImage(named: "mine_header_point_gold_coin"), for: .normal)
        pointButton.addTarget(self, action: #selector(pushMineQuestView), for: .touchUpInside)
        return pointButton
    }()
    
    lazy var questLabel: UILabel = {
        let questLabel = UILabel.init()
        questLabel.text = "做任务领积分"
        questLabel.font = BoldFont_19_Fit
        questLabel.textAlignment = .left
        questLabel.textColor = HexColor("#FFE4C4")
        return questLabel
    }()
    
    lazy var line_left_label: UILabel = {
        let lineLabel = UILabel.init()
        lineLabel.backgroundColor = HexColor("#FFDAB0")
        return lineLabel
    }()
    
    lazy var line_right_label: UILabel = {
        let rightLabel = UILabel.init()
        rightLabel.backgroundColor = HexColor("#FFDAB0")
        return rightLabel
    }()
    
    lazy var balanceLabel: UILabel = {
        let balanceLabel = UILabel.init()
        balanceLabel.text = "元码余额(元)"
        balanceLabel.textColor = HexColor("#FFE4C4")
        balanceLabel.font = Font_12
        balanceLabel.textAlignment = .left
        return balanceLabel
    }()

    lazy var pointLabel: UILabel = {
        let pointLabel = UILabel.init()
        pointLabel.text = "积分"
        pointLabel.textColor = HexColor("#FFE4C4")
        pointLabel.font = Font_12
        pointLabel.textAlignment = .left
        return pointLabel
    }()
    
    lazy var balanceNumberButton: APButton = {
        let balanceNumberButton = APButton()
        balanceNumberButton.setTitle("0", for: .normal)
        balanceNumberButton.activityIndicator.color = .white
        balanceNumberButton.titleLabel?.font = BoldFont_19_Fit
        balanceNumberButton.setTitleColor(HexColor("#FFE4C4"), for: .normal)
        balanceNumberButton.addTarget(self, action: #selector(pushBalanceMothed), for: .touchUpInside)
        return balanceNumberButton
    }()
    
    lazy var pointNumberButton: APButton = {
        let pointNumberButton = APButton()
        pointNumberButton.activityIndicator.color = .white
        pointNumberButton.titleLabel?.font = BoldFont_19_Fit
        pointNumberButton.setTitle("0", for: .normal)
        pointNumberButton.setTitleColor(HexColor("#FFE4C4"), for: .normal)
        pointNumberButton.addTarget(self, action: #selector(pushPointsMothed), for: .touchUpInside)
        return pointNumberButton
    }()
    
    var _checkModel : MinePointCheckInModel?
    var checkModel : MinePointCheckInModel? {
        get{
            return _checkModel
        }
        set{
            _checkModel = newValue
            balanceNumberButton.stopAnimating()
            pointNumberButton.stopAnimating()
            if newValue == nil {
                balanceNumberButton.setTitle("0", for: .normal)
                pointNumberButton.setTitle("0", for: .normal)
            } else {
                balanceNumberButton.setTitle((newValue!.money!.isNotBlank()) ? newValue?.money : "0", for: .normal)
                pointNumberButton.setTitle((newValue!.integral!.isNotBlank()) ? newValue?.integral : "0", for: .normal)
            }
        }
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        addSubview(mainView)
        mainView.addSubview(moreView)
        mainView.addSubview(pointButton)
        mainView.addSubview(questLabel)
        
        mainView.addSubview(line_left_label)
        mainView.addSubview(balanceLabel)
        mainView.addSubview(balanceNumberButton)
        
        mainView.addSubview(line_right_label)
        mainView.addSubview(pointLabel)
        mainView.addSubview(pointNumberButton)
        
        pointNumberButton.startAnimating()
        balanceNumberButton.startAnimating()
        
        setupConstraints()
    }
    
    func setupConstraints() {
        mainView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.top.bottom.equalToSuperview()
        }
        pointButton.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(15)
            make.left.equalToSuperview().offset(10)
            make.width.equalTo(75)
        }
        moreView.snp.makeConstraints { make in
            make.centerY.equalTo(pointButton)
            make.left.equalTo(pointButton.snp.right).offset(-5)
        }
        questLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(10)
            make.centerY.equalToSuperview().offset(10)
        }
        
        line_left_label.snp.makeConstraints { make in
            make.left.equalTo(questLabel.snp.right).offset(10)
            make.centerY.equalToSuperview()
            make.height.equalTo(40)
            make.width.equalTo(0.5)
        }
        balanceLabel.snp.makeConstraints { make in
            make.centerY.equalTo(pointButton)
            make.left.equalTo(line_left_label.snp.right).offset(10)
            make.top.equalToSuperview().offset(15)
        }
        balanceNumberButton.snp.makeConstraints { make in
            make.left.equalTo(line_left_label.snp.right).offset(10)
            make.centerY.equalToSuperview().offset(10)
        }
        
        line_right_label.snp.makeConstraints { make in
            make.left.equalTo(balanceLabel.snp.right).offset(10)
            make.centerY.equalToSuperview()
            make.height.equalTo(40)
            make.width.equalTo(0.5)
        }
        pointLabel.snp.makeConstraints { make in
            make.centerY.equalTo(balanceLabel)
            make.left.equalTo(line_right_label.snp.right).offset(10)
        }
        pointNumberButton.snp.makeConstraints { make in
            make.centerY.equalTo(balanceNumberButton)
            make.left.equalTo(line_right_label.snp.right).offset(10)
        }

    }
    
    @objc func pushBalanceMothed(sender: APButton) {
        currentViewController()?.navigationController?.pushViewController(CNLiveMineEarnViewController.init(index: 1, checkModel: _checkModel!), animated: true)
    }
    
    @objc func pushPointsMothed(sender: APButton) {
        currentViewController()?.navigationController?.pushViewController(CNLiveMineEarnViewController.init(index: 0, checkModel: _checkModel!), animated: true)
    }
    
    @objc func pushMineQuestView() {
        currentViewController()?.navigationController?.pushViewController(CNLiveMineQuestViewController.init(checkModel: _checkModel!), animated: true)
    }

    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

class MineBodyFourViewCell: UITableViewCell {
    
    lazy var mainView: UIView = {
        let mainView = UIView.init()
        mainView.backgroundColor = .white
        mainView.isUserInteractionEnabled = true
        return mainView
    }()
    
    lazy var iconView: UIImageView = {
        let iconView = UIImageView.init()
        iconView.backgroundColor = .white
        iconView.contentMode = .scaleToFill
        iconView.image = UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSizeMake(40, 40))
        return iconView
    }()
    
    lazy var nameLabel: UILabel = {
        let nameLabel = UILabel.init()
        nameLabel.backgroundColor = .white
        nameLabel.textColor = HexColor("#30364F")
        nameLabel.font = Font_15_Fit
        return nameLabel
    }()
    
    lazy var descLabel: UILabel = {
        let descLabel = UILabel.init()
        descLabel.backgroundColor = .white
        descLabel.textColor = HexColor("#9EA4B8")
        descLabel.font = Font_13_Fit
        return descLabel
    }()
    
    lazy var shareBtn: APButton = {
        let shareBtn = APButton()
        shareBtn.frame = CGRect(x: 0, y: 0, width: 70, height: 30)
        shareBtn.setTitleColor(.white, for: .normal)
        shareBtn.titleLabel?.font = Font_12
        shareBtn.layer.cornerRadius = 15
        shareBtn.layer.masksToBounds = true
        shareBtn.activityIndicator.color = UIColor.white
        shareBtn.setTitle("去完成", for: .normal)
        shareBtn.setImage(UIImage(named: "mine_list_icon_right_white_more"), for: .normal)
        shareBtn.setupButtonImageAndTitlePossitionWith(padding: 0, style: .right)
        shareBtn.addTarget(self, action: #selector(checkInAction), for: .touchUpInside)
        return shareBtn
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        addSubview(mainView)
        mainView.addSubview(iconView)
        mainView.addSubview(nameLabel)
        mainView.addSubview(descLabel)
        mainView.addSubview(shareBtn)
        
        setConstrainta()
    }
    
    func setConstrainta() {
        mainView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        iconView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(10)
            make.size.equalTo(50)
        }
        nameLabel.snp.makeConstraints { make in
            make.top.equalTo(iconView.snp.top)
            make.left.equalTo(iconView.snp.right).offset(10)
        }
        descLabel.snp.makeConstraints { make in
            make.bottom.equalTo(iconView.snp.bottom)
            make.left.equalTo(iconView.snp.right).offset(10)
        }
        shareBtn.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-10)
            make.width.equalTo(70)
            make.height.equalTo(30)
        }
        shareBtn.setGradient(colors: [UIColor(red: 255/255.0, green: 168/255.0, blue: 26/255.0, alpha: 1),UIColor(red: 255/255.0, green: 210/255.0, blue: 11/255.0, alpha: 1)], startPoint: CGPoint(x: 0, y: 0.5), endPoint: CGPoint(x: 1, y: 0.5))
        
    }
    
    var _listModel: MineTaskCheckListModel!
    func setupWithData(listModel: MineTaskCheckListModel) {
        _listModel = listModel
        iconView.kf.indicatorType = .activity
        iconView.kf.setImage(with: URL(string: listModel.icon ?? "") , placeholder: UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSizeMake(50, 50)))
        nameLabel.text = listModel.title ?? ""
        descLabel.text = "积分值+\(listModel.score ?? "")"
        if _listModel.taskId!.contains("check_in") {
            if !_listModel.checkInStatus! {
                shareBtn.setTitle("去签到", for: .normal)
            }else{
                shareBtn.titleEdgeInsets = UIEdgeInsets.zero
                shareBtn.imageEdgeInsets = UIEdgeInsets.zero
                shareBtn.setTitleColor(HexColor("#999999"), for: .normal)
                shareBtn.setTitle("已完成", for: .normal)
                shareBtn.setImage(nil, for: .normal)
                shareBtn.isUserInteractionEnabled = false
                shareBtn.setGradient(colors: [HexColor("#f9f9f9")!,HexColor("#f9f9f9")!], startPoint: CGPoint(x: 0, y: 0.5), endPoint: CGPoint(x: 1, y: 0.5))
            }
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func checkInAction(sender: APButton) {
        sender.startAnimating()
        showLoading(message: "")
        CNLiveMineViewModel.requestWithCheckInAction { [self] result, respStatue in
            sender.stopAnimating()
            showMessage(message: "签到成功")
            _listModel.status = "false"
            shareBtn.titleEdgeInsets = UIEdgeInsets.zero
            shareBtn.imageEdgeInsets = UIEdgeInsets.zero
            shareBtn.setTitleColor(HexColor("#999999"), for: .normal)
            shareBtn.setTitle("已完成", for: .normal)
            shareBtn.setImage(UIImage(), for: .normal)
            shareBtn.setGradient(colors: [HexColor("#f9f9f9")!,HexColor("#f9f9f9")!], startPoint: CGPoint(x: 0, y: 0.5), endPoint: CGPoint(x: 1, y: 0.5))
        }
    }
}

class MIneBodyFiveViewCell: UITableViewCell {
    
    lazy var mainView: UIView = {
        let mainView = UIView.init(frame: CGRect(x: 0, y: 0, width: Int(KSreenWidth) - 40, height: 70))
        mainView.backgroundColor = .white
        return mainView
    }()
    
    lazy var nameLabel: UILabel = {
        let nameLabel = UILabel.init()
        nameLabel.textColor = HexColor("#666666")
        nameLabel.font = Font_16
        nameLabel.backgroundColor = .white
        return nameLabel
    }()
    
    lazy var descLabel: UILabel = {
        let descLabel = UILabel.init()
        descLabel.textColor = HexColor("#999999")
        descLabel.font = Font_12
        descLabel.backgroundColor = .clear
        return descLabel
    }()
    
    lazy var pointLabel: UILabel = {
        let pointLabel = UILabel.init()
        pointLabel.textColor = HexColor("#F5A623")
        pointLabel.font = BoldFont_16_Fit
        pointLabel.backgroundColor = .clear
        return pointLabel
    }()
    
    lazy var line_label: UILabel = {
        let lineLabel = UILabel.init()
        lineLabel.backgroundColor = HexColor("#E5E5E5")
        return lineLabel
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        addSubview(mainView)
        mainView.addSubview(nameLabel)
        mainView.addSubview(descLabel)
        mainView.addSubview(pointLabel)
        mainView.addSubview(line_label)
        setConstrainta()
    }
    
    func setConstrainta() {
        mainView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        nameLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(20)
            make.top.equalToSuperview().offset(10)
        }
        descLabel.snp.makeConstraints { make in
            make.bottom.equalToSuperview().offset(-10)
            make.left.equalToSuperview().offset(20)
        }
        pointLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-10)
        }
        line_label.snp.makeConstraints { make in
            make.bottom.equalToSuperview().offset(-0.5)
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.height.equalTo(0.5)
        }
    }
    
    func setupWithBalanceDataSource(isLast: Bool, dataModel: MineTradingRecordModel) {
        line_label.isHidden = isLast
        nameLabel.text = dataModel.iconBean.nickName
        descLabel.text = dataModel.time
 
        if dataModel.sum!.contains("-") {
            pointLabel.text = "+\(dataModel.sum!)元"
        }
        if dataModel.sourceType!.contains("wjj_balance_transfer_refund") {
            pointLabel.text = "+\(dataModel.sum!)元"
        }else{
            pointLabel.text = "\(dataModel.sum ?? "")元"
        }
    }
    
    func setupWithRecordDataSource(isLast: Bool, dataModel: MineIntegralRecordDescModel) {
        line_label.isHidden = isLast
        nameLabel.text = dataModel.integralDesc
        descLabel.text = dataModel.exchangeTime
        pointLabel.text = "\(dataModel.integral ?? "")积分"
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

enum CNLiveBodyInputAuthShowType {
    case end//输入结束后
    case select//选择图片
}

typealias resultInputBlock = (_ type: CNLiveBodyInputAuthShowType) -> Void
class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate, QMUITextViewDelegate {
    
    var identifier = false
    lazy var mainView: UIView = {
        let mainView = UIView.init(frame: CGRect.zero)
        mainView.backgroundColor = .white
        return mainView
    }()
    
    lazy var nameLabel: UILabel = {
        let nameLabel = UILabel.init()
        nameLabel.textColor = HexColor("#333333")
        nameLabel.font = BoldFont_16_Fit
        nameLabel.backgroundColor = .white
        return nameLabel
    }()
    
    lazy var contentField: UITextField = {
        let contentField = UITextField.init()
        contentField.backgroundColor = .white
        contentField.font = BoldFont_15_Fit
        contentField.textColor = HexColor("#333333")
        contentField.clearButtonMode = .whileEditing
        contentField.textAlignment = .right
        contentField.delegate = self
        return contentField
    }()
    
    lazy var contentTextView: QMUITextView = {
        let textView = QMUITextView.init(frame: .zero)
        textView.backgroundColor = HexColor("#F7F8FA")
        textView.font = BoldFont_15_Fit
        textView.textColor = HexColor("#333333")
        textView.placeholderColor = HexColor("#C7C7C7")
        textView.placeholderMargins = UIEdgeInsets(top: 0, left: 5, bottom: 00, right: 5)
        textView.contentInset = UIEdgeInsets(top: 5, left: 10, bottom: 5, right: 10)
        textView.maximumHeight = adapt_length(length: 70)
        textView.textAlignment = .left
        textView.layer.masksToBounds = true
        textView.layer.cornerRadius = adapt_length(length: 10)
        textView.isHidden = true
        textView.delegate = self
        return textView
    }()
    
    lazy var tapGesture = UITapGestureRecognizer()
    lazy var iconView: UIImageView = {
        let  iconView = UIImageView.init()
        iconView.backgroundColor = .white
        iconView.image = UIImage.imageWithColor(color: HexColor("#f6f6f6")!, size: CGSizeMake(30, 30))
        iconView.contentMode = .scaleToFill
        iconView.clipsToBounds = true
        iconView.layer.cornerRadius = 5
        iconView.layer.masksToBounds = true
        iconView.isHidden = true
        iconView.isUserInteractionEnabled = true
        tapGesture.addTarget(self, action: #selector(setupSelectButtonAction))
        iconView.addGestureRecognizer(tapGesture)
        return iconView
    }()
    
    lazy var moreBtn: UIButton = {
        let moreBtn = UIButton.init(type: .custom)
        moreBtn.setImage(UIImage(named: "mine_header_message_gray_more"), for: .normal)
        moreBtn.layer.masksToBounds = true
        moreBtn.layer.cornerRadius = 15
        moreBtn.isHidden = true
        return moreBtn
    }()
    
    lazy var line_label: UILabel = {
        let lineLabel = UILabel.init()
        lineLabel.backgroundColor = HexColor("#f3f3f3")
        return lineLabel
    }()
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        backgroundColor = .white
        contentView.backgroundColor = .white
        
        contentView.addSubview(mainView)
        mainView.addSubview(nameLabel)
        mainView.addSubview(moreBtn)
        mainView.addSubview(contentField)
        mainView.addSubview(contentTextView)
        mainView.addSubview(iconView)
        mainView.addSubview(moreBtn)
        mainView.addSubview(line_label)
        setConstrainta()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func contentAction() {
        
    }
    
    var _infoModel : MineStandInfoModel?
    fileprivate var _resultInputBlock : resultInputBlock?
    func setListModel(infoModel: MineStandInfoModel, is_last: Bool,resultInputBlock: @escaping resultInputBlock) {
        _infoModel = infoModel
        _resultInputBlock = resultInputBlock
        nameLabel.text = infoModel.name
        if (infoModel.value ?? "").count  > 0 {
            contentField.text = infoModel.value
        }
        contentField.placeholder = "请输入\(infoModel.name ?? "")"//infoModel.sub_title?.count == 0 ? "请输入\(infoModel.name ?? "")" : infoModel.sub_title
        contentTextView.placeholder = "请输入\(infoModel.name ?? "")"
        contentTextView.maximumTextLength = UInt(infoModel.length)
        line_label.isHidden = is_last
        contentTextView.isHidden = true
        if infoModel.inputType == 2 {
            contentField.keyboardType = .numberPad
        } else if (infoModel.inputType == 1) {
            contentField.keyboardType = .default
        } else if (infoModel.inputType == 3 && infoModel.children.count > 0) {//禁止输入 显示下拉选择
            contentField.isUserInteractionEnabled = false
            moreBtn.isHidden = false
            contentField.snp.remakeConstraints { make in
                make.centerY.equalToSuperview()
                make.right.equalTo(moreBtn.snp.left)
            }
        }else if (infoModel.inputType == 6) {//禁止输入  显示证件照
            contentField.isHidden = true
            moreBtn.isHidden = false
            iconView.isHidden = false
            contentField.snp.remakeConstraints { make in
                make.centerY.equalToSuperview()
                make.right.equalTo(moreBtn.snp.left)
            }
        } else if (infoModel.inputType == 16) {//下面显示大文本框
            contentField.isHidden = true
            moreBtn.isHidden = true
            iconView.isHidden = true
            contentTextView.isHidden = false
            nameLabel.snp.remakeConstraints { make in
                make.top.equalToSuperview().offset(adapt_length(length: 10))
                make.left.equalToSuperview()
            }
            contentTextView.snp.remakeConstraints { make in
                make.centerX.equalToSuperview()
                make.top.equalTo(nameLabel.snp.bottom).offset(adapt_length(length: 10))
                make.left.equalToSuperview().offset(adapt_length(length: 10))
                make.bottom.right.equalToSuperview()
            }
        }
    }
    
    func setConstrainta() {
        mainView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.bottom.equalToSuperview()
            make.left.equalToSuperview()
            make.right.equalToSuperview()
        }
        nameLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(15)
        }
        moreBtn.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-8)
        }
        contentField.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-10)
            make.left.greaterThanOrEqualTo(self.nameLabel.snp.right).offset(5)
        }
        contentTextView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-10)
            make.left.lessThanOrEqualTo(self.nameLabel.snp.right).offset(5)
        }
        moreBtn.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-5)
        }
        iconView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalTo(moreBtn.snp.left)
            make.height.equalTo(50)
            make.width.equalTo(35)
        }
        line_label.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview().offset(-1)
            make.width.equalTo(Int(KSreenWidth) - 40)
            make.height.equalTo(0.5)
        }
    }

    func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
        if textField == contentField {
            if contentField.text!.count > _infoModel!.length {
                showMessage(message: "\(_infoModel!.name ?? "")最大限制\(_infoModel!.length)个字")
                return false
            }
        }
        return contentField.resignFirstResponder()
    }
    
    func textFieldDidEndEditing(_ textField: UITextField) {
        _infoModel?.value = textField.text ?? ""
        _resultInputBlock!(.end)
    }
    
    func textViewShouldEndEditing(_ textView: UITextView) -> Bool {
        if textView == contentTextView {
            if contentTextView.text!.count > _infoModel!.length {
                showMessage(message: "\(_infoModel!.name ?? "")最大限制\(_infoModel!.length)个字")
                return false
            }
        }
        return contentTextView.resignFirstResponder()
    }
    
    func textViewDidEndEditing(_ textView: UITextView) {
        _infoModel?.value = textView.text ?? ""
        _resultInputBlock!(.end)
    }
    
    func textViewShouldReturn(_ textView: QMUITextView!) -> Bool {
        _infoModel?.value = textView.text ?? ""
        _resultInputBlock!(.end)
        return true
    }
    
    @objc func setupSelectButtonAction() {
        _resultInputBlock!(.select)
    }
}