|
@@ -45,6 +45,10 @@ class ShoppingCartView: BaseView {
|
|
|
typealias RefreshTransBlock = () -> Void
|
|
|
var refreshTransBlock : RefreshTransBlock?
|
|
|
|
|
|
+ // 点击店铺跳转--次级block
|
|
|
+ typealias ShopClickedTransBlock = (_ shopId: Int) -> Void
|
|
|
+ var shopClickedTransBlock : ShopClickedTransBlock?
|
|
|
+
|
|
|
override func setupViews() {
|
|
|
self.backgroundColor = kf7f8faColor
|
|
|
addSubview(accountView)
|
|
@@ -80,7 +84,6 @@ class ShoppingCartView: BaseView {
|
|
|
}
|
|
|
tableView.snp.remakeConstraints { (make) in
|
|
|
make.edges.equalToSuperview()
|
|
|
-// make.bottom.equalTo(accountView.snp_top).offset(0)
|
|
|
}
|
|
|
} else {
|
|
|
accountView.isHidden = false
|
|
@@ -186,6 +189,31 @@ extension ShoppingCartView : UITableViewDelegate, UITableViewDataSource {
|
|
|
|
|
|
cell.changeProductBlock = { [weak self]
|
|
|
(productId, type) in
|
|
|
+ // 最少只能减到1件商品
|
|
|
+ let curAmount = self?.cartListModelArr![indexPath.section].productList![indexPath.row].amount
|
|
|
+ if type == 2 && curAmount == 1 {
|
|
|
+ AlertSheetView.alert(title: "确认删除商品", cancelTitle: "取消", sureTitle: "确认", cancelBlock: { (popupView, index, string) in
|
|
|
+
|
|
|
+ }, confirmBlock: {
|
|
|
+ [weak self] (popupView, index, string) in
|
|
|
+ // 删除商品
|
|
|
+ let productId = self?.cartListModelArr![indexPath.section].productList?[indexPath.row].id
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更改数量Api
|
|
|
SwiftMoyaNetWorkServiceProduct.shared().productCartAmountApi(id: productId, type: type, completion: { [weak self] (amountData) -> (Void) in
|
|
|
// 1.更新数据源
|
|
|
let cartAmountMdl = amountData as? CartAmountModel
|
|
@@ -259,6 +287,12 @@ extension ShoppingCartView : UITableViewDelegate, UITableViewDataSource {
|
|
|
// self?.judgeAllSelectedStatus()
|
|
|
// self?.refreshAccountView()
|
|
|
}
|
|
|
+ headerView.shopClickedBlock = {
|
|
|
+ [weak self] in
|
|
|
+ if let shopClickedTransBlock = self?.shopClickedTransBlock {
|
|
|
+ shopClickedTransBlock(self!.cartListModelArr![section].shopId ?? 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
return headerView
|
|
|
|
|
|
} else {
|