ShoppingCartOrderPayView.swift 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // ShoppingCartOrderPayView.swift
  3. // RainbowPlanet
  4. //
  5. // Created by Christopher on 2019/5/9.
  6. // Copyright © 2019 RainbowPlanet. All rights reserved.
  7. // 购物车--订单支付View
  8. import UIKit
  9. class ShoppingCartOrderPayView: BaseView {
  10. override func setupViews() {
  11. self.backgroundColor = kf7f8faColor
  12. addSubview(accountView)
  13. addSubview(tableView)
  14. let emptyView = EmptyView.shared.diyCustomEmptyViewStyle2(iconStr: "page04", titleStr: "当前暂无数据")
  15. emptyView.contentViewY = kScaleValue(value: 182)
  16. tableView.ly_emptyView = emptyView
  17. tableView.ly_startLoading()
  18. }
  19. override func setupLayouts() {
  20. accountView.snp.makeConstraints { (make) in
  21. make.left.right.equalToSuperview()
  22. make.bottom.equalTo(-kSafeTabBarHeight)
  23. make.height.equalTo(48)
  24. }
  25. tableView.snp.makeConstraints { (make) in
  26. make.edges.equalToSuperview()
  27. make.bottom.equalTo(accountView.snp_top).offset(-20)
  28. }
  29. }
  30. lazy var accountView: OrderPayAcountView = {
  31. let accountView = OrderPayAcountView()
  32. return accountView
  33. }()
  34. lazy var tableView: UITableView = {
  35. let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
  36. tableView.separatorStyle = .none
  37. tableView.backgroundColor = kf7f8faColor
  38. tableView.dataSource = self
  39. tableView.delegate = self
  40. tableView.estimatedRowHeight = 0.000001
  41. tableView.estimatedSectionFooterHeight = 0.000001
  42. tableView.estimatedSectionHeaderHeight = 0.000001
  43. return tableView
  44. }()
  45. }
  46. extension ShoppingCartOrderPayView : UITableViewDelegate, UITableViewDataSource {
  47. func numberOfSections(in tableView: UITableView) -> Int {
  48. return 3
  49. }
  50. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  51. if section == 0 {
  52. return 1
  53. } else {
  54. return 2
  55. }
  56. }
  57. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  58. if indexPath.section == 0 {
  59. let cell = ShoppingCartListNoneItemCell.cellWith(tableView: tableView, indexPath: indexPath)
  60. return cell
  61. } else {
  62. let cell = ShoppingCartPayOrderItemCell.cellWith(tableView: tableView, indexPath: indexPath)
  63. return cell
  64. }
  65. }
  66. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  67. return UITableView.automaticDimension
  68. }
  69. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  70. if section == 0 {
  71. return 10
  72. } else {
  73. return 48
  74. }
  75. }
  76. func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
  77. if section == 0 {
  78. return nil
  79. } else {
  80. let headerView = ShoppingCartPayOrderHeader(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 48))
  81. return headerView
  82. }
  83. }
  84. func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
  85. if section == 0 {
  86. return 0.000001
  87. } else {
  88. return 88
  89. }
  90. }
  91. func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
  92. if section == 0 {
  93. return nil
  94. } else {
  95. let footerView = ShoppingCartPayOrderFooter(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 88))
  96. return footerView
  97. }
  98. }
  99. }