Browse Source

Merge branch 'feature/liuxuqing' of http://git.caihongxingqiu.net/rainbow/platform-ios into feature/liuxuqing

Chris 6 years ago
parent
commit
a46f3b096d

+ 4 - 0
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -44,6 +44,7 @@
 		A71738A622897892000AEA6A /* SwiftMoyaServiceShopApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71738A522897892000AEA6A /* SwiftMoyaServiceShopApi.swift */; };
 		A71738A822897E96000AEA6A /* SwiftMoyaNetWorkServiceShop.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71738A722897E96000AEA6A /* SwiftMoyaNetWorkServiceShop.swift */; };
 		A71738AB22898660000AEA6A /* ShopModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71738AA22898660000AEA6A /* ShopModel.swift */; };
+		A71738AD228AB7B2000AEA6A /* ProductCommentListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71738AC228AB7B2000AEA6A /* ProductCommentListModel.swift */; };
 		A7190167227543DB00104A50 /* baidu_cityid_rel.json in Resources */ = {isa = PBXBuildFile; fileRef = A7190166227543DB00104A50 /* baidu_cityid_rel.json */; };
 		A71901692275464000104A50 /* ProvinceCityAreaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71901682275464000104A50 /* ProvinceCityAreaView.swift */; };
 		A719016B22757A5A00104A50 /* ProvinceCityAreaTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A719016A22757A5A00104A50 /* ProvinceCityAreaTableViewCell.swift */; };
@@ -365,6 +366,7 @@
 		A71738A522897892000AEA6A /* SwiftMoyaServiceShopApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftMoyaServiceShopApi.swift; sourceTree = "<group>"; };
 		A71738A722897E96000AEA6A /* SwiftMoyaNetWorkServiceShop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftMoyaNetWorkServiceShop.swift; sourceTree = "<group>"; };
 		A71738AA22898660000AEA6A /* ShopModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShopModel.swift; sourceTree = "<group>"; };
+		A71738AC228AB7B2000AEA6A /* ProductCommentListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProductCommentListModel.swift; sourceTree = "<group>"; };
 		A7190166227543DB00104A50 /* baidu_cityid_rel.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = baidu_cityid_rel.json; sourceTree = "<group>"; };
 		A71901682275464000104A50 /* ProvinceCityAreaView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProvinceCityAreaView.swift; sourceTree = "<group>"; };
 		A719016A22757A5A00104A50 /* ProvinceCityAreaTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProvinceCityAreaTableViewCell.swift; sourceTree = "<group>"; };
@@ -2087,6 +2089,7 @@
 				A70B2C0F2286A3BC00B2449F /* ProductDetailModel.swift */,
 				BDE3045C22851E4F001D050F /* ProductCartListModel.swift */,
 				BDE3045E228554CA001D050F /* ProductCartAmountModel.swift */,
+				A71738AC228AB7B2000AEA6A /* ProductCommentListModel.swift */,
 			);
 			path = ProductModel;
 			sourceTree = "<group>";
@@ -3079,6 +3082,7 @@
 				A75414FD224B5F28002480B5 /* MobileLoginViewController.swift in Sources */,
 				A771F07C226D4E1C007999DB /* AddressPOITableViewCell.swift in Sources */,
 				A72A72AE22321DE000B21995 /* CountdownButton.swift in Sources */,
+				A71738AD228AB7B2000AEA6A /* ProductCommentListModel.swift in Sources */,
 				A7A98E28227FD6C6005306E9 /* ShoppingMallListViewController.swift in Sources */,
 				A7B4E71F228131720012914A /* ProductSlidingLeftRightCollectionViewCell.swift in Sources */,
 				A77F2CB72232010F001BD3F6 /* MineViewController.swift in Sources */,

+ 12 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailEvaluation/ProductDetailEvaluationTableViewCell.swift

@@ -84,5 +84,17 @@ class ProductDetailEvaluationTableViewCell: UITableViewCell {
         evaluationLabel.attributedText = attributeString
         return evaluationLabel
     }()
+    
+    var productCommentModel : ProductCommentModel? {
+        didSet {
+//            avatarImageView.kf.setImage(with: kURLImage(name: productCommentModel? ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+            nickNameLabel.text = productCommentModel?.username
+            let attributeString = NSMutableAttributedString(string:productCommentModel?.content ?? "")
+            attributeString.changeAllLineSpacing(2)
+            evaluationLabel.attributedText = attributeString
+
+        }
+    }
+    
 
 }

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

@@ -54,6 +54,13 @@ class ProductDetailView: BaseView {
             tableView.reloadSections([4], with: UITableView.RowAnimation.none)
         }
     }
+    
+    var productCommentListModel :ProductCommentListModel? {
+        didSet {
+            tableView.reloadSections([2], with: UITableView.RowAnimation.none)
+        }
+    }
+    
 
     override func setupViews() {
         addSubview(bottomBgView)
@@ -200,6 +207,8 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
     
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         switch section {
+        case 2:
+            return productCommentListModel?.data?.isEmpty ?? true ? 0 :  1
         case 5:
             return productDetailModel?.parameter?.isEmpty ?? true ? 0 :  productDetailModel?.parameter?.count ?? 0
         default:
@@ -224,6 +233,7 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
             return cell
         case 2:
             let cell = ProductDetailEvaluationTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.productCommentModel = productCommentListModel?.data?[indexPath.row]
             return cell
         case 3:
             let cell = ProductDetailShopTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)

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

@@ -50,6 +50,7 @@ class ProductDetailViewController: BaseViewController {
             [weak self] (page) in
             self?.productDetailApi()
             self?.productListApi()
+            self?.productCommentListApi()
         }
         
         observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("ProductDetailView"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
@@ -111,6 +112,25 @@ class ProductDetailViewController: BaseViewController {
        
     }
     
+    func productCommentListApi() {
+        if self.productModel != nil {
+            SwiftMoyaNetWorkServiceProduct.shared().productCommentListApi(productId: productModel?.id ?? 0) {
+                [weak self] (productCommentListModel) -> (Void) in
+                let productCommentListModel = productCommentListModel as? ProductCommentListModel
+                self?.productDetailView.productCommentListModel = productCommentListModel
+
+            }
+        }
+        
+        if self.productSearchModel != nil {
+            SwiftMoyaNetWorkServiceProduct.shared().productCommentListApi(productId: productSearchModel?.id ?? 0) { [weak self] (productCommentListModel) -> (Void) in
+                    let productCommentListModel = productCommentListModel as? ProductCommentListModel
+                self?.productDetailView.productCommentListModel = productCommentListModel
+
+            }
+        }
+    }
+    
     
     lazy var productDetailView: ProductDetailView = {
         let productDetailView = ProductDetailView()

+ 70 - 0
RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductCommentListModel.swift

@@ -0,0 +1,70 @@
+//
+//	ProductCommentListModel.swift
+//	Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
+
+import Foundation 
+import ObjectMapper
+
+
+class ProductCommentListModel : NSObject, Mappable{
+
+	var data : [ProductCommentModel]?
+    var pagination : PaginationModel?
+
+
+	class func newInstance(map: Map) -> Mappable?{
+		return ProductCommentListModel()
+	}
+	required init?(map: Map){}
+	private override init(){}
+
+	func mapping(map: Map)
+	{
+		data <- map["data"]
+		pagination <- map["pagination"]
+		
+	}
+
+}
+
+class ProductCommentModel : NSObject, Mappable{
+    
+    var categoryName1 : String?
+    var categoryName2 : String?
+    var categoryName3 : String?
+    var content : String?
+    var createdAt : String?
+    var id : Int?
+    var imgs : [String]?
+    var productName : String?
+    var purchaseNo : String?
+    var shopName : String?
+    var star : Int?
+    var username : String?
+    
+    
+    class func newInstance(map: Map) -> Mappable?{
+        return ProductCommentModel()
+    }
+    required init?(map: Map){}
+    private override init(){}
+    
+    func mapping(map: Map)
+    {
+        categoryName1 <- map["category_name1"]
+        categoryName2 <- map["category_name2"]
+        categoryName3 <- map["category_name3"]
+        content <- map["content"]
+        createdAt <- map["created_at"]
+        id <- map["id"]
+        imgs <- map["imgs"]
+        productName <- map["product_name"]
+        purchaseNo <- map["purchase_no"]
+        shopName <- map["shop_name"]
+        star <- map["star"]
+        username <- map["username"]
+        
+    }
+    
+}
+

+ 18 - 0
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaNetWorkServiceProduct.swift

@@ -152,6 +152,24 @@ class SwiftMoyaNetWorkServiceProduct: NSObject {
         }
     }
     
+    // MARK: - 商品评价列表
+    /// 商品评价列表
+    ///
+    /// - Parameters:
+    ///   - productId: 商品id
+    ///   - completion: 回调
+    func productCommentListApi(page:Int = 1,productId:Int = 0, completion: @escaping apiCallBack) {
+        var parameters = Dictionary<String,Any>()
+        parameters.updateValue(productId, forKey: "product_id")
+        parameters.updateValue(page, forKey: "page")
+        
+        SwiftProgressHUD.shared().showWait()
+        SwiftMoyaNetWorkManager.shared().request(ProductCommentListModel.self,target: MultiTarget(SwiftMoyaServiceProductApi.productCommentList(parameters: parameters))) { (productCommentListModel) in
+            SwiftProgressHUD.shared().hide()
+            completion(productCommentListModel)
+        }
+    }
+    
     // MARK: - 购物车列表
     /// 购物车列表
     ///

+ 8 - 0
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaServiceProductApi.swift

@@ -65,6 +65,7 @@ public let kProductCartAllSelApi = "/cart/isSelectAll"
 /// - productHomeProduct: 首页商品
 /// - productDetail: 商品详情
 /// - productHotSale: 热销商品
+/// - productCommentList: 商品评价列表
 /// - productCartList: 购物车列表
 /// - productCartAdd: 购物车-添加
 /// - productCartDelete: 购物车-删除
@@ -77,6 +78,7 @@ public enum SwiftMoyaServiceProductApi {
     case productHomeProduct(parameters:Dictionary<String, Any>)
     case productDetail(parameters:Dictionary<String, Any>)
     case productHotSale(parameters:Dictionary<String, Any>)
+    case productCommentList(parameters:Dictionary<String, Any>)
     case productCartList(parameters:Dictionary<String, Any>)
     case productCartAdd(parameters:Dictionary<String, Any>)
     case productCartDelete(parameters:Dictionary<String, Any>)
@@ -94,6 +96,7 @@ extension SwiftMoyaServiceProductApi: TargetType {
              .productHomeProduct,
              .productDetail,
              .productHotSale,
+             .productCommentList,
              .productCartList,
              .productCartAdd,
              .productCartDelete,
@@ -117,6 +120,8 @@ extension SwiftMoyaServiceProductApi: TargetType {
             return kProductDetailApi
         case .productHotSale:
             return kProductHotSaleApi
+        case .productCommentList:
+            return kProductCommentListApi
         case .productCartList:
             return kProductCartListApi
         case .productCartAdd:
@@ -138,6 +143,7 @@ extension SwiftMoyaServiceProductApi: TargetType {
              .productCategory,
              .productHomeProduct,
              .productHotSale,
+             .productCommentList,
              .productCartList,
              .productDetail
             :
@@ -164,6 +170,7 @@ extension SwiftMoyaServiceProductApi: TargetType {
              .productHomeProduct(var parameters),
              .productDetail(var parameters),
              .productHotSale(var parameters),
+             .productCommentList(var parameters),
              .productCartList(var parameters),
              .productCartAdd(var parameters),
              .productCartDelete(var parameters),
@@ -197,6 +204,7 @@ extension SwiftMoyaServiceProductApi: TargetType {
              .productHomeProduct,
              .productDetail,
              .productHotSale,
+             .productCommentList,
              .productCartList,
              .productCartAdd,
              .productCartDelete,