|
|
@@ -13,18 +13,18 @@
|
|
|
#import "Masonry.h"
|
|
|
#import "SDCycleScrollView.h"
|
|
|
#import "WebViewController.h"
|
|
|
-@interface ActivityListViewController ()<UINavigationControllerDelegate,UITableViewDelegate,UITableViewDataSource, SDCycleScrollViewDelegate>
|
|
|
-{
|
|
|
+
|
|
|
+@interface ActivityListViewController () <UINavigationControllerDelegate, UITableViewDelegate, UITableViewDataSource, SDCycleScrollViewDelegate> {
|
|
|
NSInteger index;
|
|
|
}
|
|
|
|
|
|
-@property(nonatomic,weak)UINavigationController*navController;
|
|
|
-@property(nonatomic,strong)NSMutableArray *collectionSource;
|
|
|
-@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottom;
|
|
|
-@property (strong, nonatomic) UITableView *tableView;
|
|
|
-@property (strong, nonatomic) UIView *headerView;
|
|
|
-@property (nonatomic, strong) SDCycleScrollView *cycleScrollView;
|
|
|
-@property (nonatomic, strong) NSMutableArray* urlArr;
|
|
|
+@property(nonatomic, weak) UINavigationController *navController;
|
|
|
+@property(nonatomic, strong) NSMutableArray *collectionSource;
|
|
|
+@property(weak, nonatomic) IBOutlet NSLayoutConstraint *bottom;
|
|
|
+@property(strong, nonatomic) UITableView *tableView;
|
|
|
+@property(strong, nonatomic) UIView *headerView;
|
|
|
+@property(nonatomic, strong) SDCycleScrollView *cycleScrollView;
|
|
|
+@property(nonatomic, strong) NSMutableArray *topActivities;
|
|
|
@end
|
|
|
|
|
|
@implementation ActivityListViewController
|
|
|
@@ -38,17 +38,17 @@
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
-
|
|
|
+
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hideNavigationBar) name:@"hideNavigationBar" object:nil];
|
|
|
-
|
|
|
+
|
|
|
index = 1;
|
|
|
self.extendedLayoutIncludesOpaqueBars = YES;
|
|
|
- self.tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
|
|
|
-
|
|
|
+ self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
|
|
+
|
|
|
if ([UIScreen spt_currentScreenMode] == LESScreenModeIPhoneX) {
|
|
|
- self.tableView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight-88-83);
|
|
|
+ self.tableView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight - 88 - 83);
|
|
|
} else {
|
|
|
- self.tableView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight-64-49);
|
|
|
+ self.tableView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight - 64 - 49);
|
|
|
}
|
|
|
self.tableView.backgroundColor = [UIColor colorWithHexString:@"#F2F4F5"];
|
|
|
self.tableView.tableHeaderView = self.headerView;
|
|
|
@@ -62,42 +62,42 @@
|
|
|
[self getList];
|
|
|
}
|
|
|
|
|
|
--(void)hideNavigationBar{
|
|
|
+- (void)hideNavigationBar {
|
|
|
self.navigationController.navigationBar.hidden = YES;
|
|
|
}
|
|
|
|
|
|
-- (void)viewWillAppear:(BOOL)animated{
|
|
|
+- (void)viewWillAppear:(BOOL)animated {
|
|
|
self.tabBarController.tabBar.hidden = YES;
|
|
|
}
|
|
|
|
|
|
--(void)refreshList{
|
|
|
+- (void)refreshList {
|
|
|
index = 1;
|
|
|
[self.collectionSource removeAllObjects];
|
|
|
[self getList];
|
|
|
}
|
|
|
|
|
|
-- (void)loadMoreData{
|
|
|
+- (void)loadMoreData {
|
|
|
index++;
|
|
|
[self getList];
|
|
|
}
|
|
|
|
|
|
-- (void)getList{
|
|
|
+- (void)getList {
|
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
|
- NSString *indexStr = [NSString stringWithFormat:@"%zd",index];
|
|
|
- NSString *str = [NSString stringWithFormat:@"%@activity?action=dogetpartty&memberpk=%@&index=%@&size=%@",webURL,[Helper sharedAccount].accid,indexStr,@"10"];
|
|
|
- [[AHHttpManager sharedManager]POST:str parameters:nil success:^(id responseObject) {
|
|
|
- NSLog(@"%@",responseObject);
|
|
|
+ NSString *indexStr = [NSString stringWithFormat:@"%zd", index];
|
|
|
+ NSString *str = [NSString stringWithFormat:@"%@activity?action=dogetpartty&memberpk=%@&index=%@&size=%@", webURL, [Helper sharedAccount].accid, indexStr, @"10"];
|
|
|
+ [[AHHttpManager sharedManager] POST:str parameters:nil success:^(id responseObject) {
|
|
|
+ NSLog(@"%@", responseObject);
|
|
|
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
|
|
-
|
|
|
- if ([[responseObject objectForKey:@"msg"]isEqualToString:@"success"]) {
|
|
|
+
|
|
|
+ if ([[responseObject objectForKey:@"msg"] isEqualToString:@"success"]) {
|
|
|
NSArray *data = responseObject[@"data"];
|
|
|
- NSArray * array = [ActivityModel arrayOfModelsFromDictionaries:data];
|
|
|
-
|
|
|
+ NSArray *array = [ActivityModel arrayOfModelsFromDictionaries:data];
|
|
|
+
|
|
|
[self.collectionSource addObjectsFromArray:array];
|
|
|
-
|
|
|
+
|
|
|
NSString *number = responseObject[@"count"];
|
|
|
NSInteger num = [number integerValue];
|
|
|
-
|
|
|
+
|
|
|
[self.tableView.mj_header endRefreshing];
|
|
|
if (num == self.collectionSource.count || num == 0) {
|
|
|
[self.tableView.mj_footer endRefreshingWithNoMoreData];
|
|
|
@@ -105,35 +105,35 @@
|
|
|
[self.tableView.mj_footer endRefreshing];
|
|
|
}
|
|
|
[self.tableView reloadData];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
[MBProgressHUD showTextHUD:@"超时" inView:self.view hideAfterDelay:1];
|
|
|
}
|
|
|
- } failure:^(NSError *error) {
|
|
|
- NSLog(@"error = %@",error);
|
|
|
+ } failure:^(NSError *error) {
|
|
|
+ NSLog(@"error = %@", error);
|
|
|
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
|
|
}];
|
|
|
-
|
|
|
- [[AHHttpManager sharedManager]POST:[NSString stringWithFormat:@"%@activity?action=dogettoppartty", webURL] parameters:nil success:^(id responseObject) {
|
|
|
- if ([[responseObject objectForKey:@"msg"]isEqualToString:@"success"]) {
|
|
|
+
|
|
|
+ [[AHHttpManager sharedManager] POST:[NSString stringWithFormat:@"%@activity?action=dogettoppartty", webURL] parameters:nil success:^(id responseObject) {
|
|
|
+ if ([[responseObject objectForKey:@"msg"] isEqualToString:@"success"]) {
|
|
|
NSArray *data = responseObject[@"data"];
|
|
|
- NSMutableArray *urlArr = [NSMutableArray arrayWithCapacity:0];
|
|
|
+ NSMutableArray *topActivities = [NSMutableArray arrayWithCapacity:0];
|
|
|
NSMutableArray *picArr = [NSMutableArray arrayWithCapacity:0];
|
|
|
for (NSDictionary *dic in data) {
|
|
|
- [urlArr addObject:dic[@"url"]];
|
|
|
+ [topActivities addObject:dic];
|
|
|
[picArr addObject:[NSString stringWithFormat:@"%@%@", imageURl, dic[@"Pic"]]];
|
|
|
- self.urlArr = urlArr;
|
|
|
+ self.topActivities = topActivities;
|
|
|
[self.cycleScrollView setImageURLStringsGroup:picArr];
|
|
|
}
|
|
|
}
|
|
|
- } failure:^(NSError *error) {
|
|
|
- NSLog(@"error = %@",error);
|
|
|
+ } failure:^(NSError *error) {
|
|
|
+ NSLog(@"error = %@", error);
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
- (UIView *)headerView {
|
|
|
if (!_headerView) {
|
|
|
_headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 250)];
|
|
|
-
|
|
|
+
|
|
|
SDCycleScrollView *cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, ScreenWidth, 210) imageURLStringsGroup:@[]];
|
|
|
cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
|
|
|
cycleScrollView.showPageControl = NO;
|
|
|
@@ -141,7 +141,7 @@
|
|
|
[_headerView addSubview:cycleScrollView];
|
|
|
cycleScrollView.delegate = self;
|
|
|
self.cycleScrollView = cycleScrollView;
|
|
|
-
|
|
|
+
|
|
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 192, ScreenWidth, 57)];
|
|
|
view.backgroundColor = [UIColor colorWithHexString:@"#F2F4F5"];
|
|
|
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds
|
|
|
@@ -152,7 +152,7 @@
|
|
|
maskLayer.path = maskPath.CGPath;
|
|
|
view.layer.mask = maskLayer;
|
|
|
[_headerView addSubview:view];
|
|
|
-
|
|
|
+
|
|
|
UILabel *label = [[UILabel alloc] init];
|
|
|
label.font = [UIFont systemFontOfSize:22 weight:UIFontWeightMedium];
|
|
|
label.textColor = [UIColor blackColor];
|
|
|
@@ -167,36 +167,38 @@
|
|
|
}
|
|
|
|
|
|
#pragma mark - deleDate
|
|
|
--(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
|
+
|
|
|
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
return self.collectionSource.count;
|
|
|
}
|
|
|
|
|
|
--(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
-
|
|
|
- ActivityCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ActivityCell"];
|
|
|
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
+
|
|
|
+ ActivityCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ActivityCell"];
|
|
|
if (!cell) {
|
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
- cell = [[[UINib nibWithNibName:@"ActivityCell" bundle:nil]instantiateWithOwner:self options:nil]lastObject];
|
|
|
+ cell = [[[UINib nibWithNibName:@"ActivityCell" bundle:nil] instantiateWithOwner:self options:nil] lastObject];
|
|
|
cell.model = [self.collectionSource objectAtIndex:indexPath.row];
|
|
|
}
|
|
|
return cell;
|
|
|
}
|
|
|
|
|
|
--(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
|
|
+- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
--(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
return 266;
|
|
|
}
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
- self.Pushblock([self.collectionSource objectAtIndex:indexPath.row]);
|
|
|
+ self.Pushblock(self.collectionSource[indexPath.row]);
|
|
|
}
|
|
|
|
|
|
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
|
|
|
WebViewController *webVC = [[WebViewController alloc] init];
|
|
|
- webVC.url = self.urlArr[index];
|
|
|
+ webVC.url = self.topActivities[index][@"url"];
|
|
|
+ webVC.activityPK = self.topActivities[index][@"PK"];
|
|
|
webVC.hidesBottomBarWhenPushed = YES;
|
|
|
[self.findViewController pushViewController:webVC animated:YES];
|
|
|
}
|