|
@@ -13,6 +13,9 @@ class ShoppingCartOrderPayView: BaseView {
|
|
|
typealias CommitOrderTransBlock = () -> Void
|
|
|
var commitOrderTransBlock : CommitOrderTransBlock?
|
|
|
|
|
|
+ typealias JumpNavBlock = (_ jumpType: WillJumpType) -> Void
|
|
|
+ var jumpNavBlock : JumpNavBlock?
|
|
|
+
|
|
|
// 全部已选总价
|
|
|
var totalProductPrice: Int = 0 {
|
|
|
didSet {
|
|
@@ -27,6 +30,27 @@ class ShoppingCartOrderPayView: BaseView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 全部已选总价
|
|
|
+ var deliverType: String? {
|
|
|
+ didSet {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 快递地址信息Mdl
|
|
|
+ var expressAddressMdl: ExpressAddresModel? {
|
|
|
+ didSet {
|
|
|
+ self.tableView.reloadSections([0], with: UITableView.RowAnimation.none)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 自提地址信息Mdl
|
|
|
+ var selfAddressArrMdl: Array<SelfAddresModel>? {
|
|
|
+ didSet {
|
|
|
+ self.tableView.reloadSections([0], with: UITableView.RowAnimation.none)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
override func setupViews() {
|
|
|
self.backgroundColor = kf7f8faColor
|
|
|
addSubview(accountView)
|
|
@@ -82,7 +106,16 @@ extension ShoppingCartOrderPayView : UITableViewDelegate, UITableViewDataSource
|
|
|
|
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
if section == 0 {
|
|
|
- return 1
|
|
|
+ switch deliverType {
|
|
|
+ case "1":
|
|
|
+ // 自提
|
|
|
+ return 2
|
|
|
+ case "2":
|
|
|
+ // 快递
|
|
|
+ return 1
|
|
|
+ default:
|
|
|
+ return 1
|
|
|
+ }
|
|
|
} else {
|
|
|
return proListModelArr![section-1].productList!.count
|
|
|
}
|
|
@@ -90,19 +123,45 @@ extension ShoppingCartOrderPayView : UITableViewDelegate, UITableViewDataSource
|
|
|
|
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
if indexPath.section == 0 {
|
|
|
- // 快递添加地址
|
|
|
-// let cell = OrderPayExpressAddInfoCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
- // 自提添加收货人信息
|
|
|
-// let cell = OrderPaySelfPickAddInfoCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
- // 自提地址信息
|
|
|
-// let cell = OrderPaySelfPickAddressCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
- // 自提个人信息
|
|
|
-// let cell = OrderPaySelfPickInfoCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
- // 快递
|
|
|
- let cell = OrderPayExpressInfoShowCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
-
|
|
|
-
|
|
|
- return cell
|
|
|
+ switch deliverType {
|
|
|
+ case "1":
|
|
|
+ // 自提
|
|
|
+ if selfAddressArrMdl?.isEmpty ?? true {
|
|
|
+ if indexPath.row == 0 {
|
|
|
+ // 自提添加收货人信息
|
|
|
+ let cell = OrderPaySelfPickAddInfoCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ return cell
|
|
|
+ } else {
|
|
|
+ // 自提地址信息
|
|
|
+ let cell = OrderPaySelfPickAddressCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ return cell
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if indexPath.row == 0 {
|
|
|
+ // 自提个人信息
|
|
|
+ let cell = OrderPaySelfPickInfoCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ return cell
|
|
|
+ } else {
|
|
|
+ // 自提地址信息
|
|
|
+ let cell = OrderPaySelfPickAddressCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ return cell
|
|
|
+ }
|
|
|
+ }
|
|
|
+ case "2":
|
|
|
+ // 快递
|
|
|
+ if expressAddressMdl == nil {
|
|
|
+ // 快递添加地址
|
|
|
+ let expressCell = OrderPayExpressAddInfoCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ return expressCell
|
|
|
+ } else {
|
|
|
+ // 快递信息管理
|
|
|
+ let expressCell = OrderPayExpressInfoShowCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
+ expressCell.addressMdl = expressAddressMdl
|
|
|
+ return expressCell
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ return UITableViewCell()
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
// 购物车列表Item
|
|
@@ -164,9 +223,54 @@ extension ShoppingCartOrderPayView : UITableViewDelegate, UITableViewDataSource
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
|
+ if indexPath.section != 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ switch deliverType {
|
|
|
+ case "1":
|
|
|
+ // 自提
|
|
|
+ if selfAddressArrMdl?.isEmpty ?? true {
|
|
|
+ if indexPath.row == 0 {
|
|
|
+ if let jumpNavBlock = self.jumpNavBlock {
|
|
|
+ jumpNavBlock(WillJumpType.selfAddInfo)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if let jumpNavBlock = self.jumpNavBlock {
|
|
|
+ jumpNavBlock(WillJumpType.selfAddressInfo)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if indexPath.row == 0 {
|
|
|
+ if let jumpNavBlock = self.jumpNavBlock {
|
|
|
+ jumpNavBlock(WillJumpType.selfPersonalInfo)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if let jumpNavBlock = self.jumpNavBlock {
|
|
|
+ jumpNavBlock(WillJumpType.selfAddressInfo)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ case "2":
|
|
|
+ // 快递
|
|
|
+ if expressAddressMdl == nil {
|
|
|
+ if let jumpNavBlock = self.jumpNavBlock {
|
|
|
+ jumpNavBlock(WillJumpType.expressAddInfo)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if let jumpNavBlock = self.jumpNavBlock {
|
|
|
+ jumpNavBlock(WillJumpType.expressManageInfo)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-// 购物车计算
|
|
|
+// MARK: - 购物车计算
|
|
|
extension ShoppingCartOrderPayView {
|
|
|
|
|
|
// 计算Section数据,刷新结算View
|