Browse Source

商品详情页、商户详情页通过购物车icon进入购物车进行操作后返回详情页,购物车商品数量默认

南鑫林 5 years ago
parent
commit
42079e4c39

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailProductInfo/ProductDetailProductInfoTableViewCell.swift

@@ -181,7 +181,7 @@ class ProductDetailProductInfoTableViewCell: UITableViewCell {
         shareButton.backgroundColor = kf5f5f5Color
         shareButton.setTitle("分享", for: UIControl.State.normal)
         shareButton.setTitleColor(k999999Color, for: UIControl.State.normal)
-        shareButton.setImage(kImage(name: ""), for: UIControl.State.normal)
+        shareButton.setImage(kImage(name: "goods_ico_share"), for: UIControl.State.normal)
         shareButton.titleLabel?.font = kRegularFont13
         let maskPath = UIBezierPath.init(roundedRect: CGRect(x: 0, y: 0, width: kScreenWidth, height: 24), byRoundingCorners: [.topLeft,.bottomLeft], cornerRadii: CGSize(width: 12, height: 12))
         let maskLayer = CAShapeLayer.init()

+ 27 - 5
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailProductLabel/ProductDetailProductLabelTableViewCell.swift

@@ -8,9 +8,13 @@
 
 import UIKit
 import SwiftyJSON
+import RxSwift
 
 class ProductDetailProductLabelTableViewCell: UITableViewCell {
     
+    
+    let disposeBag = DisposeBag()
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailProductLabelTableViewCell {
         let ID = "ProductDetailProductSkuTableViewCell"
         tableView.register(ProductDetailProductLabelTableViewCell.self, forCellReuseIdentifier: ID)
@@ -69,12 +73,28 @@ class ProductDetailProductLabelTableViewCell: UITableViewCell {
         }
     }
     
-    lazy var bgView : UIView = {
-        let bgView = UIView()
+    lazy var bgView : UIButton = {
+        let bgView = UIButton(type: UIButton.ButtonType.custom)
+        bgView.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            if !(self?.productDetailModel?.report?.isEmpty ?? true) {
+                let vc = BrowsePicturesViewController.init(images: (self?.productDetailModel?.report)!, index: 0)
+                self?.responderViewController()?.navigationController?.pushViewController(vc, animated: true)
+            }
+        }).disposed(by: disposeBag)
         return bgView
     }()
-    
-    
+    //查找所在的ViewController
+    func responderViewController() -> UIViewController? {
+        for view in sequence(first: self.superview, next: { $0?.superview }) {
+            if let responder = view?.next {
+                if responder.isKind(of: UIViewController.self){
+                    return responder as? UIViewController
+                }
+            }
+        }
+        return nil
+    }
     
     private lazy var iconCollectionView: UICollectionView = {
         let iconCollectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: iconCollectionViewLayout)
@@ -100,14 +120,16 @@ class ProductDetailProductLabelTableViewCell: UITableViewCell {
     lazy var iconImageView : UIImageView = {
         let iconImageView = UIImageView()
         iconImageView.image = kImage(name: "common_jiancebaogao")
+        iconImageView.isUserInteractionEnabled = false
         return iconImageView
     }()
     
     lazy var titleLabel: UILabel = {
         let titleLabel = UILabel()
-        titleLabel.text = "检测机构"
+        titleLabel.text = "检测报告"
         titleLabel.textColor = k333333Color
         titleLabel.font = kRegularFont13
+        titleLabel.isUserInteractionEnabled = false
         return titleLabel
     }()
     

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailSkuView/ProductDetailSkuView.swift

@@ -266,7 +266,7 @@ class ProductDetailSkuView: FWPopupView {
             if self?.productCount ?? 1 < self?.productDetailSkuModel?.stock ?? 0 {
                 if self?.productDetailModel?.limitNumber ?? 0 > 0 {
                     if  self?.productCount ?? 1 >=  self?.productDetailModel?.limitNumber ?? 1{
-                        SwiftProgressHUD.shared().showText("该数量已是库存数量",view: self!)
+                        SwiftProgressHUD.shared().showText("该数量已是限购数量",view: self!)
                     }else {
                         self?.productCount += 1
                         self?.numberLabel.text = "\(self?.productCount ?? 0)"

+ 5 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/ViewController/ProductDetailViewController.swift

@@ -24,6 +24,11 @@ class ProductDetailViewController: BaseViewController {
     var shopId : Int?
     
     var productDetailModel : ProductDetailModel?
+    
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        self.productGetCartCountApi()
+    }
 
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -50,7 +55,6 @@ class ProductDetailViewController: BaseViewController {
             self?.productDetailApi()
             self?.productListApi()
             self?.productCommentListApi()
-            self?.productGetCartCountApi()
         }
         
         observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("ProductDetailView"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in

+ 23 - 0
RainbowPlanet/RainbowPlanet/Supporting Files/ShoppingCartModule.xcassets/goods_ico_share.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "goods_ico_share.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "goods_ico_share@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "goods_ico_share@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/ShoppingCartModule.xcassets/goods_ico_share.imageset/goods_ico_share.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/ShoppingCartModule.xcassets/goods_ico_share.imageset/goods_ico_share@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/ShoppingCartModule.xcassets/goods_ico_share.imageset/goods_ico_share@3x.png