|
@@ -17,12 +17,7 @@ class ShoppingCartView: BaseView {
|
|
|
self.judgeAllSelectedStatus()
|
|
|
self.refreshAccountView()
|
|
|
|
|
|
- // FIXME: to be deal
|
|
|
- if cartListModelArr?.isEmpty ?? true {
|
|
|
- accountView.isHidden = true
|
|
|
- } else {
|
|
|
- accountView.isHidden = false
|
|
|
- }
|
|
|
+ self.updateAccountViewCondition()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -58,14 +53,10 @@ class ShoppingCartView: BaseView {
|
|
|
tableView.ly_emptyView = emptyView
|
|
|
tableView.ly_startLoading()
|
|
|
|
|
|
- // FIXME: to be deal
|
|
|
- if cartListModelArr?.isEmpty ?? true {
|
|
|
- accountView.isHidden = true
|
|
|
- } else {
|
|
|
- accountView.isHidden = false
|
|
|
- }
|
|
|
+ self.updateAccountViewCondition()
|
|
|
}
|
|
|
|
|
|
+
|
|
|
override func setupLayouts() {
|
|
|
accountView.snp.makeConstraints { (make) in
|
|
|
make.left.right.bottom.equalToSuperview()
|
|
@@ -77,6 +68,25 @@ class ShoppingCartView: BaseView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 处理购物车结算是否显示
|
|
|
+ func updateAccountViewCondition() {
|
|
|
+ if cartListModelArr?.isEmpty ?? true {
|
|
|
+ accountView.isHidden = true
|
|
|
+ accountView.snp_updateConstraints { (make) in
|
|
|
+ accountView.snp_updateConstraints { (make) in
|
|
|
+ make.height.equalTo(0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ accountView.isHidden = false
|
|
|
+ accountView.snp_updateConstraints { (make) in
|
|
|
+ accountView.snp_updateConstraints { (make) in
|
|
|
+ make.height.equalTo(48)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
lazy var accountView: ShoppingCartAccountView = {
|
|
|
let accountView = ShoppingCartAccountView()
|
|
|
|
|
@@ -258,6 +268,12 @@ extension ShoppingCartView : UITableViewDelegate, UITableViewDataSource {
|
|
|
SwiftMoyaNetWorkServiceProduct.shared().productCartDeleteApi(id: productId ?? 0) { [weak self] (data) -> (Void) in
|
|
|
self?.cartListModelArr![indexPath.section].productList?.remove(at: indexPath.row)
|
|
|
tableView.deleteRows(at: [indexPath], with: .none)
|
|
|
+
|
|
|
+ // 删除后商店为空,刷新table
|
|
|
+ if self?.cartListModelArr![indexPath.section].productList?.isEmpty ?? true {
|
|
|
+ self?.cartListModelArr?.remove(at: indexPath.section)
|
|
|
+ tableView.reloadData()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|