//
//  WA_RakingCell.swift
//  wallpaper_project
//
//  Created by 忆海16 on 2024/3/27.
//

import UIKit

class WA_RakingCell: UITableViewCell {
    @IBOutlet weak var headImageV: UIImageView!
    
    @IBOutlet weak var nameLabel: UILabel!
    
    @IBOutlet weak var titleLabel: UILabel!
    
    @IBOutlet weak var contentimagV: UIImageView!
    
    
    @IBOutlet weak var contentImageV: UIImageView!
    
    
    @IBOutlet weak var bgView: UIView!
    
    
    @IBOutlet weak var shView: UIView!
    
    
    @IBOutlet weak var plLabel: UILabel!
    
    
    @IBOutlet weak var zanLabel: UILabel!
    
    
    @IBOutlet weak var zanBtn: UIButton!
    
    
    @IBOutlet weak var reportView: UIView!
    
    var reportBlcok:(()->())?
    var blackBLcok:(()->())?
    
    override func awakeFromNib() {
        super.awakeFromNib()
        reportView.layer.cornerRadius = 10
        reportView.layer.borderWidth = 1
        reportView.layer.borderColor = UIColor.black.cgColor
        
        headImageV.layer.cornerRadius = 25
        contentimagV.layer.cornerRadius = 5
//        bgView.layer.cornerRadius = 10
//        bgView.layer.borderWidth = 1
//        bgView.layer.borderColor = UIColor.black.cgColor
        let randomNum = Int.random(in: 1...200)
        self.zanLabel.text = "\(randomNum)"
        self.bgView.backgroundColor = .hexSting(color: "#FAFBFC", alpha: 1)
}
    
    var model:WA_RakModel?{
        didSet{
            self.nameLabel.text = model?.name
            self.titleLabel.text = model?.content
            let imageUrl = URL(string: (model?.head)!) // 替换为您的图片URL
            headImageV.sd_setImage(with: imageUrl, completed: nil)
            
            let imagecountUrl = URL(string: (model?.img)!) // 替换为您的图片URL
            contentImageV.sd_setImage(with: imagecountUrl, completed: nil)
            plLabel.text = "\(model?.data?.count ?? 0)"
        }
    }
    
    
    @IBAction func btnZan(_ sender: Any) {
        if zanBtn.isSelected == false{
            zanBtn.isSelected = true
            let zanint = Int(self.zanLabel.text!)
            self.zanLabel.text = "\(zanint! + 1)"
        }else{
            zanBtn.isSelected = false
            let zanint = Int(self.zanLabel.text!)
            self.zanLabel.text = "\(zanint! - 1)"
        }
        
    }
    
    
    @IBAction func reportBtn(_ sender: Any) {
        if self.reportBlcok != nil{
            self.reportBlcok!()
        }
    }
    
    
    @IBAction func blockBtn(_ sender: Any) {
        if self.blackBLcok != nil{
            self.blackBLcok!()
        }
    }
}
