IntegralManagerViewController.swift 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. //
  2. // IntegralManagerViewController.swift
  3. // xingchuangke
  4. //
  5. // Created by Virgil on 2019/4/28.
  6. // Copyright © 2019 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class IntegralManagerViewController: BaseViewController, UITableViewDelegate, UITableViewDataSource {
  10. var viewHeader: IntegralManagerHeaderView!
  11. @IBOutlet weak var tableView: UITableView!
  12. override func viewDidLoad() {
  13. super.viewDidLoad()
  14. self.title = "积分专区"
  15. initNavLeftBackButton()
  16. viewHeader = (CommonViewUntils.getViewForXIB(xibName: "IntegralManagerHeaderView") as! IntegralManagerHeaderView)
  17. viewHeader.initView()
  18. tableView.register(UINib(nibName: "IntegralManagerTableViewCell", bundle: nil), forCellReuseIdentifier: "IntegralManagerTableViewCell")
  19. tableView.delegate = self
  20. tableView.dataSource = self
  21. tableView.separatorStyle = .none
  22. tableView.showsVerticalScrollIndicator = false
  23. tableView.estimatedRowHeight = 100
  24. tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in
  25. self!.currentPage = 1
  26. self!.loadData()
  27. })
  28. tableView.mj_header?.lastUpdatedTimeKey = "ShowTableViewCell"
  29. tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in
  30. self!.currentPage += 1
  31. self!.loadData()
  32. })
  33. tableView.tableHeaderView = viewHeader
  34. initNavRightButtonForTitle(title: "账单", color: UIColor.white)
  35. loadData()
  36. loadHeaderData()
  37. }
  38. func initHeaderView() {
  39. 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
  40. }
  41. viewHeader.view2.addSubview(segment)
  42. }
  43. // MARK: =============加载数据===============
  44. func loadData() {
  45. for i in 0 ..< 3 {
  46. arrData.add(i)
  47. }
  48. tableView.mj_header?.endRefreshing()
  49. tableView.mj_footer?.endRefreshing()
  50. returnData(tag: 1001)
  51. // let url = RequestURL.bookList;
  52. // let params = NSMutableDictionary()
  53. // params.setValue("", forKey: "subjectId")
  54. // params.setValue("", forKey: "showTimeSort")
  55. // params.setValue("", forKey: "priceSort")
  56. // loadDataList(url: url, params: params, tableView: self.tableView,tag:1001)
  57. }
  58. let arrHeader = NSMutableArray()
  59. func loadHeaderData() {
  60. let url = RequestURL.findAdvertisingWheel
  61. let params = NSMutableDictionary()
  62. params.setValue(0, forKey: "position")
  63. loadDataList(url: url, params: params, tag: 1002, array: arrHeader)
  64. }
  65. override func returnData(tag: Int) {
  66. if tag == 1001 {
  67. tableView.reloadData()
  68. } else if tag == 1002 {
  69. if arrHeader.count > 0 {
  70. var imgUrl = [String]()
  71. for i in 0 ..< arrHeader.count {
  72. imgUrl.append(getStringForArray(key: "img_path", arr: arrHeader, current: i))
  73. }
  74. 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]
  75. (item) -> Void in
  76. if CommonValue.getUserId() == "" {
  77. appDelegate.navController.pushViewController(LoginViewController(), animated: true)
  78. return
  79. }
  80. let type = (self!.arrHeader[item] as! NSDictionary).getInt(key: "type")
  81. ///0:内部web 1:外部web 111:邀请好友 222开通商户
  82. if type == 0 || type == 1 {
  83. let web = CommonWebViewViewController()
  84. web.strTitle = "详情"
  85. web.url = (self!.arrHeader[item] as! NSDictionary).getString(key: "web_url")
  86. appDelegate.navController.pushViewController(web, animated: true)
  87. } else if type == 111 {
  88. let vc = InviteViewController()
  89. appDelegate.navController.pushViewController(vc, animated: true)
  90. } else if type == 222 {
  91. let vc = SelectPayBrandViewController()
  92. appDelegate.navController.pushViewController(vc, animated: true)
  93. }
  94. }
  95. viewHeaderAD.backgroundColor = UIColor.clear
  96. viewHeaderAD.titles = ["1111", "2222", "3333", "4444"]
  97. viewHeader.view1.removeAll()
  98. viewHeader.view1.addSubview(viewHeaderAD)
  99. initHeaderView()
  100. }
  101. }
  102. }
  103. override func returnError(tag: Int, type: String) {
  104. }
  105. override func btnRightMenuClick() {
  106. toViewController(viewController: IntegralBillViewController())
  107. }
  108. // MARK: TABLEVLEW 实现
  109. func numberOfSections(in tableView: UITableView) -> Int {
  110. return 1
  111. }
  112. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  113. return self.arrData.count
  114. }
  115. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  116. return 91
  117. }
  118. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  119. let cell = tableView.dequeueReusableCell(withIdentifier: "IntegralManagerTableViewCell", for: indexPath as IndexPath) as! IntegralManagerTableViewCell
  120. cell.btnDH.tag = indexPath.row
  121. cell.btnDH.addTarget(self, action: #selector(btnDHClick), for: .touchUpInside)
  122. return cell
  123. }
  124. @objc func btnDHClick(btn: UIButton) {
  125. toViewController(viewController: IntegralDetailViewController())
  126. }
  127. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  128. toViewController(viewController: IntegralDetailViewController())
  129. }
  130. override func viewWillAppear(_ animated: Bool) {
  131. super.viewWillAppear(animated)
  132. }
  133. override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
  134. super.init(nibName: "IntegralManagerViewController", bundle: nil)
  135. }
  136. required init?(coder aDecoder: NSCoder) {
  137. fatalError("init(coder:) has not been implemented")
  138. }
  139. }