YOUPAILCBoardDetailVC.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. //
  2. // YOUPAILCBoardDetailVC.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/9/26.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCBoardDetailVC.h"
  9. #import "YOUPAILCBoardDetailHeadView.h"
  10. #import "YOUPAILCBoardCell.h"
  11. #import "YOUPAILZUserShowVC.h"
  12. @interface YOUPAILCBoardDetailVC()<UITableViewDataSource,UITableViewDelegate,LCBoardDetailHeadViewDeleagte>
  13. @property(nonatomic,assign)NSInteger youpaiptimeType;// 1周榜 2月榜 3总榜 4日榜
  14. @property(nonatomic,assign)NSInteger youpaipcurrentPage;
  15. @property(nonatomic,strong)UITableView* youpaiptableView;
  16. @property(nonatomic,strong)YOUPAILCBoardDetailHeadView* youpaipheadView;
  17. @property(nonatomic,strong)NSMutableArray* youpaipboardArray;
  18. @property(nonatomic,strong)NSMutableArray* youpaipheadArray;
  19. @property(nonatomic,strong)YOUPAILCBoardModel* youpaipmyBoard;
  20. @property(nonatomic,strong)UILabel* youpaipnumLabel;
  21. @property(nonatomic,strong)UIImageView* youpaipavatarImgV;
  22. @property(nonatomic,strong)UILabel* youpaipnickLabel;
  23. @property(nonatomic,strong)UILabel* youpaipvalueLabel;
  24. @end
  25. @implementation YOUPAILCBoardDetailVC
  26. - (UITableView *)youpaiptableView{
  27. if (!_youpaiptableView) {
  28. _youpaiptableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight-NavBarHeight - (self.youpaiptype == 6 ? 60 : 0)) style:UITableViewStylePlain];
  29. _youpaiptableView.showsVerticalScrollIndicator = NO;
  30. _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  31. _youpaiptableView.backgroundColor = LCWhiteColor;
  32. _youpaiptableView.estimatedRowHeight = 74;
  33. _youpaiptableView.estimatedSectionHeaderHeight = 0;
  34. _youpaiptableView.estimatedSectionFooterHeight = 0;
  35. _youpaiptableView.dataSource = self;
  36. _youpaiptableView.delegate = self;
  37. if (@available(iOS 15.0, *)) {
  38. _youpaiptableView.sectionHeaderTopPadding = 0;
  39. }
  40. // _tableView.bounces = NO;
  41. }
  42. return _youpaiptableView;
  43. }
  44. - (void)viewDidLoad{
  45. [super viewDidLoad];
  46. UIView * baseView = [[UIView alloc]initWithFrame:CGRectMake(0, -1000, KScreenWidth, 1000)];
  47. baseView.backgroundColor= HexColorFromRGB(0xE3BDD8);
  48. [self.youpaiptableView addSubview:baseView];
  49. self.youpaipboardArray = [NSMutableArray array];
  50. self.youpaipheadArray = [NSMutableArray array];
  51. self.youpaiptimeType = 1;
  52. YOUPAILCBoardDetailHeadView* headView = [[YOUPAILCBoardDetailHeadView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth,35 + KScreenWidth * 281 / 375.0) headArray:self.youpaipheadArray selectIndex:self.youpaiptimeType-1 andType:self.youpaiptype];
  53. headView.youpaipdelegate = self;
  54. if( self.youpaiptype == 6)
  55. {
  56. [headView.youpaipmenuView setHidden:YES];
  57. self.youpaiptimeType =3;
  58. }
  59. if(self.youpaiptype==4 )
  60. {
  61. [headView.youpaipmenuView setHidden:YES];
  62. self.youpaiptimeType = 4;
  63. }
  64. if (self.youpaiptype != 6) {
  65. [headView.youpaiptitleLabel setHidden:YES];
  66. }
  67. self.youpaipheadView = headView;
  68. // [self.view addSubview:headView];
  69. self.youpaiptableView.tableHeaderView = headView;
  70. [self.view addSubview:self.youpaiptableView];
  71. if (self.youpaiptype == 6) {
  72. [self youpaifsetupshadowView];
  73. }
  74. [self youpaifinitData];
  75. }
  76. - (void)youpaifsegmentClick:(NSInteger)index{
  77. if(index==0)
  78. {
  79. self.youpaiptimeType = 4;
  80. }
  81. else
  82. self.youpaiptimeType = index ;
  83. [self youpaifinitData];
  84. }
  85. - (void)youpaifinitData{
  86. NSString *urlStr;
  87. if (self.youpaiptype==0) {
  88. urlStr = BigCastBoard;
  89. }else if (self.youpaiptype==1){
  90. urlStr = GiftBoard;
  91. }
  92. else if(self.youpaiptype==2)
  93. {
  94. urlStr = GuardBorderList;
  95. }
  96. else if(self.youpaiptype==3)
  97. {
  98. urlStr = WealthBoard;
  99. }
  100. else if(self.youpaiptype==4){
  101. urlStr = NewloveRank;
  102. }else if(self.youpaiptype==5){
  103. urlStr = FairyList;
  104. }else if (self.youpaiptype == 6)
  105. {
  106. urlStr = boleRank;
  107. }else if (self.youpaiptype == 7)
  108. {
  109. urlStr = AnchorRank;
  110. }
  111. self.youpaipcurrentPage = 1;
  112. [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
  113. self.youpaiptableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadMoreData)];
  114. [LCHttpHelper requestWithURLString:urlStr parameters:@{@"type":@(self.youpaiptimeType),@"page":@(self.youpaipcurrentPage)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  115. NSDictionary* dict = (NSDictionary*)responseObject;
  116. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  117. if (code==0) {//成功
  118. self.youpaipboardArray = [YOUPAILCBoardModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"list"]];
  119. self.youpaipmyBoard = [YOUPAILCBoardModel mj_objectWithKeyValues:[[dict objectForKey:@"data"]objectForKey:@"myrank"]];
  120. self.youpaipnumLabel.text = [NSString stringWithFormat:@"%@",[[[dict objectForKey:@"data"]objectForKey:@"my_rank"] objectForKey:@"no"]];
  121. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:[[[dict objectForKey:@"data"]objectForKey:@"my_rank"] objectForKey:@"avatar"]]];
  122. self.youpaipnickLabel.text = [[[dict objectForKey:@"data"]objectForKey:@"my_rank"] objectForKey:@"nickname"];
  123. if ([[[[dict objectForKey:@"data"]objectForKey:@"my_rank"] objectForKey:@"no"] integerValue] == 0) {
  124. self.youpaipvalueLabel.text = @"未上榜";
  125. }else{
  126. self.youpaipvalueLabel.text = [NSString stringWithFormat:@"%@",[[[dict objectForKey:@"data"]objectForKey:@"my_rank"] objectForKey:@"gapMoney"]];
  127. }
  128. NSInteger totalPage = [[[dict objectForKey:@"data"] objectForKey:@"total_page"]integerValue];
  129. self.youpaipcurrentPage = [[[dict objectForKey:@"data"] objectForKey:@"page"]integerValue];
  130. NSMutableArray* headArray = [NSMutableArray array];
  131. for (YOUPAILCBoardModel* model in self.youpaipboardArray) {
  132. if (model.youpaipno==1 || model.youpaipno==2 || model.youpaipno==3) {
  133. [headArray addObject:model];
  134. }
  135. }
  136. for (YOUPAILCBoardModel* model in headArray) {
  137. if ([self.youpaipboardArray containsObject:model]) {
  138. [self.youpaipboardArray removeObject:model];
  139. }
  140. }
  141. self.youpaipheadArray = headArray;
  142. [self.youpaipheadView youpaifupdateHeadArray:self.youpaipheadArray selectIndex:self.youpaiptimeType==4?0:self.youpaiptimeType];
  143. [self.youpaiptableView reloadData];
  144. if (self.youpaipcurrentPage>=totalPage) {
  145. [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
  146. self.youpaiptableView.mj_footer.hidden = YES;
  147. }
  148. [self.youpaiptableView.mj_header endRefreshing];
  149. }
  150. [self.youpaiptableView.mj_footer endRefreshing];
  151. } failure:^(NSError *error) {
  152. [self.youpaiptableView.mj_footer endRefreshing];
  153. }];
  154. }
  155. - (void)youpaifloadMoreData{
  156. NSString *urlStr;
  157. if (self.youpaiptype==0) {
  158. urlStr = BigCastBoard;
  159. }else if (self.youpaiptype==1){
  160. urlStr = GiftBoard;
  161. }
  162. else if(self.youpaiptype==2)
  163. {
  164. urlStr = GuardBorderList;
  165. }
  166. else if(self.youpaiptype==3)
  167. {
  168. urlStr = WealthBoard;
  169. }
  170. else if(self.youpaiptype==4){
  171. urlStr = NewloveRank;
  172. }else if(self.youpaiptype==5){
  173. urlStr = FairyList;
  174. }else if (self.youpaiptype == 6){
  175. urlStr = boleRank;
  176. }else if (self.youpaiptype == 7)
  177. {
  178. urlStr = AnchorRank;
  179. }
  180. [self.youpaiptableView.mj_header endRefreshing];
  181. [LCHttpHelper requestWithURLString:urlStr parameters:@{@"type":@(self.youpaiptimeType),@"page":@(self.youpaipcurrentPage+1)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  182. NSDictionary* dict = (NSDictionary*)responseObject;
  183. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  184. if (code==0) {//成功
  185. NSMutableArray* tempArray = [YOUPAILCBoardModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"list"]];
  186. self.youpaipmyBoard = [YOUPAILCBoardModel mj_objectWithKeyValues:[[dict objectForKey:@"data"]objectForKey:@"myrank"]];
  187. NSInteger totalPage = [[[dict objectForKey:@"data"] objectForKey:@"total_page"]integerValue];
  188. self.youpaipcurrentPage = [[[dict objectForKey:@"data"] objectForKey:@"page"]integerValue];
  189. [self.youpaipboardArray addObjectsFromArray:tempArray];
  190. [self.youpaiptableView reloadData];
  191. if (self.youpaipcurrentPage>=totalPage) {
  192. [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
  193. self.youpaiptableView.mj_footer.hidden = YES;
  194. }
  195. [self.youpaiptableView.mj_header endRefreshing];
  196. }
  197. [self.youpaiptableView.mj_footer endRefreshing];
  198. } failure:^(NSError *error) {
  199. [self.youpaiptableView.mj_footer endRefreshing];
  200. }];
  201. }
  202. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  203. return self.youpaipboardArray.count;
  204. }
  205. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  206. // return 230+NavBarHeight;
  207. return 0;
  208. }
  209. - (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  210. // YOUPAILCBoardDetailHeadView* headView = [[YOUPAILCBoardDetailHeadView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 230+NavBarHeight) headArray:self.headArray selectIndex:self.timeType-1];
  211. // headView.delegate = self;
  212. // self.headView = headView;
  213. // return headView;
  214. return [[UIView alloc]initWithFrame:CGRectZero];
  215. }
  216. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  217. return 74;
  218. }
  219. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  220. YOUPAILCBoardCell * cell = [[YOUPAILCBoardCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAILCBoardCell"];
  221. YOUPAILCBoardModel* model = self.youpaipboardArray[indexPath.row];
  222. cell.youpaiptype = self.youpaiptype;
  223. cell.youpaipboardModel = model;
  224. // [cell bottomLineforViewHeight:74];
  225. return cell;
  226. }
  227. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  228. if (self.youpaiptype != 6) {//伯乐榜不页面跳转
  229. YOUPAILCBoardModel* model = self.youpaipboardArray[indexPath.row];
  230. //LCUserShowVC* userShow = [[LCUserShowVC alloc]init];
  231. YOUPAILZUserShowVC *userShow = [[YOUPAILZUserShowVC alloc] init];
  232. userShow.youpaipuserId = model.youpaipuser_id;
  233. //add by leo 0不跳转
  234. if(userShow.youpaipuserId.integerValue !=0)
  235. {
  236. [self.navigationController pushViewController:userShow animated:YES];
  237. }
  238. else
  239. {
  240. [ZCHUDHelper showTitle:@"该用户排行榜设置了隐藏模式" showtime:2];
  241. }
  242. }else{
  243. [ZCHUDHelper showTitle:@"伯乐榜不支持详情查看" showtime:2];
  244. }
  245. }
  246. -(void)youpaifsetupshadowView
  247. {
  248. UIView *shadowView = [[UIView alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(_youpaiptableView.frame),KScreenWidth, 60)];
  249. [self.view addSubview:shadowView];
  250. shadowView.backgroundColor = [UIColor whiteColor];
  251. shadowView.layer.shadowColor = HexColorFromRGB(0x000000).CGColor;
  252. shadowView.layer.shadowOffset = CGSizeMake(0, 0);
  253. shadowView.layer.shadowOpacity = 0.2;
  254. shadowView.layer.shadowRadius = 6.0;
  255. UILabel* numLabel = [[UILabel alloc]initWithFrame:CGRectMake(0,0,42.5,60)];
  256. numLabel.textColor = HexColorFromRGB(0x999999);
  257. numLabel.font = LCBoldFont(18);
  258. numLabel.textAlignment = NSTextAlignmentCenter;
  259. [shadowView addSubview:numLabel];
  260. self.youpaipnumLabel = numLabel;
  261. [numLabel makeConstraints:^(MASConstraintMaker *make) {
  262. make.left.equalTo(shadowView.left).offset(@11);
  263. make.top.equalTo(shadowView).offset(@0);
  264. make.height.equalTo(@60);
  265. }];
  266. self.youpaipavatarImgV = [[UIImageView alloc]init];
  267. self.youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  268. self.youpaipavatarImgV.layer.masksToBounds = YES;
  269. self.youpaipavatarImgV.layer.cornerRadius = 8;
  270. [shadowView addSubview:self.youpaipavatarImgV];
  271. [self.youpaipavatarImgV makeConstraints:^(MASConstraintMaker *make) {
  272. make.left.equalTo(self.youpaipnumLabel.right).offset(@11);
  273. make.top.equalTo(shadowView).offset(@10);
  274. make.height.equalTo(@40);
  275. make.width.equalTo(@40);
  276. }];
  277. UILabel* nickLabel = [[UILabel alloc]init];
  278. nickLabel.textColor = HexColorFromRGB(0x333333);
  279. nickLabel.font = LCFont14;
  280. [shadowView addSubview:nickLabel];
  281. self.youpaipnickLabel = nickLabel;
  282. [nickLabel makeConstraints:^(MASConstraintMaker *make) {
  283. make.left.equalTo(self.youpaipavatarImgV.right).offset(@12);
  284. make.top.equalTo(shadowView).offset(@20);
  285. make.height.equalTo(@20);
  286. }];
  287. UILabel* valueLabel = [[UILabel alloc]init];
  288. valueLabel.textColor = HexColorFromRGB(0xaaaaaa);
  289. valueLabel.font = LCFont16;
  290. [shadowView addSubview:valueLabel];
  291. self.youpaipvalueLabel = valueLabel;
  292. [valueLabel makeConstraints:^(MASConstraintMaker *make) {
  293. make.right.equalTo(shadowView.right).offset(@-15.5);
  294. make.top.equalTo(shadowView.top).offset(@12.5);
  295. make.height.equalTo(@22.5);
  296. }];
  297. UILabel* label = [[UILabel alloc]init];
  298. label.font = LCFont(9);
  299. label.text = @"距离上一名差";
  300. label.textColor = HexColorFromRGB(0xaaaaaa);
  301. [shadowView addSubview:label];
  302. [label makeConstraints:^(MASConstraintMaker *make) {
  303. make.right.equalTo(shadowView.right).offset(@-15.5);
  304. make.bottom.equalTo(shadowView.bottom).offset(@-12.5);
  305. make.height.equalTo(@12.5);
  306. }];
  307. }
  308. @end