|
@@ -90,16 +90,17 @@ public class SWNetRequest: NSObject {
|
|
|
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
|
|
|
switch jsonResponse.result {
|
|
|
case .success:
|
|
|
let jsonData: Any = try! JSONSerialization.jsonObject(with: jsonResponse.data!, options: JSONSerialization.ReadingOptions.mutableContainers)
|
|
|
- debugPrint("response-success = \(jsonData)")
|
|
|
+ debugPrint("网络请求-成功:url = \(jsonResponse.request?.url?.absoluteString ?? ""),jsonData = \(jsonData)")
|
|
|
response(jsonData, nil, jsonResponse.metrics?.taskInterval.duration)
|
|
|
case .failure:
|
|
|
let code: Int? = jsonResponse.response?.statusCode
|
|
|
response(nil, PQError(msg: (code == -1009 || code == -1001) ? "网络不可用" : jsonResponse.error?.localizedDescription, code: code ?? 10001), jsonResponse.metrics?.taskInterval.duration)
|
|
|
- debugPrint("response-failure = \(String(describing: jsonResponse.error))")
|
|
|
+ debugPrint("网络请求-失败:url = \(jsonResponse.request?.url?.absoluteString ?? ""),error = \(String(describing: jsonResponse.error))")
|
|
|
}
|
|
|
}
|
|
|
}
|