瀏覽代碼

购物车列表删除逻辑Fixed

Chris 5 年之前
父節點
當前提交
aa2d5de249

+ 5 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/View/ShoppingCartView.swift

@@ -273,11 +273,16 @@ 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)
+                                self?.refreshAccountView()
                                 
                                 // 删除后商店为空,刷新table
                                 if self?.cartListModelArr![indexPath.section].productList?.isEmpty ?? true {
+                                    // 删除后商店为空,刷新table
                                     self?.cartListModelArr?.remove(at: indexPath.section)
                                     tableView.reloadData()
+                                } else {
+                                    // 刷新删除行所在的section(防止索引越界)
+                                    self?.tableView.reloadSections([indexPath.section], with: UITableView.RowAnimation.none)
                                 }
                             }
                         })