杨锴
2025-04-16 09a372bc45fde16fd42257ab6f78b8deeecf720b
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
//
//  HomeRelaxBanner_2_1_CCell.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/8/15.
//
 
import UIKit
import JQTools
 
class HomeRelaxBanner_2_1_CCell: UICollectionViewCell {
 
                @IBOutlet weak var view_text_bg: UIView!
                @IBOutlet weak var img_cover: UIImageView!
                @IBOutlet weak var label_title: UILabel!
                @IBOutlet weak var label_subTitle: UILabel!
                @IBOutlet weak var label_num: UILabel!
    @IBOutlet weak var image_free: UIImageView!
    @IBOutlet weak var view_price: UIView!
    @IBOutlet weak var label_price: UILabel!
    @IBOutlet weak var img_vip: UIImageView!
    @IBOutlet weak var img_offline: UIImageView!
    @IBOutlet weak var view_waitPay: UIView!
    @IBOutlet weak var label_waitPrice: UILabel!
    
                override func awakeFromNib() {
                                super.awakeFromNib()
                                // Initialization code
 
        view_waitPay.isHidden = true
        view_waitPay.jq_cornerRadius = 9.75
                                jq_cornerRadius = 15
        view_price.jq_cornerRadius = 12.55
                                let blurEffect = UIBlurEffect(style: .light)
                                let visualEffectView = UIVisualEffectView(effect: blurEffect)
                                view_text_bg.addSubview(visualEffectView)
                                visualEffectView.snp.makeConstraints { make in
                                                make.edges.equalToSuperview()
                                }
                                visualEffectView.alpha = 0.7
                                view_text_bg.sendSubviewToBack(visualEffectView)
                                visualEffectView.layer.masksToBounds = true
                }
 
                func setCourseModel(_ model:CourseModel){
 
        img_cover.sd_setImage(with: URL(string: model.coverUrl.jq_urlEncoded().components(separatedBy: ",").last))
                                label_title.text = model.courseTitle
        label_subTitle.text = model.description
 
                                label_num.text = "\(model.count)"
 
        if model.courseType == .online{
            img_offline.isHidden = true
            setChargePrice(model.chargeType, price: model.iosPrice)
        }else{
            img_offline.isHidden = false
            img_vip.isHidden = true
            view_price.isHidden = true
            image_free.isHidden = true
        }
 
 
        if model.paymentStatus == .yes{
            label_waitPrice.attributedText  = AttributedStringbuilder.build().add(string: "待支付|", withFont: .systemFont(ofSize: 10), withColor: .white).add(string: "¥", withFont: UIFont(name: "DIN-Bold", size: 7.11) ?? UIFont.systemFont(ofSize: 7, weight: .bold), withColor: .white).add(string: model.iosPrice.jq_formatFloat, withFont: UIFont(name: "DIN-Bold", size: 11.62) ?? UIFont.systemFont(ofSize: 11.62, weight: .bold), withColor: .white).mutableAttributedString
        }
 
 
        view_waitPay.isHidden = model.paymentStatus == .no
        label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: .systemFont(ofSize: 7.2, weight: .bold), withColor: .white).add(string: model.iosPrice.jq_formatFloat, withFont: .systemFont(ofSize: 11), withColor: .white).mutableAttributedString
                }
 
    func setMeditationModel(_ model:MeditationModel){
        img_cover.sd_setImage(with: URL(string: model.coverUrl.jq_urlEncoded().components(separatedBy: ",").first))
        label_title.text = model.meditationTitle
        label_subTitle.text = model.coverDescription
        label_num.text = "\(model.realLearnedNum)"
 
        img_offline.isHidden = true
        setChargePrice(model.chargeType, price: model.iosPrice)
 
        view_waitPay.isHidden = model.paymentStatus == .no
        label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: .systemFont(ofSize: 7.2, weight: .bold), withColor: .white).add(string: model.iosPrice.jq_formatFloat, withFont: .systemFont(ofSize: 11), withColor: .white).mutableAttributedString
    }
 
    private func setChargePrice(_ type:ChargeType,price:Double){
 
        image_free.isHidden = type != .free
        img_vip.isHidden = type != .vipFree
        view_price.isHidden = type != .payment
 
        switch type {
            case .payment:
                label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: UIFont(name: "DIN-Bold", size: 7.11) ?? UIFont.systemFont(ofSize: 7, weight: .bold), withColor: .white).add(string: "\(price.jq_formatFloat) ", withFont: UIFont(name: "DIN-Bold", size: 11) ?? .systemFont(ofSize: 11,weight: .bold), withColor: .white).mutableAttributedString
            default:break
        }
    }
 
 
}