Bladeren bron

地理位完成

南鑫林 5 jaren geleden
bovenliggende
commit
3b3510d41e

+ 25 - 0
RainbowPlanet/RainbowPlanet/Manager/WebViewJavascriptBridgeManager/WebViewJavascriptBridgeManager.swift

@@ -69,6 +69,21 @@ class WebViewJavascriptBridgeManager: NSObject {
         bridge?.callHandler("h5", data: dictionary)
     }
     
+    /// 返回地理位置
+    ///
+    /// - Parameter bridge: 交互对象
+    func callHandlerLocation(bridge: WebViewJavascriptBridge?,address:String? = "",latitude:String? = "",longitude:String? = "") {
+        var dictionary = Dictionary<String,Any>()
+        dictionary.updateValue("location", forKey: "type")
+        var locationDictionary = Dictionary<String,Any>()
+        locationDictionary.updateValue(address as Any, forKey: "address")
+        locationDictionary.updateValue(latitude as Any, forKey: "latitude")
+        locationDictionary.updateValue(longitude as Any, forKey: "longitude")
+        dictionary.updateValue(locationDictionary, forKey: "params")
+        NXLLog(JSON(dictionary))
+        bridge?.callHandler("h5", data: dictionary)
+    }
+    
     /// 发布
     ///
     /// - Parameter bridge: 交互对象
@@ -166,6 +181,16 @@ class WebViewJavascriptBridgeManager: NSObject {
             UIViewController.topMost?.navigationController?.pushViewController(vc, animated: true)
         }
         
+        // 选择地理位置结果
+        if wvjbModel?.modelType  == .location {
+            let vc = PublishAddAddressController()
+            vc.selectLocationClosure = {
+                [weak self] (address,latitude,longitude) in
+                self?.callHandlerLocation(bridge: bridge, address: address, latitude: latitude, longitude: longitude)
+            }
+            UIViewController.topMost?.navigationController?.pushViewController(vc, animated: true)
+        }
+        
         // 发布
         if wvjbModel?.modelType  == .publish {
             NXLLog(wvjbModel?.params?.status)

+ 2 - 0
RainbowPlanet/RainbowPlanet/Model/WVJBModel/WVJBModel.swift

@@ -19,6 +19,7 @@ import ObjectMapper
 /// - datepicker: 分享链接
 /// - selectTopic: 话题
 /// - publish: 点击发布
+/// - location: 定位
 enum WVJBModelType : String {
     case none = ""
     case share = "share"
@@ -33,6 +34,7 @@ enum WVJBModelType : String {
     case shareLink = "shareLink"
     case selectTopic = "selectTopic"
     case publish = "publish"
+    case location = "location"
 }
 /// WebViewJavascriptBridgeModel 简写 WVJBModel
 class WVJBModel:NSObject,Mappable{

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

@@ -113,7 +113,7 @@ class PublishAddressPOIView: BaseView {
         let disableShowButton = UIButton(type: UIButton.ButtonType.custom)
         disableShowButton.rx.tap.subscribe(onNext: { [weak self] in
             if let didSelectBlock = self?.didSelectBlock {
-                didSelectBlock((self?.latitude)!, (self?.longitude)!, "")
+                didSelectBlock("", "", "")
             }
         }).disposed(by: disposeBag)
         return disableShowButton

+ 2 - 2
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishAddAddress/ViewController/PublishAddAddressController.swift

@@ -22,7 +22,7 @@ class PublishAddAddressController: BaseViewController {
     }
     
     
-    typealias SelectLocationClosure = (_ address:String) -> Void
+    typealias SelectLocationClosure = (_ address:String,_ latitude:String? ,_ longitude:String?) -> Void
     var selectLocationClosure : SelectLocationClosure?
    
     
@@ -97,7 +97,7 @@ class PublishAddAddressController: BaseViewController {
         let addressPOIView = PublishAddressPOIView()
         addressPOIView.didSelectBlock = { [weak self] (latitude:String,longitude:String,address:String) in
             if let selectLocationClosure = self?.selectLocationClosure {
-                selectLocationClosure(address)
+                selectLocationClosure(address,latitude,longitude)
                 self?.navigationController?.popViewController(animated: true)
             }
             

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

@@ -55,6 +55,10 @@ class PublishEditController: BaseViewController {
     var pubContent: String = ""
     // 位置
     var locationStr: String = ""
+    // 纬度
+    var latitude: String = ""
+    // 经度
+    var longitude: String = ""
     
     // MARK: 控制器生命周期
     override func viewDidLoad() {
@@ -234,8 +238,10 @@ extension PublishEditController : UITableViewDelegate, UITableViewDataSource {
         case 4:
             let vc = PublishAddAddressController()
             vc.selectLocationClosure = {
-                [weak self] (address) in
+                [weak self] (address,latitude,longitude) in
                 self?.locationStr = address
+                self?.latitude = latitude ?? ""
+                self?.longitude = longitude ?? ""
                 self?.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
             }
             self.navigationController?.pushViewController(vc, animated: true)
@@ -298,6 +304,8 @@ extension PublishEditController {
         aliyunVodUpToYoPublishModel.title = self.pubTitle
         aliyunVodUpToYoPublishModel.content = self.pubContent
         aliyunVodUpToYoPublishModel.locationString = self.locationStr
+        aliyunVodUpToYoPublishModel.latitude = self.latitude
+        aliyunVodUpToYoPublishModel.longitude = self.longitude
         
         if self.mediaType == .video {
             aliyunVodUpToYoPublishModel.publishType = .video
@@ -313,8 +321,6 @@ extension PublishEditController {
             NotificationCenter.default.post(name: NSNotification.Name(rawValue: "DismissFromPublishEditVc"), object: aliyunVodUpToYoPublishModel)
             BaseTabbarViewController.shared.esTabBarController.selectedIndex = 0
         }
-//        self.dismissToWindowRootViewController(animated: false) {}
-
 
     }
     

+ 5 - 1
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceCommunity/SwiftMoyaNetWorkServiceCommunity.swift

@@ -133,7 +133,7 @@ public class SwiftMoyaNetWorkServiceCommunity: NSObject {
     ///   - imgs: 图集,type为image是必填,json字符串
     ///   - page: 分页
     ///   - completion: 回调
-    func communityPublishApi(type:String = "", img:String = "", topic_ids:String = "", video:String = "", title:String = "", content:String = "", location:String = "", imgs:String = "", completion: @escaping successCallBack,fail:@escaping failCallback) {
+    func communityPublishApi(type:String = "", img:String = "", topic_ids:String = "", video:String = "", title:String = "", content:String = "", location:String = "",lat:String = "",lng:String = "", imgs:String = "", completion: @escaping successCallBack,fail:@escaping failCallback) {
         var parameters = Dictionary<String,Any>()
         parameters.updateValue(type, forKey: "type")
         parameters.updateValue(img, forKey: "img")
@@ -142,6 +142,10 @@ public class SwiftMoyaNetWorkServiceCommunity: NSObject {
         parameters.updateValue(title, forKey: "title")
         parameters.updateValue(content, forKey: "content")
         parameters.updateValue(location, forKey: "location")
+        if lat != "" {
+            parameters.updateValue(lat, forKey: "lat")
+            parameters.updateValue(lng, forKey: "lng")
+        }
         parameters.updateValue(imgs, forKey: "imgs")
         
         SwiftMoyaNetWorkManager.shared.requestObject(CommunityPublishModel.self, target: MultiTarget(SwiftMoyaServiceCommunityApi.communityPublish(parameters: parameters)), completion: { (CommunityPublishModel) in

+ 2 - 2
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceManger/SwiftMoyaNetWorkManager/ApiMacro.swift

@@ -5,8 +5,8 @@ let kBetaSever = false
 let kProductSever = false
 
 /// H5Service
-let kH5PersonalService = false
-let kH5DevelopSever = true
+let kH5PersonalService = true
+let kH5DevelopSever = false
 let kH5BetaSever = false
 let kH5ProductSever = false