@@ -225,16 +225,74 @@ - (void)phoneCodeBtnClicked:(PhoneCodeButton *)sender withCaptcha:(NSString *)ca
225225 return ;
226226 }
227227 sender.enabled = NO ;
228- [[CodingNetAPIClient sharedJsonClient ] requestJsonDataWithPath: @" api/account/password/forget" withParams: @{@" account" : _userStr, @" phoneCountryCode" : @" +86" } withMethodType: Post andBlock: ^(id data, NSError *error) {
228+ NSMutableDictionary *params = @{@" account" : _userStr,
229+ @" phoneCountryCode" : @" +86" }.mutableCopy ;
230+ if (captcha.length > 0 ) {
231+ params[@" j_captcha" ] = captcha;
232+ }
233+ __weak typeof (self) weakSelf = self;
234+ [[CodingNetAPIClient sharedJsonClient ] requestJsonDataWithPath: @" api/account/password/forget" withParams: params withMethodType: Post andBlock: ^(id data, NSError *error) {
229235 if (data) {
230236 [NSObject showHudTipStr: @" 验证码发送成功" ];
231237 [sender startUpTimer ];
232238 }else {
233239 [sender invalidateTimer ];
240+ if (error && error.userInfo [@" msg" ] && [[error.userInfo[@" msg" ] allKeys ] containsObject: @" j_captcha_error" ]) {
241+ [weakSelf p_showCaptchaAlert: sender];
242+ }
234243 }
235244 }];
236245}
237246
247+ - (void )p_showCaptchaAlert : (PhoneCodeButton *)sender {
248+ SDCAlertController *alertV = [SDCAlertController alertControllerWithTitle: @" 提示" message: @" 请输入图片验证码" preferredStyle: SDCAlertControllerStyleAlert];
249+ UITextField *textF = [UITextField new ];
250+ textF.layer .sublayerTransform = CATransform3DMakeTranslation (5 , 0 , 0 );
251+ textF.backgroundColor = [UIColor whiteColor ];
252+ [textF doBorderWidth: 0.5 color: nil cornerRadius: 2.0 ];
253+ UIImageView *imageV = [UIImageView new ];
254+ imageV.backgroundColor = [UIColor lightGrayColor ];
255+ imageV.contentMode = UIViewContentModeScaleAspectFit;
256+ imageV.clipsToBounds = YES ;
257+ imageV.userInteractionEnabled = YES ;
258+ [textF doBorderWidth: 0.5 color: nil cornerRadius: 2.0 ];
259+ NSURL *imageURL = [NSURL URLWithString: [NSString stringWithFormat: @" %@ api/getCaptcha" , [NSObject baseURLStr ]]];
260+ [imageV sd_setImageWithURL: imageURL placeholderImage: nil options: (SDWebImageRetryFailed | SDWebImageRefreshCached | SDWebImageHandleCookies)];
261+
262+ [alertV.contentView addSubview: textF];
263+ [alertV.contentView addSubview: imageV];
264+ [textF mas_makeConstraints: ^(MASConstraintMaker *make) {
265+ make.left .equalTo (alertV.contentView ).offset (15 );
266+ make.height .mas_equalTo (25 );
267+ make.bottom .equalTo (alertV.contentView ).offset (-10 );
268+ }];
269+ [imageV mas_makeConstraints: ^(MASConstraintMaker *make) {
270+ make.right .equalTo (alertV.contentView ).offset (-15 );
271+ make.left .equalTo (textF.mas_right ).offset (10 );
272+ make.width .mas_equalTo (60 );
273+ make.height .mas_equalTo (25 );
274+ make.centerY .equalTo (textF);
275+ }];
276+ // Action
277+ __weak typeof (imageV) weakImageV = imageV;
278+ [imageV bk_whenTapped: ^{
279+ [weakImageV sd_setImageWithURL: imageURL placeholderImage: nil options: (SDWebImageRetryFailed | SDWebImageRefreshCached | SDWebImageHandleCookies)];
280+ }];
281+ __weak typeof (self) weakSelf = self;
282+ [alertV addAction: [SDCAlertAction actionWithTitle: @" 取消" style: SDCAlertActionStyleCancel handler: nil ]];
283+ [alertV addAction: [SDCAlertAction actionWithTitle: @" 确定" style: SDCAlertActionStyleDefault handler: nil ]];
284+ alertV.shouldDismissBlock = ^BOOL (SDCAlertAction *action){
285+ if (![action.title isEqualToString: @" 取消" ]) {
286+ [weakSelf phoneCodeBtnClicked: sender withCaptcha: textF.text];
287+ }
288+ return YES ;
289+ };
290+ [alertV presentWithCompletion: ^{
291+ [textF becomeFirstResponder ];
292+ }];
293+ }
294+
295+
238296- (void )footerBtnClicked : (id )sender {
239297 if (_stepIndex == 0 ) {
240298 CannotLoginViewController *vc = [CannotLoginViewController vcWithMethodType: [_userStr isPhoneNo ]? CannotLoginMethodPhone: CannotLoginMethodEamil stepIndex: 1 userStr: _userStr];
0 commit comments