Browse Source

添加地址

Chris 5 years ago
parent
commit
d81c1a988c

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

@@ -449,6 +449,7 @@
 		BD28079B22B79BAB002AB976 /* PublishSelTopicCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD28079A22B79BAB002AB976 /* PublishSelTopicCollectionCell.swift */; };
 		BD28079E22B7AC2C002AB976 /* PublishSuccessController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD28079D22B7AC2C002AB976 /* PublishSuccessController.swift */; };
 		BD2807A022B7AD76002AB976 /* PublishShareBottomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD28079F22B7AD76002AB976 /* PublishShareBottomView.swift */; };
+		BD2807A222B7C5D5002AB976 /* SearchAddrNavigationbarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD2807A122B7C5D5002AB976 /* SearchAddrNavigationbarView.swift */; };
 		BD29A92E228F99780018CFC3 /* OrderCommentParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD29A92D228F99780018CFC3 /* OrderCommentParameterModel.swift */; };
 		BD2FCBE222B21CF70006D974 /* CommunityRecommendController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD2FCBE122B21CF70006D974 /* CommunityRecommendController.swift */; };
 		BD2FCBE422B244250006D974 /* RecommendDetailContentCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD2FCBE322B244250006D974 /* RecommendDetailContentCell.swift */; };
@@ -457,6 +458,7 @@
 		BD3474F522857B85000908C5 /* CommonPayHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD3474F422857B85000908C5 /* CommonPayHeader.swift */; };
 		BD3AA45822AE63EC00EF4F20 /* MessageMainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD3AA45722AE63EC00EF4F20 /* MessageMainViewController.swift */; };
 		BD3AA45F22AE6F2500EF4F20 /* MessagePlanetTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD3AA45E22AE6F2500EF4F20 /* MessagePlanetTableCell.swift */; };
+		BD432E3222B7EF1C00C93DDF /* PublishAddressPOIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD432E3122B7EF1C00C93DDF /* PublishAddressPOIView.swift */; };
 		BD6EDF48229007EA009A20FE /* OrderApplyRefundModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD6EDF47229007EA009A20FE /* OrderApplyRefundModel.swift */; };
 		BD7AB83622841A8B0030646A /* ShoppingCartPayOrderItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD7AB83522841A8B0030646A /* ShoppingCartPayOrderItemCell.swift */; };
 		BD7AB838228420310030646A /* ShoppingCartPayOrderHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD7AB837228420310030646A /* ShoppingCartPayOrderHeader.swift */; };
@@ -993,6 +995,7 @@
 		BD28079A22B79BAB002AB976 /* PublishSelTopicCollectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishSelTopicCollectionCell.swift; sourceTree = "<group>"; };
 		BD28079D22B7AC2C002AB976 /* PublishSuccessController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishSuccessController.swift; sourceTree = "<group>"; };
 		BD28079F22B7AD76002AB976 /* PublishShareBottomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishShareBottomView.swift; sourceTree = "<group>"; };
+		BD2807A122B7C5D5002AB976 /* SearchAddrNavigationbarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchAddrNavigationbarView.swift; sourceTree = "<group>"; };
 		BD29A92D228F99780018CFC3 /* OrderCommentParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCommentParameterModel.swift; sourceTree = "<group>"; };
 		BD2FCBE122B21CF70006D974 /* CommunityRecommendController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityRecommendController.swift; sourceTree = "<group>"; };
 		BD2FCBE322B244250006D974 /* RecommendDetailContentCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendDetailContentCell.swift; sourceTree = "<group>"; };
@@ -1001,6 +1004,7 @@
 		BD3474F422857B85000908C5 /* CommonPayHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonPayHeader.swift; sourceTree = "<group>"; };
 		BD3AA45722AE63EC00EF4F20 /* MessageMainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageMainViewController.swift; sourceTree = "<group>"; };
 		BD3AA45E22AE6F2500EF4F20 /* MessagePlanetTableCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagePlanetTableCell.swift; sourceTree = "<group>"; };
+		BD432E3122B7EF1C00C93DDF /* PublishAddressPOIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishAddressPOIView.swift; sourceTree = "<group>"; };
 		BD6EDF47229007EA009A20FE /* OrderApplyRefundModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundModel.swift; sourceTree = "<group>"; };
 		BD7AB83522841A8B0030646A /* ShoppingCartPayOrderItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartPayOrderItemCell.swift; sourceTree = "<group>"; };
 		BD7AB837228420310030646A /* ShoppingCartPayOrderHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartPayOrderHeader.swift; sourceTree = "<group>"; };
@@ -3692,6 +3696,8 @@
 			isa = PBXGroup;
 			children = (
 				BD28078C22B76A8C002AB976 /* PublishAddAddressController.swift */,
+				BD2807A122B7C5D5002AB976 /* SearchAddrNavigationbarView.swift */,
+				BD432E3122B7EF1C00C93DDF /* PublishAddressPOIView.swift */,
 			);
 			path = PublishAddAddress;
 			sourceTree = "<group>";
@@ -4427,6 +4433,7 @@
 				BD3474F522857B85000908C5 /* CommonPayHeader.swift in Sources */,
 				BD1FC1A322B1075F00D55081 /* UIView+LX_Frame.m in Sources */,
 				A71AF0B6226EF99A001730FE /* SearchResultViewController.swift in Sources */,
+				BD2807A222B7C5D5002AB976 /* SearchAddrNavigationbarView.swift in Sources */,
 				A757C9302274839900226355 /* SelfMentionAddressListModel.swift in Sources */,
 				BDD22F0B228FAA5B00D43BFB /* ImageUrlModel.swift in Sources */,
 				A72A72D522321E2700B21995 /* ColorMacro.swift in Sources */,
@@ -4555,6 +4562,7 @@
 				A7A98E3A2280312C005306E9 /* ShoppingMallCategoryTableViewCell.swift in Sources */,
 				BD12203622AF807C0051C7C2 /* MessagePlanetActivityController.swift in Sources */,
 				A7778CAB2244B12500C7C47A /* CountDownManager.swift in Sources */,
+				BD432E3222B7EF1C00C93DDF /* PublishAddressPOIView.swift in Sources */,
 				A775CBFE2237493600EBDCF8 /* ShoppingMallNavigationBarView.swift in Sources */,
 				A71AA5212272E527008FF1A5 /* Extension+UINavigationController.swift in Sources */,
 				A7CC751822716202003C4F38 /* SetView.swift in Sources */,

+ 24 - 3
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishAddAddress/PublishAddAddressController.swift

@@ -26,7 +26,11 @@ class PublishAddAddressController: BaseViewController {
     }
     
     override func setupViews() {
-        navigationBar.title = "选择默认地址"
+        navigationBar.wr_setLeftButton(title: "", titleColor: UIColor.clear)
+        navigationBar.onClickLeftButton = nil
+        navigationBar.addSubview(navigationBarView)
+        
+        
         view.addSubview(addressPOIView)
         addressPOIView.locationAddress = locationAddress
         addressPOIView.longitude = longitude
@@ -35,14 +39,31 @@ class PublishAddAddressController: BaseViewController {
     }
     
     override func setupLayouts() {
+        navigationBarView.snp.makeConstraints { (make) in
+            make.top.equalTo(kSafeStatusBarHeight)
+            make.bottom.left.right.equalToSuperview()
+        }
         addressPOIView.snp.makeConstraints { (make) in
             make.top.equalTo(navigationBar.snp.bottom)
             make.left.right.bottom.equalToSuperview()
         }
     }
     
-    private lazy var addressPOIView: AddressPOIView = {
-        let addressPOIView = AddressPOIView()
+    private lazy var navigationBarView: SearchAddrNavigationbarView = {
+        let navigationBarView = SearchAddrNavigationbarView()
+        navigationBarView.cancelBlock = {
+            [weak self] in
+            self?.navigationController?.popViewController(animated: true)
+        }
+        navigationBarView.searchBlock = {
+            [weak self] keyword in
+            print("----search")
+        }
+        return navigationBarView
+    }()
+    
+    private lazy var addressPOIView: PublishAddressPOIView = {
+        let addressPOIView = PublishAddressPOIView()
         addressPOIView.didSelectBlock = { [weak self] (latitude:String,longitude:String,address:String) in
             if let didSelectBlock = self?.didSelectBlock {
                 didSelectBlock(latitude ,longitude ,address)

+ 184 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishAddAddress/PublishAddressPOIView.swift

@@ -0,0 +1,184 @@
+//
+//  PublishAddressPOIView.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/17.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+import RxSwift
+import RxCocoa
+
+class PublishAddressPOIView: BaseView {
+    
+    typealias DidSelectBlock = (_ latitude:String,_ longitude:String,_ address:String) -> Void
+    var didSelectBlock : DidSelectBlock?
+    
+    var suggestionList : Array<BMKSuggestionInfo>?
+    
+    var locationAddress: String? {
+        didSet {
+            tableView.reloadSections([0], with: UITableView.RowAnimation.fade)
+        }
+    }
+    /// 纬度
+    var latitude : String = LocationModel.shared().getLocationModel()?.latitude ?? "34.20840377740726"
+    /// 经度
+    var longitude : String = LocationModel.shared().getLocationModel()?.longitude ?? "108.96265686107972"
+    
+    
+    
+    override func setupViews() {
+        
+        addSubview(searchBgView)
+        
+        searchBgView.addSubview(bottomLine)
+        searchBgView.addSubview(addressLabel)        
+        addSubview(tableView)
+        
+    }
+    
+    override func setupLayouts() {
+        searchBgView.snp.makeConstraints { (make) in
+            make.top.left.right.equalToSuperview()
+            make.height.equalTo(kScaleValue(value: 60))
+        }
+        bottomLine.snp.makeConstraints { (make) in
+            make.left.right.bottom.equalToSuperview()
+            make.height.equalTo(0.5)
+        }
+        
+        addressLabel.snp.remakeConstraints { (make) in
+            make.centerY.equalTo(searchBgView.snp.centerY)
+            make.left.equalTo(kScaleValue(value: 8))
+        }
+        
+        tableView.snp.makeConstraints { (make) in
+            make.top.equalTo(searchBgView.snp.bottom)
+            make.left.right.bottom.equalToSuperview()
+        }
+        
+    }
+    
+    private lazy var searchBgView: UIView = {
+        let searchBgView = UIView()
+        searchBgView.backgroundColor = kffffffColor
+        return searchBgView
+    }()
+    
+    private lazy var addressLabel: UILabel = {
+        let addressLabel = UILabel()
+        addressLabel.text = LocationModel.shared().getLocationModel()?.city ?? "西安市"
+        addressLabel.textColor = k999999Color
+        addressLabel.font = kScaleRegularFont14
+        return addressLabel
+    }()
+    
+//    private lazy var searchTextField: UITextField = {
+//        let searchTextField = UITextField()
+//        searchTextField.placeholder = "输入地理位置"
+//        searchTextField.tintColor = kFFA42FColor
+//        searchTextField.textColor = k333333Color
+//        searchTextField.returnKeyType = .done
+//        searchTextField.font = kScaleRegularFont14
+//        searchTextField.borderStyle = .none
+//        searchTextField.rx.text.orEmpty.changed.subscribe(onNext: { (text) in
+//
+//            BaiduMapManager.shared.suggestionSearchPoi(cityname:LocationModel.shared().getLocationModel()?.city ?? "西安市", keyword: text)
+//            BaiduMapManager.shared.suggestionSearchSuccessBlock = {
+//                [weak self] (suggestionList:Array<BMKSuggestionInfo>) in
+//                self?.suggestionList = suggestionList
+//                self?.tableView.reloadSections([1], with: UITableView.RowAnimation.fade)
+//            }
+//        }).disposed(by: disposeBag)
+//        return searchTextField
+//    }()
+    
+    private lazy var bottomLine: UILabel = {
+        let bottomLine = UILabel()
+        bottomLine.backgroundColor = kf5f5f5Color
+        return bottomLine
+    }()
+    
+    private lazy var tableView: UITableView = {
+        let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.plain)
+        tableView.delegate = self
+        tableView.dataSource = self
+        tableView.backgroundColor = kffffffColor
+        tableView.estimatedRowHeight = kScaleValue(value: 48)
+        tableView.separatorStyle = .none
+        return tableView
+    }()
+    
+}
+
+// MARK: - UITableViewDataSource,UITableViewDelegate
+extension PublishAddressPOIView:UITableViewDataSource,UITableViewDelegate {
+    
+    func numberOfSections(in tableView: UITableView) -> Int {
+        return 2
+    }
+    
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        switch section {
+        case 0:
+            return 1
+        case 1:
+            if self.suggestionList != nil {
+                return self.suggestionList!.count
+            }else {
+                return 0
+            }
+        default:
+            return 1
+        }
+    }
+    
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let cell = AddressPOITableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+        switch indexPath.section {
+        case 0:
+            cell.locationAddress = locationAddress
+            cell.refreshButtonBlock = {
+                BaiduMapManager.shared.startLocation()
+                BaiduMapManager.shared.locationSuccessBlock = {
+                    [weak self] in
+                    let locationModel = LocationModel.shared().getLocationModel()
+                    self?.locationAddress = locationModel?.toString()
+                }
+                BaiduMapManager.shared.locationFalseBlock = {
+                    SwiftProgressHUD.shared().showText("定位失败\n重新定位", textAlignment: NSTextAlignment.center)
+                }
+            }
+            break
+        default:
+            cell.suggestionInfo = self.suggestionList?[indexPath.row]
+            break
+        }
+        return cell
+    }
+    
+    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        
+        if let didSelectBlock = self.didSelectBlock {
+            switch indexPath.section {
+            case 0:
+                didSelectBlock(self.latitude,self.longitude,self.locationAddress ?? "")
+                break
+            default:
+                let locationModel = LocationModel.shared().getLocationModel()
+                let suggestionList = self.suggestionList?[indexPath.row]
+                let city = suggestionList?.city ?? ""
+                let district = suggestionList?.district ?? ""
+                let key = suggestionList?.key ?? ""
+                let latitude = "\(suggestionList?.location.latitude ?? 0)"
+                let longitude = "\(suggestionList?.location.longitude ?? 0)"
+                let toString = locationModel!.province  + city + district  + key
+                didSelectBlock(latitude,longitude,toString)
+                break
+            }
+        }
+    }
+    
+}

+ 97 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishAddAddress/SearchAddrNavigationbarView.swift

@@ -0,0 +1,97 @@
+//
+//  SearchAddrNavigationbarView.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/17.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class SearchAddrNavigationbarView: BaseView {
+    
+    typealias CancelBlock = () -> Void
+    var cancelBlock : CancelBlock?
+    
+    typealias SearchBlock = (_ keyWord:String) -> Void
+    var searchBlock : SearchBlock?
+    
+    override func setupViews() {
+        addSubview(backBtn)
+        addSubview(searchbgView)
+        searchbgView.addSubview(searchIconImageView)
+        searchbgView.addSubview(searchTextField)
+    }
+    
+    override func setupLayouts() {
+        backBtn.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.left.equalToSuperview().offset(11)
+            make.width.equalTo(32)
+            make.height.equalTo(32)
+        }
+        searchbgView.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.left.equalTo(backBtn.snp_right).offset(5)
+            make.right.equalTo(-14)
+            make.height.equalTo(30)
+        }
+        searchIconImageView.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.left.equalTo(12)
+            make.size.equalTo(18)
+        }
+        searchTextField.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.left.equalTo(searchIconImageView.snp.right).offset( 8)
+            make.right.equalToSuperview().offset(8)
+            make.height.equalTo(30)
+        }
+    }
+    
+    private lazy var backBtn: UIButton = {
+        let backBtn = UIButton(type: UIButton.ButtonType.custom)
+        backBtn.setImage(kImage(name: "navbar_back_black"), for: .normal)
+        backBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
+            if let cancelBlock = self?.cancelBlock {
+                cancelBlock()
+            }
+        }).disposed(by: disposeBag)
+        return backBtn
+    }()
+    
+    private lazy var searchbgView: UIView = {
+        let searchbgView = UIView()
+        searchbgView.backgroundColor = kf7f8faColor
+        searchbgView.cornerRadius = 15
+        searchbgView.masksToBounds = true
+        return searchbgView
+    }()
+    
+    private lazy var searchIconImageView: UIImageView = {
+        let searchIconImageView = UIImageView()
+        searchIconImageView.image = kImage(name: "navbar_search")
+        return searchIconImageView
+    }()
+    
+    private lazy var searchTextField: UITextField = {
+        let searchTextField = UITextField()
+        searchTextField.placeholder = "请输入商品名称"
+        searchTextField.tintColor = kFFA42FColor
+        searchTextField.textColor = k333333Color
+        searchTextField.returnKeyType = .search
+        searchTextField.font = kScaleRegularFont14
+        searchTextField.borderStyle = .none
+        searchTextField.rx.controlEvent([.editingDidEndOnExit]).asObservable().subscribe(onNext: {
+            [weak self] (text) in
+            
+            if searchTextField.text?.count ?? 0 > 0 {
+                self?.endEditing(true)
+            }else {
+                SwiftProgressHUD.shared().showText("搜索地址不能为空")
+            }                        
+        }).disposed(by: disposeBag)
+        return searchTextField
+    }()
+    
+}