123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- //
- // YOUPAILCBoardDetailVC.m
- // LiveChat
- //
- // Created by 张灿 on 2018/9/26.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCBoardDetailVC.h"
- #import "YOUPAILCBoardDetailHeadView.h"
- #import "YOUPAILCBoardCell.h"
- #import "YOUPAILZUserShowVC.h"
- @interface YOUPAILCBoardDetailVC()<UITableViewDataSource,UITableViewDelegate,LCBoardDetailHeadViewDeleagte>
- @property(nonatomic,assign)NSInteger youpaiptimeType;// 1周榜 2月榜 3总榜 4日榜
- @property(nonatomic,assign)NSInteger youpaipcurrentPage;
- @property(nonatomic,strong)UITableView* youpaiptableView;
- @property(nonatomic,strong)YOUPAILCBoardDetailHeadView* youpaipheadView;
- @property(nonatomic,strong)NSMutableArray* youpaipboardArray;
- @property(nonatomic,strong)NSMutableArray* youpaipheadArray;
- @property(nonatomic,strong)YOUPAILCBoardModel* youpaipmyBoard;
- @property(nonatomic,strong)UILabel* youpaipnumLabel;
- @property(nonatomic,strong)UIImageView* youpaipavatarImgV;
- @property(nonatomic,strong)UILabel* youpaipnickLabel;
- @property(nonatomic,strong)UILabel* youpaipvalueLabel;
- @end
- @implementation YOUPAILCBoardDetailVC
- - (UITableView *)youpaiptableView{
- if (!_youpaiptableView) {
- _youpaiptableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight-NavBarHeight - (self.youpaiptype == 6 ? 60 : 0)) style:UITableViewStylePlain];
- _youpaiptableView.showsVerticalScrollIndicator = NO;
- _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _youpaiptableView.backgroundColor = LCWhiteColor;
- _youpaiptableView.estimatedRowHeight = 74;
- _youpaiptableView.estimatedSectionHeaderHeight = 0;
- _youpaiptableView.estimatedSectionFooterHeight = 0;
- _youpaiptableView.dataSource = self;
- _youpaiptableView.delegate = self;
- if (@available(iOS 15.0, *)) {
- _youpaiptableView.sectionHeaderTopPadding = 0;
- }
- // _tableView.bounces = NO;
- }
- return _youpaiptableView;
- }
- - (void)viewDidLoad{
- [super viewDidLoad];
-
- UIView * baseView = [[UIView alloc]initWithFrame:CGRectMake(0, -1000, KScreenWidth, 1000)];
- baseView.backgroundColor= HexColorFromRGB(0xE3BDD8);
- [self.youpaiptableView addSubview:baseView];
-
- self.youpaipboardArray = [NSMutableArray array];
- self.youpaipheadArray = [NSMutableArray array];
- self.youpaiptimeType = 1;
- YOUPAILCBoardDetailHeadView* headView = [[YOUPAILCBoardDetailHeadView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth,35 + KScreenWidth * 281 / 375.0) headArray:self.youpaipheadArray selectIndex:self.youpaiptimeType-1 andType:self.youpaiptype];
- headView.youpaipdelegate = self;
- if( self.youpaiptype == 6)
- {
- [headView.youpaipmenuView setHidden:YES];
- self.youpaiptimeType =3;
- }
- if(self.youpaiptype==4 )
- {
- [headView.youpaipmenuView setHidden:YES];
- self.youpaiptimeType = 4;
- }
- if (self.youpaiptype != 6) {
- [headView.youpaiptitleLabel setHidden:YES];
- }
-
- self.youpaipheadView = headView;
- // [self.view addSubview:headView];
- self.youpaiptableView.tableHeaderView = headView;
- [self.view addSubview:self.youpaiptableView];
- if (self.youpaiptype == 6) {
- [self youpaifsetupshadowView];
- }
- [self youpaifinitData];
- }
- - (void)youpaifsegmentClick:(NSInteger)index{
- if(index==0)
- {
- self.youpaiptimeType = 4;
- }
- else
- self.youpaiptimeType = index ;
- [self youpaifinitData];
- }
- - (void)youpaifinitData{
- NSString *urlStr;
- if (self.youpaiptype==0) {
- urlStr = BigCastBoard;
- }else if (self.youpaiptype==1){
- urlStr = GiftBoard;
- }
- else if(self.youpaiptype==2)
- {
- urlStr = GuardBorderList;
- }
- else if(self.youpaiptype==3)
- {
- urlStr = WealthBoard;
- }
- else if(self.youpaiptype==4){
- urlStr = NewloveRank;
- }else if(self.youpaiptype==5){
-
- urlStr = FairyList;
- }else if (self.youpaiptype == 6)
- {
- urlStr = boleRank;
- }else if (self.youpaiptype == 7)
- {
- urlStr = AnchorRank;
- }
- self.youpaipcurrentPage = 1;
- [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
- self.youpaiptableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadMoreData)];
-
- [LCHttpHelper requestWithURLString:urlStr parameters:@{@"type":@(self.youpaiptimeType),@"page":@(self.youpaipcurrentPage)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
-
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
-
- if (code==0) {//成功
- self.youpaipboardArray = [YOUPAILCBoardModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"list"]];
- self.youpaipmyBoard = [YOUPAILCBoardModel mj_objectWithKeyValues:[[dict objectForKey:@"data"]objectForKey:@"myrank"]];
-
- self.youpaipnumLabel.text = [NSString stringWithFormat:@"%@",[[[dict objectForKey:@"data"]objectForKey:@"my_rank"] objectForKey:@"no"]];
- [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:[[[dict objectForKey:@"data"]objectForKey:@"my_rank"] objectForKey:@"avatar"]]];
- self.youpaipnickLabel.text = [[[dict objectForKey:@"data"]objectForKey:@"my_rank"] objectForKey:@"nickname"];
-
- if ([[[[dict objectForKey:@"data"]objectForKey:@"my_rank"] objectForKey:@"no"] integerValue] == 0) {
- self.youpaipvalueLabel.text = @"未上榜";
- }else{
- self.youpaipvalueLabel.text = [NSString stringWithFormat:@"%@",[[[dict objectForKey:@"data"]objectForKey:@"my_rank"] objectForKey:@"gapMoney"]];
- }
-
- NSInteger totalPage = [[[dict objectForKey:@"data"] objectForKey:@"total_page"]integerValue];
- self.youpaipcurrentPage = [[[dict objectForKey:@"data"] objectForKey:@"page"]integerValue];
- NSMutableArray* headArray = [NSMutableArray array];
- for (YOUPAILCBoardModel* model in self.youpaipboardArray) {
- if (model.youpaipno==1 || model.youpaipno==2 || model.youpaipno==3) {
- [headArray addObject:model];
- }
- }
- for (YOUPAILCBoardModel* model in headArray) {
- if ([self.youpaipboardArray containsObject:model]) {
- [self.youpaipboardArray removeObject:model];
- }
- }
- self.youpaipheadArray = headArray;
- [self.youpaipheadView youpaifupdateHeadArray:self.youpaipheadArray selectIndex:self.youpaiptimeType==4?0:self.youpaiptimeType];
- [self.youpaiptableView reloadData];
- if (self.youpaipcurrentPage>=totalPage) {
- [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
- self.youpaiptableView.mj_footer.hidden = YES;
- }
- [self.youpaiptableView.mj_header endRefreshing];
- }
- [self.youpaiptableView.mj_footer endRefreshing];
- } failure:^(NSError *error) {
- [self.youpaiptableView.mj_footer endRefreshing];
- }];
- }
- - (void)youpaifloadMoreData{
- NSString *urlStr;
- if (self.youpaiptype==0) {
- urlStr = BigCastBoard;
- }else if (self.youpaiptype==1){
- urlStr = GiftBoard;
- }
- else if(self.youpaiptype==2)
- {
- urlStr = GuardBorderList;
- }
- else if(self.youpaiptype==3)
- {
- urlStr = WealthBoard;
- }
- else if(self.youpaiptype==4){
- urlStr = NewloveRank;
- }else if(self.youpaiptype==5){
-
- urlStr = FairyList;
- }else if (self.youpaiptype == 6){
- urlStr = boleRank;
- }else if (self.youpaiptype == 7)
- {
- urlStr = AnchorRank;
- }
- [self.youpaiptableView.mj_header endRefreshing];
- [LCHttpHelper requestWithURLString:urlStr parameters:@{@"type":@(self.youpaiptimeType),@"page":@(self.youpaipcurrentPage+1)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- NSMutableArray* tempArray = [YOUPAILCBoardModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"list"]];
- self.youpaipmyBoard = [YOUPAILCBoardModel mj_objectWithKeyValues:[[dict objectForKey:@"data"]objectForKey:@"myrank"]];
- NSInteger totalPage = [[[dict objectForKey:@"data"] objectForKey:@"total_page"]integerValue];
- self.youpaipcurrentPage = [[[dict objectForKey:@"data"] objectForKey:@"page"]integerValue];
- [self.youpaipboardArray addObjectsFromArray:tempArray];
- [self.youpaiptableView reloadData];
- if (self.youpaipcurrentPage>=totalPage) {
- [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
- self.youpaiptableView.mj_footer.hidden = YES;
- }
- [self.youpaiptableView.mj_header endRefreshing];
- }
- [self.youpaiptableView.mj_footer endRefreshing];
- } failure:^(NSError *error) {
- [self.youpaiptableView.mj_footer endRefreshing];
- }];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.youpaipboardArray.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
-
- // return 230+NavBarHeight;
- return 0;
-
- }
- - (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
- // YOUPAILCBoardDetailHeadView* headView = [[YOUPAILCBoardDetailHeadView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 230+NavBarHeight) headArray:self.headArray selectIndex:self.timeType-1];
- // headView.delegate = self;
- // self.headView = headView;
- // return headView;
- return [[UIView alloc]initWithFrame:CGRectZero];
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- return 74;
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- YOUPAILCBoardCell * cell = [[YOUPAILCBoardCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAILCBoardCell"];
- YOUPAILCBoardModel* model = self.youpaipboardArray[indexPath.row];
- cell.youpaiptype = self.youpaiptype;
- cell.youpaipboardModel = model;
- // [cell bottomLineforViewHeight:74];
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- if (self.youpaiptype != 6) {//伯乐榜不页面跳转
- YOUPAILCBoardModel* model = self.youpaipboardArray[indexPath.row];
- //LCUserShowVC* userShow = [[LCUserShowVC alloc]init];
- YOUPAILZUserShowVC *userShow = [[YOUPAILZUserShowVC alloc] init];
- userShow.youpaipuserId = model.youpaipuser_id;
- //add by leo 0不跳转
- if(userShow.youpaipuserId.integerValue !=0)
- {
- [self.navigationController pushViewController:userShow animated:YES];
- }
- else
- {
- [ZCHUDHelper showTitle:@"该用户排行榜设置了隐藏模式" showtime:2];
- }
- }else{
- [ZCHUDHelper showTitle:@"伯乐榜不支持详情查看" showtime:2];
- }
-
-
- }
- -(void)youpaifsetupshadowView
- {
- UIView *shadowView = [[UIView alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(_youpaiptableView.frame),KScreenWidth, 60)];
- [self.view addSubview:shadowView];
- shadowView.backgroundColor = [UIColor whiteColor];
- shadowView.layer.shadowColor = HexColorFromRGB(0x000000).CGColor;
- shadowView.layer.shadowOffset = CGSizeMake(0, 0);
- shadowView.layer.shadowOpacity = 0.2;
- shadowView.layer.shadowRadius = 6.0;
-
- UILabel* numLabel = [[UILabel alloc]initWithFrame:CGRectMake(0,0,42.5,60)];
- numLabel.textColor = HexColorFromRGB(0x999999);
- numLabel.font = LCBoldFont(18);
- numLabel.textAlignment = NSTextAlignmentCenter;
- [shadowView addSubview:numLabel];
- self.youpaipnumLabel = numLabel;
- [numLabel makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(shadowView.left).offset(@11);
- make.top.equalTo(shadowView).offset(@0);
- make.height.equalTo(@60);
- }];
-
- self.youpaipavatarImgV = [[UIImageView alloc]init];
- self.youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
- self.youpaipavatarImgV.layer.masksToBounds = YES;
- self.youpaipavatarImgV.layer.cornerRadius = 8;
- [shadowView addSubview:self.youpaipavatarImgV];
- [self.youpaipavatarImgV makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.youpaipnumLabel.right).offset(@11);
- make.top.equalTo(shadowView).offset(@10);
- make.height.equalTo(@40);
- make.width.equalTo(@40);
- }];
-
-
- UILabel* nickLabel = [[UILabel alloc]init];
- nickLabel.textColor = HexColorFromRGB(0x333333);
- nickLabel.font = LCFont14;
- [shadowView addSubview:nickLabel];
- self.youpaipnickLabel = nickLabel;
- [nickLabel makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.youpaipavatarImgV.right).offset(@12);
- make.top.equalTo(shadowView).offset(@20);
- make.height.equalTo(@20);
- }];
-
- UILabel* valueLabel = [[UILabel alloc]init];
- valueLabel.textColor = HexColorFromRGB(0xaaaaaa);
- valueLabel.font = LCFont16;
- [shadowView addSubview:valueLabel];
- self.youpaipvalueLabel = valueLabel;
- [valueLabel makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(shadowView.right).offset(@-15.5);
- make.top.equalTo(shadowView.top).offset(@12.5);
- make.height.equalTo(@22.5);
- }];
-
-
- UILabel* label = [[UILabel alloc]init];
- label.font = LCFont(9);
- label.text = @"距离上一名差";
- label.textColor = HexColorFromRGB(0xaaaaaa);
- [shadowView addSubview:label];
- [label makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(shadowView.right).offset(@-15.5);
- make.bottom.equalTo(shadowView.bottom).offset(@-12.5);
- make.height.equalTo(@12.5);
- }];
-
- }
- @end
|