CNLiveDigitalAuthViewModel.swift
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// CNLiveDigitalAuthViewModel.swift
// metaCode
//
// Created by zx on 2024/6/12.
// 上传头像-实名认知
import Foundation
import CNLiveRequestBastKit
class CNLiveDigitalAuthViewModel:NSObject{
/*
上传人脸实名图片
参数 name 姓名
参数 idNo 身份证号
参数 fileData 图片data
*/
static func postFaceImageDataWithParams(name:String,idNo:String,fileData:Data,resultBlock: @escaping downSlideResultBlock) {
let param = NSMutableDictionary()
param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
param.setValue(name, forKey: "name")
param.setValue(idNo, forKey: "idNo")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupShowResult(true)
let custom_param = NSMutableDictionary()
custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey, forKey: "appKey")
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.uploadNetwork(withURLString: APPBaseMCUrl+"/toolApi/verify", param: param as! [AnyHashable : Any]) { formData in
formData?.appendPart(withFileData: fileData as Data, name: "file", fileName: ".jpg", mimeType: "image/jpg")
} progressBlock: { progress in
print("已上传==>\(progress!.fractionCompleted*100)")
} completionBlock: { task, any, error in
print("completionBlock")
if (error != nil){
resultBlock(NSNull(),.failed)
}else{
if let dic = any as? Dictionary<String, Any>{
if let data = dic["data"] as? Bool{
if data == true{
resultBlock(true,.success)
}else{
resultBlock(NSNull(),.failed)
}
}
}else{
resultBlock(NSNull(),.failed)
}
}
}
}
}