// // ShouYeLingYuViewController.m // ProductApp // // Created by 工作 on 2024/9/26. // #import "ShouYeLingYuViewController.h" #import "ShouYeShenFenViewController.h" #import "NetWorkManager.h" #import "PublicNetWorkManager.h" @interface ShouYeLingYuViewController () /// @property (nonatomic , strong) NSMutableArray *arrLB; /// @property (nonatomic , strong) NSArray *arrdata; @end @implementation ShouYeLingYuViewController - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleDefault; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:animated]; [self showNaviGationView:YES]; [self.navigationView setTitle:@"领域身份" titleColor:RGBCOLOR(60, 60, 60)]; [self.navigationView setBackgroundColor:[UIColor clearColor]]; } - (void)viewDidLoad { [super viewDidLoad]; UIImageView *imgvback = [[UIImageView alloc] init]; [imgvback setImage:[UIImage imageNamed:@"yd_back"]]; [self.view addSubview:imgvback]; [imgvback mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.view); }]; [self.view sendSubviewToBack:imgvback]; UILabel *lbname = [[UILabel alloc] init]; [lbname setText:@"请选择您的领域"]; [lbname setTextColor:RGBCOLOR(26, 26, 26)]; [lbname setTextAlignment:NSTextAlignmentLeft]; [lbname setFont:[UIFont systemFontOfSize:24]]; [self.view addSubview:lbname]; [lbname mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(20); make.top.offset(KMagrinTop+74); }]; UILabel *lbinfo = [[UILabel alloc] init]; [lbinfo setText:@"请选择您的领域"]; [lbinfo setTextColor:RGBCOLOR(26, 26, 26)]; [lbinfo setTextAlignment:NSTextAlignmentLeft]; [lbinfo setFont:[UIFont systemFontOfSize:15]]; [self.view addSubview:lbinfo]; [lbinfo mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(lbname); make.top.equalTo(lbname.mas_bottom).offset(10); }]; NSArray *arrtt = @[@"教育",@"职场"]; self.arrLB = [NSMutableArray new]; for(int i = 0 ; i < arrtt.count; i++) { UIView *viewitem = [[UIView alloc] init]; [self.view addSubview:viewitem]; [viewitem mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(20); make.right.equalTo(self.view).offset(-20); make.top.equalTo(lbinfo.mas_bottom).offset(60+120*i); make.height.offset(100); }]; UILabel *lbitem = [self drawItemView:viewitem title:arrtt[i] tag:i]; [self.arrLB addObject:lbitem]; } [self getNianJiData]; } -(UILabel *)drawItemView:(UIView *)view title:(NSString *)title tag:(int)tag { [view.layer setMasksToBounds:YES]; [view.layer setCornerRadius:10]; [view setBackgroundColor:[UIColor whiteColor]]; UIImageView *imgvback = [[UIImageView alloc] init]; [imgvback setImage:[UIImage imageNamed:[NSString stringWithFormat:@"yd_%@",title]]]; [view addSubview:imgvback]; [imgvback mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(10); make.top.bottom.equalTo(view); make.width.offset(100); }]; UILabel *lbname = [[UILabel alloc] init]; [lbname setText:title]; [lbname setTextColor:RGBCOLOR(26, 26, 26)]; [lbname setTextAlignment:NSTextAlignmentLeft]; [lbname setFont:[UIFont systemFontOfSize:16]]; [view addSubview:lbname]; [lbname mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(imgvback.mas_right).offset(41); make.centerY.equalTo(view); }]; UIImageView *imgvnext = [[UIImageView alloc] init]; [imgvnext setImage:[UIImage imageNamed:@"yd_next"]]; [view addSubview:imgvnext]; [imgvnext mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.offset(18); make.centerY.equalTo(view); make.right.equalTo(view).offset(-12); }]; UIButton *bt = [[UIButton alloc] init]; [view addSubview:bt]; [bt mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(view); }]; [bt setTag:tag]; [bt addTarget:self action:@selector(btAction:) forControlEvents:UIControlEventTouchUpInside]; return lbname; } -(void)btAction:(UIButton *)sender { [self.view setUserInteractionEnabled:NO]; for(UILabel *lb in self.arrLB) { [lb setTextColor:RGBCOLOR(26, 26, 26)]; } UILabel *lb = self.arrLB[sender.tag]; [lb setTextColor:MainColor]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.view setUserInteractionEnabled:YES]; if(sender.tag==0) { NSArray *arrvc = self.navigationController.viewControllers; for(UIViewController *vc in arrvc) { if([vc isKindOfClass:[ShouYeShenFenViewController class]]) { [self.navigationController popToViewController:vc animated:YES]; return; } } ShouYeShenFenViewController *vc = [ShouYeShenFenViewController new]; [self.navigationController pushViewController:vc animated:YES]; } else { [self updataUserInfo]; } }); } -(void)getNianJiData { [LoadAlterView show]; [NetWorkManager requestRoleTreeData:self.view Callback:^(BOOL state, RoleTreeModel *responseObject, NSString * _Nullable describle) { [LoadAlterView dismiss]; if(state) { self.arrdata = responseObject.data; } else { [HXHud showMessage:responseObject.message afterDelayType:1]; } }]; } -(void)updataUserInfo { for(RoleTreeModelData *model in self.arrdata) { if([model.name isEqualToString:@"职场"]) {///更新用户信息 RoleTreeModelData *modelson = model.node.firstObject; NSDictionary *dicuser_stage = [modelson yy_modelToJSONObject]; NSMutableDictionary *dicpush = [NSMutableDictionary new]; [dicpush setObject:dicuser_stage forKey:@"user_stage"]; [dicpush setObject:[NSNumber numberWithBool:NO] forKey:@"isAllLevel"]; [dicpush setObject:[NSNumber numberWithInt:3] forKey:@"identityType"]; [PublicNetWorkManager requestUserPutData:self.view body:dicpush Callback:^(BOOL state, BaseModel *responseObject, NSString * _Nullable describle) { if(state) { [UserInfoModel shareModel].user_stage = modelson; [UserInfoModel shareModel].isAllLevel = [NSString stringWithFormat:@"%@",[NSNumber numberWithBool:NO]]; [UserInfoModel shareModel].identityType = @"3"; [UserInfoModel shareModel].isupdataJiaoyu = YES; [self.navigationController popToRootViewControllerAnimated:YES]; } else { [HXHud showMessage:responseObject.message afterDelayType:1]; } }]; } } } @end