123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- //
- // Base_tbVC.m
- // LNManager
- //
- // Created by EchoShacolee on 2017/4/9.
- // Copyright © 2017年 lee. All rights reserved.
- //
- #import "Base_tbVC.h"
- @interface Base_tbVC ()
- @end
- @implementation Base_tbVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.view.backgroundColor = KBackGroundColor;
-
- _dataurce = [[NSMutableArray alloc]init];
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-SafeAreaBottomHeight)];
- _tableView.backgroundColor = KBackGroundColor;
- _tableView.dataSource = self;
- _tableView.delegate = self;
- [self.view addSubview:_tableView];
- self.tableView.tableFooterView = [UIView new];
-
- self.holderV = [[HolderView alloc] initWithFrame:_tableView.frame];
- [self.holderV freshBlock:^{
- if (_block) {
- _block();
- }
- }];
- [self.view addSubview:self.holderV];
- }
- #pragma mark 获取数据
- -(void)getDataWithDic:(NSMutableDictionary *)mdic method:(NSString *)method{
-
- //判断网络是否连接
- if (![NetworkManager connectedToNetWork]) {
- [self showMsgByAlertVCWithString:@"网络连接异常"];
- return;
- }
-
- [MBProgressHUD hideHUDForView:self.view animated:NO];
- [MBProgressHUD showHUDAddedTo:self.view animated:YES];
- [NetworkManager requestWithMethod:method parameters:mdic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
-
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- self.holderV.hidden = NO;
-
- if (failureStr) {
- [self showMsgByAlertVCWithString:failureStr];
- return;
- }
-
- if ([successDic[@"code"] isEqualToString:@"1"]) {
- [self showMsgByAlertVCWithString:successDic[@"msg"]];
- return;
- }
-
- _dataurce = successDic[@"body"];
- if (_dataurce.count != 0) {
- self.holderV.hidden = YES;
- }
-
- [self.tableView reloadData];
- }];
- }
- #pragma mark 获取数据2
- -(void)getDataWithDic:(NSMutableDictionary *)mdic method:(NSString *)method block:(Block)block{
-
- //判断网络是否连接
- if (![NetworkManager connectedToNetWork]) {
- [self showMsgByAlertVCWithString:@"网络连接异常"];
- return;
- }
-
- [MBProgressHUD hideHUDForView:self.view animated:NO];
- [MBProgressHUD showHUDAddedTo:self.view animated:YES];
- [NetworkManager requestWithMethod:method parameters:mdic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
-
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- self.holderV.hidden = NO;
- //设置加载状态
- _IS_LOADING=NO;
-
- if (failureStr) {
- [self showMsgByAlertVCWithString:failureStr];
- return;
- }
-
- if ([successDic[@"code"] isEqualToString:@"1"]) {
- [self showMsgByAlertVCWithString:successDic[@"msg"]];
- return;
- }
-
- if (block) {
- block(successDic);
- }
- }];
- }
- #pragma mark 弹出框提示
- - (void)showMsgByAlertVCWithString:(NSString *)str{
-
- UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:str preferredStyle:UIAlertControllerStyleAlert];
-
- [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
- [self presentViewController:alertFind animated:true completion:nil];
- }
- - (void)showMsgByMBWithString:(NSString *)str{
- MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
- hud.mode = MBProgressHUDModeText;
- hud.label.text = str;
- hud.margin = HUD_MARGIN;
- hud.removeFromSuperViewOnHide = YES;
- [hud hideAnimated:YES afterDelay:2];
- }
- #pragma mark 代理方法,具体实现子类完成
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return 0;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"nouse"];
- return cell;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
-
- // Configure the cell...
-
- return cell;
- }
- */
- /*
- // Override to support conditional editing of the table view.
- - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
- // Return NO if you do not want the specified item to be editable.
- return YES;
- }
- */
- /*
- // Override to support editing the table view.
- - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- // Delete the row from the data source
- [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
- } else if (editingStyle == UITableViewCellEditingStyleInsert) {
- // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
- }
- }
- */
- /*
- // Override to support rearranging the table view.
- - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
- }
- */
- /*
- // Override to support conditional rearranging of the table view.
- - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
- // Return NO if you do not want the item to be re-orderable.
- return YES;
- }
- */
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|