CNLiveMineGiftCell.swift 3.22 KB
//
//  CNLiveMineGiftCell.swift
//  metaCode
//
//  Created by zx on 2025/4/25.
//

import Foundation
import CNLiveShareToolKit
class CNLiveMineGiftCell:UITableViewCell{

    //giftModel
    var _giftModel : CNLiveHomePageHuBiLieGiftModel?
    var giftModel : CNLiveHomePageHuBiLieGiftModel? {
        get{
            _giftModel
        }
        set{
            _giftModel = newValue
            let mine_image =  _giftModel?.data?.share_app_banner?.mine_image
            self.iconImgView.kf.setImage(with: URL(string: mine_image ?? ""))

        }
    }

    lazy var mainView: UIView = {
        let mainView = UIView.init()
        mainView.backgroundColor = .white
        mainView.layer.cornerRadius = 15
        mainView.layer.masksToBounds = true
        return mainView
    }()
    lazy var iconImgView :UIImageView = {
        let imageView = UIImageView()
        imageView.layer.cornerRadius = 9
        imageView.clipsToBounds = true
        imageView.contentMode = .scaleAspectFill
        imageView.isUserInteractionEnabled = true
        imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
        return imageView
    }()

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.backgroundColor = .clear
        contentView.backgroundColor = .clear
        self.contentView.clipsToBounds = true

        self.initUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func initUI(){
        addSubview(mainView)
        mainView.addSubview(iconImgView)

        mainView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.top.bottom.equalToSuperview()
        }

        iconImgView.snp.makeConstraints { make in
            make.left.equalTo(0)
            make.top.equalTo(0)
            make.height.equalTo(Float(CNLiveHomeADH))
            make.width.equalTo(CNLiveHomeADW)
        }
        
    }
    
    @objc func imgTapAction(ges: UITapGestureRecognizer){
//        let jumpUrl =  self.giftModel?.data?.share_app_banner?.jumpUrl

        let shareTitle = metaAppDelegate.giftModel?.data?.share_app_banner?.share_title
        let shareDesc = metaAppDelegate.giftModel?.data?.share_app_banner?.share_content
        let shareImage = metaAppDelegate.giftModel?.data?.share_app_banner?.share_icon
        let shareUrl = metaAppDelegate.giftModel?.data?.share_app_banner?.jumpUrl

        CNLiveShareManager.showShareViewWithParam(forShareTitle: shareTitle, shareUrl: shareUrl, shareDesc: shareDesc, shareImage: shareImage, screenFull: false, hiddenWjj: true, hiddenQQ: true, hiddenWB: true, hiddenLifeCircle: true, hiddenWechatCircle: false, hiddenWechat: false, hiddenSafari: true, formVC: currentViewController(), topImage: [], topTitles: [], platformType: .all) { title in
            
        } completerBlock: { resultType, platformType, typeString in
            if resultType == .succ{
                print("succ")
            }
        }
    }
}