123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- //
- // IntegralManagerViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/4/28.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class IntegralManagerViewController: BaseViewController, UITableViewDelegate, UITableViewDataSource {
- var viewHeader: IntegralManagerHeaderView!
- @IBOutlet weak var tableView: UITableView!
- override func viewDidLoad() {
- super.viewDidLoad()
- self.title = "积分专区"
- initNavLeftBackButton()
- viewHeader = (CommonViewUntils.getViewForXIB(xibName: "IntegralManagerHeaderView") as! IntegralManagerHeaderView)
- viewHeader.initView()
- tableView.register(UINib(nibName: "IntegralManagerTableViewCell", bundle: nil), forCellReuseIdentifier: "IntegralManagerTableViewCell")
- 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.tableHeaderView = viewHeader
- initNavRightButtonForTitle(title: "账单", color: UIColor.white)
- loadData()
- loadHeaderData()
- }
- func initHeaderView() {
- let segment = Virgil_SegmentView(frame: CGRect(x: 0, y: 3, width: ScreenWidth, height: 45), titles: ["招商银行", "交通银行", "平安银行", "工商银行", "广发银行", "深发银行", "农商银行", "民生银行"], defaultColor: CommonUntils.getUIColorFromRGB(rgbValue: 0x333333, alpha: 1.0), currentColor: CommonUntils.getUIColorFromRGB(rgbValue: 0x2094f5, alpha: 1.0), lineHeight: 2, lineIsBottom: true) { [weak self](_) in
- }
- viewHeader.view2.addSubview(segment)
- }
- // MARK: =============加载数据===============
- func loadData() {
- for i in 0 ..< 3 {
- arrData.add(i)
- }
- tableView.mj_header?.endRefreshing()
- tableView.mj_footer?.endRefreshing()
- returnData(tag: 1001)
- // 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)
- }
- let arrHeader = NSMutableArray()
- func loadHeaderData() {
- let url = RequestURL.findAdvertisingWheel
- let params = NSMutableDictionary()
- params.setValue(0, forKey: "position")
- loadDataList(url: url, params: params, tag: 1002, array: arrHeader)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- tableView.reloadData()
- } else if tag == 1002 {
- if arrHeader.count > 0 {
- var imgUrl = [String]()
- for i in 0 ..< arrHeader.count {
- imgUrl.append(getStringForArray(key: "img_path", arr: arrHeader, current: i))
- }
- let viewHeaderAD = Virgil_PagedView(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: viewHeader.view1.frame.height), imageURLStrings: imgUrl, placeholderImage: UIImage(named: "img_banner_01")!, timeInterval: 6) {[weak self]
- (item) -> Void in
- if CommonValue.getUserId() == "" {
- appDelegate.navController.pushViewController(LoginViewController(), animated: true)
- return
- }
- let type = (self!.arrHeader[item] as! NSDictionary).getInt(key: "type")
- ///0:内部web 1:外部web 111:邀请好友 222开通商户
- if type == 0 || type == 1 {
- let web = CommonWebViewViewController()
- web.strTitle = "详情"
- web.url = (self!.arrHeader[item] as! NSDictionary).getString(key: "web_url")
- appDelegate.navController.pushViewController(web, animated: true)
- } else if type == 111 {
- let vc = InviteViewController()
- appDelegate.navController.pushViewController(vc, animated: true)
- } else if type == 222 {
- let vc = SelectPayBrandViewController()
- appDelegate.navController.pushViewController(vc, animated: true)
- }
- }
- viewHeaderAD.backgroundColor = UIColor.clear
- viewHeaderAD.titles = ["1111", "2222", "3333", "4444"]
- viewHeader.view1.removeAll()
- viewHeader.view1.addSubview(viewHeaderAD)
- initHeaderView()
- }
- }
- }
- override func returnError(tag: Int, type: String) {
- }
- override func btnRightMenuClick() {
- toViewController(viewController: IntegralBillViewController())
- }
- // 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 91
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "IntegralManagerTableViewCell", for: indexPath as IndexPath) as! IntegralManagerTableViewCell
- cell.btnDH.tag = indexPath.row
- cell.btnDH.addTarget(self, action: #selector(btnDHClick), for: .touchUpInside)
- return cell
- }
- @objc func btnDHClick(btn: UIButton) {
- toViewController(viewController: IntegralDetailViewController())
- }
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- toViewController(viewController: IntegralDetailViewController())
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "IntegralManagerViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|