YOUPAIHRSubGuildDetailVC.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. //
  2. // YOUPAIHRSubGuildDetailVC.m
  3. // VQU
  4. //
  5. // Created by xiaohaoran on 2021/11/5.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIHRSubGuildDetailVC.h"
  9. #import "YOUPAIHRSubGuildDetailCell.h"
  10. #import "PGDatePickManager.h"
  11. #import "UIViewController+TFPresent.h"
  12. #import "YOUPAILZBillSectionModel.h"
  13. #import "YOUPAIHRDatePickerView.h"
  14. #import "BRPickerView.h"
  15. #import "YOUPAIHRChatRoomWindow.h"
  16. #import "YOUPAIHRSubGuildDetailModel.h"
  17. #import "UIScrollView+LZRefresh.h"
  18. @interface YOUPAIHRSubGuildDetailVC ()<UITableViewDelegate,UITableViewDataSource,PGDatePickerDelegate>
  19. @property(nonatomic,assign)NSInteger youpaippage;
  20. @property(nonatomic,assign)NSInteger youpaiptotalPage;
  21. @property(nonatomic,strong)NSMutableArray* youpaipbillArray;
  22. @property (nonatomic,strong)UITableView *youpaiptableView;
  23. @property(nonatomic,strong)NSString *youpaipdate;
  24. @property (nonatomic, assign) NSInteger youpaipselectIndex;
  25. @property(nonatomic,copy)NSString *youpaipstarDate;
  26. @property(nonatomic,copy)NSString *youpaipendDate;
  27. @property(nonatomic,strong)YOUPAIHRSubGuildDetailModel *youpaipmodel;
  28. @property(nonatomic,assign)NSInteger youpaiproomId;
  29. @property(nonatomic,copy)NSString *youpaiptimeType;
  30. @property(nonatomic,strong)UIView *youpaipbgView;
  31. @end
  32. @implementation YOUPAIHRSubGuildDetailVC
  33. -(void)viewWillAppear:(BOOL)animated{
  34. [super viewWillAppear:animated];
  35. self.youpaiptimeType = @"2";
  36. self.youpaipstarDate =nil;
  37. self.youpaipendDate =nil;
  38. [self.youpaiptableView.mj_header beginRefreshing];
  39. }
  40. -(void)dealloc{
  41. [[NSNotificationCenter defaultCenter]removeObserver:self];
  42. }
  43. - (void)viewDidLoad {
  44. [super viewDidLoad];
  45. self.youpaipdate = @"";
  46. self.youpaipbillArray = [NSMutableArray array];
  47. self.youpaiptimeType = @"2";
  48. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifchangSelectDate:) name:@"changSelectDate" object:nil];
  49. [self youpaifinitUI];
  50. [self youpaifloadRoomFilterView];
  51. @weakify(self);
  52. [self.youpaiptableView setRefreshHeaderWithBlock:^{
  53. @strongify(self);
  54. [self youpaifrequestRankListWithStatus:kRefreshHeader];
  55. }];
  56. [self.youpaiptableView.mj_header beginRefreshing];
  57. }
  58. -(void)youpaifchangSelectDate:(NSNotification*)notic{
  59. NSDictionary *dict = notic.userInfo;
  60. self.youpaipstarDate =dict[@"starDate"];
  61. self.youpaipendDate =dict[@"endDate"];
  62. self.youpaiptimeType = dict[@"timeType"];
  63. [self.youpaiptableView.mj_header beginRefreshing];
  64. }
  65. -(void)youpaifloadRoomFilterView{
  66. UIView *youpaipbgView = [UIView new];
  67. self.youpaipbgView =youpaipbgView;
  68. [self.view addSubview:youpaipbgView];
  69. [youpaipbgView mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.left.mas_equalTo(0);
  71. make.top.mas_equalTo(-44);
  72. make.height.mas_equalTo(44);
  73. make.right.mas_equalTo(0);
  74. }];
  75. youpaipbgView.backgroundColor = LCBkgColor;
  76. //title
  77. UILabel *enterL = [[UILabel alloc] init];
  78. enterL.font = [UIFont systemFontOfSize:11];
  79. enterL.textColor = [UIColor whiteColor];
  80. [youpaipbgView addSubview:enterL];
  81. [enterL mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.left.offset(14.0f);
  83. make.centerY.offset(0.0f);
  84. }];
  85. UIButton *roomFilterBtn = [UIButton new];
  86. [youpaipbgView addSubview:roomFilterBtn];
  87. [roomFilterBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.right.mas_equalTo(-14);
  89. make.centerY.mas_equalTo(0);
  90. }];
  91. [roomFilterBtn setTitle:@"房间筛选" forState:UIControlStateNormal];
  92. [roomFilterBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  93. roomFilterBtn.titleLabel.font = [UIFont systemFontOfSize:11];
  94. [roomFilterBtn setImage:[UIImage imageNamed:@"vqu_images_commen_ic_up"] forState:UIControlStateNormal];
  95. [roomFilterBtn setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
  96. [roomFilterBtn addTarget:self action:@selector(youpaifroomFilterBtnClick) forControlEvents:UIControlEventTouchUpInside];
  97. enterL.text = [NSString stringWithFormat:@"房间收入0钻石"];
  98. }
  99. //房间筛选
  100. -(void)youpaifroomFilterBtnClick{
  101. YOUPAIHRChatRoomWindow *vc = [YOUPAIHRChatRoomWindow new];
  102. vc.isTouchDismiss = YES;
  103. [self TFPresentVC:vc completion:^{
  104. }];
  105. @weakify(self);
  106. [vc setYoupaipdidResetBlock:^{
  107. @strongify(self);
  108. self.youpaiproomId = 0;
  109. [self.youpaiptableView.mj_header beginRefreshing];
  110. }];
  111. [vc setYoupaipdidSelectCellUserBlock:^(NSInteger room_ID) {
  112. @strongify(self);
  113. self.youpaiproomId = room_ID;
  114. [self.youpaiptableView.mj_header beginRefreshing];
  115. }];
  116. }
  117. - (void)youpaifinitUI{
  118. self.youpaiptableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  119. [self.view addSubview:self.youpaiptableView];
  120. [self.youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.top.mas_equalTo(0);
  122. make.left.mas_equalTo(0);
  123. make.right.mas_equalTo(0);
  124. make.bottom.mas_equalTo(0);
  125. }];
  126. self.youpaiptableView.backgroundColor = [UIColor clearColor];
  127. self.youpaiptableView.showsVerticalScrollIndicator = NO;
  128. self.youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  129. self.youpaiptableView.estimatedRowHeight = 78.0f;
  130. self.youpaiptableView.rowHeight = 78.0f;
  131. self.youpaiptableView.delegate = self;
  132. self.youpaiptableView.dataSource= self;
  133. if (@available(iOS 15.0, *)) {
  134. self.youpaiptableView.sectionHeaderTopPadding = 0;
  135. }
  136. }
  137. /// 设置加载更多
  138. - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{
  139. @weakify(self);
  140. [self.youpaiptableView setRefreshFooter:hidden withBlock:^{
  141. @strongify(self);
  142. [self youpaifrequestRankListWithStatus:kRefreshFooter];
  143. }];
  144. }
  145. - (void)youpaifrequestRankListWithStatus:(kRefreshStatus)status{
  146. if (status == kRefreshFooter) {
  147. self.youpaippage ++;
  148. }else{
  149. self.youpaippage = 1;
  150. }
  151. @weakify(self);
  152. NSMutableDictionary *dict = [NSMutableDictionary new];
  153. [dict setObject:@(self.youpaippage) forKey:@"page"];
  154. [dict setObject:@(15) forKey:@"number"];
  155. [dict setValue:@(self.youpaiptype) forKey:@"type"];
  156. [dict setValue:self.youpaipstarDate forKey:@"beginTime"];
  157. [dict setValue:self.youpaipendDate forKey:@"endTime"];
  158. [dict setValue:[NSString stringWithFormat:@"%@",self.youpaiptimeType] forKey:@"timeType"];
  159. [dict setValue:@(self.youpaiproomId) forKey:@"roomId"];
  160. [LCHttpHelper requestWithURLString:ChatRoom_guildIncome parameters:dict needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  161. NSDictionary* dict = (NSDictionary*)responseObject;
  162. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  163. if (code==0) {//成功
  164. @strongify(self);
  165. [self.youpaipbillArray removeAllObjects];
  166. YOUPAIHRSubGuildDetailModel *Detailmodel = [YOUPAIHRSubGuildDetailModel mj_objectWithKeyValues:dict[@"data"]];
  167. self.youpaipmodel = Detailmodel;
  168. NSArray *array1 = Detailmodel.youpaiplist;
  169. NSMutableArray *array = [NSMutableArray arrayWithArray:array1];
  170. NSMutableArray *dateMutablearray = [NSMutableArray new];
  171. for (int i = 0; i < array.count; i ++) {
  172. listModel *model =array[i];
  173. NSMutableArray *tempArray = [NSMutableArray new];
  174. [tempArray addObject:model];
  175. for (int j = i+1; j < array.count; j ++) {
  176. listModel *model1 = array[j];
  177. if([model.youpaipdate isEqualToString:model1.youpaipdate]){
  178. [tempArray addObject:model1];
  179. [array removeObjectAtIndex:j];
  180. j -= 1;
  181. }
  182. }
  183. [dateMutablearray addObject:tempArray];
  184. }
  185. [self.youpaipbillArray addObjectsFromArray:dateMutablearray];
  186. self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue];
  187. self.youpaippage = [[[dict objectForKey:@"data"]objectForKey:@"page"]integerValue];
  188. [self.youpaiptableView reloadData];
  189. if (self.youpaippage>=self.youpaiptotalPage) {
  190. [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
  191. self.youpaiptableView.mj_footer.hidden = YES;
  192. }
  193. [self.youpaiptableView lz_hideEmptyView];
  194. if (self.youpaipbillArray.count == 0) {
  195. [UIView animateWithDuration:0.01 animations:^{
  196. [self.youpaipbgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  197. make.left.mas_equalTo(0);
  198. make.top.mas_equalTo(0);
  199. make.height.mas_equalTo(44);
  200. make.right.mas_equalTo(0);
  201. }];
  202. } completion:^(BOOL finished) {
  203. }];
  204. [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无记录"];
  205. }else{
  206. [UIView animateWithDuration:0.01 animations:^{
  207. [self.youpaipbgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  208. make.left.mas_equalTo(0);
  209. make.top.mas_equalTo(-44);
  210. make.height.mas_equalTo(44);
  211. make.right.mas_equalTo(0);
  212. }];
  213. } completion:^(BOOL finished) {
  214. }];
  215. }
  216. [self.youpaiptableView.mj_header endRefreshing];
  217. }else{
  218. [self.youpaiptableView.mj_header endRefreshing];
  219. }
  220. } failure:^(NSError *error) {
  221. [self.youpaiptableView.mj_header endRefreshing];
  222. }];
  223. }
  224. #pragma mark - tableView代理
  225. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  226. return self.youpaipbillArray.count;
  227. }
  228. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  229. NSArray *arr = self.youpaipbillArray[section];
  230. return arr.count;
  231. }
  232. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  233. NSArray *arr = self.youpaipbillArray[indexPath.section];
  234. YOUPAIHRSubGuildDetailCell* cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIHRSubGuildDetailCell"];
  235. if (cell == nil) {
  236. cell = [[YOUPAIHRSubGuildDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAIHRSubGuildDetailCell"];
  237. }
  238. listModel *model = arr[indexPath.row];
  239. cell.youpaipbillModel = model;
  240. return cell;
  241. }
  242. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  243. }
  244. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  245. if (section == 0) {
  246. return 68;
  247. }else{
  248. return 46.0f;
  249. }
  250. }
  251. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  252. listModel *sectionModel = self.youpaipbillArray[section][0];
  253. CGFloat height;
  254. if (section == 0) {
  255. height = 68;
  256. }else{
  257. height = 46;
  258. }
  259. UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, height)];
  260. bgV.backgroundColor = LCBkgColor;
  261. UILabel *enterL = [[UILabel alloc] init];
  262. enterL.font = [UIFont systemFontOfSize:11];
  263. enterL.textColor = [UIColor whiteColor];
  264. [bgV addSubview:enterL];
  265. [enterL mas_makeConstraints:^(MASConstraintMaker *make) {
  266. make.left.offset(14.0f);
  267. make.top.offset(16.0f);
  268. }];
  269. UILabel *dayL = [[UILabel alloc] init];
  270. dayL.text = sectionModel.youpaipdate;//@"2020年12月";
  271. dayL.font = [UIFont systemFontOfSize:11];
  272. dayL.textColor = HexColorFromRGB(0x9F9DA5);
  273. [bgV addSubview:dayL];
  274. [dayL mas_makeConstraints:^(MASConstraintMaker *make) {
  275. make.left.offset(14.0f);
  276. make.top.mas_equalTo(enterL.mas_bottom).offset(20);
  277. }];
  278. if (section != 0) {
  279. [dayL mas_remakeConstraints:^(MASConstraintMaker *make) {
  280. make.left.offset(14.0f);
  281. make.centerY.mas_equalTo(0);
  282. }];
  283. }
  284. if (self.youpaiptype ==1 &&section == 0) {
  285. //房间筛选
  286. UIButton *roomFilterBtn = [UIButton new];
  287. [bgV addSubview:roomFilterBtn];
  288. [roomFilterBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  289. make.right.mas_equalTo(-14);
  290. make.centerY.mas_equalTo(0);
  291. }];
  292. [roomFilterBtn setTitle:@"房间筛选" forState:UIControlStateNormal];
  293. [roomFilterBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  294. roomFilterBtn.titleLabel.font = [UIFont systemFontOfSize:11];
  295. [roomFilterBtn setImage:[UIImage imageNamed:@"vqu_images_commen_ic_up"] forState:UIControlStateNormal];
  296. [roomFilterBtn setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
  297. [roomFilterBtn addTarget:self action:@selector(youpaifroomFilterBtnClick) forControlEvents:UIControlEventTouchUpInside];
  298. enterL.text = [NSString stringWithFormat:@"房间收入 %@钻石",self.youpaipmodel.youpaipincome];
  299. }
  300. else if ( self.youpaiptype ==0&&section == 0){
  301. enterL.text = [NSString stringWithFormat:@"总收入 %@钻石",self.youpaipmodel.youpaipincome];
  302. }else if (self.youpaiptype ==2&&section == 0){
  303. enterL.text = [NSString stringWithFormat:@"公会收入 %@钻石",self.youpaipmodel.youpaipincome];
  304. }
  305. return bgV;
  306. }
  307. #pragma mark - JXCategoryListContainerView
  308. - (UIView *)listView{
  309. return self.view;
  310. }
  311. @end