//
|
// VIPCenterVC.swift
|
// XQMuse
|
//
|
// Created by 无故事王国 on 2024/8/15.
|
//
|
|
import UIKit
|
import JQTools
|
|
class VIPCenterVC: BaseVC {
|
|
@IBOutlet weak var collectionView: UICollectionView!
|
private var selectIndex = 0
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
title = "会员中心"
|
|
collectionView.delegate = self
|
collectionView.dataSource = self
|
collectionView.showsHorizontalScrollIndicator = false
|
collectionView.contentInset = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15)
|
collectionView.register(VipCenterCCell.self, forCellWithReuseIdentifier: "cell")
|
}
|
}
|
|
extension VIPCenterVC:UICollectionViewDelegate & UICollectionViewDataSource{
|
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
selectIndex = indexPath.row
|
collectionView.reloadData()
|
}
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! VipCenterCCell
|
cell.isSelect(indexPath.row == selectIndex)
|
return cell
|
}
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
return 5
|
}
|
}
|
|
extension VIPCenterVC:UICollectionViewDelegateFlowLayout{
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
return CGSize(width: 111, height: 132)
|
}
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
|
return 11.5
|
}
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
|
return 11.5
|
}
|
}
|
|
class VipCenterCCell:UICollectionViewCell{
|
|
private var label_title:UILabel!
|
private var label_price:UILabel!
|
private var lable_priorDay:UILabel!
|
|
override init(frame: CGRect) {
|
super.init(frame: frame)
|
contentView.jq_cornerRadius = 10
|
contentView.backgroundColor = UIColor(hexString: "#EFF2F2")
|
setUI()
|
}
|
|
|
func setUI(){
|
label_title = UILabel()
|
label_title.text = "年度会员"
|
label_title.textAlignment = .center
|
label_title.textColor = UIColor(hexString: "#353535")
|
label_title.font = .systemFont(ofSize: 16, weight: .medium)
|
contentView.addSubview(label_title)
|
label_title.snp.makeConstraints { make in
|
make.top.equalTo(31)
|
make.centerX.equalToSuperview()
|
make.height.equalTo(15)
|
}
|
|
label_price = UILabel()
|
label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: .systemFont(ofSize: 15, weight:.heavy), withColor: UIColor(hexString: "#353535")!).add(string: "199", withFont: .systemFont(ofSize: 20, weight:.heavy), withColor: UIColor(hexString: "#353535")!).mutableAttributedString
|
label_price.textAlignment = .center
|
label_price.font = .systemFont(ofSize: 16, weight: .medium)
|
contentView.addSubview(label_price)
|
label_price.snp.makeConstraints { make in
|
make.top.equalTo(label_title.snp.bottom).offset(15.5)
|
make.centerX.equalToSuperview()
|
make.height.equalTo(15)
|
}
|
|
lable_priorDay = UILabel()
|
lable_priorDay.text = "¥0/天"
|
lable_priorDay.textAlignment = .center
|
lable_priorDay.font = .systemFont(ofSize: 11, weight: .medium)
|
contentView.addSubview(lable_priorDay)
|
lable_priorDay.snp.makeConstraints { make in
|
make.top.equalTo(label_price.snp.bottom).offset(15.5)
|
make.centerX.equalToSuperview()
|
make.height.equalTo(15)
|
}
|
}
|
|
func isSelect(_ state:Bool){
|
if state{
|
contentView.backgroundColor = UIColor(hexString: "#A6C586")
|
label_title.textColor = .white
|
lable_priorDay.textColor = .white
|
label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: .systemFont(ofSize: 15, weight:.heavy), withColor: .white).add(string: "199", withFont: .systemFont(ofSize: 20, weight:.heavy), withColor: .white).mutableAttributedString
|
}else{
|
contentView.backgroundColor = UIColor(hexString: "#EFF2F2")
|
label_title.textColor = UIColor(hexString: "#353535")
|
lable_priorDay.textColor = UIColor(hexString: "#B7B7B7")
|
label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: .systemFont(ofSize: 15, weight:.heavy), withColor: UIColor(hexString: "#353535")!).add(string: "199", withFont: .systemFont(ofSize: 20, weight:.heavy), withColor: UIColor(hexString: "#353535")!).mutableAttributedString
|
}
|
}
|
|
required init?(coder: NSCoder) {
|
fatalError("init(coder:) has not been implemented")
|
}
|
}
|