瀏覽代碼

no message

南鑫林 6 年之前
父節點
當前提交
0e3d62340e

+ 1 - 1
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -813,8 +813,8 @@
 				A70B2C442288408E00B2449F /* ProductDetailHotSell */,
 				A70B2C4122883B2F00B2449F /* ProductDetailShop */,
 				A70B2C3C2288259200B2449F /* ProductDetailEvaluation */,
-				A70B2C3A228819DC00B2449F /* ProductDetailProductInfo */,
 				A70B2C38228819B500B2449F /* ProductDetailProductSku */,
+				A70B2C3A228819DC00B2449F /* ProductDetailProductInfo */,
 			);
 			path = Cell;
 			sourceTree = "<group>";

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

@@ -203,14 +203,21 @@ class ProductDetailProductInfoTableViewCell: UITableViewCell {
                         let attributeString = NSMutableAttributedString(string:"¥\( sku.originPrice ?? 0)")
                         attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle(rawValue: NSUnderlineStyle.single.rawValue), color: UIColor.white)
                         markPriceLabel.attributedText = attributeString
-                        soldNumberLabel.text = "已售\(sku.originPrice ?? 0)"
                         stockLabel.text = "仅剩\(sku.stock ?? 0)"
                     }
                 }
             }
             titleLabel.text = productDetailModel?.name
-            timeLabel.text = "  次日达  "
             detailTitleLabel.text = productDetailModel?.subtitle
+            soldNumberLabel.text = "已售\(productDetailModel?.totalCount ?? 0)"
+            
+            if productDetailModel?.receiveType == 0 {
+                 timeLabel.text = "  次日达  "
+            }else if productDetailModel?.receiveType == 1 {
+                timeLabel.text = "  \(productDetailModel?.receiveTime ?? "")  "
+            }else if productDetailModel?.receiveType == 2 {
+                timeLabel.text = "  \(productDetailModel?.receiveTime ?? "")  "
+            }
             
         }
     }

+ 7 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailProductSku/ProductDetailProductSkuTableViewCell.swift

@@ -10,6 +10,13 @@ import UIKit
 
 class ProductDetailProductSkuTableViewCell: UITableViewCell {
     
+    var productDetailModel : ProductDetailModel? {
+        didSet {
+            
+        }
+    }
+    
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailProductSkuTableViewCell {
         let ID = "ProductDetailProductSkuTableViewCell"
         tableView.register(ProductDetailProductSkuTableViewCell.self, forCellReuseIdentifier: ID)

+ 28 - 6
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailView.swift

@@ -15,9 +15,24 @@ class ProductDetailView: BaseView {
     
     var index : Int? {
         didSet {
-            let reloadSection = 2 * index!
-            let indexPtah = IndexPath(row: 0, section: reloadSection)
-            tableView.scrollToRow(at: indexPtah, at: UITableView.ScrollPosition.top, animated: true)
+            if index == 0 {
+                tableView.scrollToTop()
+            }else {
+                let reloadSection = 2 * index!
+                let indexPtah = IndexPath(row: 0, section: reloadSection)
+                tableView.scrollToRow(at: indexPtah, at: UITableView.ScrollPosition.top, animated: true)
+//                UIEdgeInsets insets = self.collectionView.scrollIndicatorInsets;
+//
+//                CGRect rect = attr.frame;
+//                rect.size = self.collectionView.frame.size;
+//                rect.size.height -= insets.top + insets.bottom;
+//                CGFloat offset = (rect.origin.y + rect.size.height) - self.collectionView.contentSize.height;
+//                if ( offset > 0.0 ) rect = CGRectOffset(rect, 0, -offset);
+//
+//                [_collectionView scrollRectToVisible:rect animated:YES];
+
+            }
+           
         }
     }
     
@@ -197,6 +212,7 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
             return cell
         case 1:
             let cell = ProductDetailProductSkuTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.productDetailModel = productDetailModel
             cell.frame = tableView.bounds
             cell.layoutIfNeeded()
             cell.reloadData()
@@ -265,7 +281,13 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
         return nil
     }
     
+    func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
+        
+    }
+    
+    func scrollViewDidScroll(_ scrollView: UIScrollView) {
+        let offset = scrollView.contentOffset
+        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ProductDetailView"), object: offset)
+    }
+    
 }
-
-
-

+ 28 - 6
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/ViewController/ProductDetailViewController.swift

@@ -11,8 +11,13 @@ import JXSegmentedView
 
 class ProductDetailViewController: BaseViewController {
     
-    var productModel : ProductModel?
+    deinit {
+        NotificationCenter.default.removeObserver(observe!)
+    }
+    weak var observe : NSObjectProtocol?
     
+    var productModel : ProductModel?
+
     override func viewDidLoad() {
         super.viewDidLoad()
         setupViews()
@@ -21,7 +26,7 @@ class ProductDetailViewController: BaseViewController {
     }
     
     override func setupViews() {
-        navigationBar.wr_setBackgroundAlpha(alpha: 1)
+        navigationBar.wr_setBackgroundAlpha(alpha: 0)
         view.addSubview(productDetailView)
         view.insertSubview(navigationBar, aboveSubview: productDetailView)
         navigationBar.addSubview(segmentedView)
@@ -43,6 +48,18 @@ class ProductDetailViewController: BaseViewController {
             [weak self] (page) in
             self?.productDetailApi()
         }
+        
+        observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("ProductDetailView"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
+            let offset = notification.object as! CGPoint
+            if offset.y <= 0  {
+                self?.segmentedView.isHidden = true
+                self?.navigationBar.wr_setBackgroundAlpha(alpha: 0)
+            }else {
+                self?.segmentedView.isHidden = false
+                self?.navigationBar.wr_setBackgroundAlpha(alpha: 1)
+            }
+        }
+        
     }
     
     private func productDetailApi() {
@@ -63,6 +80,7 @@ class ProductDetailViewController: BaseViewController {
         segmentedView.delegate = self
         segmentedView.indicators = [indicator]
         segmentedView.dataSource = segmentedDataSource
+        segmentedView.isHidden = true
         return segmentedView
     }()
     
@@ -101,8 +119,14 @@ extension ProductDetailViewController : JXSegmentedViewDelegate {
     
     // 点击选中的情况才会调用该方法
     func segmentedView(_ segmentedView: JXSegmentedView, didClickSelectedItemAt index: Int) {
-        //传递didClickSelectedItemAt事件给listContainerView,必须调用!!!
-//        listContainerView.didClickSelectedItem(at: index)
+        if index == 0 {
+            self.segmentedView.isHidden = true
+            navigationBar.wr_setBackgroundAlpha(alpha: 0)
+        }else {
+            self.segmentedView.isHidden = false
+            navigationBar.wr_setBackgroundAlpha(alpha: 1)
+        }
+
         productDetailView.index = index
     }
     
@@ -113,8 +137,6 @@ extension ProductDetailViewController : JXSegmentedViewDelegate {
     
     // 正在滚动中的回调
     func segmentedView(_ segmentedView: JXSegmentedView, scrollingFrom leftIndex: Int, to rightIndex: Int, percent: CGFloat) {
-        //传递scrolling事件给listContainerView,必须调用!!!
-//        listContainerView.segmentedViewScrolling(from: leftIndex, to: rightIndex, percent: percent, selectedIndex: segmentedView.selectedIndex)
     }
     
     /// 是否允许点击选中目标index的item

+ 75 - 72
RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductDetailModel.swift

@@ -6,79 +6,82 @@ import Foundation
 import ObjectMapper
 
 class ProductDetailModel : NSObject, Mappable{
+    
+    class func newInstance(map: Map) -> Mappable?{
+        return ProductDetailModel()
+    }
+    required init?(map: Map){}
+    private override init(){}
 
-	var attributeCategoryId : Int?
-	var bigImg : String?
-	var categoryId1 : Int?
-	var categoryId2 : Int?
-	var categoryId3 : Int?
-	var city : [Int]?
-	var deliverType : Int?
-	var desc : String?
-	var id : Int?
-	var img : String?
-	var imgs : [String]?
-	var isConfirmSale : Int?
-	var label : [ProductDetailLabelModel]?
-	var limitNumber : Int?
-	var limitType : String?
-	var name : String?
-	var otherCode : String?
-	var parameter : [ProductDetailParameterModel]?
-	var receiveTime : String?
-	var receiveType : Int?
-	var report : [String]?
-	var saleName : String?
-	var shopId : Int?
-	var shopName : String?
-	var sku : [ProductDetailSkuModel]?
-	var spec : [ProductDetailSpecNameModel]?
-	var spuCode : String?
-	var storeTypeIds : String?
-	var subtitle : String?
-	var video : String?
-
-
-	class func newInstance(map: Map) -> Mappable?{
-		return ProductDetailModel()
-	}
-	required init?(map: Map){}
-	private override init(){}
-
-	func mapping(map: Map)
-	{
-		attributeCategoryId <- map["attribute_category_id"]
-		bigImg <- map["big_img"]
-		categoryId1 <- map["category_id1"]
-		categoryId2 <- map["category_id2"]
-		categoryId3 <- map["category_id3"]
-		city <- map["city"]
-		deliverType <- map["deliver_type"]
-		desc <- map["desc"]
-		id <- map["id"]
-		img <- map["img"]
-		imgs <- map["imgs"]
-		isConfirmSale <- map["is_confirm_sale"]
-		label <- map["label"]
-		limitNumber <- map["limit_number"]
-		limitType <- map["limit_type"]
-		name <- map["name"]
-		otherCode <- map["other_code"]
-		parameter <- map["parameter"]
-		receiveTime <- map["receive_time"]
-		receiveType <- map["receive_type"]
-		report <- map["report"]
-		saleName <- map["sale_name"]
-		shopId <- map["shop_id"]
-		shopName <- map["shop_name"]
-		sku <- map["sku"]
-		spec <- map["spec"]
-		spuCode <- map["spu_code"]
-		storeTypeIds <- map["store_type_ids"]
-		subtitle <- map["subtitle"]
-		video <- map["video"]
-		
-	}
+    var attributeCategoryId : Int?
+    var bigImg : String?
+    var categoryId1 : Int?
+    var categoryId2 : Int?
+    var categoryId3 : Int?
+    var city : [Int]?
+    var deliverType : Int?
+    var desc : String?
+    var id : Int?
+    var img : String?
+    var imgs : [String]?
+    var isConfirmSale : Int?
+    var limitNumber : Int?
+    var limitType : String?
+    var name : String?
+    var otherCode : String?
+    var receiveTime : String?
+    var receiveType : Int?
+    var report : [String]?
+    var saleName : String?
+    var shopId : Int?
+    var shopName : String?
+    var spuCode : String?
+    var storeTypeIds : String?
+    var subtitle : String?
+    var totalCount : Int?
+    var totalStock : Int?
+    var video : String?
+    var label : [ProductDetailLabelModel]?
+    var parameter : [ProductDetailParameterModel]?
+    var sku : [ProductDetailSkuModel]?
+    var spec : [ProductDetailSpecNameModel]?
+    
+    func mapping(map: Map)
+    {
+        attributeCategoryId <- map["attribute_category_id"]
+        bigImg <- map["big_img"]
+        categoryId1 <- map["category_id1"]
+        categoryId2 <- map["category_id2"]
+        categoryId3 <- map["category_id3"]
+        city <- map["city"]
+        deliverType <- map["deliver_type"]
+        desc <- map["desc"]
+        id <- map["id"]
+        img <- map["img"]
+        imgs <- map["imgs"]
+        isConfirmSale <- map["is_confirm_sale"]
+        label <- map["label"]
+        limitNumber <- map["limit_number"]
+        limitType <- map["limit_type"]
+        name <- map["name"]
+        otherCode <- map["other_code"]
+        parameter <- map["parameter"]
+        receiveTime <- map["receive_time"]
+        receiveType <- map["receive_type"]
+        report <- map["report"]
+        saleName <- map["sale_name"]
+        shopId <- map["shop_id"]
+        shopName <- map["shop_name"]
+        sku <- map["sku"]
+        spec <- map["spec"]
+        spuCode <- map["spu_code"]
+        storeTypeIds <- map["store_type_ids"]
+        subtitle <- map["subtitle"]
+        totalCount <- map["total_count"]
+        totalStock <- map["total_stock"]
+        video <- map["video"]
+        
+    }
 }
 
 class ProductDetailLabelModel : NSObject, Mappable{