admin
2023-04-21 0b3a4aaf99ea251bc8e27b96115288f0988fcffe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//
//  AllSpecialController.m
//  BuWanVideo2.0
//
//  Created by weikou2016 on 16/8/19.
//  Copyright © 2016年 com.yeshi.buwansheque.ios. All rights reserved.
//
 
#import "AllSpecialController.h"
#import "AllSpecialCell.h"
#import "OnlySpecialController.h"
 
@interface AllSpecialController ()<UITableViewDelegate,UITableViewDataSource>{
    UITableView * tableview;
    NSMutableArray * arrdata;
    int page;
}
 
@end
 
@implementation AllSpecialController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    //[MobClick beginLogPageView:@"进入专题合集"];
    
    [self initScene];
}
 
-(void)dealloc{
    //[MobClick beginLogPageView:@"退出专题合集"];
}
 
-(void)initScene{
    self.navigationItem.title = @"专题合集";
    
    self.navigationController.navigationBar.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]};;
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[[UIImage imageNamed:@"详情页面返回"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(back:)
     forControlEvents:UIControlEventTouchUpInside];
    button.frame = CGRectMake(0, 0, 32, 32);
    UIBarButtonItem *iconBarItem=[[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.leftBarButtonItem = iconBarItem;
    
    self.view.backgroundColor = kGlobalBackgroundColor;
    
    arrdata = [NSMutableArray arrayWithCapacity:0];
    tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
    tableview.delegate  = self;
    tableview.dataSource = self;
    tableview.backgroundColor = kGlobalBackgroundColor;
    tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:tableview];
    
    [tableview registerNib:[UINib nibWithNibName:@"AllSpecialCell" bundle:nil] forCellReuseIdentifier:@"AllSpecialCell"];
    tableview.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headupdata)];
    [tableview.mj_header beginRefreshing];
    
}
 
-(void)headupdata{
    [[YTHNetInterface startInterface]getFoundSpecialList:[YTHsharedManger startManger].Uid withPage:@"1" WithSystem:@"1" WithBlock:^(BOOL isSuccessful, id result, NSString *error) {
        if(isSuccessful){
            arrdata = [[result objectForKey:@"Data"] objectForKey:@"data"];
            if (arrdata.count > 0) {
                ++page;
                [tableview reloadData];
            }
            if (arrdata.count >5) {
                tableview.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footupdata)];
            }
        }else{
          
            NSLog(@"%@",error);
        }
        [tableview.mj_header endRefreshing];
    }];
    
}
 
-(void)footupdata{
    [[YTHNetInterface startInterface]getFoundSpecialList:[YTHsharedManger startManger].Uid withPage:[NSString stringWithFormat:@"%d",page] WithSystem:@"1" WithBlock:^(BOOL isSuccessful, id result, NSString *error) {
        if(isSuccessful){
            NSArray *newarr = [[result objectForKey:@"Data"] objectForKey:@"data"];
            if (arrdata!=nil) {
                [arrdata removeAllObjects];
            }else{
                arrdata=[NSMutableArray arrayWithCapacity:0];
            }
            if(newarr.count >0){
                [arrdata addObjectsFromArray:newarr];
                [tableview reloadData];
                ++page;
            }
        }else{
            NSLog(@"%@",error);
        }
        [tableview.mj_footer endRefreshing];
    }];
}
 
 
#pragma mark   UITableViewDelegate   UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return arrdata.count;
}
 
 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    AllSpecialCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AllSpecialCell" forIndexPath:indexPath];
    NSDictionary *dic = arrdata[indexPath.row];
    [cell.image setYthImageWithURL:[dic objectForKey:@"Picture"] placeholderImage:[UIImage imageNamed:@"默认加载图片"]];
    cell.lable.text  = [dic objectForKey:@"Name"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
 
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return KScreenW/16*7+40;
}
 
-(void)back:(UIButton*)sender{
    [self.navigationController popViewControllerAnimated:YES];
}
 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    OnlySpecialController * oscontroller = [OnlySpecialController new];
    oscontroller.Id = ((NSString*)[arrdata[indexPath.row] objectForKey:@"Id"]).intValue;
    [self.navigationController pushViewController:oscontroller animated:YES];
}
 
 
 
@end