// // MySetViewController.m // 双子星云手机 // // Created by APPLE on 2023/8/17. // #import "MySetViewController.h" #import #import #import "UseAccountManage.h" #import "HelpDownScrollView.h" #import "MineViewCell.h" #import "ChangeLogoViewController.h" #import "HidenMaskSetViewController.h" #import "CustomerWebViewController.h" #import "AboutViewController.h" #import "iPhone.h" #import "CloudPhoneAPI.h" #import "UserDetailInfoModel.h" #import "BuyVIPViewController.h" #import "PayRecoderListViewController.h" #import "ComontAlretViewController.h" @interface MySetViewController () { UILabel *phoneLabel; UILabel *vipTypeTipsLabel; } @property (nonatomic, strong, nullable) UITableView *tableView; @end @implementation MySetViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self drawAnyView]; NSString* bg_tableName = nil; NSDictionary *dictLogin = [[UseAccountManage shareInstance] getLoginInfo]; if (dictLogin && [[dictLogin allKeys] containsObject:@"touristId"]) { NSString* username = [dictLogin objectForKey:@"touristId"]; bg_tableName = User_Info_tableName(username); NSArray* finfAlls = [UserDetailInfoModel bg_findAll:bg_tableName]; if (finfAlls && finfAlls.count >0) { UserDetailInfoModel *model = finfAlls[0]; /*更新用户名称*/ [phoneLabel setText:model.userName]; } } /*获取个人信息*/ [[UseAccountManage shareInstance] CommonPostCallBackCode:PostUserDetailInfo Params:[NSDictionary new] success:^(id _Nonnull responseObject) { UserDetailInfoDataModel *model = [[UserDetailInfoDataModel alloc] initWithDictionary:responseObject error:nil]; if (model.status.integerValue == 0){ /*内容用数据库更新到本地*/ if (bg_tableName){ model.data.bg_tableName = bg_tableName; [model.data bg_cover]; if (self.whetherPhoneStatus != 0){ [self->vipTypeTipsLabel setText:[NSString stringWithFormat:@"%@%@",NSLocalizedString(@"my_set_no_time_top",nil),model.data.exceptTime]]; } } }else{ ; } } failure:^(NSError * _Nonnull error) { ; }]; //http://testprivacy.phone.armclouding.com:11180/api/user/v1/user/getUserDetailInfo } - (void)drawAnyView{ [self.view setBackgroundColor:HWF5F7FAColor]; [self.toolBar setHidden:YES]; [self.navigationBar setHidden:YES]; [self.view addSubview:self.tableView]; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(0); make.top.mas_equalTo(0); }]; [self.tableView setTableHeaderView:[self headViewForTable]]; } - (UIView *)headViewForTable{ /*236顶部视图, 44中间试图下部分, 126下方视图*/ UIView *headView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, SCREEN_W, 236.f + 44.f + 126))]; [headView setBackgroundColor:[UIColor clearColor]]; UIImage *bgImage = [UIImage imageNamed:@"set_up_bg"]; // bgImage = [bgImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 40, 80)]; UIImageView *bgImView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 236.f)]; [bgImView setImage:bgImage]; [headView addSubview:bgImView]; /*头像*/ UIImageView *photoImage = [[UIImageView alloc] init]; [photoImage setImage:[UIImage imageNamed:@"photo_normal"]]; [bgImView addSubview:photoImage]; [photoImage mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(16.f); make.top.mas_equalTo(99.f); make.width.mas_equalTo(62.f); make.height.mas_equalTo(62.f); }]; NSDictionary *loginInfo = [[UseAccountManage shareInstance] getLoginInfo]; /*用户名*/ phoneLabel = [[UILabel alloc] init]; [phoneLabel setFont:[UIFont boldSystemFontOfSize:18.f]]; [phoneLabel setTextColor:[UIColor whiteColor]]; if (loginInfo && [[loginInfo allKeys] containsObject:@"phone"]){ [phoneLabel setText:[loginInfo objectForKey:@"phone"]]; } [bgImView addSubview:phoneLabel]; [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(photoImage.mas_right).offset(9); make.centerY.equalTo(photoImage.mas_centerY); make.right.mas_equalTo(-22.f); make.height.mas_equalTo(25.f); }]; /*下方会员视图*/ // vip_bg UIImageView *downBgView = [[UIImageView alloc] init]; [downBgView setImage:[UIImage imageNamed:@"vip_bg"]]; [headView addSubview:downBgView]; [downBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15.f); make.right.mas_equalTo(-15.f); make.bottom.mas_equalTo(-126.f); make.height.mas_equalTo(96.f); }]; [downBgView setUserInteractionEnabled:YES]; /*VIP类型*/ UILabel *vipType = [[UILabel alloc] init]; [vipType setText:@"VIP"]; [vipType setTextColor:[UIColor whiteColor]]; [vipType setFont:[UIFont boldSystemFontOfSize:24.f]]; [downBgView addSubview:vipType]; [vipType mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(20.f); make.right.mas_equalTo(-100.f); make.top.mas_equalTo(18.f); make.height.mas_equalTo(33.f); }]; /*VIP类型提示*/ vipTypeTipsLabel = [[UILabel alloc] init]; if (self.whetherPhoneStatus != 0){ [vipTypeTipsLabel setText:@""]; }else{ [vipTypeTipsLabel setText:NSLocalizedString(@"my_set_no_vip_tips",nil)]; } [vipTypeTipsLabel setTextColor:[UIColor whiteColor]]; [vipTypeTipsLabel setFont:[UIFont systemFontOfSize:12.f]]; [downBgView addSubview:vipTypeTipsLabel]; [vipTypeTipsLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(20.f); make.right.mas_equalTo(-100.f); make.top.mas_equalTo(53.f); make.height.mas_equalTo(17.f); }]; /*免费会员按钮*/ UIButton *vipBtn = [[UIButton alloc] init]; [vipBtn setBackgroundColor:[UIColor whiteColor]]; if (self.whetherPhoneStatus != 0){ [vipBtn setTitle:NSLocalizedString(@"no_enough_time_exchange",nil) forState:(UIControlStateNormal)]; }else{ [vipBtn setTitle:NSLocalizedString(@"my_set_no_vip_open_vip",nil) forState:(UIControlStateNormal)]; } [vipBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)]; [vipBtn.titleLabel setFont:[UIFont systemFontOfSize:13.f]]; [vipBtn addTarget:self action:@selector(vipBtnPressed) forControlEvents:(UIControlEventTouchUpInside)]; [vipBtn.layer setCornerRadius:31.f/2.f]; [downBgView addSubview:vipBtn]; [vipBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(86.f); make.right.mas_equalTo(-20.f); make.centerY.equalTo(downBgView.mas_centerY); make.height.mas_equalTo(31.f); }]; /*下方视图*/ HelpDownScrollView *helpDownScrollView = [[HelpDownScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W - 30, 96.f) withImageAry:@[@"icon-tubiao",@"icon-jincheng"] tilteAry:@[NSLocalizedString(@"my_set_no_change_logo",nil),NSLocalizedString(@"my_set_no_hidden_app",nil)] numberOfLine:3]; helpDownScrollView.presedDelegate = self; [headView addSubview:helpDownScrollView]; [helpDownScrollView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15.f); make.right.mas_equalTo(-15.f); make.bottom.mas_equalTo(-15.f); make.height.mas_equalTo(96.f); }]; [helpDownScrollView setBackgroundColor:[UIColor whiteColor]]; [helpDownScrollView.layer setCornerRadius:8.f]; return headView; } /* #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. } */ - (void)helpDownScrollViewBePressed:(nonnull id)sender withIndex:(NSInteger)index { HLog(@"\n----点击了第个%ld按钮----",index); if (index == 0){ ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init]; [self.navigationController pushViewController:nextVC animated:YES]; }else if (index == 1){/**/ HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init]; [self.navigationController pushViewController:nextVC animated:YES]; } } #pragma mark - 懒加载 - (UITableView *)tableView{ if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStyleGrouped]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.showsVerticalScrollIndicator = NO; _tableView.showsHorizontalScrollIndicator = NO; _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0); [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)]; [_tableView setSeparatorColor:[UIColor clearColor]]; [_tableView setBackgroundColor:[UIColor clearColor]]; [_tableView setTableFooterView:[UIView new]]; [_tableView setBounces:YES]; if (@available(iOS 15.0, *)) { _tableView.sectionHeaderTopPadding = 0; } } return _tableView; } #pragma mark - 列表委托 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 7; } - (MineViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSInteger row = indexPath.row; static NSString *identifier = @"MineViewCell"; MineViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier]; cell.selectionStyle = UITableViewCellSelectionStyleNone; if (!cell){ cell = [[MineViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier]; [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; [cell setBackgroundColor:[UIColor clearColor]]; [cell setAccessoryType:(UITableViewCellAccessoryNone)]; } [cell.bgViewLayer removeFromSuperlayer]; [cell.titleLabel2 setHidden:YES]; [cell.rightImage setHidden:NO]; [cell.lineView setHidden:NO]; [cell.maskSwitch setHidden:YES]; if (row == 0){ [cell.titleLabel setText:NSLocalizedString(@"my_set_no_invite_friend",nil)]; [cell.titleLabel2 setText:NSLocalizedString(@"my_set_no_invite_friend_get_vip",nil)]; [cell.mImageView setImage:[UIImage imageNamed:@"icon-yaoqing"]]; [cell.titleLabel2 setHidden:NO]; /*上圆角*/ //设置部分圆角 贝塞尔曲线 UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(8, 8)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = cell.cellBgView.bounds; maskLayer.path = maskPath.CGPath; cell.bgViewLayer = maskLayer; cell.cellBgView.layer.mask = cell.bgViewLayer; }else if (row == 1){ [cell.titleLabel setText:NSLocalizedString(@"my_set_no_fanzhuan_exit",nil)]; [cell.mImageView setImage:[UIImage imageNamed:@"fanzhuan"]]; [cell.rightImage setHidden:YES]; [cell.maskSwitch setHidden:NO]; }else if (row == 2){ [cell.titleLabel setText:NSLocalizedString(@"my_set_no_check_update",nil)]; [cell.mImageView setImage:[UIImage imageNamed:@"app_update"]]; }else if (row == 3){ [cell.titleLabel setText:NSLocalizedString(@"my_set_no_connect_kefu",nil)]; [cell.mImageView setImage:[UIImage imageNamed:@"icon-kefu"]]; }else if (row == 4){ [cell.titleLabel setText:NSLocalizedString(@"my_set_no_buy_recoder",nil)]; [cell.mImageView setImage:[UIImage imageNamed:@"buy_recoder_icon"]]; }else if (row == 5){/*重启空间*/ [cell.titleLabel setText:NSLocalizedString(@"my_set_no_restart_phone",nil)]; [cell.mImageView setImage:[UIImage imageNamed:@"icon-gengxin"]]; }else if (row == 6){ [cell.titleLabel setText:NSLocalizedString(@"my_set_no_logout",nil)]; [cell.mImageView setImage:[UIImage imageNamed:@"icon-tuichu"]]; [cell.rightImage setHidden:YES]; /*下圆角*/ UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60) byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(8, 8)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = cell.cellBgView.bounds; maskLayer.path = maskPath.CGPath; cell.bgViewLayer = maskLayer; cell.cellBgView.layer.mask = cell.bgViewLayer; [cell.lineView setHidden:YES]; } return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 60; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; NSInteger row = indexPath.row; if (0 == row){ CustomerWebViewController *vc = [[CustomerWebViewController alloc] init]; vc.needHidenNav = YES; NSDictionary *dictLogin = [[UseAccountManage shareInstance] getLoginInfo]; if (dictLogin && [[dictLogin allKeys] containsObject:@"token"]) { NSString *tokenStr = [dictLogin objectForKey:@"token"]; NSString *url = [NSString stringWithFormat:@"http://192.168.11.32:11180/cloud/privacy/#/pages/invitation/index?token=%@&iosVersionNumber=%@", tokenStr,[iPhone appVersion]]; vc.webUrl = url; [self.navigationController pushViewController:vc animated:YES]; } }else if (1 == row){ /*翻转退出*/ }else if (2 == row){ AboutViewController *vc = [[AboutViewController alloc] init]; [self.navigationController pushViewController:vc animated:YES]; }else if (3 == row){ CustomerWebViewController *vc = [[CustomerWebViewController alloc] init]; vc.titleStr = NSLocalizedString(@"my_set_no_app_kefu",nil); NSDictionary *dictLogin = [[UseAccountManage shareInstance] getLoginInfo]; if (dictLogin && [[dictLogin allKeys] containsObject:@"token"]) { NSString *tokenStr = [dictLogin objectForKey:@"token"]; NSString *url = [NSString stringWithFormat:@"http://192.168.11.32:11180/cloud/privacy/#/pages/setup/online-customer-service?autoopen=true&token=%@", tokenStr]; // if ([CloudService containsString:@"14.18.190.141:11180"]) { // 测试环境 // url = [NSString stringWithFormat:@"http://testprivacy.phone.armclouding.com:11180/h5/customer-service?autoopen=true&token=%@", tokenStr]; // } vc.webUrl = url; [self.navigationController pushViewController:vc animated:YES]; } } else if (4 == row){/*购买记录*/ /*跳入订单界面*/ PayRecoderListViewController *nextVC = [[PayRecoderListViewController alloc] init]; [self.navigationController pushViewController:nextVC animated:YES]; }else if (5 == row){/*重启空间*/ NSArray *phoneList = [UseAccountManage shareInstance].cloudPhoneListModel.diskInfo; if (!phoneList || phoneList.count == 0){ [[iToast makeText:NSLocalizedString(@"my_set_no_restart_phone_tips_no_vip",nil)] show]; return; } /*弹窗提示重启*/ ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil) msg:nil cancelTitle:NSLocalizedString(@"other_cancel",nil) okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil)]; nextVC.modalPresentationStyle = UIModalPresentationCustom; nextVC.delegate = self; [self presentViewController:nextVC animated:YES completion:^{ nextVC.view.superview.backgroundColor = [UIColor clearColor]; }]; }else if (6 == row){/*退出登录*/ [self.navigationController popToRootViewControllerAnimated:NO]; [[UseAccountManage shareInstance] logout]; } } - (void)okBtnClickPressed{ /*重启云手机*/ [self showNewIndicatorWithCanBack:YES canTouch:NO]; CloudPhoneModel *model = [UseAccountManage shareInstance].cloudPhoneListModel.diskInfo.firstObject; [[UseAccountManage shareInstance] CommonGetWithCallBackCode:GetPhonereboot Parameters:@{@"userCardId":[NSNumber numberWithInteger:model.userCardId]} success:^(id _Nonnull responseObject) { HLog(@"%@", responseObject); [self removeNewIndicator]; SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil]; if (model.status && model.status.integerValue == 0) { if (model.msg.length > 0){ [[iToast makeText:model.msg] show]; }else{ [[iToast makeText:NSLocalizedString(@"my_set_no_restart_phone_ok_tips",nil)] show]; } } else { [[iToast makeText:model.msg] show]; } } failure:^(NSError * _Nonnull error) { HLog(@"%@", error); [[iToast makeText:@"网络异常,请稍后重试!"] show]; [self removeNewIndicator]; }]; } - (void)vipBtnPressed{ /*跳转购买界面*/ BuyVIPViewController *nextVC = [[BuyVIPViewController alloc] init]; [self.navigationController pushViewController:nextVC animated:YES]; } @end