// // YOUPAILZUnionsPopularizeVC.m // TIANYAN // // Created by CY on 2021/4/12. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAILZUnionsPopularizeVC.h" @interface YOUPAILZUnionsPopularizeVC () @property (nonatomic,strong) NSDictionary *youpaipnetworkData; @end @implementation YOUPAILZUnionsPopularizeVC - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController.navigationBar setClearBar]; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [self.navigationController.navigationBar setDefaultBar]; } - (void)viewDidLoad { [super viewDidLoad]; self.title = @"我的等级"; [self youpaifrequestData]; } - (void)youpaifsetupUI{ NSInteger level = [self.youpaipnetworkData[@"level"] integerValue]; NSInteger num_int = [self.youpaipnetworkData[@"num_int"] integerValue]; NSArray *scales = self.youpaipnetworkData[@"table"]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; scrollView.showsVerticalScrollIndicator = NO; scrollView.showsHorizontalScrollIndicator = NO; [self.view addSubview:scrollView]; UIImageView *headerV = [[UIImageView alloc] init]; headerV.image = [UIImage imageNamed:@"vqu_images_ic_profile_unions_popularize_header_bg"]; [scrollView addSubview:headerV]; [headerV mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.view); make.top.offset(0.0f); make.height.offset(208.0f); }]; UIImageView *levelBigV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"vqu_images_ic_unions_popularize_%ld",level - 1]]]; [headerV addSubview:levelBigV]; [levelBigV mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(headerV.mas_bottom).offset(0.0f); make.centerX.equalTo(headerV); make.size.mas_offset(CGSizeMake(84.0f, 84.0f)); }]; // UILabel *timeL = [[UILabel alloc] init]; // timeL.font = LCFont12; // timeL.textColor = HexColorFromRGB(0xFF80AF); // timeL.text = @"截止时间:5月21日"; // [headerInfoV addSubview:timeL]; // [timeL mas_makeConstraints:^(MASConstraintMaker *make) { // make.right.offset(-16.0f); // make.top.bottom.offset(0.0f); // }]; UIView *levelMinBgV = [[UIView alloc] init]; [scrollView addSubview:levelMinBgV]; [levelMinBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(ScaleSize(22.0f)); make.right.offset(-ScaleSize(22.0f)); make.top.equalTo(headerV.mas_bottom).offset(20.0f); make.height.offset(60.0f); }]; NSMutableArray *levelTitles = [NSMutableArray array]; for (NSInteger i = 0; i < scales.count; i ++) { NSDictionary *dict = scales[i]; [levelTitles addObject:[NSString stringWithFormat:@"%@/%@",@(num_int),[dict objectForKey:@"num_int"]]]; } NSArray *levels = @[ @{@"image":@"vqu_images_ic_unions_popularize_min_selected_0",@"selectedImage":@"vqu_images_ic_unions_popularize_min_selected_0"}, @{@"image":@"vqu_images_ic_unions_popularize_min_1",@"selectedImage":@"vqu_images_ic_unions_popularize_min_selected_1"}, @{@"image":@"vqu_images_ic_unions_popularize_min_2",@"selectedImage":@"vqu_images_ic_unions_popularize_min_selected_2"}, // @{@"image":@"vqu_images_ic_unions_popularize_min_3",@"selectedImage":@"vqu_images_ic_unions_popularize_min_selected_3"}, // @{@"image":@"vqu_images_ic_unions_popularize_min_4",@"selectedImage":@"vqu_images_ic_unions_popularize_min_selected_4"}, ]; CGFloat totalWidth = KScreenWidth - ScaleSize(44.0f); CGFloat width = (totalWidth - 28.0f) / (levels.count - 1); for (NSInteger i = 0; i < levels.count; i ++) { NSInteger currentIndex = level - 1; NSDictionary *dict = levels[i]; UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(i * width, 6.0f, 28.0f, 28.0f)]; imageV.image = [UIImage imageNamed:dict[@"image"]]; [levelMinBgV addSubview:imageV]; UILabel *levelV = [[UILabel alloc] init]; levelV.text =levelTitles[i]; levelV.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.25f]; levelV.font = LCFont(11.0f); levelV.textAlignment = NSTextAlignmentCenter; [levelMinBgV addSubview:levelV]; [levelV mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(imageV); make.top.equalTo(imageV.mas_bottom).offset(4.0f); make.height.offset(16.0f); }]; if (i <= currentIndex) { imageV.image = [UIImage imageNamed:dict[@"selectedImage"]]; levelV.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.85f]; } if (i < levels.count - 1) { UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imageV.frame) + 2.0f, (28.0f - 1.0f) / 2.0f + 6.0f, width - (imageV.mj_h + 4.0f), 1.0f)]; progressView.progress = 0.0f; if (i <= currentIndex - 1) { progressView.progress = 1.0f; } progressView.progressTintColor = HexColorFromRGB(0xFF80AF); progressView.trackTintColor = [HexColorFromRGB(0xAAAAAA) colorWithAlphaComponent:0.30f]; [levelMinBgV addSubview:progressView]; }else{ } } // UILabel *currentLevelL = [[UILabel alloc] init]; // currentLevelL.font = LCFont12; // currentLevelL.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8f]; // currentLevelL.text = @"当前等级"; // [headerV addSubview:currentLevelL]; // [currentLevelL mas_makeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(levelBigV.mas_bottom).offset(4.0f); // make.centerX.equalTo(headerV); // }]; UIView *headerInfoV = [[UIView alloc] init]; headerInfoV.backgroundColor = HexColorFromRGB(0x2F3038); [scrollView addSubview:headerInfoV]; [headerInfoV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(0.0f); make.top.equalTo(levelMinBgV.mas_bottom).offset(20.0f); make.width.offset(KScreenWidth); make.height.offset(40.0f); }]; UILabel *moneyL = [[UILabel alloc] init]; moneyL.font = LCBoldFont(14.0f); moneyL.textColor = [UIColor whiteColor]; moneyL.text = [NSString stringWithFormat:@"%@%@",LCStr(word28),self.youpaipnetworkData[@"num"]];//本期贡献流水: [headerInfoV addSubview:moneyL]; [moneyL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(16.0f); make.top.bottom.offset(0.0f); }]; UILabel *descL = [[UILabel alloc] init]; descL.font = LCFont14; descL.textColor = [UIColor whiteColor]; descL.text = @"推广制度:"; [scrollView addSubview:descL]; [descL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.top.equalTo(headerInfoV.mas_bottom).offset(40.0f); }]; UILabel *contentL = [[UILabel alloc] init]; contentL.font = LCFont12; contentL.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.65f];; contentL.numberOfLines = 0; NSString *str = LCStr(word29); //@"1、用户邀请女神便可成为推广人,当流水达到相对应的成长值时,会自动升级,可跳级成长;\n\n2、成为相应的等级时,推广人会在未来的30天内享受对应的分成比例,若30天内没有达到当前等级的月贡献流水时,则下降一级。"; NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:str]; NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init]; paragraphStyle1.alignment=NSTextAlignmentJustified; NSDictionary * dic =@{ NSParagraphStyleAttributeName:paragraphStyle1, NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone], }; [attributedString1 setAttributes:dic range:NSMakeRange(0, attributedString1.length)]; [contentL setAttributedText:attributedString1]; [scrollView addSubview:contentL]; [contentL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.width.offset(KScreenWidth-28.0f); make.top.equalTo(descL.mas_bottom).offset(20.0f); }]; NSArray *colors = @[ @[HexColorFromRGB(0xE7CCB6),HexColorFromRGB(0xC47A65)], @[HexColorFromRGB(0xCCE5FF),HexColorFromRGB(0x5D93E6)], @[HexColorFromRGB(0xFFE397),HexColorFromRGB(0xDB9E2F)], ]; UIView *footerV = [[UIView alloc] init]; footerV.backgroundColor = HexColorFromRGB(0x2F3038); footerV.layer.cornerRadius = 20.0f; footerV.clipsToBounds = YES; [scrollView addSubview:footerV]; [footerV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.width.offset(KScreenWidth-28.0f); make.top.equalTo(contentL.mas_bottom).offset(40.0f); make.height.offset((ScaleSize(48.0f) * (scales.count + 1))); }]; UIView *fHeaderV = [[UIView alloc] init]; fHeaderV.backgroundColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 28.0f, ScaleSize(48.0f)) FromColors:colors[level - 1] ByGradientType:GradientTopToBottom]]; [footerV addSubview:fHeaderV]; [fHeaderV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.right.offset(0.0f); make.height.offset(ScaleSize(48.0f)); }]; UILabel *levelL = [[UILabel alloc] init]; levelL.font = LCFont14; levelL.textColor = [UIColor whiteColor]; levelL.text = @"推广等级"; levelL.textAlignment = NSTextAlignmentCenter; [fHeaderV addSubview:levelL]; [levelL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.bottom.offset(0.0f); make.width.offset((KScreenWidth - 28.0f) * 0.25f); }]; UILabel *scaleL = [[UILabel alloc] init]; scaleL.font = LCFont14; scaleL.textColor = [UIColor whiteColor]; scaleL.text = LCStr(word30);//1v1分成 scaleL.textAlignment = NSTextAlignmentCenter; [fHeaderV addSubview:scaleL]; [scaleL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.offset(0.0f); make.left.equalTo(levelL.mas_right); make.width.offset((KScreenWidth - 28.0f) * 0.25f); }]; UILabel *liveScaleL = [[UILabel alloc] init]; liveScaleL.font = LCFont14; liveScaleL.textColor = [UIColor whiteColor]; liveScaleL.text = LCStr(word31);//直播分成 liveScaleL.textAlignment = NSTextAlignmentCenter; [fHeaderV addSubview:liveScaleL]; [liveScaleL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.offset(0.0f); make.left.equalTo(scaleL.mas_right); make.width.offset((KScreenWidth - 28.0f) * 0.25f); }]; UILabel *priceL = [[UILabel alloc] init]; priceL.font = LCFont14; priceL.textColor = [UIColor whiteColor]; priceL.text = @"成长值"; priceL.textAlignment = NSTextAlignmentCenter; [fHeaderV addSubview:priceL]; [priceL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.offset(0.0f); make.left.equalTo(liveScaleL.mas_right); make.right.offset(0.0f); }]; // NSArray *levelContents = @[ // @{@"level":@"0",@"scale":@"5%",@"price":@"0"}, // @{@"level":@"1星",@"scale":@"8%",@"price":@"10万"}, // @{@"level":@"2星",@"scale":@"12%",@"price":@"30万"}, // @{@"level":@"3星",@"scale":@"16%",@"price":@"60万"}, // ]; for (NSInteger i = 0; i < scales.count; i ++) { NSDictionary *dict = scales[i]; UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, ScaleSize(48.0f) + i * ScaleSize(48.0f), KScreenWidth - 28.0f, ScaleSize(48.0f))]; [footerV addSubview:view]; UILabel *levelL = [[UILabel alloc] init]; levelL.font = LCFont14; levelL.textColor = [UIColor whiteColor]; levelL.text = [NSString stringWithFormat:@"%@级",dict[@"level"]]; levelL.textAlignment = NSTextAlignmentCenter; [view addSubview:levelL]; [levelL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.bottom.offset(0.0f); make.width.offset((KScreenWidth - 28.0f) * 0.25f); }]; UILabel *scaleL = [[UILabel alloc] init]; scaleL.font = LCFont14; scaleL.textColor = [UIColor whiteColor]; scaleL.text = dict[@"ratio2"]; scaleL.textAlignment = NSTextAlignmentCenter; [view addSubview:scaleL]; [scaleL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.offset(0.0f); make.left.equalTo(levelL.mas_right); make.width.offset((KScreenWidth - 28.0f) * 0.25f); }]; UILabel *liveScaleL = [[UILabel alloc] init]; liveScaleL.font = LCFont14; liveScaleL.textColor = [UIColor whiteColor]; liveScaleL.text = dict[@"ratio1"]; liveScaleL.textAlignment = NSTextAlignmentCenter; [view addSubview:liveScaleL]; [liveScaleL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.offset(0.0f); make.left.equalTo(scaleL.mas_right); make.width.offset((KScreenWidth - 28.0f) * 0.25f); }]; UILabel *priceL = [[UILabel alloc] init]; priceL.font = LCFont14; priceL.textColor = [UIColor whiteColor]; priceL.text = [NSString stringWithFormat:@"%@",dict[@"num_text"]]; priceL.textAlignment = NSTextAlignmentCenter; [view addSubview:priceL]; [priceL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.right.offset(0.0f); make.left.equalTo(liveScaleL.mas_right); }]; if (i == level - 1) { view.backgroundColor = [HexColorFromRGB(0x585A6A) colorWithAlphaComponent:0.47f]; } } [scrollView layoutIfNeeded]; scrollView.contentSize = CGSizeMake(KScreenWidth, footerV.frame.size.height + footerV.frame.origin.y + TabbarHeight); } - (void)youpaifrequestData{ [LCHttpHelper requestWithURLString:UnionsPromotion parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) {//成功 self.youpaipnetworkData = [dict objectForKey:@"data"]; [self youpaifsetupUI]; } } failure:^(NSError *error) { }]; } @end