|
@@ -264,7 +264,7 @@ public class SwiftMoyaNetWorkManager: NSObject {
|
|
|
.subscribeOn(ConcurrentDispatchQueueScheduler(qos: .userInitiated))
|
|
|
.observeOn(MainScheduler.instance)
|
|
|
.subscribe(onSuccess: { [weak self] response in
|
|
|
- self?.getResponseStatusCode(response: response, isCustomAlert: isCustomAlert, completion: completion)
|
|
|
+ self?.getResponseStatusCode(response: response, completion: completion)
|
|
|
}) {
|
|
|
[weak self] (error) in
|
|
|
SwiftProgressHUD.shared().showText(error.localizedDescription)
|
|
@@ -281,7 +281,7 @@ public class SwiftMoyaNetWorkManager: NSObject {
|
|
|
/// - Parameters:
|
|
|
/// - target: 请求地址加参数
|
|
|
/// - completion: 请求成功回调
|
|
|
- func requestValue(target: MultiTarget,isCustomAlert:Bool = false,completion: @escaping successCallback) -> Void {
|
|
|
+ func requestValue(target: MultiTarget,completion: @escaping successCallback) -> Void {
|
|
|
//判断是否链接网络
|
|
|
if !isNetworkConnect{
|
|
|
SwiftProgressHUD.shared().showText("网络链接失败,请检查网络")
|
|
@@ -294,7 +294,7 @@ public class SwiftMoyaNetWorkManager: NSObject {
|
|
|
.subscribeOn(ConcurrentDispatchQueueScheduler(qos: .userInitiated))
|
|
|
.observeOn(MainScheduler.instance)
|
|
|
.subscribe(onSuccess: { [weak self] response in
|
|
|
- self?.getResponseValueStatusCode(response: response, isCustomAlert: isCustomAlert, completion: completion)
|
|
|
+ self?.getResponseValueStatusCode(response: response, completion: completion)
|
|
|
}) {
|
|
|
[weak self] (error) in
|
|
|
SwiftProgressHUD.shared().showText(error.localizedDescription)
|
|
@@ -311,7 +311,7 @@ public class SwiftMoyaNetWorkManager: NSObject {
|
|
|
/// - Parameters:
|
|
|
/// - target: 请求地址加参数
|
|
|
/// - completion: 请求成功回调
|
|
|
- func requestArray(target: MultiTarget,isCustomAlert:Bool = false,completion: @escaping successCallArrayback) -> Void {
|
|
|
+ func requestArray(target: MultiTarget,completion: @escaping successCallArrayback) -> Void {
|
|
|
//判断是否链接网络
|
|
|
if !isNetworkConnect{
|
|
|
SwiftProgressHUD.shared().showText("网络链接失败,请检查网络")
|
|
@@ -325,7 +325,7 @@ public class SwiftMoyaNetWorkManager: NSObject {
|
|
|
.observeOn(MainScheduler.instance)
|
|
|
.subscribe(onSuccess: { [weak self] response in
|
|
|
|
|
|
- self?.getResponseArrayStatusCode(response: response, isCustomAlert: isCustomAlert, completion: completion)
|
|
|
+ self?.getResponseArrayStatusCode(response: response, completion: completion)
|
|
|
}) {
|
|
|
[weak self] (error) in
|
|
|
SwiftProgressHUD.shared().showText(error.localizedDescription)
|
|
@@ -418,7 +418,7 @@ extension SwiftMoyaNetWorkManager {
|
|
|
/// - Parameters:
|
|
|
/// - response: 响应结果
|
|
|
/// - completion: 回调
|
|
|
- private func getResponseStatusCode(response:Response, isCustomAlert:Bool , completion: @escaping successCallback) -> Void {
|
|
|
+ private func getResponseStatusCode(response:Response, completion: @escaping successCallback) -> Void {
|
|
|
let json = try? JSON(response.mapJSON())
|
|
|
if response.statusCode == 200 {
|
|
|
let url = String(describing: response.request!.url!)
|
|
@@ -431,9 +431,8 @@ extension SwiftMoyaNetWorkManager {
|
|
|
if rootModel!.code == 0 {
|
|
|
completion(rootModel as Any)
|
|
|
}else if rootModel!.code == 1 {
|
|
|
- if !isCustomAlert {
|
|
|
- SwiftProgressHUD.shared().showText(rootModel!.msg ?? "信息有误!!!", textAlignment: .left)
|
|
|
- }
|
|
|
+ SwiftProgressHUD.shared().showText(rootModel!.msg ?? "信息有误!!!", textAlignment: .left)
|
|
|
+
|
|
|
if let falseCallback = self.falseCallback {
|
|
|
falseCallback()
|
|
|
}
|
|
@@ -470,7 +469,7 @@ extension SwiftMoyaNetWorkManager {
|
|
|
/// - Parameters:
|
|
|
/// - response: 响应结果
|
|
|
/// - completion: 回调
|
|
|
- private func getResponseValueStatusCode(response:Response, isCustomAlert:Bool , completion: @escaping successCallback) -> Void {
|
|
|
+ private func getResponseValueStatusCode(response:Response, completion: @escaping successCallback) -> Void {
|
|
|
let json = try? JSON(response.mapJSON())
|
|
|
if response.statusCode == 200 {
|
|
|
let url = String(describing: response.request!.url!)
|
|
@@ -482,9 +481,8 @@ extension SwiftMoyaNetWorkManager {
|
|
|
if rootModel!.code == 0 {
|
|
|
completion(rootModel?.data as Any)
|
|
|
}else if rootModel!.code == 1 {
|
|
|
- if !isCustomAlert {
|
|
|
- SwiftProgressHUD.shared().showText(rootModel!.msg ?? "信息有误!!!", textAlignment: .left)
|
|
|
- }
|
|
|
+ SwiftProgressHUD.shared().showText(rootModel!.msg ?? "信息有误!!!", textAlignment: .left)
|
|
|
+
|
|
|
if let falseCallback = self.falseCallback {
|
|
|
falseCallback()
|
|
|
}
|
|
@@ -522,7 +520,7 @@ extension SwiftMoyaNetWorkManager {
|
|
|
/// - Parameters:
|
|
|
/// - response: 响应结果 数组
|
|
|
/// - completion: 回调
|
|
|
- private func getResponseArrayStatusCode(response:Response, isCustomAlert:Bool , completion: @escaping successCallArrayback) -> Void {
|
|
|
+ private func getResponseArrayStatusCode(response:Response, completion: @escaping successCallArrayback) -> Void {
|
|
|
let json = try? JSON(response.mapJSON())
|
|
|
if response.statusCode == 200 {
|
|
|
let url = String(describing: response.request!.url!)
|
|
@@ -535,9 +533,7 @@ extension SwiftMoyaNetWorkManager {
|
|
|
let array = JSON(parseJSON: rootModel?.data ?? "").arrayObject ?? Array<Any>()
|
|
|
completion(array)
|
|
|
}else if rootModel!.code == 1 {
|
|
|
- if !isCustomAlert {
|
|
|
- SwiftProgressHUD.shared().showText(rootModel!.msg ?? "信息有误!!!", textAlignment: .left)
|
|
|
- }
|
|
|
+ SwiftProgressHUD.shared().showText(rootModel!.msg ?? "信息有误!!!", textAlignment: .left)
|
|
|
if let falseCallback = self.falseCallback {
|
|
|
falseCallback()
|
|
|
}
|
|
@@ -590,8 +586,10 @@ extension PrimitiveSequence where TraitType == SingleTrait, ElementType == Respo
|
|
|
let mapper = T(JSONString: rootModel!.data ?? "")
|
|
|
return Single<T?>.just(mapper)
|
|
|
}else if rootModel!.code == 1 {
|
|
|
+ SwiftProgressHUD.shared().showError(rootModel!.msg ?? "信息有误!!!")
|
|
|
return Single<T?>.just(nil)
|
|
|
}else {
|
|
|
+ SwiftProgressHUD.shared().showError(rootModel!.msg ?? "信息有误!!!")
|
|
|
return Single<T?>.just(nil)
|
|
|
}
|
|
|
}else if response.statusCode == 401 {
|
|
@@ -604,6 +602,8 @@ extension PrimitiveSequence where TraitType == SingleTrait, ElementType == Respo
|
|
|
}else {
|
|
|
let url = String(describing: response.request!.url!)
|
|
|
NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
+ SwiftProgressHUD.shared().showText(response.description)
|
|
|
+
|
|
|
return Single<T?>.just(nil)
|
|
|
}
|
|
|
|
|
@@ -637,7 +637,8 @@ extension PrimitiveSequence where TraitType == SingleTrait, ElementType == Respo
|
|
|
}else if rootModel!.code == 1 {
|
|
|
SwiftProgressHUD.shared().showText(rootModel!.msg ?? "信息有误!!!", textAlignment: .left)
|
|
|
return Single<[T]?>.just(nil)
|
|
|
- }else { SwiftProgressHUD.shared().showText(response.description)
|
|
|
+ }else {
|
|
|
+ SwiftProgressHUD.shared().showText(rootModel!.msg ?? "信息有误!!!", textAlignment: .left)
|
|
|
return Single<[T]?>.just(nil)
|
|
|
}
|
|
|
}else if response.statusCode == 401 {
|
|
@@ -650,6 +651,7 @@ extension PrimitiveSequence where TraitType == SingleTrait, ElementType == Respo
|
|
|
}else {
|
|
|
let url = String(describing: response.request!.url!)
|
|
|
NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
+ SwiftProgressHUD.shared().showText(response.description)
|
|
|
return Single<[T]?>.just(nil)
|
|
|
}
|
|
|
|