Files
yuyin_ios/SweetParty/主类/Mine/设置/View/SPZhuxiaoAlert.m
2025-08-08 11:05:33 +08:00

105 lines
3.2 KiB
Objective-C
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// SPZhuxiaoAlert.m
// SweetParty
//
// Created by bj_szd on 2022/6/9.
//
#import "SPZhuxiaoAlert.h"
#import "ZWTimer.h"
@interface SPZhuxiaoAlert ()<ZWTimerDelegate>
@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
@property (weak, nonatomic) IBOutlet UITextField *phoneTF;
@property (weak, nonatomic) IBOutlet UITextField *codeTF;
@property (weak, nonatomic) IBOutlet UIButton *codeBtn;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@property (nonatomic, strong) ZWTimer *timer;
@property (nonatomic, assign) NSInteger leftSecond;
@end
@implementation SPZhuxiaoAlert
- (void)awakeFromNib {
[super awakeFromNib];
[self.confirmBtn setJianBianWithCGSize:CGSizeMake(155, 45)];
// self.codeTF.attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:@"请输入验证码" attributes:@{NSForegroundColorAttributeName:HEXCOLORA(0xFFFFFF, 0.3)}];
self.phoneTF.text = BJUserManager.userInfo.user_name;
self.phoneLabel.text = [NSString stringWithFormat:@"绑定手机号:%@",BJUserManager.userInfo.user_name];
}
- (IBAction)onConfirm:(id)sender {
if (self.codeTF.text.length <= 0) {
[HelpPageDefine showMessage:@"请输入验证码"];
return;
}
NSDictionary *params = @{@"sms_code":self.codeTF.text};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/user/logout_user_name" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
if (self.onCompleteBlock) {
self.onCompleteBlock();
}
[self removeFromSuperview];
} Failure:^(id _Nonnull errorData) {
}];
}
- (IBAction)onCancel:(id)sender {
[self removeFromSuperview];
}
- (IBAction)onGetCode:(id)sender {
// if (self.phoneTF.text.length != 11) {
// [HelpPageDefine showMessage:@"手机号格式不正确"];
// return;
// }
BJPicCodeView *view = LoadNib(@"BJPicCodeView");
view.frame = [UIScreen mainScreen].bounds;
[MainWindow() addSubview:view];
view.onConfirmBlock = ^(NSString * _Nonnull picCodeStr, NSString * _Nonnull codeKey) {
[self onSendSmsCodeWith:picCodeStr codeKey:codeKey];
};
}
- (void)onSendSmsCodeWith:(NSString *)picCodeStr codeKey:(NSString *)codeKey {
//type 1,其他时候使用2注册时候用
NSDictionary *dict = @{@"mobile":BJUserManager.userInfo.user_name, @"type":@"1", @"captcha_code":picCodeStr, @"captcha_key":codeKey};
[BJHttpTool BJ_login_send_smsWithParameters:dict success:^(id response) {
self.leftSecond = 60;
[self.timer startTimer:1 delegate:self repeats:YES];
} failure:^(NSError *error) {
}];
}
- (void)onTimerFired:(ZWTimer *)timer {
NSString *str = [NSString stringWithFormat:@"%ld秒后重发", self.leftSecond];
self.codeBtn.userInteractionEnabled = NO;
self.leftSecond -= 1;
if (self.leftSecond < 0) {
str = @"获取验证码";
[self.timer stopTimer];
self.codeBtn.userInteractionEnabled = YES;
}
self.codeBtn.titleLabel.text = str;
[self.codeBtn setTitle:str forState:UIControlStateNormal];
}
- (ZWTimer *)timer {
if (!_timer) {
_timer = [[ZWTimer alloc] init];
}
return _timer;
}
@end