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

101 lines
3.6 KiB
Objective-C
Executable File
Raw Permalink 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.

//
// SPEditPasswordVC.m
// SweetParty
//
// Created by bj_szd on 2022/6/9.
//
#import "SPEditPasswordVC.h"
#import "ZWTimer.h"
@interface SPEditPasswordVC ()<ZWTimerDelegate>
@property (weak, nonatomic) IBOutlet UITextField *phoneTF;
@property (weak, nonatomic) IBOutlet UITextField *codeTF;
@property (weak, nonatomic) IBOutlet UIButton *codeBtn;
@property (weak, nonatomic) IBOutlet UITextField *passwordTF;
@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
@property (nonatomic, strong) ZWTimer *timer;
@property (nonatomic, assign) NSInteger leftSecond;
@end
@implementation SPEditPasswordVC
- (void)viewDidLoad {
[super viewDidLoad];
[self showNaviBarWithTitle:@"修改交易密码"];
self.phoneTF.attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:@"请输入手机号" attributes:@{NSForegroundColorAttributeName:[HEXCOLOR(0x333333) colorWithAlphaComponent:0.6]}];
self.codeTF.attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:@"请输入验证码" attributes:@{NSForegroundColorAttributeName:[HEXCOLOR(0x333333) colorWithAlphaComponent:0.6]}];
self.passwordTF.attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:@"请输入交易密码" attributes:@{NSForegroundColorAttributeName:[HEXCOLOR(0x333333) colorWithAlphaComponent:0.6]}];
[self.confirmBtn setJianBianWithCGSize:CGSizeMake(ScreenWidth-27*2, 49)];
self.leftSecond = 60;
self.phoneTF.text = BJUserManager.userInfo.user_name;
}
- (IBAction)onConfirm:(id)sender {
if (self.phoneTF.text.length != 11) {
[HelpPageDefine showMessage:@"手机号格式不正确"];
return;
}
if (self.codeTF.text.length <= 0) {
[HelpPageDefine showMessage:@"请输入验证码"];
return;
}
if (self.passwordTF.text.length <= 0) {
[HelpPageDefine showMessage:@"请输入交易密码"];
return;
}
NSDictionary *params = @{@"sms_code":self.codeTF.text, @"trade_password":self.passwordTF.text};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/user/modify_trade_password" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.navigationController popViewControllerAnimated:YES];
});
} Failure:^(id _Nonnull errorData) {
}];
}
- (IBAction)onGetCode:(id)sender {
if (self.phoneTF.text.length != 11) {
[HelpPageDefine showMessage:@"手机号格式不正确"];
return;
}
//type 1,其他时候使用2注册时候用
NSDictionary *params = @{@"mobile":self.phoneTF.text, @"type":@"1"};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/login/send_sms" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
self.leftSecond = 60;
[self.timer startTimer:1 delegate:self repeats:YES];
} Failure:^(id _Nonnull errorData) {
}];
}
- (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