宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
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
//
//  ChangeListVC.swift
//  OKProject
//
//  Created by Sweet on 2020/12/26.
//  Copyright © 2020 yangwang. All rights reserved.
//
 
import UIKit
 
class ChangeListVC: YYTableViewController {
    let viewModel = PointsListViewModel()
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "兑换记录"
        
        viewModel.configure(tableView: tableView)
        tableView.mj_header?.beginRefreshing()
        // Do any additional setup after loading the view.
    }
    //MARK: - UI
    override func setupViews() {
        super.setupViews()
        tableView.separatorStyle = .none
        tableView.delegate = self
        tableView.dataSource = self
        tableView.register(cellName: "ChangeListCell", identifier: "item")
    }
    //MARK: - Layouts
    override func defineLayouts() {
        super.defineLayouts()
        tableView.snp.makeConstraints { (make) in
            if #available(iOS 11.0, *) {
                make.edges.equalTo(view.safeAreaLayoutGuide)
            } else {
                make.edges.equalToSuperview()
            }
        }
    }
 
    
}
// MARK: - UITableViewDelegate
extension ChangeListVC:UITableViewDelegate{
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 60
    }
}
 
// MARK: - UITableViewDelegate
extension ChangeListVC:UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return viewModel.dataSource.value.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "item", for: indexPath) as! ChangeListCell
        cell.selectionStyle = .none
        cell.name.text = viewModel.dataSource.value[indexPath.row].name
        cell.points.text = "\(viewModel.dataSource.value[indexPath.row].integral)"
        cell.time.text = viewModel.dataSource.value[indexPath.row].time
        return cell
    }
    
    
}