123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- //
- // BusinessViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/3/22.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class BusinessViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate, UIScrollViewDelegate, BusinessHeaderViewDelegate {
- @IBOutlet weak var tableView: UITableView!
- var headerView: BusinessHeaderView!
- var machineType: NSString = "2"
- override func viewDidLoad() {
- super.viewDidLoad()
- tableView.register(UINib(nibName: "BusinessTableViewCell", bundle: nil), forCellReuseIdentifier: "BusinessTableViewCell")
- tableView.delegate = self
- tableView.dataSource = self
- tableView.separatorStyle = .none
- tableView.showsVerticalScrollIndicator = false
- tableView.estimatedRowHeight = 100
- tableView.setSizeHeight(height: ScreenHeight - common_nav_status_height - common_bottom_height - 48)
- 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()
- })
- headerView = (CommonViewUntils.getViewForXIB(xibName: "BusinessHeaderView") as! BusinessHeaderView)
- headerView.delegate = self
- headerView.initView()
- tableView.tableHeaderView = headerView
- tableView.reloadData()
- headerTop = headerView.viewContent2.topm()
- loadData()
- // Do any additional setup after loading the view.
- }
- // MARK: =============加载数据===============
- func loadData() {
- let url = RequestURL.transactionListPage
- let params = NSMutableDictionary()
- // params.setValue("", forKey: "machineTypeId")
- params.setValue(self.machineType, forKey: "machineTypeId")
- params.setValue("", forKey: "timeStart")
- params.setValue("", forKey: "timeEnd")
- params.setValue("", forKey: "cardType")
- params.setValue("", forKey: "transactionType")
- params.setValue("desc", forKey: "sortType")
- 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 57
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "BusinessTableViewCell", for: indexPath as IndexPath) as! BusinessTableViewCell
- //cell.lblTitle.text = getString(indexPath.row, key: "Name")
- cell.lblName.text = getString(current: indexPath.row, key: "shopName")
- cell.lblDate.text = getString(current: indexPath.row, key: "tradeDate")
- cell.lblPayName.text = getString(current: indexPath.row, key: "machineTypeCN")
- cell.lblMoney.text = "¥\(getString(current: indexPath.row, key: "tradeAmount") )"
- let depositTrade = getString(current: indexPath.row, key: "depositTrade") == "19" ? "押金" : "消费"
- cell.lblType.text = "(\(depositTrade))"
- cell.lblType.isHidden = true
- return cell
- }
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- }
- var headerIsTop = false
- var headerTop: CGFloat = 258; //view距顶部的距离
- func scrollViewDidScroll(_ scrollView: UIScrollView) {
- if scrollView.contentOffset.y >= headerTop {
- if !headerIsTop {
- headerView.viewContent2.removeFromSuperview()
- self.view.addSubview(headerView.viewContent2)
- headerView.viewContent2.marginTop(top: 0)
- headerIsTop = true
- }
- } else {
- if headerIsTop {
- headerView.viewContent2.removeFromSuperview()
- headerView.addSubview(headerView.viewContent2)
- headerView.viewContent2.marginTop(top: 258)
- headerIsTop = false
- }
- }
- }
- func segmentDidClickedWithIndex(index: NSInteger) {
- if index == 0 {
- self.machineType = "2"
- } else if index == 1 {
- self.machineType = "300595e17ed94b5f8c2b3f437ce26116"
- } else if index == 2 {
- self.machineType = "f391406346e04510ab6b3be081b2e4aa"
- } else if index == 3 {
- self.machineType = "4"
- }
- self.currentPage = 1
- loadData()
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- appDelegate.setNavigationBarHidden(isHidden: false)
- self.tabBarController?.title = "我的业务"
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "BusinessViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|