Alamofire.request(loginSTR, method: .post, parameters: para, encoding: URLEncoding.init(destination: .methodDependent), headers: ["Content-Type":"application/x-www-form-urlencoded","Accept":"application/json;charset=utf-8"]).responseJSON { (data) in}
class TBUploadDataManager: NSObject {
public static let share = TBUploadDataManager()
public func loginData(parameters:[String:String]?,
hostUrl:String,type:tbUploadType, comparBlock:@escaping (SessionManager.MultipartFormDataEncodingResult) -> Void){
Alamofire.upload(
multipartFormData: { multipartFormData in
if parameters != nil{
for parameter in parameters!{
multipartFormData.append((parameter.value.data(using: .utf8)!), withName: parameter.key, mimeType: type.rawValue)
}
}
},
to: hostUrl,
encodingCompletion: { encodingResult in
//把encodingResult返回出去
comparBlock(encodingResult)
}
)
}
}
//实现
TBUploadDataManager.share.loginData(parameters: para as! [String : String], hostUrl: loginSTR, type: tbUploadType.formdata) { (encodingResult) in
switch encodingResult {
case .success(let upload, _, _):
upload.responseJSON { response in