123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 |
- //
- // JXVIPDetailViewController.m
- // shiku_im
- //
- // Created by cindy on 2020/5/29.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXVIPDetailViewController.h"
- #import "XFStepView.h"
- #import "JXVipCenterView.h"
- #import "JXMyModel.h"
- #import "JXVipDetailHeaderView.h"
- #import "JXVipDetailCenterView.h"
- #import "JXVipDetailBottomView.h"
- #import "LabelSize.h"
- #import "Common.h"
- @interface JXVIPDetailViewController ()<JXVipDetailCenterViewDelegate>
- @property (nonatomic, strong) UIScrollView *mainScrollView;
- @property (nonatomic, strong) JXVipDetailHeaderView *headerView;//头部UI
- @property (nonatomic, strong)JXVipDetailCenterView *centerView;
- @property (nonatomic, strong)JXVipDetailBottomView *bottomView;
- @property (nonatomic,strong) NSMutableArray *dataArr;
- @property (nonatomic,assign) int page;
- @property (nonatomic,strong) NSDictionary *getUserDict;
- @end
- @implementation JXVIPDetailViewController
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- [self.navigationController setNavigationBarHidden:NO];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- _getUserDict=[NSDictionary dictionary];
- _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 getUser:g_server.myself.userId toView:self];
- }
- #pragma mark --- 请求成功
- -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
-
- //NSLog(@"dict: %@ --- arry: %@",dict ,array1 );
- if([aDownload.action isEqualToString:act_UserGet]){
-
- //头像
- [g_server delHeadImage:g_server.myself.userId];
- [g_server getHeadImageSmall:g_server.myself.userId userName:g_server.myself.userNickname imageView:self.headerView.headerImageView];
-
- //昵称
- self.headerView.nameLabel.text = [NSString stringWithFormat:@"%@",dict[@"membershipAccount"]];
-
- if ([dict[@"gradeIndex"] isEqualToNumber:@0]) {
- self.headerView.myGradeBigBackView.image=[UIImage imageNamed:[NSString stringWithFormat:@"vip_icon_%@",@"1"]];
- }
- self.headerView.myGradeBigBackView.image=[UIImage imageNamed:[NSString stringWithFormat:@"vip_icon_%@",dict[@"gradeIndex"]]];
-
- if ([dict[@"gradeIndex"] intValue]>=2) {
- self.headerView.myGradeView.image = [UIImage imageNamed:[NSString stringWithFormat:@"组%d",[dict[@"gradeIndex"] intValue]+43]];
- }else{
- self.headerView.myGradeView.image = [UIImage imageNamed:[NSString stringWithFormat:@"组%d",[dict[@"gradeIndex"] intValue]+42]];
- }
-
-
-
- //右边等级值
- self.headerView.numberLabel.text = [NSString stringWithFormat:@"%@",dict[@"gradeIndex"]];
- // rechargeMoney
- //进度条左右按钮
- // dict[@"gradeIndex"] = @"10";
- if ([dict[@"gradeIndex"] intValue]>=10) {
- [self.headerView.leftGradeButton setTitle:[NSString stringWithFormat:@"%d级",9] forState:UIControlStateNormal];
- [self.headerView.nextGradeButton setTitle:[NSString stringWithFormat:@"%d级",10] forState:UIControlStateNormal];
- }else {
- NSString *vipleftIMG=[NSString stringWithFormat:@"%d级",[dict[@"gradeIndex"] intValue]];
- NSString *viprightIMG=[NSString stringWithFormat:@"%d级",[dict[@"gradeIndex"] intValue]+1];
- [self.headerView.leftGradeButton setTitle:vipleftIMG forState:UIControlStateNormal];
- [self.headerView.nextGradeButton setTitle:viprightIMG forState:UIControlStateNormal];
- }
-
-
- _getUserDict=dict;
- 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];
-
- //累计存款值
- self.headerView.currentPriceLabel.text =[NSString stringWithFormat:@"%@",dict[@"totalRecharge"]];
-
- //中间View赋值
- NSString *sss = [NSString stringWithFormat:@"%@",dict[@"gradeIndex"]];
- int p = [sss intValue];
- self.page = p;
-
-
- }if([aDownload.action isEqualToString:act_userGradelistGrade]){
- [SVProgressHUD dismiss];
- NSArray *array =[[array1 reverseObjectEnumerator] allObjects];
- _dataArr=[vipDetailModel mj_objectArrayWithKeyValuesArray:array];
-
- [self _createdCenterView:_dataArr];
-
- [self _createdBottomView];
- NSLog(@"page===%d",self.page);
-
- self.centerView.stepView.stepIndex =_page-1;
-
- NSDictionary *dictCurrent = _getUserDict[@"vipInfo"];
-
- //当前用户的钱
- CGFloat aaaaMoney= [_getUserDict[@"totalRecharge"] intValue]*1.0;
- //当前用户的等级
- int aaaa= [dictCurrent[@"current"][@"gradeIndex"] intValue];
-
- //int aaaaMoney= [dictCurrent[@"current"][@"rechargeMoney"] intValue];
-
- // 进度 = (累计-当前级)/(下一级晋级-当前级)
- CGFloat aaaaxx=0.0;
-
-
- if (aaaa==0) {
- aaaa=1;
- }
- // 当前级
- vipDetailModel *model1 = _dataArr[aaaa-1];
- int chaMoney1= [model1.rechargeMoney intValue];
- // 下一级
- vipDetailModel *model2 = _dataArr[aaaa];
- int chaMoney2= [model2.rechargeMoney intValue];
- if (aaaa==10) {
- aaaaxx= 1;
- }else {
- aaaaxx = (aaaaMoney-chaMoney1)/(chaMoney2-chaMoney1)*1.0;
- }
- if (aaaaxx>1) {
- aaaaxx=1;
- }
-
- /* */
- //进度值
- self.headerView.progressLabel.text=[NSString stringWithFormat:@"%.f%%",floor(aaaaxx*100)];
-
- if ( aaaaxx !=0) {
- //更新进度Label的x坐标
- [self.headerView.progressLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.headerView.leftGradeButton.mas_right).offset(aaaaxx* self.headerView.progressImageView.frame.size.width);
- }];
- //当前进度View
- [self.headerView.currentProgressImageView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.offset(aaaaxx* self.headerView.progressImageView.frame.size.width);
- }];
-
- }
-
-
- if (self.page*100 >kScreenWidth) { //判断是否超出屏幕
- self.centerView.grapeScrollView.contentOffset = CGPointMake((self.page *100)-kScreenWidth, 0);
- }else {
- self.centerView.grapeScrollView.contentOffset = CGPointMake(0, 0);
- }
- self.centerView.currentPageLabel.text = [NSString stringWithFormat:@"%d",self.page];
- //底部View赋值
- self.bottomView.zunxiangLabel.text = [NSString stringWithFormat:@"VIP%d尊享",self.page];
-
- self.centerView.pictureScrollView.contentOffset = CGPointMake(self.centerView.pictureScrollView.width*(self.page-1), 0);
-
-
- //int aaaa2222= [dictCurrent[@"current"][@"gradeIndex"] intValue];
-
-
- // if (i == self.page) {
- if (aaaa<1) {
- return;
- }
- NSArray *images=@[@"sjlj",@"群聊等级VIp标识",@"meirhb",@"bqb",@"bqb"];
-
- for (int i=0; i<images.count; i++) {
- vipDetailModel *model = _dataArr[aaaa-1];
-
- UIButton *but = (UIButton *)[_bottomView viewWithTag:10+i];
- UILabel *titleLabel = (UILabel *)[but viewWithTag:200+i];
- UILabel *titleLabel2 = (UILabel *)[but viewWithTag:300+i];
- UIImageView *imageLevel = (UIImageView *)[but viewWithTag:100+i];
-
- if (i==0) {
- titleLabel.text = model.upgradeAward;
- }if (i==2) {
- // titleLabel2.text = [NSString stringWithFormat:@"%zd ",model.bubbleFontSet.count];
- titleLabel.text = @"1";
- titleLabel2.text = @"准点红包(群聊专属)";
-
- }if (i==1) {
-
- [imageLevel sd_setImageWithURL:[NSURL URLWithString:model.vipUrl] placeholderImage:[UIImage imageNamed:@"群聊等级VIp标识"]];
- titleLabel.text = model.vipName;
-
-
-
- }if (i==3) {
- titleLabel.text = [NSString stringWithFormat:@"特殊表情包"];
- titleLabel2.text = [NSString stringWithFormat:@"%@",@"VIP8级以上会员专享"];
- if ([model.grade intValue]>=8) {
- but.hidden=NO;
-
-
- } else{
-
- but.hidden=YES;
- }
- }if (i==4) {
- titleLabel.text = [NSString stringWithFormat:@"视频服务"];
-
- if ([model.grade intValue]>=8) {
- but.hidden=NO;
- } else{
- but.hidden=YES;
-
- }
- }
- }
- }
- }
- -(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)gobackBtnClick{
-
- [g_navigation dismissViewController:self animated:NO];
- }
- - (void)_createdTopView {
- //顶部UI
- self.headerView = [[JXVipDetailHeaderView alloc] init];
- [self.headerView.gobackBtn addTarget:self action:@selector(gobackBtnClick) forControlEvents:UIControlEventTouchUpInside];
- self.headerView.headerImageView.image = [UIImage imageNamed:@"组1"];
- self.headerView.nameLabel.text = self.name;
- self.headerView.numberLabel.text = self.dengji;
- [self.headerView.leftGradeButton setTitle:[NSString stringWithFormat:@"%@级",self.dengji] forState:UIControlStateNormal];
- [self.headerView.nextGradeButton setTitle:[NSString stringWithFormat:@"%d级",[self.dengji intValue]+1] forState:UIControlStateNormal];
- self.headerView.progressLabel.text = @"0%";
- self.headerView.currentPriceLabel.text = @"0";
- [self.mainScrollView addSubview:self.headerView];
- [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(@0);
- make.top.equalTo(@0);
- make.centerX.offset(0);
- make.right.equalTo(@0);
- make.height.equalTo(@280);
- }];
- }
- - (void)_createdCenterView:(NSMutableArray *)array {
-
- self.centerView = [[JXVipDetailCenterView alloc] initWithFrame:CGRectZero Titles:array];
- self.centerView.delegate = self;
- [self.mainScrollView addSubview:self.centerView];
- [self.centerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(@0);
- make.top.equalTo(self.headerView.mas_bottom).offset(20);
- make.right.equalTo(@0);
- make.height.equalTo(@210);
- }];
- }
- - (void)_createdBottomView {
- self.bottomView = [[JXVipDetailBottomView alloc] init];
- [self.mainScrollView addSubview:self.bottomView];
- _bottomView.userInteractionEnabled=YES;
- [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(@0);
- make.top.equalTo(self.centerView.mas_bottom).offset(10);
- make.right.equalTo(@0);
- make.height.equalTo(@200);
-
- }];
-
-
- }
- #pragma mark -UIScrollView delegate
- - (void)scrollViewDidEndDeceleratingWithCenterView:(UIScrollView *)scrollView {
- int page = (scrollView.contentOffset.x /scrollView.width)+1;
- int p = scrollView.contentOffset.x /scrollView.width;
-
- self.centerView.currentPageLabel.text = [NSString stringWithFormat:@"%d",page];
- //当前显示的图片数量
- self.centerView.stepView.stepIndex = p;
-
- if (page*100 >kScreenWidth) { //判断是否超出屏幕
- self.centerView.grapeScrollView.contentOffset = CGPointMake((page *100)-kScreenWidth, 0);
- }else {
- self.centerView.grapeScrollView.contentOffset = CGPointMake(0, 0);
- }
- NSArray *images=@[@"sjlj",@"群聊等级VIp标识",@"meirhb",@"bqb",@"bqb",@"bqb"];
-
-
- for (int i=0; i<=p; i++) {
- self.bottomView.zunxiangLabel.text = [NSString stringWithFormat:@"VIP%d尊享",p+1];
-
- for (int a=0; a<images.count; a++) {
- vipDetailModel *stringModel = _dataArr[p];
- UIButton *but = (UIButton *)[_bottomView viewWithTag:10+a];
- UILabel *titleLabel = (UILabel *)[but viewWithTag:200+a];
- UILabel *titleLabel2 = (UILabel *)[but viewWithTag:300+a];
- UIImageView *imageLevel = (UIImageView *)[but viewWithTag:100+i];
- if (a==0) {
- titleLabel.text = stringModel.upgradeAward;
-
- }if (a==2) {
- titleLabel.text = @"1";
- titleLabel2.text = @"准点红包(群聊专属)";
- }if (a==1) {
- [imageLevel sd_setImageWithURL:[NSURL URLWithString:stringModel.vipUrl] placeholderImage:[UIImage imageNamed:@"群聊等级VIp标识"]];
- titleLabel.text = stringModel.vipName;
- titleLabel2.text = @"荣誉称号";
- }if (a==3) {
-
- titleLabel2.text = [NSString stringWithFormat:@"%@",@"VIP8级以上会员专享"];
- if ([stringModel.grade intValue]>=8) {
- but.hidden=NO;
-
-
- } else{
-
- but.hidden=YES;
- }
- }
- if (a==4) {
-
- if ([stringModel.grade intValue]>=8) {
- but.hidden=NO;
- titleLabel.text = [NSString stringWithFormat:@"视频服务"];
- } else{
- but.hidden=YES;
-
- }
-
- }
-
-
-
- }
- }
-
- }
- - (UIScrollView *)mainScrollView {
- if (!_mainScrollView) {
- _mainScrollView = [[UIScrollView alloc] init];
- // _mainScrollView.bounces = NO;
- _mainScrollView.backgroundColor = kWhiteColor;
- [self.view addSubview:_mainScrollView];
- [_mainScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(@0);
- make.top.equalTo(@0);
- make.right.equalTo(@0);
- make.bottom.equalTo(@0);
- }];
-
- if (JX_SCREEN_HEIGHT>=812) {
-
-
- }else{
-
- UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc]
- initWithTarget:self
- action:@selector(foundSwipe:)];
- //设置识别滑动方向
- recognizer.direction =UISwipeGestureRecognizerDirectionUp;
- //Swipe手势识别器关联到View
- [_mainScrollView addGestureRecognizer:recognizer];
-
- UISwipeGestureRecognizer *recognizer2 = [[UISwipeGestureRecognizer alloc]
- initWithTarget:self
- action:@selector(foundSwipe2:)];
- recognizer2.direction =UISwipeGestureRecognizerDirectionDown;
- [_mainScrollView addGestureRecognizer:recognizer2];
- }
-
-
- }
- return _mainScrollView;
- }
- - (void)foundSwipe2:(UISwipeGestureRecognizer *)sender {
-
- //设置识别滑动方向
- sender.direction =UISwipeGestureRecognizerDirectionDown;
- //Swipe手势识别器关联到View
- [self.view addGestureRecognizer:sender];
- [UIView animateWithDuration:0.2 animations:^{
- CGRect bounds=self.view.bounds;
- bounds.origin.y=0;
- _mainScrollView.bounds=bounds;
- }];
-
- }
- - (void)foundSwipe:(UISwipeGestureRecognizer *)sender {
-
-
-
- [UIView animateWithDuration:0.2 animations:^{
-
- CGRect bounds=_mainScrollView.bounds;
- if (JX_SCREEN_WIDTH>=414) {
- bounds.origin.y=15;
- }else{
- bounds.origin.y=80;
- }
- _mainScrollView.bounds=bounds;
- }];
-
- }
- @end
|