YBDayTaskView.m 5.7 KB

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