杨锴
2024-09-13 9ac9fdb427af823fcafe945a19ba83befe462dfb
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
//
//  TreeTeskEnergyExchangeVC.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/9/11.
//
 
import UIKit
import JQTools
 
class TreeTeskEnergyExchangeVC: BaseVC {
 
                @IBOutlet weak var tableView: UITableView!
 
                override func viewDidLoad() {
                                super.viewDidLoad()
                                title = "礼品兑换"
                }
 
                override func setUI() {
 
                                let btn = UIButton(type: .custom)
                                btn.setTitle("兑换记录", for: .normal)
                                btn.setTitleColor(.black.withAlphaComponent(0.55), for: .normal)
                                btn.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
                                btn.addTarget(self, action: #selector(exchangeRecordAction), for: .touchUpInside)
 
                                navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn)
 
                                tableView.delegate = self
                                tableView.dataSource = self
                                tableView.separatorStyle = .none
                                tableView.register(UINib(nibName: "TreeTeskEnergyTCell", bundle: nil), forCellReuseIdentifier: "_TreeTeskEnergyTCell")
                }
 
                @objc func exchangeRecordAction(){
                                let vc = TreeTeskEnergyExchangeRecordVC()
                                push(vc: vc)
                }
}
 
extension TreeTeskEnergyExchangeVC:UITableViewDataSource & UITableViewDelegate{
 
                func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
 
                                let attribute = AttributedStringbuilder.build().add(string: "是否确认使用X能量值兑换当前礼品?\n兑换后系统将自动扣除能量值", withFont: .systemFont(ofSize: 14, weight: .medium), withColor: .black.withAlphaComponent(0.59), indent: 0, lineSpace: 6).mutableAttributedString
 
                                CommonAlertView.show(title: "提示", attribute: attribute, isSingle: false, cancelStr: "再想想", completeStr: "确认") { state in
 
                                                if state{
                                                                TreeTeskExchangeSuccessView.show()
                                                }
 
                                }
                }
 
                func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
                                let cell = tableView.dequeueReusableCell(withIdentifier: "_TreeTeskEnergyTCell") as! TreeTeskEnergyTCell
                                cell.isExchanged(indexPath.row == 0)
                                return cell
                }
 
                func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
                                return 11
                }
 
                func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
                                return 91
                }
}