// // RankingListViewController.swift // xingchuangke // // Created by Virgil on 2019/4/16. // Copyright © 2019 Virgil. All rights reserved. // import UIKit class RankingListViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() let viewNav = (CommonViewUntils.getViewForXIB(xibName: "NavView") as! NavView) viewNav.initView(title: "明星排行榜") {[weak self] (index, _) in if index == 0 { self!.handleBack() } } self.view.addSubview(viewNav) tableView.marginTop(top: 0, view: viewNav) tableView.setSizeHeight(height: ScreenHeight - viewNav.bottom()) let view = (CommonViewUntils.getViewForXIB(xibName: "RankingListHeaderView") as! RankingListHeaderView) let strs = ["http://5b0988e595225.cdn.sohucs.com/q_70,c_zoom,w_640/images/20181020/0c031822ed4f4d41b7cd60424f27b999.jpeg", "http://5b0988e595225.cdn.sohucs.com/q_70,c_zoom,w_640/images/20181020/0c031822ed4f4d41b7cd60424f27b999.jpeg", "http://homesitetask.zbjimg.com/homesite/task/1.jpg/origine/3ff4a910-9b6c-4b1c-bf25-ef14baaf970f"] view.initView(strNames: ["小小小", "大大大", "中中中"], strIcons: strs) tableView.tableHeaderView = view tableView.register(UINib(nibName: "RankingListTableViewCell", bundle: nil), forCellReuseIdentifier: "RankingListTableViewCell") 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() }) tableView.mj_header?.beginRefreshing() } // MARK: =============加载数据=============== func loadData() { for i in 0 ..< 10 { self.arrData.add(i) } returnData(tag: 1001) tableView.mj_header?.endRefreshing() tableView.mj_footer?.endRefreshing() // let url = RequestURL.bookList; // let params = NSMutableDictionary() // params.setValue("", forKey: "subjectId") // params.setValue("", forKey: "showTimeSort") // params.setValue("", forKey: "priceSort") // loadDataList(url: url, params: params, tableView: self.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 87 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "RankingListTableViewCell", for: indexPath as IndexPath) as! RankingListTableViewCell cell.lblName.text = "李某某\(indexPath.row)" cell.imgIcon.loadImage(imgUrl: "http://homesitetask.zbjimg.com/homesite/task/1.jpg/origine/3ff4a910-9b6c-4b1c-bf25-ef14baaf970f", defaultImage: "") cell.imgIcon.setCornerRadius() cell.lblNo.text = "\((indexPath.row + 4))" cell.lblRight.setColorFontString(str: "16(核卡)", range: NSRange.init(location: 0, length: 2), defaultColor: CommonUntils.getUIColorFromRGB(rgbValue: 0x333333, alpha: 1.0), currentColor: UIColor.red, defauntFont: 10, currentFont: 15) 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) appDelegate.setNavigationBarHidden(isHidden: true) } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: "RankingListViewController", bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }