123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- //
- // HomeMingShiVC.m
- // smartRhino
- //
- // Created by niuzhen on 2020/6/23.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "HomeUserVC.h"
- #import "HomeSubModel.h"
- #import "HomeSubItemModel.h"
- #import "HomeUserPrivilegeCell.h"
- #import "BookTeacherDetailVC.h"
- #import "BookWCDetailVC.h"
- #import "BookListenVC.h"
- #import "BookListDetailVC.h"
- #import "BookLabelAllVC.h"
- #import "HomeSCDetailVC.h"
- @interface HomeUserVC ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) UITableView * tableView;
- @property (nonatomic, strong) NSMutableArray * dataSource;
- @property (nonatomic, assign) NSInteger currentPage;
- @property (nonatomic, assign) NSInteger Total;
- @end
- @implementation HomeUserVC
- - (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":@(self.currentPage),@"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];
- HomeUserPrivilegeCell * cell = [HomeUserPrivilegeCell configCell:tableView indexPath:indexPath];
- if (indexPath.row == 0) {
- cell.height.constant = 11.f;
- }
- cell.ClickItemBlock = ^(HomeSubItemModel * _Nonnull pmodel) {
- [weakSelf pushVC:pmodel];
- };
- // BOOL isEnd = self.dataSource.count - 1 == indexPath.row;
- [cell setDataWithItem:indexPath.row isUnUser:NO model:model];
- [cell.lookBtn setAction:^{
- [weakSelf ShowAll:model];
- }];
- return cell;
- }
- - (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;
- }
- }
- - (void)ShowAll:(HomeSubModel *)model
- {
- BookLabelAllVC * vc = [BookLabelAllVC initBookLabelAllVC];
- vc.Id = model.Id;
- vc.titleStr = model.LabelName;
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- }
- @end
|