218 lines
8.6 KiB
Mathematica
218 lines
8.6 KiB
Mathematica
![]() |
//
|
|||
|
// DDMyAuthorViewController.m
|
|||
|
// DingDangApp
|
|||
|
//
|
|||
|
// Created by apple on 2023/6/20.
|
|||
|
//
|
|||
|
|
|||
|
#import "DDMyAuthorViewController.h"
|
|||
|
#import "DDMyAuthorStatusViewController.h"
|
|||
|
#import <AliyunFaceAuthFacade/AliyunFaceAuthFacade.h>
|
|||
|
#import "DDAuthorTipsTableViewCell.h"
|
|||
|
#import "DDAuthorTitleTableViewCell.h"
|
|||
|
@interface DDMyAuthorViewController ()
|
|||
|
|
|||
|
@end
|
|||
|
|
|||
|
@implementation DDMyAuthorViewController
|
|||
|
|
|||
|
- (void)viewDidLoad {
|
|||
|
[super viewDidLoad];
|
|||
|
/*
|
|||
|
初始化SDK
|
|||
|
*/
|
|||
|
[AliyunFaceAuthFacade init];
|
|||
|
|
|||
|
[self defaultNavTitle:@"实名认证" hideLine:YES];
|
|||
|
[self creatV];
|
|||
|
// Do any additional setup after loading the view.
|
|||
|
}
|
|||
|
- (void)requestRealnameAuthenRequest{
|
|||
|
self.metaInfo = [NSDictionary new];
|
|||
|
self.metaInfo = [AliyunFaceAuthFacade getMetaInfo];
|
|||
|
if ([ToolsObject IsNullWithObject:self.metaInfo]){
|
|||
|
return;
|
|||
|
}
|
|||
|
NSMutableDictionary *parameter = [NSMutableDictionary dictionaryWithCapacity:0];
|
|||
|
[parameter setValue:[ToolsObject convertToJsonData:self.metaInfo] forKey:@"metaInfo"];
|
|||
|
WeakSelf(weakSelf)
|
|||
|
[NetworkRequest requestPOST:@"/user/main" parameters:parameter block:^(BaseResponse * _Nonnull response) {
|
|||
|
if (response.code == 200){
|
|||
|
NSString * certifyId = response.data[@"certifyId"];
|
|||
|
if (![ToolsObject IsNullWithObject:certifyId]){
|
|||
|
NSMutableDictionary *extParams = [NSMutableDictionary new];
|
|||
|
[extParams setValue:weakSelf forKey:@"currentCtr"];
|
|||
|
[AliyunFaceAuthFacade verifyWith:certifyId extParams:extParams onCompletion:^(ZIMResponse * _Nonnull response) {
|
|||
|
//1000:采集成功并且服务端成功
|
|||
|
//1001:用户被动退出
|
|||
|
//1003:用户主动退出
|
|||
|
//2002:网络失败
|
|||
|
//2003:设备时间设置不对
|
|||
|
//2006:服务端validate失败
|
|||
|
if (response.code == 1001){
|
|||
|
[SVProgressHUD showInfoWithStatus:@"认证失败,请稍后重试"];
|
|||
|
}else if (response.code == 1003){
|
|||
|
[SVProgressHUD showInfoWithStatus:@"认证失败,用户主动退出"];
|
|||
|
}else if (response.code == 2002){
|
|||
|
[SVProgressHUD showInfoWithStatus:@"认证失败,请检查网络"];
|
|||
|
}else if (response.code == 2003){
|
|||
|
[SVProgressHUD showInfoWithStatus:@"认证失败,请更换设备重试"];
|
|||
|
}else if (response.code == 2006){
|
|||
|
[SVProgressHUD showInfoWithStatus:@"认证失败,请重新认证"];
|
|||
|
}else{
|
|||
|
[weakSelf requestDescribeFace:certifyId reason:@"" verifyCode:response.code];
|
|||
|
}
|
|||
|
}];
|
|||
|
}
|
|||
|
}
|
|||
|
}];
|
|||
|
}
|
|||
|
- (void)requestDescribeFace:(NSString *)certifyId reason:(NSString *)reason verifyCode:(NSInteger)verifyCode{
|
|||
|
NSMutableDictionary *parameter = [NSMutableDictionary dictionaryWithCapacity:0];
|
|||
|
[parameter setValue:certifyId forKey:@"certifyId"];
|
|||
|
WeakSelf(weakSelf)
|
|||
|
[NetworkRequest requestPOST:@"/user/DescribeFace" parameters:parameter block:^(BaseResponse * _Nonnull response) {
|
|||
|
if (response.code == 200){
|
|||
|
NSString * name = response.data[@"name"];
|
|||
|
NSString * cardNo = response.data[@"cardNo"];
|
|||
|
if ([ToolsObject IsNullWithObject:response.data[@"result_code"]]) {
|
|||
|
DDRealNameModel * realnameModel = [DDRealNameModel new];
|
|||
|
realnameModel.name = name;
|
|||
|
realnameModel.cardNo = cardNo;
|
|||
|
realnameModel.remark = reason;
|
|||
|
if (verifyCode == 1000){
|
|||
|
realnameModel.status = 1;
|
|||
|
}else{
|
|||
|
realnameModel.status = 2;
|
|||
|
}
|
|||
|
[weakSelf pushAuthorStatusVC:realnameModel];
|
|||
|
return;
|
|||
|
}
|
|||
|
NSInteger result_code = [response.data[@"result_code"] integerValue];
|
|||
|
if(result_code ==0){
|
|||
|
DDRealNameModel * realnameModel = [DDRealNameModel new];
|
|||
|
realnameModel.name = name;
|
|||
|
realnameModel.cardNo = cardNo;
|
|||
|
realnameModel.remark = reason;
|
|||
|
if (verifyCode == 1000){
|
|||
|
realnameModel.status = 1;
|
|||
|
}else{
|
|||
|
realnameModel.status = 2;
|
|||
|
}
|
|||
|
[weakSelf pushAuthorStatusVC:realnameModel];
|
|||
|
}else if(result_code ==1){
|
|||
|
[SVProgressHUD showInfoWithStatus:@"认证异常"];
|
|||
|
}else if(result_code ==2){
|
|||
|
[SVProgressHUD showInfoWithStatus:@"未满18岁,不提供服务"];
|
|||
|
}else if(result_code ==3){
|
|||
|
[SVProgressHUD showInfoWithStatus:@"超过55岁,不提供服务"];
|
|||
|
}
|
|||
|
}else{
|
|||
|
[SVProgressHUD showInfoWithStatus:@"获取认证信息失败,请检查网络"];
|
|||
|
}
|
|||
|
}];
|
|||
|
}
|
|||
|
-(void)creatV
|
|||
|
{
|
|||
|
self.view.backgroundColor = [UIColor whiteColor];
|
|||
|
[self.view addSubview:self.tableView];
|
|||
|
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|||
|
make.bottom.right.left.equalTo(self.view);
|
|||
|
make.top.equalTo(self.view).offset(DDNavigationBarHeight());
|
|||
|
}];
|
|||
|
}
|
|||
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
|||
|
{
|
|||
|
return 1;
|
|||
|
}
|
|||
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
|||
|
{
|
|||
|
if (indexPath.row == 0) {
|
|||
|
return 358;
|
|||
|
}
|
|||
|
return 265 ;
|
|||
|
}
|
|||
|
|
|||
|
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
|||
|
return [[UIView alloc] init];
|
|||
|
}
|
|||
|
|
|||
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
|||
|
return CGFLOAT_MIN;
|
|||
|
}
|
|||
|
|
|||
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|||
|
{
|
|||
|
return 2;
|
|||
|
}
|
|||
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|||
|
|
|||
|
if (indexPath.row == 0) {
|
|||
|
DDAuthorTitleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DDAuthorTitleTableViewCell"];
|
|||
|
if (cell == nil) {
|
|||
|
cell = [[DDAuthorTitleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"DDAuthorTitleTableViewCell"];
|
|||
|
}
|
|||
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|||
|
WeakSelf(weakSelf)
|
|||
|
cell.openClickBlock = ^{
|
|||
|
[NetworkRequest requestPOST:@"/user/check/realname" parameters:@{} block:^(BaseResponse * _Nonnull response) {
|
|||
|
if ([ToolsObject IsNullWithObject:response.data]) {
|
|||
|
return;
|
|||
|
}
|
|||
|
if (response.code == 200) {
|
|||
|
DDRealNameModel *model = [DDRealNameModel yy_modelWithJSON:response.data];
|
|||
|
if (model.isAuthen == 1) {
|
|||
|
[weakSelf pushAuthorStatusVC:model];
|
|||
|
}else{
|
|||
|
[weakSelf requestRealnameAuthenRequest];
|
|||
|
}
|
|||
|
}
|
|||
|
}];
|
|||
|
};
|
|||
|
return cell ;
|
|||
|
}
|
|||
|
DDAuthorTipsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DDAuthorTipsTableViewCell"];
|
|||
|
if (cell == nil) {
|
|||
|
cell = [[DDAuthorTipsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"DDAuthorTipsTableViewCell"];
|
|||
|
}
|
|||
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|||
|
return cell ;
|
|||
|
}
|
|||
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
|||
|
|
|||
|
}
|
|||
|
/*
|
|||
|
跳转到显示认证状态
|
|||
|
*/
|
|||
|
- (void)pushAuthorStatusVC:(DDRealNameModel *)model {
|
|||
|
DDMyAuthorStatusViewController * statusVC = [[DDMyAuthorStatusViewController alloc] init];
|
|||
|
statusVC.realNameModel = model;
|
|||
|
statusVC.authenType = model.status;
|
|||
|
statusVC.isPopRoot = YES;
|
|||
|
[self.navigationController pushViewController:statusVC animated:YES];
|
|||
|
}
|
|||
|
- (UITableView *)tableView
|
|||
|
{
|
|||
|
if (!_tableView) {
|
|||
|
_tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
|
|||
|
_tableView.backgroundColor = [UIColor clearColor];
|
|||
|
_tableView.delegate =self;
|
|||
|
_tableView.dataSource =self;
|
|||
|
_tableView.showsVerticalScrollIndicator = NO;
|
|||
|
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|||
|
|
|||
|
}
|
|||
|
return _tableView;
|
|||
|
}
|
|||
|
/*
|
|||
|
#pragma mark - Navigation
|
|||
|
|
|||
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|||
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|||
|
// Get the new view controller using [segue destinationViewController].
|
|||
|
// Pass the selected object to the new view controller.
|
|||
|
}
|
|||
|
*/
|
|||
|
|
|||
|
@end
|