younger_times
2023-07-24 858bd6df13a6a6415d12d8e60141575574646f58
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//
//  RechargeCenterVC.swift
//  WanPai
//
//  Created by 无故事王国 on 2023/6/28.
//
 
import UIKit
import JQTools
import QMUIKit
 
class RechargeCenterVC: BaseVC {
 
    struct RechargeItem {
        var coin = 0
        var money:Double = 0
    }
 
    @IBOutlet weak var view_topBg: UIView!
    @IBOutlet weak var view_cion: JQ_RollNumberLabel!
    @IBOutlet weak var btn_rechange: UIButton!
    @IBOutlet weak var view_container: UIView!
    @IBOutlet weak var btn_rechargeInfo: UIButton!
    @IBOutlet weak var collectionView: UICollectionView!
 
    private var items = [RechargeItem]()
    private let cellW = (JQ_ScreenW - 100) / 3.0
    private let cellH = ((JQ_ScreenW - 100) / 3.0) * 0.5148
    private var selectIndex = 0
 
    var viewModel:RechargeRecordViewModel!
 
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        view_cion.valueNumber = NSNumber(value: viewModel.coin.value)
    }
 
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "充值中心"
        view_cion.font = UIFont.init(name: "Impact", size: 36)!
        view_cion.textColor = .white
 
        Services.voucherCenter().subscribe(onNext: {[weak self] data in
            for v in data.data ?? []{
                self?.items.append(RechargeItem(coin: v.wpGold, money: v.amount))
            }
            self?.collectionView.reloadData()
        }).disposed(by: disposeBag)
    }
 
    override func setUI() {
        let colors = [UIColor(hexStr: "#FD8C02").cgColor,
                      UIColor(hexStr: "#FD7202").cgColor,]
        view_topBg.jq_gradientColor(colorArr: colors)
        btn_rechange.jq_gradientNibColor(colorArr: colors, cornerRadius: 20)
 
        let attribute = AttributedStringbuilder()
        attribute.add(string: "储值说明?", withFont: UIFont.systemFont(ofSize: 14), withColor: Def_ThemeColor)
        attribute.underLine(color: Def_ThemeColor)
        btn_rechargeInfo.titleLabel?.attributedText = attribute.mutableAttributedString
 
        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.isScrollEnabled = false
        collectionView.contentInset = UIEdgeInsets(top: 0, left: 12, bottom: 0, right: 12)
        collectionView.register(UINib(nibName: "RechargeItemCCell", bundle: nil), forCellWithReuseIdentifier: "_RechargeItemCCell")
    }
 
 
    @IBAction func introAction(_ sender: UIButton) {
          let vc = JQ_CommonWebViewController(htmlText: "说明。。。。", baseURL: nil)
        present(vc, animated: true)
    }
 
 
 
    @IBAction func rechargeAction(_ sender: UIButton) {
        let item = items[selectIndex]
        PaymentView.show(money: (ali:item.money,wx:item.money,coin:item.coin,course:nil)) { type in
 
//            let result:PaymentResultVC.PaymentResult = status ? .success:.fail
//            let vc = PaymentResultVC(result: result, objType: .activityApply)
//            vc.modalPresentationStyle = .fullScreen
//            self.present(vc, animated: true)
        }
    }
}
 
extension RechargeCenterVC:UICollectionViewDelegate{
 
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        selectIndex = indexPath.row
    }
 
}
 
extension RechargeCenterVC:UICollectionViewDataSource{
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let item = items[indexPath.row]
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_RechargeItemCCell", for:indexPath) as! RechargeItemCCell
        cell.isSelected = indexPath.row == selectIndex
        cell.label_coin.text = "\(item.coin)币"
        cell.label_moeny.text = item.money.currency()
        return cell
    }
 
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return items.count
    }
}
 
extension RechargeCenterVC:UICollectionViewDelegateFlowLayout{
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
        return 18
    }
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
        return 18
    }
 
 
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: cellW, height: cellH)
    }
}