YBDayTaskVC.m 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. //
  2. // YBDayTaskVC.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2020/10/9.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "YBDayTaskVC.h"
  9. #import "YBDayTaskCell.h"
  10. @interface YBDayTaskVC ()<UITableViewDataSource, UITableViewDelegate,dailyCellDelegate>
  11. {
  12. UIImageView *backImg;
  13. UILabel *tapLb;
  14. UIView *backView;
  15. }
  16. @property (nonatomic, strong)UITableView *listTable;
  17. @property (nonatomic, strong)NSArray *infoArray;
  18. @end
  19. @implementation YBDayTaskVC
  20. -(void)requestListData{
  21. [YBNetworking postWithUrl:@"User.seeDailyTasks" Dic:@{@"liveuid":@"0",@"islive":@"0"} Suc:^(int code, id info, NSString *msg) {
  22. if (code == 0) {
  23. NSArray *infoA = [info objectAtIndex:0];
  24. NSArray *list =[infoA valueForKey:@"list"];
  25. _infoArray = list;
  26. [self.listTable reloadData];
  27. tapLb.text = minstr([infoA valueForKey:@"tip_m"]);
  28. }else {
  29. [MBProgressHUD showPop:msg];
  30. }
  31. } Fail:^(id fail) {
  32. }];
  33. /*
  34. _infoArray = @[@{@"title":@"这个标题呢",@"tip_m":@"副标题呢副标题呢副标题呢副标题呢副标题呢副标题呢",@"state":@"0"},
  35. @{@"title":@"这个标题呢",@"tip_m":@"副标题呢",@"state":@"1"},
  36. @{@"title":@"这个标题呢",@"tip_m":@"副标题呢",@"state":@"2"},];
  37. */
  38. [self.listTable reloadData];
  39. }
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. self.titleL.text = YZMsg(@"每日任务");
  43. _infoArray = [NSArray array];
  44. [self createUI];
  45. [self requestListData];
  46. }
  47. -(void)createUI{
  48. backImg = [[UIImageView alloc]init];
  49. backImg.frame = CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight);
  50. backImg.image = [UIImage imageNamed:@"日任-页面背景"];
  51. backImg.userInteractionEnabled = YES;
  52. [self.view addSubview:backImg];
  53. UIImageView *titleImg = [[UIImageView alloc]init];
  54. titleImg.image = [UIImage imageNamed:getImagename(@"日任-标题1")];
  55. [backImg addSubview:titleImg];
  56. [titleImg mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.top.equalTo(backImg).offset(30);
  58. make.centerX.equalTo(backImg);
  59. make.height.mas_equalTo(76);
  60. make.width.mas_equalTo(248);
  61. }];
  62. backView = [[UIView alloc]init];
  63. backView.backgroundColor = [UIColor whiteColor];
  64. backView.layer.cornerRadius = 10;
  65. backView.layer.masksToBounds = YES;
  66. [backImg addSubview:backView];
  67. [backView mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.equalTo(backImg).offset(22);
  69. make.right.equalTo(backImg).offset(-22);
  70. make.top.equalTo(titleImg.mas_bottom).offset(50);
  71. make.bottom.equalTo(backImg).offset(-100-ShowDiff);
  72. }];
  73. _listTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
  74. _listTable.dataSource = self;
  75. _listTable.delegate = self;
  76. _listTable.showsVerticalScrollIndicator = NO;
  77. _listTable.separatorStyle= UITableViewCellSeparatorStyleNone;
  78. [backView addSubview:_listTable];
  79. if (IS_BIG_SCREEN) {
  80. [_listTable mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.bottom.equalTo(backView).offset(-50);
  82. make.top.equalTo(backView).offset(40);
  83. make.left.right.equalTo(backView);
  84. }];
  85. }else{
  86. [_listTable mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.bottom.left.right.equalTo(backView);
  88. make.top.equalTo(backView).offset(10);
  89. }];
  90. }
  91. UIImageView *tapImg = [[UIImageView alloc]init];
  92. tapImg.image = [UIImage imageNamed:getImagename(@"日任-标题2")];
  93. [backImg addSubview:tapImg];
  94. [tapImg mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.bottom.equalTo(backView.mas_top).offset(21);
  96. make.centerX.equalTo(backImg);
  97. make.height.mas_equalTo(38);
  98. make.width.mas_equalTo(188);
  99. }];
  100. tapLb = [[UILabel alloc]init];
  101. tapLb.font = [UIFont systemFontOfSize:12];
  102. tapLb.textColor = RGB_COLOR(@"#FFFFFF", 0.52);
  103. tapLb.numberOfLines = 0;
  104. tapLb.lineBreakMode = NSLineBreakByWordWrapping;
  105. [backImg addSubview:tapLb];
  106. [tapLb mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.left.right.equalTo(backView);
  108. make.top.equalTo(backView.mas_bottom).offset(20);
  109. }];
  110. }
  111. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  112. return 1;
  113. }
  114. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  115. return 5;
  116. }
  117. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  118. return _listTable.height/5;
  119. }
  120. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  121. YBDayTaskCell *cell = [YBDayTaskCell cellWithTab:tableView andIndexPath:indexPath];
  122. cell.dataDic = _infoArray[indexPath.row];
  123. cell.delegate = self;
  124. if (indexPath.row == _infoArray.count -1) {
  125. cell.lineLb.hidden = YES;
  126. }
  127. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  128. return cell;
  129. }
  130. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  131. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  132. }
  133. -(void)stateBtnClick:(NSDictionary *)data{
  134. YBWeakSelf;
  135. NSDictionary *dic = @{
  136. @"uid":[Config getOwnID],
  137. @"token":[Config getOwnToken],
  138. @"taskid":minstr([data valueForKey:@"id"])
  139. };
  140. [YBNetworking postWithUrl:@"User.receiveTaskReward" Dic:dic Suc:^(int code, id info, NSString *msg) {
  141. [MBProgressHUD showError:msg];
  142. if (code == 0) {
  143. [weakSelf requestListData];
  144. }
  145. } Fail:^(id fail) {
  146. }];
  147. }
  148. @end