cdts/xdts-ios 3/TreeHole/Code/Features/Login/ViewController/SetNickNameViewController.m

82 lines
2.7 KiB
Mathematica
Raw Normal View History

2023-07-27 09:20:00 +08:00
//
// SetNickNameViewController.m
// Youth
//
// Created by mambaxie on 2022/1/1.
//
#import "SetNickNameViewController.h"
#import "SetAvatarViewController.h"
//#import <BaiduActionSDK/BaiduAction.h>
@interface SetNickNameViewController ()
@property (nonatomic, strong) UITextField *textFiled;
@end
@implementation SetNickNameViewController
- (NSString *)topImageName {
return @"TH_login_name_img";
}
- (NSString *)tipsContent {
return @"起一个好听的名字";
}
- (void)viewDidLoad {
[super viewDidLoad];
PYThemeTextField *textFiled = [PYThemeTextField fieldWithPlaceholder:@"2-15个字符 支持中英文" maxLength:15];
textFiled.y = [self topContentMargin];
[self.cardView addSubview:textFiled];
self.textFiled = textFiled.textField;
WeakSelf(self);
PYThemeButton *nextButton = [PYThemeButton nextButtonWithAction:^(UIButton * _Nonnull button) {
if (weakself.textFiled.text.length < 2) {
[SVProgressHUD showInfoWithStatus:@"至少2个字符"];
return;
}
[SVProgressHUD showWithStatus:nil];
[UserService updateUserToRemoteWithParams:@{
@"nick_name": weakself.textFiled.text,
@"want_genders": weakself.wantGendersArray?: @[],
@"birthday": weakself.birthday?:@"",
@"province": weakself.province?:@"",
@"city": weakself.city?:@"",
@"district": weakself.district?:@"",
@"gender_str": weakself.gender_str,
@"register_complete": @(1)
} completion:^(id _Nullable rsp, NSError * _Nullable error) {
[SVProgressHUD dismiss];
if (!error) {
/*
//广
[BaiduAction logAction:BaiduSDKActionNameRegister actionParam:
@{
BaiduSDKActionParamKeyOuterActionId:[NSString stringWithFormat:@"%@", rsp[@"user_id"]],
BaiduSDKActionParamKeyAudienceType:@(BaiduActionParamAudienceType_NewAudience)
}
];
*/
[PYAppService pushViewControllerAnimated:[[SetAvatarViewController alloc] init]];
}else{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[SVProgressHUD showErrorWithStatus:[error.userInfo objectForKey:@"message"]];
});
}
}];
}];
nextButton.y = textFiled.bottom + FIX_SIZE(76);
[self.cardView addSubview:nextButton];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.textFiled becomeFirstResponder];
}
@end