123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- //
- // MyWalletListViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/4/12.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class MyWalletListViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate {
- @IBOutlet weak var tableView: UITableView!
- @IBOutlet weak var viewMenu: UIView!
- /// 0:pos机收益 1:办卡收益 2:积分收益 3:激活奖励
- var type = 0
- override func viewDidLoad() {
- super.viewDidLoad()
- self.title = "我的钱包"
- initNavLeftBackButton()
- let segment = Virgil_SegmentView(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: 47), titles: ["POS机", "激活奖励", "办卡", "积分"], defaultColor: CommonUntils.getUIColorFromRGB(rgbValue: 0x333333, alpha: 1.0), currentColor: CommonUntils.getUIColorFromRGB(rgbValue: 0x2094F5, alpha: 1.0), lineHeight: 2, lineIsBottom: true) {[weak self] (index) in
- if index == 0 {
- self!.type = 0
- } else if index == 1 {
- self!.type = 3
- } else if index == 2 {
- self!.type = 1
- } else if index == 3 {
- self!.type = 2
- }
- self!.currentPage = 1
- self!.tableView.mj_header?.beginRefreshing()
- }
- self.viewMenu.addSubview(segment)
- tableView.register(UINib(nibName: "MyWalletListTableViewCell", bundle: nil), forCellReuseIdentifier: "MyWalletListTableViewCell")
- tableView.delegate = self
- tableView.dataSource = self
- tableView.separatorStyle = .none
- tableView.showsVerticalScrollIndicator = false
- tableView.estimatedRowHeight = 100
- tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in
- self!.currentPage = 1
- self!.loadData()
- })
- tableView.mj_header?.lastUpdatedTimeKey = "ShowTableViewCell"
- tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in
- self!.currentPage += 1
- self!.loadData()
- })
- segment.setTabIndex(index: type)
- tableView.mj_header?.beginRefreshing()
- }
- // MARK: =============加载数据===============
- func loadData() {
- // if(self.currentPage == 1)
- // {
- // self.arrData.removeAllObjects()
- // }
- // for i in 0 ..< 20
- // {
- // self.arrData.add(i)
- // }
- // returnData(tag:1001)
- // tableView.mj_header.endRefreshing()
- // tableView.mj_footer.endRefreshing()
- let url = RequestURL.walletList
- let params = NSMutableDictionary()
- params.setValue(type, forKey: "type")
- loadDataList(url: url, params: params, tableView: tableView, tag: 1001)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- tableView.reloadData()
- }
- }
- override func returnError(tag: Int, type: String) {
- }
- // MARK: TABLEVLEW 实现
- func numberOfSections(in tableView: UITableView) -> Int {
- return 1
- }
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return self.arrData.count
- }
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 68
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "MyWalletListTableViewCell", for: indexPath as IndexPath) as! MyWalletListTableViewCell
- cell.lblName.text = getString(current: indexPath.row, key: "name")
- cell.lblMoney.text = "+\(getDoubleValue(current: indexPath.row, key: "wallet_amount", defaultValue: 0.0))"
- cell.lblDate.text = getString(current: indexPath.row, key: "createtime")
- cell.lblAmountMoney.text = "交易总额:\(getDoubleValue(current: indexPath.row, key: "amount_total", defaultValue: 0.0))"
- if self.type == 0 {
- cell.lblMoney.marginTop(top: 20)
- cell.lblAmountMoney.isHidden = false
- } else {
- cell.lblMoney.marginTop(top: 27)
- cell.lblAmountMoney.isHidden = true
- }
- //cell.lblAmountMoney.isHidden = true;
- return cell
- }
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- // let view = UIViewController()
- // view.oneGoId = self.arrData[indexPath.row]["ItemId"] as! Int
- // self.navigationController?.pushViewController(view, animated: true)
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "MyWalletListViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|