Forráskód Böngészése

地址选择 -- logic fixed

Chris 5 éve
szülő
commit
48475b1270

+ 5 - 4
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishAddAddress/PublishAddAddressController.swift

@@ -10,8 +10,9 @@ import UIKit
 
 class PublishAddAddressController: BaseViewController {
     
-    typealias DidSelectBlock = (_ latitude:String,_ longitude:String,_ address:String) -> Void
-    var didSelectBlock : DidSelectBlock?
+    typealias SelectLocationClosure = (_ address:String) -> Void
+    var selectLocationClosure : SelectLocationClosure?
+    
     var locationAddress: String?
     /// 纬度
     var latitude : String = LocationModel.shared().getLocationModel()?.latitude ?? "34.20840377740726"
@@ -65,8 +66,8 @@ class PublishAddAddressController: BaseViewController {
     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)
+            if let selectLocationClosure = self?.selectLocationClosure {
+                selectLocationClosure(address)
                 self?.navigationController?.popViewController(animated: true)
             }
             

+ 3 - 1
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishAddAddress/PublishAddressPOIView.swift

@@ -104,7 +104,9 @@ class PublishAddressPOIView: BaseView {
     private lazy var disableShowButton: UIButton = {
         let disableShowButton = UIButton(type: UIButton.ButtonType.custom)
         disableShowButton.rx.tap.subscribe(onNext: { [weak self] in
-            print("----点击-不显示")
+            if let didSelectBlock = self?.didSelectBlock {
+                didSelectBlock(self!.latitude, self!.longitude, "")
+            }
         }).disposed(by: disposeBag)
         return disableShowButton
     }()

+ 9 - 3
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishEditController/Controller/PublishEditController.swift

@@ -49,7 +49,7 @@ class PublishEditController: BaseViewController {
     // 内容
     var pubContent: String = ""
     // 位置
-    var location: String = ""
+    var locationStr: String = ""
     // 视频id,当type为video时必填
     var paraVideo: String = ""
     
@@ -246,6 +246,7 @@ extension PublishEditController : UITableViewDelegate, UITableViewDataSource {
             return topicCell
         case 4:
             let addrCell = PublishEditAddAddressCell.cellWith(tableView: tableView, indexPath: indexPath)
+            addrCell.location = locationStr
             return addrCell
         default:
             return UITableViewCell()
@@ -273,11 +274,16 @@ extension PublishEditController : UITableViewDelegate, UITableViewDataSource {
                         self?.selTopicName.append(", \(topicModel.name!)")
                     }
                 }
-                self?.tableView.reloadData()
+                self?.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
             }
             self.navigationController?.pushViewController(vc, animated: true)
         case 4:
             let vc = PublishAddAddressController()
+            vc.selectLocationClosure = {
+                [weak self] (address) in
+                self?.locationStr = address
+                self?.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
+            }
             self.navigationController?.pushViewController(vc, animated: true)
         default:
             break
@@ -383,7 +389,7 @@ extension PublishEditController {
         
         print("----mediaType == \(typeStr)\n----pubTitle = \(pubTitle)\n----topicJsonStr == \(topicJsonStr)\n----imgsJsonStr == \(imgsJsonStr)")
         
-        SwiftMoyaNetWorkServiceCommunity.shared().communityPublishApi(type: typeStr, img: majorImageUrl ?? "", topic_ids: topicJsonStr, video: paraVideo, title: pubTitle, content: pubContent, location: "", imgs: imgsJsonStr) {
+        SwiftMoyaNetWorkServiceCommunity.shared().communityPublishApi(type: typeStr, img: majorImageUrl ?? "", topic_ids: topicJsonStr, video: paraVideo, title: pubTitle, content: pubContent, location: locationStr, imgs: imgsJsonStr) {
             [weak self] (communityPublishModel) -> (Void) in
             let communityPublishModel = communityPublishModel as? CommunityPublishModel
             print("----发布成功")

+ 12 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishEditController/View/PublishEditAddAddressCell.swift

@@ -10,6 +10,18 @@ import UIKit
 
 class PublishEditAddAddressCell: UITableViewCell {
     
+    var location: String? {
+        didSet {
+            if self.location != "" {
+                subLabel.text = self.location
+                iconImageView.image = kImage(name: "edit_ico_address_pre")
+            } else {
+                subLabel.text = "(打卡地点,结识附近的彩虹居民)"
+                iconImageView.image = kImage(name: "edit_ico_address")
+            }
+        }
+    }
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> PublishEditAddAddressCell {
         let ID = "PublishEditAddAddressCell"
         tableView.register(PublishEditAddAddressCell.self, forCellReuseIdentifier: ID)