172 lines
5.7 KiB
Objective-C
172 lines
5.7 KiB
Objective-C
//
|
|
// GongJuListViewController.m
|
|
// ProductApp
|
|
//
|
|
// Created by 工作 on 2024/10/15.
|
|
//
|
|
|
|
#import "GongJuListViewController.h"
|
|
#import "GongJuListTableViewCell.h"
|
|
#import "NetWorkManager.h"
|
|
#import "GongJuCreateViewController.h"
|
|
#import "KeTangXieZuoViewController.h"
|
|
#import "GongJuTextViewController.h"
|
|
#import "GongJuWenBenViewController.h"
|
|
#import "GongJuFanYiViewController.h"
|
|
#import "GongJuImageToTextViewController.h"
|
|
#import "GongJuMinGanCiController.h"
|
|
|
|
@interface GongJuListViewController ()<UITableViewDelegate,UITableViewDataSource>
|
|
///
|
|
@property (nonatomic , strong) UITableView *tableView;
|
|
@property (nonatomic , assign) int ipage;
|
|
///
|
|
@property (nonatomic , strong) NSMutableArray *arrdata;
|
|
|
|
@end
|
|
|
|
@implementation GongJuListViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self.view setBackgroundColor:[UIColor clearColor]];
|
|
|
|
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
|
|
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
|
|
[tableView setBackgroundColor:[UIColor clearColor]];
|
|
[tableView setDelegate:self];
|
|
[tableView setDataSource:self];
|
|
[self.view addSubview:tableView];
|
|
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.view);
|
|
}];
|
|
_tableView = tableView;
|
|
tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
|
|
self.ipage += 1;
|
|
[self getdata];
|
|
}];
|
|
}
|
|
|
|
-(void)setModel:(ToolsTypeModelData *)model
|
|
{
|
|
_model = model;
|
|
self.ipage = 1;
|
|
self.arrdata = [NSMutableArray new];
|
|
[self.tableView reloadData];
|
|
[self getdata];
|
|
}
|
|
|
|
-(void)getdata
|
|
{
|
|
[LoadAlterView show];
|
|
[NetWorkManager requestToolsListData:self.view page:self.ipage type_id:self.model.ID tool_name:self.model.type_name is_recommend:[Tools isStringnil:self.model.ID].length==0?@"0":@"" Callback:^(BOOL state, ToolsListModel *responseObject, NSString * _Nullable describle) {
|
|
[LoadAlterView dismiss];
|
|
[self.tableView.mj_header endRefreshing];
|
|
[self.tableView.mj_footer endRefreshing];
|
|
if(self.ipage==1)self.arrdata = [NSMutableArray new];
|
|
if(state)
|
|
{
|
|
[self.arrdata addObjectsFromArray:responseObject.data.items];
|
|
}
|
|
else
|
|
{
|
|
[HXHud showMessage:responseObject.message afterDelayType:1];
|
|
}
|
|
[self.tableView reloadData];
|
|
}];
|
|
}
|
|
|
|
#pragma mark - UITableView
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
{
|
|
return self.arrdata.count;
|
|
}
|
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
static NSString *strcell = @"GongJuListTableViewCell";
|
|
GongJuListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strcell];
|
|
if(!cell)
|
|
{
|
|
cell = [[GongJuListTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strcell];
|
|
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
|
|
[cell setBackgroundColor:[UIColor clearColor]];
|
|
}
|
|
cell.model = self.arrdata[indexPath.row];
|
|
return cell;
|
|
}
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
|
{
|
|
return 0.01;
|
|
}
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
|
{
|
|
return 10;
|
|
}
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
float fheight = 82;
|
|
ToolsListModelDataItems *model = self.arrdata[indexPath.row];
|
|
float f_w = [Tools getWidthWithText:model.Descriptions height:20 font:12]+1;
|
|
if(f_w>UISCREEN_WIDTH-157)
|
|
{
|
|
fheight = 95;
|
|
}
|
|
return fheight;
|
|
}
|
|
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
|
{
|
|
return [UIView new];
|
|
}
|
|
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
|
{
|
|
return [UIView new];
|
|
}
|
|
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
ToolsListModelDataItems *model = self.arrdata[indexPath.row];
|
|
if(model.ID.intValue>=1 && model.ID.intValue<=9)
|
|
{
|
|
if(model.ID.intValue==9)
|
|
{
|
|
KeTangXieZuoViewController *vc = [KeTangXieZuoViewController new];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
else if(model.ID.intValue==6||model.ID.intValue==7||model.ID.intValue==8||model.ID.intValue==3)
|
|
{
|
|
GongJuTextViewController *vc = [GongJuTextViewController new];
|
|
vc.strtitle = model.tool_name;
|
|
vc.type = model.ID.intValue;
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
else if(model.ID.intValue==5)
|
|
{
|
|
GongJuMinGanCiController *vc = [GongJuMinGanCiController new];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
else if(model.ID.intValue==4)
|
|
{
|
|
GongJuFanYiViewController *vc = [GongJuFanYiViewController new];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
else if(model.ID.intValue==2)
|
|
{
|
|
GongJuWenBenViewController *vc = [GongJuWenBenViewController new];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
else if(model.ID.intValue==1)
|
|
{
|
|
GongJuImageToTextViewController *vc = [GongJuImageToTextViewController new];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GongJuCreateViewController *vc = [GongJuCreateViewController new];
|
|
vc.modelDetail = model;
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
}
|
|
|
|
|
|
@end
|