JLChen
2021-11-04 1443556e9ccb1a19ed8e6710c16c8adc4d4f4fb3
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
//
//  Copyright © 2019 dahua. All rights reserved.
//
 
#import "LCAccountPresenter.h"
 
@implementation LCAccountPresenter
 
- (instancetype)init {
    if (self = [super init]) {
        
    }
    return self;
}
 
//输入Appid
- (void)accountJointClickAction:(LCButton *)sender {
    switch (sender.tag) {
        case 1000: {
            //点击确认按钮事件
            [self.container.view endEditing:YES];
              
 
            if (![self accountJointVaildCheck]) {
                return;
            }
        }
            break;
        default: {
        }
            break;
    }
}
 
//选择对接模式页面点击事件
- (void)modeSelectBtnClick:(LCButton *)sender {
    switch (sender.tag) {
        case 1001: {
            //对接管理员模式
            [self getManagerModeToken];
        }
            break;
        case 1002: {
            //了解管理员模式
            [self.container.navigationController pushToManagerModeIntroduce];
        }
            break;
        case 1003: {
            //对接用户模式
            [self.container.navigationController pushToUserModeLogin];
        }
            break;
        case 1004: {
            //了解用户模式
            [self.container.navigationController pushToUserModeIntroduce];
        }
            break;
        default:
            break;
    }
}
 
//用户注册页面点击事件
- (void)userModeRegisterBtnClick:(LCButton *)sender {
    if (sender.tag == 1002) {
        //免验证注册
         self.isAvoidRegister = YES;
    }
    [self registerParamCheck];
}
 
//用户登录页面点击事件
- (void)userModeLoginBtnClick:(LCButton *)sender {
    switch (sender.tag) {
        case 1001: {
            //登录
            if (![self loginParamCheck]) {
                return;
            }
        }
            break;
        case 1002: {
            //注册跳转
            [self.container.navigationController pushToUserModeRegist];
        }
            break;
        default:
            break;
    }
}
 
///获取验证码
- (void)userModeRegisterGetSMSCode {
    if (!self.userEmail || ![self.userEmail isVaildEmail]) {
        [LCOCAlertView lc_ShowAlertWith:@"Alert_Title_Notice".lc_T Detail:@"Choose_Injonit_Mode_Phone_Alert".lc_T ConfirmTitle:@"Alert_Title_Button_Confirm".lc_T CancleTitle:nil Handle:nil];
        return;
    }
    [LCAccountInterface userBindSms:self.userEmail success:^{
        [LCOCAlertView lc_ShowAlertWith:@"Alert_Title_Notice".lc_T Detail:@"User_Mode_Register_Phone_SMS_Success".lc_T ConfirmTitle:@"Alert_Title_Button_Confirm".lc_T CancleTitle:nil Handle:nil];
        
    } failure:^(LCError * _Nonnull error) {
        [LCOCAlertView lc_ShowAlertWith:@"Alert_Title_Notice".lc_T Detail:@"Choose_Injonit_Mode_Phone_Alert".lc_T ConfirmTitle:@"User_Mode_Register_Phone_SMS_Fail".lc_T CancleTitle:nil Handle:nil];
    }];
}
 
///选择平台界面有效性检查
- (BOOL)accountJointVaildCheck {
    if (!self.appId || [self.appId isNull]) {
        //提示APPID不能为空
        [LCOCAlertView lc_ShowAlertWith:@"Alert_Title_Notice".lc_T Detail:@"Choose_Plantform_APPID_Alert".lc_T ConfirmTitle:@"Alert_Title_Button_Confirm".lc_T CancleTitle:nil Handle:nil];
        return NO;
    }
    if (!self.appSecret || [self.appSecret isNull]) {
        //提示APPID不能为空
        [LCOCAlertView lc_ShowAlertWith:@"Alert_Title_Notice".lc_T Detail:@"Choose_Plantform_APPSecret_Alert".lc_T ConfirmTitle:@"Alert_Title_Button_Confirm".lc_T CancleTitle:nil Handle:nil];
        return NO;
    }
    if (!self.hostApi || [self.hostApi isNull] || ![self.hostApi isVaildURL]) {
        //检查Host有效性
        [LCOCAlertView lc_ShowAlertWith:@"Alert_Title_Notice".lc_T Detail:@"Choose_Plantform_HOST_Alert".lc_T ConfirmTitle:@"Alert_Title_Button_Confirm".lc_T CancleTitle:nil Handle:nil];
        return NO;
    }
    //保存下当前信息
    [LCApplicationDataManager setAppIdWith:self.appId];
    [LCApplicationDataManager setAppSecretWith:self.appSecret];
    [LCApplicationDataManager setHostApiWith:self.hostApi];
 
    [self getManagerModeToken];
    return YES;
}
 
//注册校验
- (BOOL)registerParamCheck {
    if (!self.userEmail || ![self.userEmail isVaildEmail]) {
        [LCOCAlertView lc_ShowAlertWith:@"Alert_Title_Notice".lc_T Detail:@"Choose_Injonit_Mode_Phone_Alert".lc_T ConfirmTitle:@"Alert_Title_Button_Confirm".lc_T CancleTitle:nil Handle:nil];
        return NO;
    }
    if (!self.isAvoidRegister && !self.verificationCode) {
        //需要验证码
            return NO;
    }
    //需要验证码
    weakSelf(self);
    [LCProgressHUD showHudOnView:nil];
    [LCAccountInterface userBind:self.userEmail success:^{
        //成功直接跳转登录
        [LCProgressHUD showMsg:@"regist_user_account_success".lc_T];
        [LCProgressHUD hideAllHuds:nil];
        [weakself loginParamCheck];
    } failure:^(LCError * _Nonnull error) {
        //Alert提示
        [LCProgressHUD hideAllHuds:nil];
        [LCOCAlertView lc_ShowAlertWithContent:error.errorMessage];
    }];
    return YES;
}
 
//登录校验
- (BOOL)loginParamCheck {
    weakSelf(self);
    if (!self.userEmail || ![self.userEmail isVaildEmail]) {
        [LCOCAlertView lc_ShowAlertWith:@"Alert_Title_Notice".lc_T Detail:@"Choose_Injonit_Mode_Phone_Alert".lc_T ConfirmTitle:@"Alert_Title_Button_Confirm".lc_T CancleTitle:nil Handle:nil];
        return NO;
    }
    [LCProgressHUD showHudOnView:nil];
    [LCAccountInterface userTokenWithPhone:self.userEmail success:^(LCAuthModel *_Nonnull authInfo) {
        //跳转主页
        [LCProgressHUD hideAllHuds:nil];
        [weakself.container.navigationController pushToLeChanegMainPage];
    } failure:^(LCError *_Nonnull error) {
        [LCProgressHUD hideAllHuds:nil];
        [LCOCAlertView lc_ShowAlertWith:@"Alert_Title_Notice".lc_T Detail:error.errorMessage ConfirmTitle:@"Alert_Title_Button_Confirm".lc_T CancleTitle:nil Handle:nil];
    }];
    return YES;
}
 
- (void)getManagerModeToken {
    weakSelf(self);
    [LCProgressHUD showHudOnView:nil];
    [LCAccountInterface accessTokenWithsuccess:^(LCAuthModel *_Nonnull authInfo) {
        [LCProgressHUD hideAllHuds:nil];
        [weakself.container.navigationController pushToLeChanegMainPage];
    } failure:^(LCError *_Nonnull error) {
        //返回初始界面
        [LCProgressHUD hideAllHuds:nil];
        [LCProgressHUD showMsg:error.errorMessage];
    }];
}
 
@end