|
@@ -20,11 +20,14 @@ class ShoppingCartView: BaseView {
|
|
// 热销ModelArr
|
|
// 热销ModelArr
|
|
var hotSaleModelArr : Array<ProductSearchModel>? {
|
|
var hotSaleModelArr : Array<ProductSearchModel>? {
|
|
didSet {
|
|
didSet {
|
|
- //FIXME:刷新指定section
|
|
|
|
- tableView.reloadData()
|
|
|
|
|
|
+ let sectionIdx = cartListModelArr?.count ?? 1
|
|
|
|
+ self.tableView.reloadSections([sectionIdx], with: UITableView.RowAnimation.none)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ typealias OrderPayTransBlock = () -> Void
|
|
|
|
+ var orderPayTransBlock : OrderPayTransBlock?
|
|
|
|
+
|
|
override func setupViews() {
|
|
override func setupViews() {
|
|
self.backgroundColor = kf7f8faColor
|
|
self.backgroundColor = kf7f8faColor
|
|
addSubview(accountView)
|
|
addSubview(accountView)
|
|
@@ -48,6 +51,14 @@ class ShoppingCartView: BaseView {
|
|
|
|
|
|
lazy var accountView: ShoppingCartAccountView = {
|
|
lazy var accountView: ShoppingCartAccountView = {
|
|
let accountView = ShoppingCartAccountView()
|
|
let accountView = ShoppingCartAccountView()
|
|
|
|
+
|
|
|
|
+ accountView.orderPayBlock = {
|
|
|
|
+ [weak self] in
|
|
|
|
+ if let orderPayTransBlock = self?.orderPayTransBlock {
|
|
|
|
+ orderPayTransBlock()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
return accountView
|
|
return accountView
|
|
}()
|
|
}()
|
|
|
|
|
|
@@ -149,4 +160,19 @@ extension ShoppingCartView : UITableViewDelegate, UITableViewDataSource {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
|
|
|
|
+
|
|
|
|
+ if editingStyle == .delete {
|
|
|
|
+ // 删除商品
|
|
|
|
+ let productId = 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)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? {
|
|
|
|
+ return "删除"
|
|
|
|
+ }
|
|
}
|
|
}
|