|
@@ -85,13 +85,15 @@ public class SWNetRequest: NSObject {
|
|
|
}
|
|
|
|
|
|
/// 网络请求
|
|
|
- fileprivate class func requestData(method: HTTPMethod, encoding: ParameterEncoding, url: String, parames: [String: Any]?, timeoutInterval _: TimeInterval = timeoutInterval, response: @escaping completeHander) {
|
|
|
+ fileprivate class func requestData(method: HTTPMethod, encoding: ParameterEncoding, url: String, parames: [String: Any]?, timeoutInterval: TimeInterval = timeoutInterval, response: @escaping completeHander) {
|
|
|
if !bf_validURL(url: url) {
|
|
|
response(nil, PQError(msg: "非法地址", code: 0), nil)
|
|
|
return
|
|
|
}
|
|
|
debugPrint("网络请求-发起:url = \(url),parames = \(parames ?? [:])")
|
|
|
- AF.request(url, method: method, parameters: parames, encoding: encoding, headers: nil).responseJSON { jsonResponse in
|
|
|
+ AF.request(url, method: method, parameters: parames, encoding: encoding, headers: nil, requestModifier: { request in
|
|
|
+ request.timeoutInterval = timeoutInterval
|
|
|
+ }).validate().responseJSON { jsonResponse in
|
|
|
switch jsonResponse.result {
|
|
|
case .success:
|
|
|
let jsonData: Any = try! JSONSerialization.jsonObject(with: jsonResponse.data!, options: JSONSerialization.ReadingOptions.mutableContainers)
|