소스 검색

店铺排序修改完

南鑫林 6 년 전
부모
커밋
e278ae967c

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

@@ -167,6 +167,7 @@
 		A7636AC52268139C00374F9E /* LocationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7636AC42268139C00374F9E /* LocationViewController.swift */; };
 		A7636AC822682BAF00374F9E /* LocationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7636AC722682BAF00374F9E /* LocationView.swift */; };
 		A76390EB2248E27A0067EEE0 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A76390EA2248E27A0067EEE0 /* UserNotifications.framework */; };
+		A7649B6922977A4300BCE9D1 /* ShopSectionHeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7649B6822977A4300BCE9D1 /* ShopSectionHeaderModel.swift */; };
 		A771F07C226D4E1C007999DB /* AddressPOITableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A771F07B226D4E1C007999DB /* AddressPOITableViewCell.swift */; };
 		A775CBFE2237493600EBDCF8 /* ShoppingMallNavigationBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A775CBFD2237493600EBDCF8 /* ShoppingMallNavigationBarView.swift */; };
 		A775CC00223774A300EBDCF8 /* ShoppingMallView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A775CBFF223774A300EBDCF8 /* ShoppingMallView.swift */; };
@@ -555,6 +556,7 @@
 		A7636AC42268139C00374F9E /* LocationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationViewController.swift; sourceTree = "<group>"; };
 		A7636AC722682BAF00374F9E /* LocationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationView.swift; sourceTree = "<group>"; };
 		A76390EA2248E27A0067EEE0 /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
+		A7649B6822977A4300BCE9D1 /* ShopSectionHeaderModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShopSectionHeaderModel.swift; sourceTree = "<group>"; };
 		A771F07B226D4E1C007999DB /* AddressPOITableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressPOITableViewCell.swift; sourceTree = "<group>"; };
 		A775CBFD2237493600EBDCF8 /* ShoppingMallNavigationBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingMallNavigationBarView.swift; sourceTree = "<group>"; };
 		A775CBFF223774A300EBDCF8 /* ShoppingMallView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingMallView.swift; sourceTree = "<group>"; };
@@ -1060,6 +1062,7 @@
 				A70B2C5D22886F4D00B2449F /* ShopViewTableViewCell.swift */,
 				A70B2C63228875DE00B2449F /* ShopViewShopInfoTableViewCell.swift */,
 				A70B2C5F228870CE00B2449F /* ShopSectionHeaderView.swift */,
+				A7649B6822977A4300BCE9D1 /* ShopSectionHeaderModel.swift */,
 			);
 			path = View;
 			sourceTree = "<group>";
@@ -3570,6 +3573,7 @@
 				A7CC750F22715AAC003C4F38 /* MessageDetailesTableViewCell.swift in Sources */,
 				A7B4E72D228176060012914A /* ProductMallBarChartCollectionViewCell.swift in Sources */,
 				A70B2C4E22884AE800B2449F /* ProductDetailDescriptionTableViewCell.swift in Sources */,
+				A7649B6922977A4300BCE9D1 /* ShopSectionHeaderModel.swift in Sources */,
 				A7CC7516227161D5003C4F38 /* SetViewController.swift in Sources */,
 				A7778CBA2244F14B00C7C47A /* Extension+UIViewController.swift in Sources */,
 				A7CC752C2271A1AE003C4F38 /* SetPasswordViewController.swift in Sources */,

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

@@ -9,7 +9,6 @@
 import UIKit
 import RxSwift
 
-
 /// 跳转方式
 ///
 /// - none: 默认

+ 15 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopSectionHeaderModel.swift

@@ -0,0 +1,15 @@
+//
+//  ShopSectionHeaderModel.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/5/24.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class ShopSectionHeaderModel: NSObject {
+    var priceState : Int = 0 // 0默认,1down,2up
+    var salesState : Int = 0 // 0默认,1down,2up
+    var state : Int = 0 // 0默认,1down,2up
+}

+ 54 - 39
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopSectionHeaderView.swift

@@ -38,28 +38,21 @@ class ShopSectionHeaderView: BaseView {
         priceButton.setTitle("价格", for: UIControl.State.normal)
         priceButton.setTitleColor(k333333Color, for: UIControl.State.normal)
         priceButton.titleLabel?.font = kRegularFont14
-        priceButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
-        priceButton.isSelected = true
-        priceState = 2
+        priceButton.setImage(kImage(name: "common_store_arrow_normal"), for: UIControl.State.normal)
         priceButton.rx.tap.subscribe(onNext: {
             [weak self] (data) in
-            self?.salesVolumeButton.isSelected = false
-            self?.salesState = 0
-            if priceButton.isSelected && self?.priceState == 2 {
-                self?.priceState = 1
-                priceButton.setImage(kImage(name: "common_store_arrow_down"), for: UIControl.State.normal)
-            }else if priceButton.isSelected && self?.priceState == 1 {
-                self?.priceState = 2
-                priceButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
-            }else {
-                priceButton.isSelected = true
-                self?.priceState = 2
-                
-                priceButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
-                
-                self?.salesVolumeButton.setImage(kImage(name: "common_store_arrow_normal"), for: UIControl.State.normal)
+            self?.shopSectionHeaderModel?.salesState = 0
+
+            if self?.shopSectionHeaderModel?.priceState == 0 && self?.shopSectionHeaderModel?.salesState == 0 {
+                self?.shopSectionHeaderModel?.priceState = 1
+            }else if self?.shopSectionHeaderModel?.priceState == 1 && self?.shopSectionHeaderModel?.salesState == 0 {
+                self?.shopSectionHeaderModel?.priceState = 2
+            }else if self?.shopSectionHeaderModel?.priceState == 2 && self?.shopSectionHeaderModel?.salesState == 0 {
+                self?.shopSectionHeaderModel?.priceState = 0
             }
-            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ShopVCDesc"), object: nil, userInfo: ["desc":self?.priceState as Any,"field_order":2])
+            self?.shopSectionHeaderModel?.state = (self?.shopSectionHeaderModel?.priceState)!
+
+            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ShopVCDesc"), object: self?.shopSectionHeaderModel?.priceState, userInfo: ["desc":self?.shopSectionHeaderModel as Any,"field_order":2])
 
         }).disposed(by: disposeBag)
         return priceButton
@@ -71,32 +64,54 @@ class ShopSectionHeaderView: BaseView {
         salesVolumeButton.setTitleColor(k333333Color, for: UIControl.State.normal)
         salesVolumeButton.titleLabel?.font = kRegularFont14
         salesVolumeButton.setImage(kImage(name: "common_store_arrow_normal"), for: UIControl.State.normal)
-        salesState = 0
         salesVolumeButton.rx.tap.subscribe(onNext: {
             [weak self] (data) in
-            self?.priceButton.isSelected = false
-            self?.priceState = 0
-            if salesVolumeButton.isSelected && self?.salesState == 2 {
-                self?.salesState = 1
-                salesVolumeButton.setImage(kImage(name: "common_store_arrow_down"), for: UIControl.State.normal)
-
-            }else if salesVolumeButton.isSelected && self?.salesState == 1 {
-                self?.salesState = 2
-                salesVolumeButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
-
-            }else {
-                salesVolumeButton.isSelected = true
-                self?.salesState = 2
-                self?.priceButton.setImage(kImage(name: "common_store_arrow_normal"), for: UIControl.State.normal)
-
-                salesVolumeButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
+            self?.shopSectionHeaderModel?.priceState = 0
 
+            if self?.shopSectionHeaderModel?.priceState == 0 && self?.shopSectionHeaderModel?.salesState == 0 {
+                self?.shopSectionHeaderModel?.salesState = 1
+            } else if self?.shopSectionHeaderModel?.priceState == 0 && self?.shopSectionHeaderModel?.salesState == 1 {
+                self?.shopSectionHeaderModel?.salesState = 2
+            } else if self?.shopSectionHeaderModel?.priceState == 0 && self?.shopSectionHeaderModel?.salesState == 2 {
+                self?.shopSectionHeaderModel?.salesState = 0
             }
-            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ShopVCDesc"), object: nil, userInfo: ["desc":self?.salesState as Any,"field_order":1])
+            self?.shopSectionHeaderModel?.state = (self?.shopSectionHeaderModel?.salesState)!
+            
+            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ShopVCDesc"), object: self?.shopSectionHeaderModel?.salesState, userInfo: ["desc":self?.shopSectionHeaderModel as Any,"field_order":1])
         }).disposed(by: disposeBag)
         return salesVolumeButton
     }()
     
-    
-
+    var shopSectionHeaderModel : ShopSectionHeaderModel?  {
+        didSet {
+            if shopSectionHeaderModel?.salesState == 0 {
+                salesVolumeButton.setImage(kImage(name: "common_store_arrow_normal"), for: UIControl.State.normal)
+            }
+            
+            if shopSectionHeaderModel?.salesState == 1 {
+                salesVolumeButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
+                
+            }
+            
+            if  shopSectionHeaderModel?.salesState == 2 {
+                salesVolumeButton.setImage(kImage(name: "common_store_arrow_down"), for: UIControl.State.normal)
+                
+            }
+            
+            if shopSectionHeaderModel?.priceState == 0 {
+                priceButton.setImage(kImage(name: "common_store_arrow_normal"), for: UIControl.State.normal)
+                
+            }
+            
+            if shopSectionHeaderModel?.priceState == 1 {
+                priceButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
+                
+            }
+            
+            if  shopSectionHeaderModel?.priceState == 2 {
+                priceButton.setImage(kImage(name: "common_store_arrow_down"), for: UIControl.State.normal)
+                
+            }
+        }
+    }
 }

+ 8 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopView.swift

@@ -39,6 +39,12 @@ class ShopView: BaseView {
         }
     }
     
+    var shopSectionHeaderModel : ShopSectionHeaderModel? {
+        didSet {
+            tableView.reloadData()
+        }
+    }
+    
     override func setupViews() {
         addSubview(tableView)
     }
@@ -61,6 +67,7 @@ class ShopView: BaseView {
         return tableView
     }()
     
+    
 }
 
 extension ShopView : UITableViewDelegate, UITableViewDataSource {
@@ -128,6 +135,7 @@ extension ShopView : UITableViewDelegate, UITableViewDataSource {
             return nil
         case 1:
             let view = ShopSectionHeaderView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 44))
+            view.shopSectionHeaderModel = self.shopSectionHeaderModel
             return view
         default:
             return nil

+ 7 - 3
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/ViewController/ShopViewController.swift

@@ -14,7 +14,7 @@ class ShopViewController: BaseViewController {
     var productSearchModelArray = Array<ProductSearchModel>()
     
     var fieldOrder : Int = 2
-    var desc : Int = 2
+    var shopSectionHeaderModel = ShopSectionHeaderModel()
     
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -46,6 +46,7 @@ class ShopViewController: BaseViewController {
         }
     }
     
+    
     override func setupData() {
         
         shopView.tableView.addHeaderWithHeader(withBeginRefresh: true, animation: false) { [weak self] (page) in
@@ -63,7 +64,8 @@ class ShopViewController: BaseViewController {
             .takeUntil(self.rx.deallocated) //页面销毁自动移除通知监听
             .subscribe(onNext: {
                 [weak self] notification in
-                self?.desc = notification.userInfo!["desc"] as! Int
+
+                self?.shopSectionHeaderModel = notification.userInfo!["desc"] as! ShopSectionHeaderModel
                 self?.fieldOrder = notification.userInfo!["field_order"] as! Int
                 self?.productListApi(page: 1)
             })
@@ -98,7 +100,7 @@ class ShopViewController: BaseViewController {
     /// 获取商家商品列表
     private func productListApi(page:Int) {
         
-        SwiftMoyaNetWorkServiceProduct.shared().productListApi(page: page, shopId: shopId ?? 0,desc: desc, fieldOrder: fieldOrder) {
+        SwiftMoyaNetWorkServiceProduct.shared().productListApi(page: page, shopId: shopId ?? 0,desc: self.shopSectionHeaderModel.state, fieldOrder: fieldOrder) {
             [weak self] (productListModel) -> (Void) in
             let productSearchListModel = productListModel as? ProductSearchListModel
             if productSearchListModel?.pagination?.currentPage ?? 1  <= productSearchListModel?.pagination?.totalPages ?? 1 {
@@ -109,6 +111,8 @@ class ShopViewController: BaseViewController {
                 }
                 self?.productSearchModelArray = (self?.productSearchModelArray)! + (productSearchListModel?.data!)!
                 self?.shopView.productSearchModelArray = self?.productSearchModelArray
+                self?.shopView.shopSectionHeaderModel = self?.shopSectionHeaderModel
+
             }else {
                 self?.shopView.tableView.endFooterNoMoreData()
             }