123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- //
- // FirstSettingViewController.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/20.
- //
- #import "FirstSettingViewController.h"
- #import "FirstSettingBodyView.h"
- #import "AppDelegate.h"
- #import "UserInfoManager.h"
- @interface FirstSettingViewController ()
- @property (nonatomic, strong) FirstSettingBodyView *bodyView;
- @property (nonatomic, strong) NSString *userSex;
- @end
- @implementation FirstSettingViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- [self configUI];
- }
- - (void)configUI {
-
- CGFloat height = KPortraitHeight;
- _bodyView = [FirstSettingBodyView shareInstance];
- [self.scrollView addSubview:_bodyView];
- [_bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.scrollView.mas_top);
- make.right.left.mas_equalTo(self.view);
- make.height.mas_equalTo(height);
- }];
- MJWeakSelf;
- [_bodyView sureCallback:^(NSString *myCode, NSString *nickName) {
- [weakSelf settingPassword:myCode nickName:nickName];
- }];
-
- [_bodyView chooseSexCallback:^{
- [weakSelf showModifySexAlert];
- }];
- }
- - (void)showModifySexAlert {
- NSString *titleString = @"选择性别";
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"" message:titleString preferredStyle:IS_IPAD ? UIAlertControllerStyleAlert : UIAlertControllerStyleActionSheet];
- NSMutableAttributedString *titleAtt = [[NSMutableAttributedString alloc] initWithString:titleString];
- [titleAtt addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0f] range:NSMakeRange(0, titleString.length)];
- [titleAtt addAttribute:NSForegroundColorAttributeName value:HexRGB(0x999999) range:NSMakeRange(0, titleString.length)];
- [alertVC setValue:titleAtt forKey:@"attributedMessage"];
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"男" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- self.bodyView.sexField.text = @"男";
- self.userSex = @"1";
- }];
- [actionOne setValue:THEMECOLOR forKey:@"_titleTextColor"];
- [alertVC addAction:actionOne];
- UIAlertAction *actionTwo = [UIAlertAction actionWithTitle:@"女" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- self.bodyView.sexField.text = @"女";
- self.userSex = @"0";
- }];
- [actionTwo setValue:THEMECOLOR forKey:@"_titleTextColor"];
- [alertVC addAction:actionTwo];
-
- UIAlertAction *cancleAlert = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alertVC addAction:cancleAlert];
- [cancleAlert setValue:HexRGB(0x444444) forKey:@"_titleTextColor"];
- alertVC.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:alertVC animated:true completion:nil];
- }
- - (void)settingPassword:(NSString *)pwdCode nickName:(NSString *)nickName {
- if ([NSString isEmptyString:self.userSex]) {
- [self MBPShow:@"请设置性别"];
- return;
- }
- [self showhud];
- [KSNetworkingManager setPasswordRequest:KS_POST username:nickName password:pwdCode userSex:self.userSex token:self.access_token success:^(NSDictionary * _Nonnull dic) {
- [self removehub];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- MJWeakSelf;
- UserDefaultSet(self.phone, PHONEKEY);
- UserDefaultSet(self.access_token, TokenKey);
- UserDefaultSet(pwdCode, PASSWORDKEY);
- [self KSShowMsg:@"设置成功" promptCompletion:^{
- [weakSelf toHomeView];
- }];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [self removehub];
- }];
- }
- - (void)toHomeView {
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
- [appDelegate initTableBar];
- UITabBarController *tabBarController = appDelegate.tabBarController;
- [tabBarController setSelectedIndex:0];
- appDelegate.window.rootViewController = tabBarController;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|