// // QSLVipGoodCollectionViewCell.swift // QuickSearchLocation // // Created by Destiny on 2024/11/28. // import UIKit enum GoodCellType { case big case small case top } class QSLVipGoodCollectionViewCell: UICollectionViewCell { struct UX { static let smallMainViewWidth = (QSLConst.qsl_kScreenW - 42.0.rpx) / 3.0 - 9.0.rpx static let mainViewHeight = 94.0.rpx static let bigMainViewWidth = (QSLConst.qsl_kScreenW - 36.0.rpx) / 2.0 - 9.0.rpx } var type: GoodCellType = .small { didSet { self.updateUI() } } var goodModel: QSLGoodModel? lazy var bgView: UIView = { let view = UIView() view.backgroundColor = .hexStringColor(hexString: "#EEEEEE") view.addRadius(radius: 12) return view }() lazy var mostTagIcon: UIImageView = { let imageView = UIImageView() imageView.image = UIImage(named: "vip_goods_most_tag") return imageView }() lazy var tagIcon: UIImageView = { let imageView = UIImageView() imageView.image = UIImage(named: "vip_goods_tag_icon") return imageView }() lazy var mainView: UIView = { let view = UIView(frame: CGRect(x: 0, y: 0, width: UX.smallMainViewWidth, height: UX.mainViewHeight)) view.addFourCorner(topLeft: 11, topRight: 11, bottomLeft: 0, bottomRight: 0) view.backgroundColor = .white return view }() lazy var goodNameLabel: UILabel = { let label = UILabel() label.text("年度会员") label.boldFont(13) label.textColor = .hexStringColor(hexString: "#404040") return label }() lazy var priceLabel: UILabel = { let label = UILabel() label.textAlignment = .center // label.addRadius(radius: 12.rpx) // label.backgroundColor = .hexStringColor(hexString: "#F6F6F6") label.text("¥128") label.mediumFont(24) label.textColor = .hexStringColor(hexString: "#404040") label.setSpecificTextColorFont("¥", color: .hexStringColor(hexString: "#404040"), font: UIFont.systemFont(ofSize: 14, weight: .medium)) return label }() lazy var originPriceLabel: UILabel = { let label = UILabel() label.text("¥299") label.font(13) label.textColor = .hexStringColor(hexString: "#A7A7A7") label.centerLineText(lineValue: 1, underlineColor: .hexStringColor(hexString: "#A7A7A7")) return label }() lazy var goodDailyPriceLabel: UILabel = { let label = UILabel() let text = "仅需¥9.2/天,时刻守护Ta的安全" label.text(text) label.font(9) label.textColor = .hexStringColor(hexString: "#818181") label.setSpecificTextColorFont("¥", color: .hexStringColor(hexString: "#818181"), font: UIFont.systemFont(ofSize: 9, weight: .heavy)) if let yuanIndex = text.firstIndex(of: "¥") { // 获取文本最后一位的index let lastIndex = text.index(before: text.endIndex) // 创建从¥后面一个字符到文本最后一位的range let contentRange = text.index(after: yuanIndex)..