Sfoglia il codice sorgente

getCurrentVc方式替换

Chris 6 anni fa
parent
commit
a283638766

+ 9 - 0
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderFinishPay/View/OrderFinishPayView.swift

@@ -16,6 +16,9 @@ class OrderFinishPayView: BaseView {
     typealias JumpTransBlock = (_ jType: PayJumpDes) -> Void
     typealias JumpTransBlock = (_ jType: PayJumpDes) -> Void
     var jumpTransBlock : JumpTransBlock?
     var jumpTransBlock : JumpTransBlock?
     
     
+    typealias JumpToDetailTransClosure = (_ proId: Int,_ shopId : Int) -> Void
+    var jumpToDetailTransClosure : JumpToDetailTransClosure?
+    
     // 热销ModelArr
     // 热销ModelArr
     var hotSaleModelArr : Array<ProductSearchModel>? {
     var hotSaleModelArr : Array<ProductSearchModel>? {
         didSet {
         didSet {
@@ -104,6 +107,12 @@ extension OrderFinishPayView : UITableViewDelegate, UITableViewDataSource {
             hotSaleCell.hotSaleModelArr = hotSaleModelArr
             hotSaleCell.hotSaleModelArr = hotSaleModelArr
             hotSaleCell.layoutIfNeeded()
             hotSaleCell.layoutIfNeeded()
             hotSaleCell.reloadData()
             hotSaleCell.reloadData()
+            hotSaleCell.jumpToDetailClosure = {
+                [weak self] (proId, shopId) in
+                if let jumpToDetailTransClosure = self?.jumpToDetailTransClosure {
+                    jumpToDetailTransClosure(proId, shopId)
+                }
+            }
             return hotSaleCell
             return hotSaleCell
             
             
         default:
         default:

+ 7 - 0
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderFinishPay/ViewController/OrderFinishPayController.swift

@@ -128,6 +128,13 @@ class OrderFinishPayController: BaseViewController {
                 self?.navigationController?.pushViewController(vc, animated: true)
                 self?.navigationController?.pushViewController(vc, animated: true)
             }
             }
         }
         }
+        finishPayView.jumpToDetailTransClosure = {
+            [weak self] (proId, shopId) in
+            let vc = ProductDetailViewController()
+            vc.productId = proId
+            vc.shopId = shopId
+            self?.navigationController?.pushViewController(vc, animated: true)
+        }
         
         
         return finishPayView
         return finishPayView
     }()
     }()

+ 6 - 4
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/View/ShoppingCartHotSale/ShoppingCartHotSaleTableViewCell.swift

@@ -13,6 +13,9 @@ class ShoppingCartHotSaleTableViewCell: UITableViewCell {
     typealias RefreshBlock = () -> Void
     typealias RefreshBlock = () -> Void
     var refreshBlock : RefreshBlock?
     var refreshBlock : RefreshBlock?
     
     
+    typealias JumpToDetailClosure = (_ proId: Int,_ shopId : Int) -> Void
+    var jumpToDetailClosure : JumpToDetailClosure?
+    
     // 热销ModelArr
     // 热销ModelArr
     var hotSaleModelArr : Array<ProductSearchModel>? {
     var hotSaleModelArr : Array<ProductSearchModel>? {
         didSet {
         didSet {
@@ -173,10 +176,9 @@ extension ShoppingCartHotSaleTableViewCell: UICollectionViewDelegateFlowLayout,U
     
     
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
         let productSearchModel = hotSaleModelArr?[indexPath.row]
         let productSearchModel = hotSaleModelArr?[indexPath.row]
-        let vc = ProductDetailViewController()
-        vc.productId = productSearchModel?.id
-        vc.shopId = productSearchModel?.shopId
-        getCurrentVC().navigationController?.pushViewController(vc, animated: true)
+        if let jumpToDetailClosure = self.jumpToDetailClosure {
+            jumpToDetailClosure(productSearchModel?.id ?? 0, productSearchModel?.shopId ?? 0)
+        }
     }
     }
     
     
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

+ 15 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/View/ShoppingCartView.swift

@@ -10,6 +10,9 @@ import UIKit
 
 
 class ShoppingCartView: BaseView {
 class ShoppingCartView: BaseView {
     
     
+    typealias JumpToDetailTransClosure = (_ proId: Int,_ shopId : Int) -> Void
+    var jumpToDetailTransClosure : JumpToDetailTransClosure?
+    
     typealias ProductDidSelectRowAt = (ProductModel) -> Void
     typealias ProductDidSelectRowAt = (ProductModel) -> Void
     var productDidSelectRowAt : ProductDidSelectRowAt?
     var productDidSelectRowAt : ProductDidSelectRowAt?
     
     
@@ -220,6 +223,12 @@ extension ShoppingCartView : UITableViewDelegate, UITableViewDataSource {
                         refreshTransBlock()
                         refreshTransBlock()
                     }
                     }
                 }
                 }
+                hotSaleCell.jumpToDetailClosure = {
+                    [weak self] (proId, shopId) in
+                    if let jumpToDetailTransClosure = self?.jumpToDetailTransClosure {
+                        jumpToDetailTransClosure(proId, shopId)
+                    }
+                }
                 return hotSaleCell
                 return hotSaleCell
             default:
             default:
                 return UITableViewCell()
                 return UITableViewCell()
@@ -292,6 +301,12 @@ extension ShoppingCartView : UITableViewDelegate, UITableViewDataSource {
                         refreshTransBlock()
                         refreshTransBlock()
                     }
                     }
                 }
                 }
+                hotSaleCell.jumpToDetailClosure = {
+                    [weak self] (proId, shopId) in
+                    if let jumpToDetailTransClosure = self?.jumpToDetailTransClosure {
+                        jumpToDetailTransClosure(proId, shopId)
+                    }
+                }
                 return hotSaleCell
                 return hotSaleCell
             }
             }
         }
         }
@@ -394,7 +409,6 @@ extension ShoppingCartView : UITableViewDelegate, UITableViewDataSource {
                 tableView.deleteRows(at: [indexPath], with: .none)
                 tableView.deleteRows(at: [indexPath], with: .none)
                 self?.refreshAccountView()
                 self?.refreshAccountView()
                 
                 
-                
                 if self?.cartListModelArr![indexPath.section].productList?.isEmpty ?? true {
                 if self?.cartListModelArr![indexPath.section].productList?.isEmpty ?? true {
                     // 删除后商店为空,刷新table
                     // 删除后商店为空,刷新table
                     self?.cartListModelArr?.remove(at: indexPath.section)
                     self?.cartListModelArr?.remove(at: indexPath.section)

+ 7 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/ViewController/ShoppingCartViewController.swift

@@ -95,6 +95,13 @@ class ShoppingCartViewController: BaseViewController {
     
     
     private lazy var shoppingCartView: ShoppingCartView = {
     private lazy var shoppingCartView: ShoppingCartView = {
         let shoppingCartView = ShoppingCartView()
         let shoppingCartView = ShoppingCartView()
+        shoppingCartView.jumpToDetailTransClosure = {
+            [weak self] (proId, shopId) in
+            let vc = ProductDetailViewController()
+            vc.productId = proId
+            vc.shopId = shopId
+            self?.navigationController?.pushViewController(vc, animated: true)
+        }
         return shoppingCartView
         return shoppingCartView
     }()
     }()
     
     

+ 5 - 5
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailHotSell/ProductDetailHotSellTableViewCell.swift

@@ -10,6 +10,8 @@ import UIKit
 
 
 class ProductDetailHotSellTableViewCell: UITableViewCell {
 class ProductDetailHotSellTableViewCell: UITableViewCell {
 
 
+    typealias JumpToDetailClosure = (_ proId: Int,_ shopId : Int) -> Void
+    var jumpToDetailClosure : JumpToDetailClosure?
     
     
     var productSearchListModel: ProductSearchListModel? {
     var productSearchListModel: ProductSearchListModel? {
         didSet {
         didSet {
@@ -111,11 +113,9 @@ extension ProductDetailHotSellTableViewCell: UICollectionViewDelegateFlowLayout,
     
     
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
         let productSearchModel = productSearchListModel?.data?[indexPath.row]
         let productSearchModel = productSearchListModel?.data?[indexPath.row]
-        let vc = ProductDetailViewController()
-        vc.productId = productSearchModel?.id
-        vc.shopId = productSearchModel?.shopId
-        getCurrentVC().navigationController?.pushViewController(vc, animated: true)
-        
+        if let jumpToDetailClosure = self.jumpToDetailClosure {
+            jumpToDetailClosure(productSearchModel?.id ?? 0, productSearchModel?.shopId ?? 0)
+        }
     }
     }
 
 
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

+ 6 - 4
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailShop/ProductDetailShopTableViewCell.swift

@@ -13,6 +13,9 @@ class ProductDetailShopTableViewCell: UITableViewCell {
     
     
     let disposeBag = DisposeBag()
     let disposeBag = DisposeBag()
     
     
+    typealias JumpToShopBlock = (_ shopName: String,_ shopId : Int) -> Void
+    var jumpToShopBlock : JumpToShopBlock?
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailShopTableViewCell {
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailShopTableViewCell {
         let ID = "ProductDetailShopTableViewCell"
         let ID = "ProductDetailShopTableViewCell"
         tableView.register(ProductDetailShopTableViewCell.self, forCellReuseIdentifier: ID)
         tableView.register(ProductDetailShopTableViewCell.self, forCellReuseIdentifier: ID)
@@ -93,10 +96,9 @@ class ProductDetailShopTableViewCell: UITableViewCell {
         comeInButton.backgroundColor = kFFA42FColor
         comeInButton.backgroundColor = kFFA42FColor
         comeInButton.rx.tap.subscribe(onNext: { //跳转到店铺
         comeInButton.rx.tap.subscribe(onNext: { //跳转到店铺
              [weak self] (data) in
              [weak self] (data) in
-            let vc = ShopViewController()
-            vc.navigationBar.title = self?.productDetailModel?.shopName
-            vc.shopId = self?.productDetailModel?.shopId
-            getCurrentVC().navigationController?.pushViewController(vc, animated: true)
+            if let jumpToShopBlock = self?.jumpToShopBlock {
+                jumpToShopBlock(self?.productDetailModel?.shopName ?? "", self?.productDetailModel?.shopId ?? 0)
+            }
         }).disposed(by: disposeBag)
         }).disposed(by: disposeBag)
         return comeInButton
         return comeInButton
     }()
     }()

+ 18 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailView.swift

@@ -24,6 +24,12 @@ class ProductDetailView: BaseView {
     typealias CartButtonClosure = () -> Void
     typealias CartButtonClosure = () -> Void
     var cartButtonClosure : CartButtonClosure?
     var cartButtonClosure : CartButtonClosure?
     
     
+    typealias JumpToShopTransClosure = (_ shopName: String,_ shopId : Int) -> Void
+    var jumpToShopTransClosure : JumpToShopTransClosure?
+    
+    typealias JumpToDetailTransClosure = (_ proId: Int,_ shopId : Int) -> Void
+    var jumpToDetailTransClosure : JumpToDetailTransClosure?
+    
     var productDetailSkuModel : ProductDetailSkuModel?
     var productDetailSkuModel : ProductDetailSkuModel?
     
     
     var titles = ["","","商品评价","","热销排行","商品参数","商品详情"]
     var titles = ["","","商品评价","","热销排行","商品参数","商品详情"]
@@ -386,10 +392,22 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
         case 3:
         case 3:
             let cell = ProductDetailShopTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
             let cell = ProductDetailShopTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
             cell.productDetailModel = productDetailModel
             cell.productDetailModel = productDetailModel
+            cell.jumpToShopBlock = {
+                [weak self] (shopName, shopId) in
+                if let jumpToShopTransClosure = self?.jumpToShopTransClosure {
+                    jumpToShopTransClosure(shopName, shopId)
+                }
+            }
             return cell
             return cell
         case 4:
         case 4:
             let cell = ProductDetailHotSellTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
             let cell = ProductDetailHotSellTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
             cell.productSearchListModel = productSearchListModel
             cell.productSearchListModel = productSearchListModel
+            cell.jumpToDetailClosure = {
+                [weak self] (proId, shopId) in
+                if let jumpToDetailTransClosure = self?.jumpToDetailTransClosure {
+                    jumpToDetailTransClosure(proId, shopId)
+                }
+            }
             return cell
             return cell
         case 5:
         case 5:
             let cell = ProductDetailParameterTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
             let cell = ProductDetailParameterTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)

+ 14 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/ViewController/ProductDetailViewController.swift

@@ -185,6 +185,20 @@ class ProductDetailViewController: BaseViewController {
     
     
     lazy var productDetailView: ProductDetailView = {
     lazy var productDetailView: ProductDetailView = {
         let productDetailView = ProductDetailView()
         let productDetailView = ProductDetailView()
+        productDetailView.jumpToShopTransClosure = {
+            [weak self] (shopName, shopId) in
+            let vc = ShopViewController()
+            vc.navigationBar.title = shopName
+            vc.shopId = shopId
+            self?.navigationController?.pushViewController(vc, animated: true)
+        }
+        productDetailView.jumpToDetailTransClosure = {
+            [weak self] (proId, shopId) in
+            let vc = ProductDetailViewController()
+            vc.productId = proId
+            vc.shopId = shopId
+            self?.navigationController?.pushViewController(vc, animated: true)
+        }
         return productDetailView
         return productDetailView
     }()
     }()