首次提交

This commit is contained in:
启星
2025-08-08 11:05:33 +08:00
parent 1b3bb91b4a
commit adc1a2a25d
8803 changed files with 708874 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
//
// YYVipChangeVC.m
// SweetParty
//
// Created by bj_szd on 2023/1/6.
//
#import "YYVipChangeVC.h"
#import "ZWTimer.h"
#import "YYVipChangeAlert.h"
@interface YYVipChangeVC ()<ZWTimerDelegate>
@property (weak, nonatomic) IBOutlet UITextField *phoneTF;
@property (weak, nonatomic) IBOutlet UITextField *codeTF;
@property (weak, nonatomic) IBOutlet UITextField *changeTF;
@property (weak, nonatomic) IBOutlet UIButton *codeBtn;
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;
@property (weak, nonatomic) IBOutlet UILabel *moneyLab;
@property (weak, nonatomic) IBOutlet UILabel *currentInviteLab;
@property (nonatomic, strong) ZWTimer *timer;
@property (nonatomic, assign) NSInteger leftSecond;
@end
@implementation YYVipChangeVC
- (void)viewDidLoad {
[super viewDidLoad];
[self showNaviBarWithTitle:@"更换邀请人"];
[self.loginBtn setJianBianWithCGSize:CGSizeMake(ScreenWidth-15*2, 45)];
self.leftSecond = 60;
self.phoneTF.text = BJUserManager.userInfo.user_name;
[self fetchData];
}
- (void)fetchData {
NSDictionary *params = @{};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/vip/get_update_invite_info" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
self.moneyLab.text = [NSString stringWithFormat:@"%@金币", responseDic[@"data"][@"update_inviter_price"]];
NSString *invite_uid = [responseDic[@"data"] safeStringForKey:@"invite_uid"];
NSString *inviter_nick_name = [responseDic[@"data"] safeStringForKey:@"inviter_nick_name"];
if ([invite_uid integerValue] > 0) {
self.currentInviteLab.text = [NSString stringWithFormat:@"%@(ID:%@)", inviter_nick_name, invite_uid];
}else {
self.currentInviteLab.text = @"无";
}
} Failure:^(id _Nonnull errorData) {
}];
}
- (IBAction)onConfirm:(id)sender {
if (self.phoneTF.text.length != 11) {
[HelpPageDefine showMessage:@"手机号格式不正确"];
return;
}
if (self.codeTF.text.length <= 0) {
[HelpPageDefine showMessage:@"请输入验证码"];
return;
}
if (self.changeTF.text.length <= 0) {
[HelpPageDefine showMessage:@"请输入邀请人ID"];
return;
}
YYVipChangeAlert *view = LoadNib(@"YYVipChangeAlert");
view.frame = [UIScreen mainScreen].bounds;
view.contentLab.text = [NSString stringWithFormat:@"更换邀请人需要支付%@的费用\n您确定要更换吗", self.moneyLab.text];
[self.view addSubview:view];
view.onCompleteBlock = ^{
[self onChoosePayType];
};
}
- (void)onChoosePayType {
NSDictionary *params = @{@"sms_code":self.codeTF.text, @"user_id":self.changeTF.text};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/pay/update_user_inviter" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
[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