// // JXVIPDetailViewController.m // shiku_im // // Created by cindy on 2020/5/29. // Copyright © 2020 Reese. All rights reserved. // #import "JXVIPDetailVc.h" #import "XFStepView.h" #import "JXVipCenterView.h" #import "JXMyModel.h" #import "JXVipDetailTopView.h" @interface JXVIPDetailVc () @property (nonatomic, strong) UIScrollView *mainScrollView; @property (strong, nonatomic)UIImageView *topImageView;//顶部背景图 @property (nonatomic,strong) UIImageView *vipGradeBigImageView; //顶部右边最大的等级图 @property (nonatomic,strong) UILabel *vipNumberLabelForBigVIPGradeImageView; @property (nonatomic,strong) UILabel *vipNumberLabelForvipImageView; @property (nonatomic,strong) UIImageView *headerImageView; @property (nonatomic,strong) UILabel *nameLabel;//昵称 @property (nonatomic,strong) UIButton *leftVipGradeLabel; @property (nonatomic,strong) UIButton *rightVipGradeLabel; @property (nonatomic,strong) UILabel *progressLabel; //进度Label @property (nonatomic,strong)UIView *oneDianView; @property (nonatomic,strong)UIImageView *progressImageView; @property (nonatomic,strong)UIImageView *progressImageView2; @property (nonatomic,strong)UIImageView *progressImageView3; @property (nonatomic,strong)UIImageView *sanjiaoxingView; @property (nonatomic,strong) UILabel *currentLabel; @property (nonatomic,strong)UILabel *currentCompanyLabel; @property (nonatomic,strong)UIView *twoDianView; @property (nonatomic,strong) UILabel *currentPriceLabel; //当前存款数 @property (nonatomic,strong) UILabel *differencePriceLabel; //升级还差的数 @property (nonatomic,strong) UILabel *differenceLabel; @property (nonatomic,strong)UILabel *differenceCompanyLabel; @property (strong, nonatomic)UIView *centerView; @property (strong, nonatomic)XFStepView *stepView; //等级进度UI @property (strong, nonatomic)UIScrollView *grapeScrollView;//等级进度UI的ScrollView @property (strong, nonatomic)UILabel *currentPageLabel;//当前显示的图片数 @property (strong, nonatomic)UIScrollView *centerScrollView; @property (strong, nonatomic)UIView *bottomView; @property (strong, nonatomic)UIButton *button; @property (strong, nonatomic)UILabel *zunxiangLabel;//尊享Label @property (strong, nonatomic)UIImageView *buttonIconImageView;; @property (strong, nonatomic)UILabel *buttonTitleLabel; @property (strong, nonatomic)UILabel *buttonDetailLabel; @property (nonatomic,strong) NSMutableArray *dataArr; @property (nonatomic,strong) UIImageView *vipGradeImageView; @property (nonatomic,assign) int page; @property (nonatomic,strong) JXVipDetailTopView *topView; @end @implementation JXVIPDetailVc - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO]; } - (void)viewDidLoad { [super viewDidLoad]; _dataArr=[NSMutableArray array]; //自定义导航栏 [self _createdNavigationBar]; //创建View [self _createdViews]; } //自定义导航栏 - (void)_createdNavigationBar { self.navigationItem.title=@"VIP特权"; long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; ///user/vip/info /user/vip/info [g_server getact_act_userGradelistGrade:salt andToView:self]; [SVProgressHUD show]; [g_server getUserVipInformation:salt andToView:self]; [g_server getUseract_userGradelistGrade:salt andToView:self]; } #pragma mark --- 请求成功 -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{ // NSLog(@"dict: %@ --- arry: %@",dict ,array1 ); if([aDownload.action isEqualToString:act_userGradelistGrade]){ _dataArr=[vipDetailModel mj_objectArrayWithKeyValuesArray:array1]; // NSArray *smallArray = [_dataArr subarrayWithRange:NSMakeRange(0, 10)]; // _dataArr=[smallArray mutableCopy]; [self _createdCenterView:_dataArr]; } if([aDownload.action isEqualToString:act_userViplist]){ // _dataArr=[vipDetailModel mj_objectArrayWithKeyValuesArray:array1]; // NSArray *smallArray = [_dataArr subarrayWithRange:NSMakeRange(0, 10)]; // // _dataArr=[smallArray mutableCopy]; // [self _createdCenterView:_dataArr]; // // [self _createdBottomView]; }if([aDownload.action isEqualToString:act_GetUserVipInformation]){ [SVProgressHUD dismiss]; self.topView.dictInfo=dict; //当前等级 NSString *ss = [NSString stringWithFormat:@"%@",dict[@"current"][@"level"]]; int c = [ss intValue]; self.currentPageLabel.text = [NSString stringWithFormat:@"%d",c]; self.centerScrollView.contentOffset = CGPointMake(self.centerScrollView.width*(c), 0); self.zunxiangLabel.text = [NSString stringWithFormat:@"VIP%d尊享",c]; for (int i=0; i<_dataArr.count; i++) { if (i == c) { vipDetailModel *model = _dataArr[c]; self.vipNumberLabelForvipImageView.text =[NSString stringWithFormat:@"%@",model.level]; UIImageView *imageView = (UIImageView *)[_centerView viewWithTag:200+(c)]; UILabel *label1 = (UILabel *)[imageView viewWithTag:1000+(c)]; label1.text = [NSString stringWithFormat:@"VIP%@",model.level]; UILabel *label2 = (UILabel *)[imageView viewWithTag:10000+(c)]; label2.text = [NSString stringWithFormat:@"%@",model.money]; UIButton *but = (UIButton *)[self.bottomView viewWithTag:10]; UIButton *but2 = (UIButton *)[self.bottomView viewWithTag:10+2]; UILabel *titleLabel = (UILabel *)[but viewWithTag:200]; UILabel *titleLabel2 = (UILabel *)[but2 viewWithTag:200+c]; titleLabel.text = model.money; titleLabel2.text = model.upgradeCoin; } } // [self.mainScrollView reloadInputViews]; } } -(CGSize)titleBtnWight:(NSString *)titBtnW and:(UILabel *)titBtn { CGSize titleSize = [titBtnW boundingRectWithSize:CGSizeMake(MAXFLOAT, 17) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:titBtn.font} context:nil].size; return titleSize; } -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{ [SVProgressHUD dismiss]; NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]]; if([errorCode isEqualToString:@"权限验证失败"]) { if ([aDownload.action isEqualToString:act_userViplist]) { }if([aDownload.action isEqualToString:actuservipinfo]){ } } return [errorCode intValue]; } - (void)goback{ [g_navigation dismissViewController:self animated:NO]; } - (void)_createdViews { _dataArr=[NSMutableArray array]; //顶部UI [self _createdTopView]; } - (void)gobackxx{ [g_navigation dismissViewController:self animated:YES]; } - (void)_createdTopView { JXVipDetailTopView *topView=[JXVipDetailTopView XIBJXVipDetailTopView]; topView.frame=CGRectMake(0, 0, JX_SCREEN_WIDTH, 260); self.topView=topView; [self.mainScrollView addSubview:topView]; [topView.gobackBt addTarget:self action:@selector(gobackxx) forControlEvents:UIControlEventTouchUpInside]; return; //顶部图。V1 self.topImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 250)]; self.topImageView.image=[UIImage imageNamed:@"bgVip02"]; [self.mainScrollView addSubview:self.topImageView]; //最右边VIP等级big图 UIImageView *vipGradeBigImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.topImageView.width-100, 0, 65, 85)]; vipGradeBigImageView.image = [UIImage imageNamed:@"组54"]; [self.topImageView addSubview:vipGradeBigImageView]; UILabel *vip = [[UILabel alloc] initWithFrame:CGRectMake(0, 40, vipGradeBigImageView.width, 15)]; vip.text = @"VIP"; vip.textColor = [UIColor brownColor]; vip.textAlignment = NSTextAlignmentCenter; vip.font = kBoldFont(8); [vipGradeBigImageView addSubview:vip]; self.vipNumberLabelForBigVIPGradeImageView = [[UILabel alloc] initWithFrame:CGRectMake(0, vip.bottom, vipGradeBigImageView.width, 15)]; self.vipNumberLabelForBigVIPGradeImageView.text = @"0"; self.vipNumberLabelForBigVIPGradeImageView.textColor = [UIColor brownColor]; self.vipNumberLabelForBigVIPGradeImageView.textAlignment = NSTextAlignmentCenter; self.vipNumberLabelForBigVIPGradeImageView.font = kBoldFont(20); [vipGradeBigImageView addSubview:self.vipNumberLabelForBigVIPGradeImageView]; //头像 self.headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 15, 70, 70)]; self.headerImageView.layer.cornerRadius= 35; self.headerImageView.layer.masksToBounds = YES; [self.topImageView addSubview:self.headerImageView]; [g_server delHeadImage:g_server.myself.userId]; [g_server getHeadImageSmall:g_server.myself.userId userName:g_server.myself.userNickname imageView:self.headerImageView]; //昵称 self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.headerImageView.right+15, 30, 100, 25)]; self.nameLabel.text = @"唐小七"; self.nameLabel.textColor = [UIColor blackColor]; self.nameLabel.textAlignment = NSTextAlignmentLeft; self.nameLabel.font = [UIFont boldSystemFontOfSize:17]; [self.topImageView addSubview:self.nameLabel]; //vip等级 self.vipGradeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.nameLabel.right+5, 34, 50, 17)]; self.vipGradeImageView.image = [UIImage imageNamed:@"组38"]; //self.vipGradeImageView.backgroundColor = [UIColor yellowColor]; [self.topImageView addSubview:self.vipGradeImageView]; self.leftVipGradeLabel = [[UIButton alloc] initWithFrame:CGRectMake(35, self.headerImageView.bottom+40, 60, 30)]; // self.leftVipGradeLabel .backgroundColor = [UIColor brownColor]; self.leftVipGradeLabel .layer.cornerRadius = 10; self.leftVipGradeLabel .layer.masksToBounds = YES; self.leftVipGradeLabel.imageView.contentMode = UIViewContentModeScaleAspectFill; //[self.leftVipGradeLabel setTitle:@"VIP0" forState:UIControlStateNormal]; self.leftVipGradeLabel.titleLabel.font = [UIFont systemFontOfSize:13]; [self.topImageView addSubview:self.leftVipGradeLabel ]; self.rightVipGradeLabel = [[UIButton alloc] initWithFrame:CGRectMake(self.topImageView.width-80, self.headerImageView.bottom+40, 60, 30)]; //self.rightVipGradeLabel.backgroundColor = [UIColor lightGrayColor]; self.rightVipGradeLabel.layer.cornerRadius = 10; self.rightVipGradeLabel.layer.masksToBounds = YES; self.rightVipGradeLabel.imageView.contentMode = UIViewContentModeScaleAspectFill; //[self.leftVipGradeLabel setTitle:@"VIP1" forState:UIControlStateNormal]; self.rightVipGradeLabel.titleLabel.font = [UIFont systemFontOfSize:13]; [self.topImageView addSubview:self.rightVipGradeLabel]; self.progressImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.leftVipGradeLabel.right+10, self.headerImageView.bottom+45, self.topImageView.width-90-90, 20)]; // self.progressImageView.backgroundColor = [UIColor blueColor]; // self.progressImageView.layer.cornerRadius=7; self.progressImageView.image = [UIImage imageNamed:@"my_progress"]; self.progressImageView.contentMode = UIViewContentModeScaleToFill; [self.topImageView addSubview:self.progressImageView]; self.progressImageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 0, 20)]; self.progressImageView2.layer.cornerRadius=7; self.progressImageView2.backgroundColor = kRGBColor(222, 186, 152); [self.progressImageView addSubview:self.progressImageView2]; self.progressImageView3 = [[UIImageView alloc] initWithFrame:CGRectMake(self.leftVipGradeLabel.right+10, self.headerImageView.bottom+39, 42 , 32)]; self.progressImageView3.image = [UIImage imageNamed:@"组37"]; [self.topImageView addSubview:self.progressImageView3]; self.progressLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.leftVipGradeLabel.right+self.progressImageView2.width, self.headerImageView.bottom+15, 50, 20)]; self.progressLabel.text = @"2%"; self.progressLabel.textColor = [UIColor blackColor]; self.progressLabel.textAlignment = NSTextAlignmentLeft; self.progressLabel.font = [UIFont systemFontOfSize:13]; [self.topImageView addSubview:self.progressLabel]; self.sanjiaoxingView = [[UIImageView alloc] initWithFrame:CGRectMake(self.leftVipGradeLabel.right+self.progressImageView2.width, self.progressLabel.bottom, 15, 10)]; self.sanjiaoxingView.image = [UIImage imageNamed:@"组38"]; // self.sanjiaoxingView.backgroundColor = [UIColor redColor]; [self.topImageView addSubview:self.sanjiaoxingView]; //当前累计存款 self.oneDianView = [[UIView alloc] initWithFrame:CGRectMake(35, self.headerImageView.bottom+100, 6, 6)]; self.oneDianView.layer.cornerRadius = 3; self.oneDianView.layer.masksToBounds = YES; self.oneDianView.backgroundColor = [UIColor grayColor]; [self.topImageView addSubview:self.oneDianView]; self.currentLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.oneDianView.right+3, self.headerImageView.bottom+96, 260, 15)]; self.currentLabel.textAlignment = NSTextAlignmentLeft; self.currentLabel.textColor = [UIColor purpleColor]; self.currentLabel.font = [UIFont systemFontOfSize:12]; self.currentLabel.text = @"当前累计存款(元):"; [self.topImageView addSubview:self.currentLabel]; return; self.currentPriceLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.currentLabel.right+3, self.headerImageView.bottom+96, 100+5, 15)]; self.currentPriceLabel.textAlignment = NSTextAlignmentLeft; self.currentPriceLabel.textColor = [UIColor blackColor]; self.currentPriceLabel.font = [UIFont systemFontOfSize:12]; self.currentPriceLabel.text = @"0.00"; [self.topImageView addSubview:self.currentPriceLabel]; self.currentCompanyLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.currentPriceLabel.right+3, self.headerImageView.bottom+96, 100, 15)]; self.currentCompanyLabel.textAlignment = NSTextAlignmentLeft; self.currentCompanyLabel.textColor = [UIColor purpleColor]; self.currentCompanyLabel.font = [UIFont systemFontOfSize:12]; self.currentCompanyLabel.text = @"(0.00/500)"; [self.topImageView addSubview:self.currentCompanyLabel]; //还差升级存款 self.twoDianView = [[UIView alloc] initWithFrame:CGRectMake(35, self.currentLabel.bottom+14, 6, 6)]; self.twoDianView.layer.cornerRadius = 3; self.twoDianView.layer.masksToBounds = YES; self.twoDianView.backgroundColor = [UIColor grayColor]; [self.topImageView addSubview:self.twoDianView]; self.differenceLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.twoDianView.right+3, self.currentLabel.bottom+10, 100, 15)]; self.differenceLabel.textAlignment = NSTextAlignmentLeft; self.differenceLabel.textColor = [UIColor purpleColor]; self.differenceLabel.font = [UIFont systemFontOfSize:12]; self.differenceLabel.text = @"还差升级存款(元):"; [self.topImageView addSubview:self.differenceLabel]; self.differencePriceLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.differenceLabel.right+3, self.currentLabel.bottom+10, 100, 15)]; self.differencePriceLabel.textAlignment = NSTextAlignmentLeft; self.differencePriceLabel.textColor = [UIColor blackColor]; self.differencePriceLabel.font = [UIFont systemFontOfSize:12]; self.differencePriceLabel.text = @"0.00"; [self.topImageView addSubview:self.differencePriceLabel]; self.differenceCompanyLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.differencePriceLabel.right+3, self.currentLabel.bottom+10, 100, 15)]; self.differenceCompanyLabel.textAlignment = NSTextAlignmentLeft; self.differenceCompanyLabel.textColor = [UIColor purpleColor]; self.differenceCompanyLabel.font = [UIFont systemFontOfSize:12]; self.differenceCompanyLabel.text = @"(0.00/3,000)"; [self.topImageView addSubview:self.differenceCompanyLabel]; } - (void)_createdCenterView:(NSMutableArray *)array { self.centerView = [[UIView alloc] initWithFrame:CGRectMake(0, self.topView.bottom+20, kScreenWidth, 210)]; [self.mainScrollView addSubview:self.centerView]; //等级ScrollView self.grapeScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.centerView.width, 40)]; self.grapeScrollView.contentSize = CGSizeMake(100*array.count, 40); self.grapeScrollView.bounces = NO; [self.centerView addSubview:self.grapeScrollView]; //等级UI _stepView = [[XFStepView alloc]initWithFrame:CGRectMake(0, 0, 100*array.count, 40) Titles:array]; [self.grapeScrollView addSubview:_stepView]; self.centerScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(50, self.grapeScrollView.bottom+10, kScreenWidth-100, 120)]; self.centerScrollView.delegate = self; self.centerView.clipsToBounds = NO; self.centerScrollView.clipsToBounds = NO; self.centerScrollView.pagingEnabled = YES; self.centerScrollView.bounces = NO; self.centerScrollView.showsHorizontalScrollIndicator = NO; self.centerScrollView.contentSize = CGSizeMake(self.centerScrollView.width*array.count, 120); [self.centerView addSubview:self.centerScrollView]; //创建图片 for(int i = 0; i kScreenWidth){ xLeft = 0; yleft = yleft+10+50; } _button.frame = CGRectMake(xLeft + 10, yleft + 10, buttonWidth, 50); _button.tag = 10+i; [self.bottomView addSubview:_button]; self.buttonIconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 0, 25, 40)]; self.buttonIconImageView.image = [UIImage imageNamed:imageArray[i]]; self.buttonIconImageView.contentMode=UIViewContentModeScaleAspectFit; self.buttonIconImageView.tag = 100+i; [_button addSubview:self.buttonIconImageView]; self.buttonTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.buttonIconImageView.right+10, 0, _button.width-(self.buttonIconImageView.right+10), 20)]; self.buttonTitleLabel.text = title; self.buttonTitleLabel.tag = 200+i; self.buttonTitleLabel.textColor = [UIColor blackColor]; self.buttonTitleLabel.font = [UIFont boldSystemFontOfSize:15]; self.buttonTitleLabel.textAlignment = NSTextAlignmentLeft; [_button addSubview:self.buttonTitleLabel]; self.buttonDetailLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.buttonIconImageView.right+10, self.buttonTitleLabel.bottom, _button.width-(self.buttonIconImageView.right+10), 20)]; self.buttonDetailLabel.text = detai; self.buttonDetailLabel.tag = 300+i; self.buttonDetailLabel.textColor = [UIColor lightGrayColor]; self.buttonDetailLabel.font = [UIFont systemFontOfSize:12]; self.buttonDetailLabel.textAlignment = NSTextAlignmentLeft; [_button addSubview:self.buttonDetailLabel]; CGFloat oranginX = CGRectGetMaxX(_button.frame); xLeft = oranginX; } self.mainScrollView.contentSize = CGSizeMake(kScreenWidth, self.bottomView.bottom+100); } #pragma mark -UIScrollView delegate - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { int page = (scrollView.contentOffset.x /scrollView.width)+1; int p = scrollView.contentOffset.x /scrollView.width; self.currentPageLabel.text = [NSString stringWithFormat:@"%d",page]; //当前显示的图片数量 _stepView.stepIndex = p; if (page*100 >kScreenWidth) { //判断是否超出屏幕 self.grapeScrollView.contentOffset = CGPointMake((page *100)-kScreenWidth, 0); }else { self.grapeScrollView.contentOffset = CGPointMake(0, 0); } NSArray *images=@[@"sjlj",@"ltkuang",@"meirhb",@"bqb"]; for (int i=0; i<=p; i++) { self.zunxiangLabel.text = [NSString stringWithFormat:@"VIP%d尊享",p+1]; for (int a=0; a