ShoppingCartOrderPayView.swift 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. typealias CommitOrderTransBlock = () -> Void
  11. var commitOrderTransBlock : CommitOrderTransBlock?
  12. override func setupViews() {
  13. self.backgroundColor = kf7f8faColor
  14. addSubview(accountView)
  15. addSubview(tableView)
  16. let emptyView = EmptyView.shared.diyCustomEmptyViewStyle2(iconStr: "page04", titleStr: "当前暂无数据")
  17. emptyView.contentViewY = kScaleValue(value: 182)
  18. tableView.ly_emptyView = emptyView
  19. tableView.ly_startLoading()
  20. }
  21. override func setupLayouts() {
  22. accountView.snp.makeConstraints { (make) in
  23. make.left.right.equalToSuperview()
  24. make.bottom.equalTo(-kSafeTabBarHeight)
  25. make.height.equalTo(48)
  26. }
  27. tableView.snp.makeConstraints { (make) in
  28. make.edges.equalToSuperview()
  29. make.bottom.equalTo(accountView.snp_top).offset(-20)
  30. }
  31. }
  32. lazy var accountView: OrderPayAcountView = {
  33. let accountView = OrderPayAcountView()
  34. accountView.commitOrderBlock = {
  35. [weak self] in
  36. if let commitOrderTransBlock = self?.commitOrderTransBlock {
  37. commitOrderTransBlock()
  38. }
  39. }
  40. return accountView
  41. }()
  42. lazy var tableView: UITableView = {
  43. let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
  44. tableView.separatorStyle = .none
  45. tableView.backgroundColor = kf7f8faColor
  46. tableView.dataSource = self
  47. tableView.delegate = self
  48. tableView.estimatedRowHeight = 0.000001
  49. tableView.estimatedSectionFooterHeight = 0.000001
  50. tableView.estimatedSectionHeaderHeight = 0.000001
  51. return tableView
  52. }()
  53. }
  54. extension ShoppingCartOrderPayView : UITableViewDelegate, UITableViewDataSource {
  55. func numberOfSections(in tableView: UITableView) -> Int {
  56. return 3
  57. }
  58. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  59. if section == 0 {
  60. return 1
  61. } else {
  62. return 2
  63. }
  64. }
  65. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  66. if indexPath.section == 0 {
  67. // 快递添加地址
  68. // let cell = OrderPayExpressAddInfoCell.cellWith(tableView: tableView, indexPath: indexPath)
  69. // 自提添加收货人信息
  70. // let cell = OrderPaySelfPickAddInfoCell.cellWith(tableView: tableView, indexPath: indexPath)
  71. // 自提地址信息
  72. // let cell = OrderPaySelfPickAddressCell.cellWith(tableView: tableView, indexPath: indexPath)
  73. // 自提个人信息
  74. // let cell = OrderPaySelfPickInfoCell.cellWith(tableView: tableView, indexPath: indexPath)
  75. // 快递
  76. let cell = OrderPayExpressInfoShowCell.cellWith(tableView: tableView, indexPath: indexPath)
  77. return cell
  78. } else {
  79. let cell = ShoppingCartPayOrderItemCell.cellWith(tableView: tableView, indexPath: indexPath)
  80. return cell
  81. }
  82. }
  83. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  84. return UITableView.automaticDimension
  85. }
  86. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  87. if section == 0 {
  88. return 10
  89. } else {
  90. return 48
  91. }
  92. }
  93. func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
  94. if section == 0 {
  95. return nil
  96. } else {
  97. let headerView = ShoppingCartPayOrderHeader(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 48))
  98. return headerView
  99. }
  100. }
  101. func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
  102. if section == 0 {
  103. return 0.000001
  104. } else {
  105. return 88
  106. }
  107. }
  108. func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
  109. if section == 0 {
  110. return nil
  111. } else {
  112. let footerView = ShoppingCartPayOrderFooter(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 88))
  113. return footerView
  114. }
  115. }
  116. }