123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- //
- // HomeBigshotVC.m
- // smartRhino
- //
- // Created by niuzhen on 2020/6/23.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "HomeBigshotVC.h"
- #import "HomeSubModel.h"
- #import "HomeSubItemModel.h"
- #import "HomeBigshotCell.h"
- #import "BookTeacherDetailVC.h"
- #import "BookWCDetailVC.h"
- #import "BookListenVC.h"
- #import "BookListDetailVC.h"
- #import "IndexMoreVC.h"
- #import "HomeSCDetailVC.h"
- @interface HomeBigshotVC ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) UITableView * tableView;
- @property (nonatomic, strong) NSMutableArray * dataSource;
- @end
- @implementation HomeBigshotVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self.view addSubview:self.tableView];
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- [self getData];
- }
- - (void)setHeight:(CGFloat)height
- {
- [self.tableView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, height - 45)];
- }
- - (UITableView *)tableView
- {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.showsVerticalScrollIndicator = NO;
- }
- return _tableView;
- }
- - (NSMutableArray *)dataSource
- {
- if (!_dataSource) {
- _dataSource = [NSMutableArray array];
- }
- return _dataSource;
- }
- - (void)getData
- {
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_PAGE_CATHEDRA) parameters:@{@"StyleCss":self.style,@"Page":@(1),@"PerPage":@20} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- if ([responseObject isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject) {
- HomeSubModel *model = [HomeSubModel modelWithDictionary:dict];
- [weakSelf.dataSource addObject:model];
- }
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.dataSource.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return UITableViewAutomaticDimension;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- WS(weakSelf);
- HomeSubModel *model = self.dataSource[indexPath.row];
- if (indexPath.row == 0) {
- HomeBigshotCell * cell = [HomeBigshotCell configCell0:tableView indexPath:indexPath];
- [cell setDatatype:0 model:model];
- cell.ClickItemBlock = ^(HomeSubItemModel * _Nonnull pmodel) {
- [weakSelf pushVC:pmodel];
- };
- return cell;
- }else{
- HomeBigshotCell * cell = [HomeBigshotCell configCell1:tableView indexPath:indexPath];
- [cell setDatatype:1 model:model];
- cell.ClickItemBlock = ^(HomeSubItemModel * _Nonnull pmodel) {
- [weakSelf pushVC:pmodel];
- };
- return cell;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- }
- - (void)pushVC:(HomeSubItemModel *)model
- {
- switch ((CollectModelType)model.MediaType) {
- case CollectModel_StoreBook:
- {
- BookListDetailVC * vc = [BookListDetailVC initBookListDetailVC];
- vc.Id = model.Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_StoreVideo:
- {
- BookWCDetailVC * vc = [BookWCDetailVC initBookWCDetailVC];
- vc.Id = model.Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_StoreSound:
- {
- BookListenVC * vc = [BookListenVC initBookListenVC];
- vc.Id = model.Id;
- vc.MediaType = MediaMusicType;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_Teacher:
- {
- BookTeacherDetailVC * vc = [BookTeacherDetailVC initBookTeacherDetailVC];
- vc.Id = model.Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_Organization:
- {
- HomeSCDetailVC * vc = [[HomeSCDetailVC alloc] init];
- vc.Id = model.Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_MediaAritle:
- {
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_MediaAritle;
- vc.Id = model.Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- default:
- {
-
- }
- break;
- }
- }
- @end
|