2025-08-08 10:49:36 +08:00
|
|
|
//
|
|
|
|
|
// QXTaskViewController.m
|
|
|
|
|
// QXLive
|
|
|
|
|
//
|
|
|
|
|
// Created by 启星 on 2025/5/9.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "QXTaskViewController.h"
|
|
|
|
|
#import "QXDayTaskTopView.h"
|
|
|
|
|
#import "QXDayTaskCell.h"
|
|
|
|
|
#import "QXDayTaskRuleView.h"
|
|
|
|
|
#import "QXMineNetwork.h"
|
|
|
|
|
#import "QXTaskGiftRecordVC.h"
|
|
|
|
|
|
|
|
|
|
@interface QXTaskViewController ()<UITableViewDataSource,UITableViewDelegate>
|
|
|
|
|
@property (nonatomic,strong)QXDayTaskTopView *topView;
|
|
|
|
|
@property (nonatomic,strong)UITableView *tableView;
|
|
|
|
|
@property (nonatomic,strong)QXDayTaskModel *model;
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation QXTaskViewController
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
}
|
|
|
|
|
-(void)viewWillAppear:(BOOL)animated{
|
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
|
|
|
|
[self getDayTask];
|
|
|
|
|
}
|
2025-10-28 09:18:28 +08:00
|
|
|
|
2025-08-08 10:49:36 +08:00
|
|
|
-(void)setNavgationItems{
|
|
|
|
|
[super setNavgationItems];
|
|
|
|
|
self.navigationItem.title = QXText(@"每日任务");
|
|
|
|
|
UIButton*recordBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
|
|
|
|
|
[recordBtn setTitle:QXText(@"礼盒记录") forState:(UIControlStateNormal)];
|
2025-10-20 09:43:10 +08:00
|
|
|
[recordBtn setTitleColor:QXConfig.themeColor forState:(UIControlStateNormal)];
|
2025-08-08 10:49:36 +08:00
|
|
|
recordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
|
|
|
|
|
[recordBtn addTarget:self action:@selector(recordAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
|
|
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:recordBtn];
|
|
|
|
|
}
|
|
|
|
|
- (void)initSubViews{
|
|
|
|
|
self.bgImageHidden = YES;
|
2025-10-20 09:43:10 +08:00
|
|
|
self.view.backgroundColor = RGB16(0xD7CDFF);
|
2025-08-08 10:49:36 +08:00
|
|
|
self.tableView.tableHeaderView = self.topView;
|
|
|
|
|
[self.view addSubview:self.tableView];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void)getDayTask{
|
|
|
|
|
MJWeakSelf
|
|
|
|
|
[QXMineNetwork getDayTaskListSuccessBlock:^(QXDayTaskModel * _Nonnull model) {
|
|
|
|
|
weakSelf.model = model;
|
|
|
|
|
weakSelf.topView.model = model;
|
|
|
|
|
[weakSelf.tableView reloadData];
|
|
|
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void)recordAction{
|
|
|
|
|
QXTaskGiftRecordVC *vc = [[QXTaskGiftRecordVC alloc] init];
|
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
|
}
|
|
|
|
|
-(QXDayTaskTopView *)topView{
|
|
|
|
|
if (!_topView) {
|
|
|
|
|
_topView = [[QXDayTaskTopView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-32, ScaleWidth(285)+12)];
|
|
|
|
|
}
|
|
|
|
|
return _topView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - UITableViewDataSource,UITableViewDelegate
|
|
|
|
|
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
|
|
|
|
if (self.model == nil) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2025-11-28 22:43:06 +08:00
|
|
|
if (self.model.tasks.teacher_tasks.count > 0) {
|
|
|
|
|
return 4;
|
|
|
|
|
}else{
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-08 10:49:36 +08:00
|
|
|
}
|
|
|
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
|
|
|
if (section == 0) {
|
|
|
|
|
return self.model.tasks.daily_tasks.count;
|
|
|
|
|
}else if(section == 1){
|
|
|
|
|
return self.model.tasks.daily_tasks_special.count;
|
2025-11-28 22:43:06 +08:00
|
|
|
}else if(section == 2){
|
2025-08-08 10:49:36 +08:00
|
|
|
return self.model.tasks.usual_tasks.count;
|
2025-11-28 22:43:06 +08:00
|
|
|
}else{
|
|
|
|
|
return self.model.tasks.teacher_tasks.count;
|
2025-08-08 10:49:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
|
QXDayTaskCell *cell = [QXDayTaskCell cellWithTableView:tableView];
|
|
|
|
|
QXDayTaskListModel *model;
|
|
|
|
|
if (indexPath.section == 0) {
|
|
|
|
|
model = self.model.tasks.daily_tasks[indexPath.row];
|
|
|
|
|
}else if(indexPath.section == 1){
|
|
|
|
|
model = self.model.tasks.daily_tasks_special[indexPath.row];
|
2025-11-28 22:43:06 +08:00
|
|
|
}else if(indexPath.section == 2){
|
2025-08-08 10:49:36 +08:00
|
|
|
model = self.model.tasks.usual_tasks[indexPath.row];
|
2025-11-28 22:43:06 +08:00
|
|
|
}else{
|
|
|
|
|
model = self.model.tasks.teacher_tasks[indexPath.row];
|
2025-08-08 10:49:36 +08:00
|
|
|
}
|
|
|
|
|
cell.model = model;
|
|
|
|
|
return cell;
|
|
|
|
|
}
|
|
|
|
|
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
|
|
|
|
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-32, 35)];
|
|
|
|
|
header.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
[header addRoundedCornersWithRadius:17.5 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
|
|
|
|
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 12, SCREEN_WIDTH-32*2, 23)];
|
|
|
|
|
titleLabel.font = [UIFont boldSystemFontOfSize:16];
|
|
|
|
|
titleLabel.textColor = QXConfig.textColor;
|
|
|
|
|
if (section == 0) {
|
|
|
|
|
titleLabel.text = QXText(@"每日任务");
|
|
|
|
|
}else if(section == 1){
|
|
|
|
|
titleLabel.text = QXText(@"特殊任务");
|
2025-11-28 22:43:06 +08:00
|
|
|
}else if(section == 2){
|
2025-08-08 10:49:36 +08:00
|
|
|
titleLabel.text = QXText(@"平台任务");
|
2025-11-28 22:43:06 +08:00
|
|
|
}else{
|
|
|
|
|
titleLabel.text = QXText(@"师徒任务");
|
2025-08-08 10:49:36 +08:00
|
|
|
}
|
|
|
|
|
[header addSubview:titleLabel];
|
|
|
|
|
return header;
|
|
|
|
|
}
|
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
|
|
|
|
return 35;
|
|
|
|
|
}
|
|
|
|
|
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
|
|
|
|
|
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-32, 35)];
|
|
|
|
|
footer.backgroundColor = [UIColor clearColor];
|
|
|
|
|
UIView *roundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-32, 25)];
|
|
|
|
|
roundView.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
[roundView addRoundedCornersWithRadius:17.5 byRoundingCorners:(UIRectCornerBottomLeft|UIRectCornerBottomRight)];
|
|
|
|
|
[footer addSubview:roundView];
|
|
|
|
|
return footer;
|
|
|
|
|
}
|
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
|
|
|
|
return 35;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(UITableView *)tableView{
|
|
|
|
|
if (!_tableView) {
|
|
|
|
|
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(16, NavContentHeight, SCREEN_WIDTH-32, SCREEN_HEIGHT-NavContentHeight) style:(UITableViewStyleGrouped)];
|
|
|
|
|
_tableView.dataSource = self;
|
|
|
|
|
_tableView.delegate = self;
|
|
|
|
|
_tableView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
_tableView.rowHeight = 60;
|
|
|
|
|
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
|
|
|
if (@available(iOS 15.0, *)) {
|
|
|
|
|
_tableView.sectionHeaderTopPadding = 0;
|
|
|
|
|
} else {
|
|
|
|
|
// Fallback on earlier versions
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return _tableView;
|
|
|
|
|
}
|
|
|
|
|
@end
|