// // ApplyCardBillViewController.swift // xingchuangke // // Created by Virgil on 2019/7/16. // Copyright © 2019 Virgil. All rights reserved. // import UIKit class IntegralBillViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var lblCount1: UILabel! @IBOutlet weak var lblCount2: UILabel! @IBOutlet weak var lblCount3: UILabel! @IBOutlet weak var lblCount4: UILabel! @IBOutlet weak var tableView: UITableView! //【积分】0:下单、1:交易中、2:交易失败(3:面值不符)、4:交易成功 var type = 0 override func viewDidLoad() { super.viewDidLoad() tableView.register(UINib(nibName: "IntegralBillTableViewCell", bundle: nil), forCellReuseIdentifier: "IntegralBillTableViewCell") 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() }) loadCount() // Do any additional setup after loading the view. } //btnAddTarget(view: self.view, selector: #selector(self.btnMenuClick)) @IBAction func btnMenuClick(_ sender: AnyObject) { switch (sender as! UIButton).tag { case 1001: // 待确认 type = 0 lblCount1.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xFF680B, alpha: 1.0) lblCount2.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount3.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount4.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) self.currentPage = 1 loadData() break case 1002: // 待审核 type = 1 lblCount1.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount2.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xFF680B, alpha: 1.0) lblCount3.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount4.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) self.currentPage = 1 loadData() break case 1003: // 申请成功 type = 4 lblCount1.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount2.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount3.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xFF680B, alpha: 1.0) lblCount4.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) self.currentPage = 1 loadData() break case 1004: // 关闭 type = 2 lblCount1.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount2.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount3.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount4.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xFF680B, alpha: 1.0) self.currentPage = 1 loadData() break case 1005: // break case 1006: // break default: break } } // MARK: =============加载数据=============== func loadData() { let url = RequestURL.scorePageList let params = NSMutableDictionary() params.setValue(type, forKey: "type") loadDataList(url: url, params: params, tableView: self.tableView, tag: 1001) } func loadCount() { let url = RequestURL.scoreNum let params = NSMutableDictionary() params.setValue(type, forKey: "type") loadDataInfo(url: url, params: params, tag: 1002) } override func returnData(tag: Int) { if tag == 1001 { tableView.reloadData() } else if tag == 1002 { self.loadData() lblCount1.text = "(\(getIntValue(key: "status0")))" lblCount2.text = "(\(getIntValue(key: "status1")))" lblCount3.text = "(\(getIntValue(key: "status3")))" lblCount4.text = "(\(getIntValue(key: "status2")))" } } override func returnError(tag: Int, type: String) { if tag == 1002 { self.loadData() } } // 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 { if type == 2 { return 132 } else { return 105 } } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "IntegralBillTableViewCell", for: indexPath as IndexPath) as! IntegralBillTableViewCell cell.lblTitle.text = getString(current: indexPath.row, key: "brand_name") cell.lblDate.text = getString(current: indexPath.row, key: "createtime") cell.lblJF.text = getString(current: indexPath.row, key: "point") cell.lblMoney.text = getString(current: indexPath.row, key: "user_price") if type == 2 { cell.lblError.isHidden = false cell.lblError.text = "原因:\(getString(current: indexPath.row, key: "refuse"))" } else { cell.lblError.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) self.tabBarController?.title = self.title } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: "IntegralBillViewController", bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }