123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352 |
- //
- // DRPrivilegeReferralViewController.m
- // YouHuiProject
- //
- // Created by jcymac on 2018/5/21.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "DRPrivilegeReferralViewController.h"
- #import "DRPrivilegeReferralTableViewCell.h"
- #import "DRMyFansViewController.h"
- #import "DRInviteFansViewController.h"
- #import "DRPushToWeixViewController.h"
- #import "DRTopLevelView.h"
- #import "UIView+CCShadow.h"
- #import "DRMiddlePlanView.h"
- #import "DRBottomRuleView.h"
- #import "DRMyFansViewController.h"
- #import "DRChildAccountViewController.h"
- #import "DRAchievementViewController.h"
- @interface DRPrivilegeReferralViewController ()<UIScrollViewDelegate,TopLevelViewDelegate>
- {
- NSInteger _layoutCount;
- ActivityIndicatorView *_indicatorView;
- }
- @property (nonatomic, strong) UIScrollView *scrollView;
- @property (nonatomic, strong) DRTopLevelView *topLevelView;
- @property (nonatomic, strong) UIPageControl *pageCrontrol;
- @property (nonatomic, strong) DRMiddlePlanView *middlePlan;
- @property (nonatomic, strong) UIView *containerView;
- @property (nonatomic, strong) DRBottomRuleView *bottomRuleView;
- @property (nonatomic, strong) UIButton *bottomButton;
- @end
- @implementation DRPrivilegeReferralViewController
- #pragma mark -生命周期
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor=[UIColor whiteColor];
- [self configNavigationBar];
- [self initSubViews];
- [self loadPrivilegeData];
- [self initLoadingView];
-
-
- }
- -(void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
- }
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
-
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
-
- }
- -(void)viewDidDisappear:(BOOL)animated{
- [super viewDidDisappear:animated];
-
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
- }
- - (void)initLoadingView {
- ActivityIndicatorView *indicatorView = [ActivityIndicatorView showInView:self.view frame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)];
- _indicatorView = indicatorView;
- [_indicatorView startAnimating];
- }
- - (void)initSubViews {
-
-
- [self.view addSubview:self.scrollView];
- [self.scrollView addSubview:self.containerView];
- [self.containerView addSubview:self.topLevelView];
- [self.containerView addSubview:self.pageCrontrol];
- [self.containerView addSubview:self.middlePlan];
- [self.containerView addSubview:self.bottomRuleView];
- [self.containerView addSubview:self.bottomButton];
-
- [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(NavBarHeight);
- make.right.left.mas_equalTo(0);
- make.height.mas_equalTo(SCREEN_HEIGHT-NavBarHeight);
- }];
-
- [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.scrollView);
- make.width.equalTo(self.scrollView);
- }];
-
- [self.topLevelView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.top.mas_equalTo(10);
- make.right.mas_equalTo(-20);
- make.height.mas_equalTo(360);
- }];
- [self.pageCrontrol mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(100);
- make.height.mas_equalTo(18);
- make.top.mas_equalTo(self.topLevelView.mas_bottom).mas_offset(3);
- make.centerX.mas_equalTo(self.topLevelView.mas_centerX);
- }];
- [self.middlePlan mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.top.mas_equalTo(self.pageCrontrol.mas_bottom).mas_offset(3);
- make.right.mas_equalTo(-20);
- make.height.mas_equalTo(120);
- }];
-
- [self.bottomRuleView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.middlePlan.mas_bottom).mas_offset(20);
- make.left.mas_equalTo(20);
- make.right.mas_equalTo(-20);
- }];
-
- [self.bottomButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.bottomRuleView.mas_bottom).mas_offset(20);
- make.width.mas_equalTo(Fitsize(307));
- make.height.mas_equalTo(Fitsize(40));
- make.centerX.mas_equalTo(self.containerView.mas_centerX);
- }];
-
- [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.bottomButton.mas_bottom).offset(60);// 这里放最后一个view的底部
- }];
-
-
- }
- - (void)loadPrivilegeData {
- NSDictionary *para = @{@"type":@(1)};
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/adzoneCreate/getPrivilegeTop",BaseURL];
- [DRHttp post:url params:para success:^(id json) {
-
- NSArray *arr = [NSArray yy_modelArrayWithClass:[DRPrivilegeReferralModel class] json:json[@"data"]];
- CGFloat headerHeight = (SCREEN_WIDTH-40)*49/340;
- [self.topLevelView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(arr.count*90+headerHeight);
- }];
- [self.topLevelView setScrollViewContentHeight:arr.count*90+headerHeight];
- [self.view layoutIfNeeded];
- [self subviewLayoutComplete];
- } failure:^(NSError *error) {
-
- }];
- }
- - (void)configNavigationBar {
- self.navigationBar.backgroundColor = [UIColor clearColor];
- [self.navigationBar setNavTitle:@""];
- self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
- UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
- [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
- [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- [self.navigationBar setCustomLeftButtons:@[leftBtn]];
- UIImageView *imgTitle = [[UIImageView alloc] initWithFrame:CGRectMake(0, KStatusBarHeight+(44-18)/2, 75, 18)];
- imgTitle.image = [UIImage imageNamed:@"privilege_referral_top_title"];
- [self.navigationBar addSubview:imgTitle];
- imgTitle.centerX = SCREEN_WIDTH/2;
-
- UIImageView *imgBg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, Fitsize(300))];
- imgBg.image = [UIImage imageNamed:@"privilege_bg_hei"];
- [self.view addSubview:imgBg];
-
- self.view.backgroundColor = [UIColor yhGrayColor];
- }
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)subviewLayoutComplete {
- _layoutCount++;
- if (_layoutCount >= 3) {
- [self.view layoutIfNeeded];
- [self.topLevelView addShadowWithOpacity:.5 shadowRadius:5 andCornerRadius:9 andShadowColor:[UIColor YHColorWithHex:0x9D9D9B]];
- [self.middlePlan addShadowWithOpacity:.5 shadowRadius:5 andCornerRadius:9 andShadowColor:[UIColor YHColorWithHex:0x9D9D9B]];
- [self.bottomRuleView addShadowWithOpacity:.5 shadowRadius:5 andCornerRadius:9 andShadowColor:[UIColor YHColorWithHex:0x9D9D9B]];
-
- NSDictionary *userDic = [DRUserInfoManager shareManager].userInfoDic;
- DRUserInfo *userInfo = [DRUserInfo yy_modelWithJSON:userDic];
-
- [self.topLevelView setScollViewIndex:[userInfo.user_level integerValue]];
-
- [_indicatorView stopAnimating];
- }
- }
- - (void)jumpToPageWithType:(NSString *)type {
- switch ([type integerValue]) {
- case 1:
- //我的好友
- [self goToMyFansPage];
- break;
- case 2:
- //我的收益
- [self gotoMyIncomePage];
- break;
- case 3:
- //我的余额
- [self gotoMyBlancePage];
- break;
- default:
- break;
- }
- }
- /**
- 我的收益
- */
- - (void)gotoMyIncomePage {
-
- DRAchievementViewController *detail = [[DRAchievementViewController alloc] init];
- [self.navigationController pushViewController:detail animated:YES];
- }
- /**
- 我的粉丝
- */
- - (void)goToMyFansPage {
-
- DRMyFansViewController *myFans = [[DRMyFansViewController alloc] init];
- [self.navigationController pushViewController:myFans animated:YES];
- }
- /**
- 去我的余额界面
- */
- - (void)gotoMyBlancePage {
- DRChildAccountViewController *accountDetail = [[DRChildAccountViewController alloc] init];//提现
- [self.navigationController pushViewController:accountDetail animated:YES];
- }
- /**
- 专属客服
- */
- - (void)connectToUs {
-
-
- DRPushToWeixViewController *weixin = [[DRPushToWeixViewController alloc] init];
- NSDictionary *userDic = [DRUserInfoManager shareManager].userInfoDic;
- DRUserInfo *userInfo = [DRUserInfo yy_modelWithJSON:userDic];
- weixin.userInfo = userInfo;
- [self.navigationController pushViewController:weixin animated:YES];
- }
- #pragma mark ----- TopLevelViewDelegate -----
- - (void)TopLevelViewChangePage:(NSInteger)index {
- self.pageCrontrol.currentPage = index;
- }
- #pragma mark ---------
- - (UIScrollView *)scrollView {
- if (!_scrollView) {
- _scrollView = [[UIScrollView alloc] init];
- _scrollView.showsVerticalScrollIndicator = NO;
- _scrollView.backgroundColor = [UIColor clearColor];
- }
- return _scrollView;
- }
- - (UIView *)containerView {
- if (!_containerView) {
- _containerView = [[UIView alloc] init];
- }
- return _containerView;
- }
- - (DRTopLevelView *)topLevelView {
- if (!_topLevelView) {
- _topLevelView = [[DRTopLevelView alloc] initWithFrame:CGRectMake(20, NavBarHeight, SCREEN_WIDTH-40, 360)];
- _topLevelView.layer.cornerRadius = 9;
- _topLevelView.layer.masksToBounds = YES;
- _topLevelView.delegate = self;
- }
- return _topLevelView;
- }
- - (UIPageControl *)pageCrontrol {
- if (!_pageCrontrol) {
- _pageCrontrol = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 0, 100, 20)];
- _pageCrontrol.numberOfPages = 3;
- _pageCrontrol.currentPage = 0;
- _pageCrontrol.currentPageIndicatorTintColor = [UIColor YHColorWithHex:0xCCA062];
- _pageCrontrol.pageIndicatorTintColor = [UIColor whiteColor];
- }
- return _pageCrontrol;
- }
- - (DRMiddlePlanView *)middlePlan {
- if (!_middlePlan) {
- _middlePlan = [[DRMiddlePlanView alloc] initWithFrame:CGRectMake(20, 0, SCREEN_WIDTH-40, 120)];
- __weak typeof(self) weakSelf = self;
- _middlePlan.layer.cornerRadius = 9;
- _middlePlan.layer.masksToBounds = YES;
- _middlePlan.layoutComplete = ^{
- [weakSelf subviewLayoutComplete];
- };
- _middlePlan.selectedBlock = ^(DRMiddlePrvilegeModel * _Nonnull model) {
- [weakSelf jumpToPageWithType:model.type];
- };
- }
- return _middlePlan;
- }
- - (DRBottomRuleView *)bottomRuleView {
- if (!_bottomRuleView) {
- _bottomRuleView = [[DRBottomRuleView alloc] initWithFrame:CGRectMake(20, 0, SCREEN_WIDTH-40, 40)];
- __weak typeof(self) weakSelf = self;
- _bottomRuleView.layer.cornerRadius = 9;
- _bottomRuleView.layer.masksToBounds = YES;
- _bottomRuleView.backgroundColor = [UIColor whiteColor];
- _bottomRuleView.layoutComplete = ^{
- [weakSelf subviewLayoutComplete];
- };
- }
- return _bottomRuleView;
- }
- - (UIButton *)bottomButton {
- if (!_bottomButton) {
- _bottomButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [_bottomButton setBackgroundImage:[UIImage imageNamed:@"pri_bottom_btn"] forState:UIControlStateNormal];
- [_bottomButton setTitle:@"联系专属客服" forState:UIControlStateNormal];
- _bottomButton.titleLabel.font = [UIFont systemFontOfSize:15];
- [_bottomButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- _bottomButton.layer.cornerRadius = Fitsize(20);
- _bottomButton.layer.masksToBounds = YES;
- [_bottomButton addTarget:self action:@selector(connectToUs) forControlEvents:UIControlEventTouchUpInside];
- }
- return _bottomButton;
- }
- @end
|