swift 313 && 314 Request.swift
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift 313 && 314 Request.swift相关的知识,希望对你有一定的参考价值。
if model.statusCode == 314 || model.statusCode == 313{
//Token
if model.statusCode == 314{
JXNet.tokenLoginNum += 1
JXLog(">>>tokenLoginNum:\(JXNet.tokenLoginNum)")
if JXNet.tokenLoginNum > 9 {
Consumer.current.logout()
return
}
}
if model.statusCode == 313{
let statusCode313 = "statusCode313"
if let dictString = (par as NSDictionary).sign() as? [AnyHashable : Any]{
let string = dictString.convertToJSONString()
UserDefaults.standard.set(">>>\(isAbsoluteURL ? "" : Constant.Base.URLString)\(url)" + string, forKey: statusCode313)
let result = (par as NSDictionary).getSignBegin()//内部存储UserDefualts
BUGReport.reportBugToServer(string: "\(string) \n \(result)")
}
}
//优先尝试校准时间戳, 然后重新拉取用户信息获得Token
Date.netTime(successBlock: {
Consumer.getToken(update: false, block: {
//在自动登陆成功以后会执行登陆成功推送,在这里断绝首页重新请求的问题,直接返回Error, 如果其他接口也发现类似问题, 直接去除重新请求逻辑
if url == "v5/challenge/selectAllGoingChallenges"{
handler(model)
}else{
JXNet.retryNum += 1
if JXNet.retryNum > 2{
JXNet.retryNum = 0
errorBlock()
}else{//重请求, 此次不再进行返回
JXNet.requestBase(url, par: par, method: method, isJSON: isJSON, isAbsoluteURL: isAbsoluteURL, isDelay: isDelay, timeout: timeout, handler: handler, error: errorBlock)
}
}
NotificationCenter.default.postNotificationOnMainThread(withName: kGETTOKENDONE.rawValue, object: nil, userInfo: ["url" : url])//并没有通知接收者
}, fallBlock: {//自动登录失败, 进入登录页面
JXNet.retryNum += 1
if JXNet.retryNum > 2{
JXNet.retryNum = 0
errorBlock()
}else{//重请求, 此次不再进行返回
JXNet.requestBase(url, par: par, method: method, isJSON: isJSON, isAbsoluteURL: isAbsoluteURL, isDelay: isDelay, timeout: timeout, handler: handler, error: errorBlock)
}
})
SVProgressHUD.dismiss()
}, failBlock: {
errorBlock()
SVProgressHUD.dismiss()
})
return
}
以上是关于swift 313 && 314 Request.swift的主要内容,如果未能解决你的问题,请参考以下文章
<LeetCode OJ> 26 / 264 / 313 Ugly Number (I / II / III)