Commit a8838d43afb6fdfc7a53344b0063792ebd5832c7
1 parent
605b7d42
no message
Showing
5 changed files
with
116 additions
and
63 deletions
CNLiveBalanceModule/Classes/Detail/CNLiveBalanceDetailBaseController.m
| ... | ... | @@ -32,42 +32,56 @@ |
| 32 | 32 | static const CGFloat height = 44; |
| 33 | 33 | #pragma mark - 加载数据 |
| 34 | 34 | - (void)loadData { |
| 35 | + __weak typeof(self) weakSelf = self; | |
| 35 | 36 | [CNLiveBalanceRequest getTradingRecordListWithID:self.ID type:[NSString stringWithFormat:@"%ld",self.type] pageNo:self.pageNo pageSize:self.pageSize block:^(BOOL isSuccess, NSDictionary * _Nonnull data, NSError *error) { |
| 36 | - | |
| 37 | - [self.tableView.mj_header endRefreshing]; | |
| 38 | - [self.tableView.mj_footer endRefreshing]; | |
| 37 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 38 | + if(!strongSelf) return ; | |
| 39 | + [strongSelf.tableView.mj_header endRefreshing]; | |
| 40 | + [strongSelf.tableView.mj_footer endRefreshing]; | |
| 41 | + strongSelf.isRefreshing = NO; | |
| 42 | + | |
| 39 | 43 | if (error) { |
| 40 | - [self.data removeAllObjects]; | |
| 41 | - [self.tableView reloadData]; | |
| 42 | - [self.tableView showEmptyViewWithType:CNLiveCustomTipsTypeLoadFail noData:self.data.count == 0 block:^{ | |
| 43 | - [self.tableView.mj_header beginRefreshing]; | |
| 44 | - }]; | |
| 44 | + | |
| 45 | + if (error.code == -1001||error.code == -1003||error.code == -1009) { | |
| 46 | + [strongSelf.tableView showEmptyViewWithType:CNLiveCustomTipsTypeNoNet noData:strongSelf.data.count == 0 block:^{ | |
| 47 | + [strongSelf.tableView.mj_header beginRefreshing]; | |
| 48 | + | |
| 49 | + }]; | |
| 50 | + }else{ | |
| 51 | + [strongSelf.tableView showEmptyViewWithType:CNLiveCustomTipsTypeLoadFail noData:strongSelf.data.count == 0 block:^{ | |
| 52 | + [strongSelf.tableView.mj_header beginRefreshing]; | |
| 53 | + | |
| 54 | + }]; | |
| 55 | + } | |
| 56 | + strongSelf.tableView.emptyView.top = 0; | |
| 57 | + strongSelf.tableView.mj_footer.hidden = self.data.count == 0; | |
| 58 | + | |
| 45 | 59 | return; |
| 46 | 60 | } |
| 47 | 61 | |
| 48 | 62 | if (isSuccess) { |
| 49 | - if(self.pageNo == 1 && self.data.count>0){ | |
| 50 | - [self.data removeAllObjects]; | |
| 63 | + if(strongSelf.pageNo == 1 && strongSelf.data.count>0){ | |
| 64 | + [strongSelf.data removeAllObjects]; | |
| 51 | 65 | } |
| 52 | - self.pageNo++; | |
| 66 | + strongSelf.pageNo++; | |
| 53 | 67 | CNLiveTradingRecordModel *model = [CNLiveTradingRecordModel mj_objectWithKeyValues:data]; |
| 54 | - if (model.list.count < self.pageSize) { | |
| 55 | - [self.tableView.mj_footer endRefreshingWithNoMoreData]; | |
| 68 | + if (model.list.count < strongSelf.pageSize) { | |
| 69 | + [strongSelf.tableView.mj_footer endRefreshingWithNoMoreData]; | |
| 56 | 70 | |
| 57 | 71 | } else { |
| 58 | - [self.tableView.mj_footer endRefreshing]; | |
| 72 | + [strongSelf.tableView.mj_footer endRefreshing]; | |
| 59 | 73 | |
| 60 | 74 | } |
| 61 | - [self.data addObjectsFromArray:model.list]; | |
| 62 | - UIImage *image = [self getImageWithImageName:@"cnlive_no_bill" bundleName:@"CNLiveBalanceModule" targetClass:[self class]]; | |
| 63 | - [self.tableView showEmptyViewWithImage:image text:@"您现在没有相关内容哦" buttonText:@"重新加载" noData:self.data.count == 0 block:nil]; | |
| 64 | - self.tableView.emptyView.top = 0; | |
| 65 | - [self.tableView reloadData]; | |
| 75 | + [strongSelf.data addObjectsFromArray:model.list]; | |
| 76 | + UIImage *image = [strongSelf getImageWithImageName:@"cnlive_no_bill" bundleName:@"CNLiveBalanceModule" targetClass:[strongSelf class]]; | |
| 77 | + [strongSelf.tableView showEmptyViewWithImage:image text:@"您现在没有相关内容哦" buttonText:@"重新加载" noData:strongSelf.data.count == 0 block:nil]; | |
| 78 | + strongSelf.tableView.emptyView.top = 0; | |
| 79 | + [strongSelf.tableView reloadData]; | |
| 66 | 80 | |
| 67 | 81 | } |
| 68 | - self.tableView.mj_footer.hidden = self.data.count == 0; | |
| 69 | - self.isRefreshing = NO; | |
| 70 | - | |
| 82 | + strongSelf.tableView.mj_footer.hidden = self.data.count == 0; | |
| 83 | + [strongSelf.tableView reloadData]; | |
| 84 | + | |
| 71 | 85 | }]; |
| 72 | 86 | |
| 73 | 87 | } |
| ... | ... | @@ -155,8 +169,10 @@ static const CGFloat height = 44; |
| 155 | 169 | [_tableView registerClass:[CNLiveTradingRecordCell class] forCellReuseIdentifier:kCNLiveTradingRecordCell]; |
| 156 | 170 | __weak __typeof(self)weakSelf = self; |
| 157 | 171 | _tableView.mj_header = [CNLiveRefreshHeader headerWithRefreshingBlock:^{ |
| 158 | - weakSelf.pageNo = 1; | |
| 159 | - [weakSelf loadData]; | |
| 172 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 173 | + if(!strongSelf) return ; | |
| 174 | + strongSelf.pageNo = 1; | |
| 175 | + [strongSelf loadMoreData]; | |
| 160 | 176 | }]; |
| 161 | 177 | _tableView.mj_footer = [CNLiveRefreshFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; |
| 162 | 178 | ... | ... |
CNLiveBalanceModule/Classes/TradingRecord/CNLiveMonthBillController.m
| ... | ... | @@ -57,32 +57,46 @@ static const CGFloat height = 60; |
| 57 | 57 | } |
| 58 | 58 | #pragma mark - 加载数据 |
| 59 | 59 | - (void)loadData { |
| 60 | + __weak typeof(self) weakSelf = self; | |
| 60 | 61 | [CNLiveBalanceRequest getTradingRecordListWithType:self.type ID:CNUserShareModel.uid startTime:self.startTime endTime:self.endTime block:^(BOOL isSuccess, NSDictionary * _Nonnull data, NSError *error) { |
| 61 | - [self.tableView.mj_header endRefreshing]; | |
| 62 | - [self.tableView.mj_footer endRefreshing]; | |
| 63 | - self.monthBillView.interactionEnabled = YES; | |
| 62 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 63 | + if(!strongSelf) return ; | |
| 64 | + [strongSelf.tableView.mj_header endRefreshing]; | |
| 65 | + [strongSelf.tableView.mj_footer endRefreshing]; | |
| 66 | + strongSelf.monthBillView.interactionEnabled = YES; | |
| 64 | 67 | if (error) { |
| 65 | - [self.data removeAllObjects]; | |
| 66 | - [self.tableView reloadData]; | |
| 67 | - [self.tableView showEmptyViewWithType:CNLiveCustomTipsTypeLoadFail noData:self.data.count == 0 block:^{ | |
| 68 | - [self.tableView.mj_header beginRefreshing]; | |
| 69 | - }]; | |
| 70 | - self.tableView.emptyView.top = 0; | |
| 68 | + | |
| 69 | + if (error.code == -1001||error.code == -1003||error.code == -1009) { | |
| 70 | + [strongSelf.tableView showEmptyViewWithType:CNLiveCustomTipsTypeNoNet noData:strongSelf.data.count == 0 block:^{ | |
| 71 | + [strongSelf.tableView.mj_header beginRefreshing]; | |
| 72 | + | |
| 73 | + }]; | |
| 74 | + }else{ | |
| 75 | + [strongSelf.tableView showEmptyViewWithType:CNLiveCustomTipsTypeLoadFail noData:strongSelf.data.count == 0 block:^{ | |
| 76 | + [strongSelf.tableView.mj_header beginRefreshing]; | |
| 77 | + | |
| 78 | + }]; | |
| 79 | + } | |
| 80 | + strongSelf.tableView.emptyView.top = 0; | |
| 81 | + strongSelf.tableView.mj_footer.hidden = self.data.count == 0; | |
| 82 | + | |
| 71 | 83 | return; |
| 72 | 84 | } |
| 73 | 85 | |
| 74 | 86 | if (isSuccess) { |
| 75 | 87 | CNLiveTradingRecordModel *model = [CNLiveTradingRecordModel mj_objectWithKeyValues:data]; |
| 76 | - if(self.pageNo == 1&&self.data.count > 0){ | |
| 77 | - [self.data removeAllObjects]; | |
| 88 | + if(strongSelf.pageNo == 1&&strongSelf.data.count > 0){ | |
| 89 | + [strongSelf.data removeAllObjects]; | |
| 78 | 90 | } |
| 79 | - [self.data addObjectsFromArray:model.list]; | |
| 91 | + [strongSelf.data addObjectsFromArray:model.list]; | |
| 80 | 92 | |
| 81 | - UIImage *image = [self getImageWithImageName:@"cnlive_no_bill" bundleName:@"CNLiveBalanceModule" targetClass:[self class]]; | |
| 82 | - [self.tableView showEmptyViewWithImage:image text:@"您现在没有相关内容哦" buttonText:@"重新加载" noData:self.data.count == 0 block:nil]; | |
| 83 | - self.tableView.emptyView.top = 0; | |
| 84 | - [self.tableView reloadData]; | |
| 93 | + UIImage *image = [strongSelf getImageWithImageName:@"cnlive_no_bill" bundleName:@"CNLiveBalanceModule" targetClass:[strongSelf class]]; | |
| 94 | + [strongSelf.tableView showEmptyViewWithImage:image text:@"您现在没有相关内容哦" buttonText:@"重新加载" noData:strongSelf.data.count == 0 block:nil]; | |
| 95 | + strongSelf.tableView.emptyView.top = 0; | |
| 85 | 96 | } |
| 97 | + strongSelf.tableView.mj_footer.hidden = self.data.count == 0; | |
| 98 | + [strongSelf.tableView reloadData]; | |
| 99 | + | |
| 86 | 100 | }]; |
| 87 | 101 | |
| 88 | 102 | } | ... | ... |
CNLiveBalanceModule/Classes/TradingRecord/CNLiveTradingRecordController.m
| ... | ... | @@ -65,33 +65,43 @@ static const CGFloat height = 80; |
| 65 | 65 | |
| 66 | 66 | #pragma mark - 加载数据 |
| 67 | 67 | - (void)loadData { |
| 68 | + __weak typeof(self) weakSelf = self; | |
| 68 | 69 | [CNLiveBalanceRequest getTradingRecordListWithType:self.type == TradingRecordTypeDefault?@"0":@"Special" ID:self.ID startTime:self.startTime endTime:self.endTime block:^(BOOL isSuccess, NSDictionary * _Nonnull data, NSError *error) { |
| 69 | - [self.tableView.mj_header endRefreshing]; | |
| 70 | - [self.tableView.mj_footer endRefreshing]; | |
| 71 | - | |
| 70 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 71 | + if(!strongSelf) return ; | |
| 72 | + [strongSelf.tableView.mj_header endRefreshing]; | |
| 73 | + [strongSelf.tableView.mj_footer endRefreshing]; | |
| 72 | 74 | if (error) { |
| 73 | - [self.data removeAllObjects]; | |
| 74 | - [self.tableView reloadData]; | |
| 75 | - [self.tableView showEmptyViewWithType:CNLiveCustomTipsTypeLoadFail noData:self.data.count == 0 block:^{ | |
| 76 | - [self.tableView.mj_header beginRefreshing]; | |
| 77 | - }]; | |
| 78 | - self.tableView.emptyView.top = 0; | |
| 75 | + if (error.code == -1001||error.code == -1003||error.code == -1009) { | |
| 76 | + [strongSelf.tableView showEmptyViewWithType:CNLiveCustomTipsTypeNoNet noData:strongSelf.data.count == 0 block:^{ | |
| 77 | + [strongSelf.tableView.mj_header beginRefreshing]; | |
| 78 | + | |
| 79 | + }]; | |
| 80 | + }else{ | |
| 81 | + [strongSelf.tableView showEmptyViewWithType:CNLiveCustomTipsTypeLoadFail noData:strongSelf.data.count == 0 block:^{ | |
| 82 | + [strongSelf.tableView.mj_header beginRefreshing]; | |
| 83 | + | |
| 84 | + }]; | |
| 85 | + } | |
| 86 | + strongSelf.tableView.emptyView.top = 0; | |
| 87 | + strongSelf.tableView.mj_footer.hidden = self.data.count == 0; | |
| 88 | + | |
| 79 | 89 | return; |
| 80 | 90 | } |
| 81 | 91 | |
| 82 | 92 | if (isSuccess) { |
| 83 | 93 | CNLiveTradingRecordModel *model = [CNLiveTradingRecordModel mj_objectWithKeyValues:data]; |
| 84 | - if(self.pageNo == 1&&self.data.count > 0){ | |
| 85 | - [self.data removeAllObjects]; | |
| 94 | + if(strongSelf.pageNo == 1&&strongSelf.data.count > 0){ | |
| 95 | + [strongSelf.data removeAllObjects]; | |
| 86 | 96 | } |
| 87 | - [self.data addObjectsFromArray:self.type == TradingRecordTypeDefault?model.list:model.transferRecordList]; | |
| 97 | + [strongSelf.data addObjectsFromArray:strongSelf.type == TradingRecordTypeDefault?model.list:model.transferRecordList]; | |
| 88 | 98 | UIImage *image = [self getImageWithImageName:@"cnlive_no_bill" bundleName:@"CNLiveBalanceModule" targetClass:[self class]]; |
| 89 | - [self.tableView showEmptyViewWithImage:image text:@"您现在没有相关内容哦" buttonText:@"重新加载" noData:self.data.count == 0 block:nil]; | |
| 90 | - self.tableView.emptyView.top = 0; | |
| 91 | - | |
| 92 | - self.tradingRecordView.model = model; | |
| 93 | - [self.tableView reloadData]; | |
| 99 | + [strongSelf.tableView showEmptyViewWithImage:image text:@"您现在没有相关内容哦" buttonText:@"重新加载" noData:strongSelf.data.count == 0 block:nil]; | |
| 100 | + strongSelf.tableView.emptyView.top = 0; | |
| 101 | + strongSelf.tradingRecordView.model = model; | |
| 94 | 102 | } |
| 103 | + strongSelf.tableView.mj_footer.hidden = self.data.count == 0; | |
| 104 | + [strongSelf.tableView reloadData]; | |
| 95 | 105 | }]; |
| 96 | 106 | |
| 97 | 107 | } | ... | ... |
CNLiveBalanceModule/Classes/TradingRecord/CNLiveTradingRecordDetailController.m
| ... | ... | @@ -60,18 +60,31 @@ static const CGFloat height = 80; |
| 60 | 60 | |
| 61 | 61 | #pragma mark - 加载数据 |
| 62 | 62 | - (void)loadData { |
| 63 | + __weak typeof(self) weakSelf = self; | |
| 63 | 64 | [CNLiveBalanceRequest getTradingRecordDetailWithModel:self.model block:^(BOOL isSuccess, NSDictionary * _Nonnull data, NSError *error) { |
| 65 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 66 | + if(!strongSelf) return ; | |
| 64 | 67 | if (error) { |
| 65 | - [self showEmptyViewWithImage:[UIImage imageNamed:@"wufalianjie"] text:error.localizedDescription detailText:@"别紧张,试试看刷新页面~" buttonTitle:@" 重试 " buttonAction:@selector(loadData)]; | |
| 66 | - [self setCNAPIErrorEmptyView]; | |
| 67 | - self.emptyView.verticalOffset = -(NavigationContentTop+height); | |
| 68 | + if (error.code == -1001||error.code == -1003||error.code == -1009) { | |
| 69 | + [strongSelf.tableView showEmptyViewWithType:CNLiveCustomTipsTypeNoNet noData:strongSelf.data.count == 0 block:^{ | |
| 70 | + [strongSelf loadData]; | |
| 71 | + | |
| 72 | + }]; | |
| 73 | + }else{ | |
| 74 | + [strongSelf.tableView showEmptyViewWithType:CNLiveCustomTipsTypeLoadFail noData:strongSelf.data.count == 0 block:^{ | |
| 75 | + [strongSelf loadData]; | |
| 76 | + | |
| 77 | + }]; | |
| 78 | + } | |
| 79 | + strongSelf.tableView.emptyView.top = 0; | |
| 68 | 80 | return; |
| 69 | 81 | } |
| 70 | 82 | if (isSuccess) { |
| 71 | 83 | CNLiveTradingRecordDetailModel *model = [CNLiveTradingRecordDetailModel mj_objectWithKeyValues:data]; |
| 72 | - self.data = [CNLiveBalanceRequest handleDataWithModel:model name:self.model.iconBean.nickName isAdd:self.type == TradingRecordDetailTypeDefault]; | |
| 73 | - [self.tableView reloadData]; | |
| 84 | + strongSelf.data = [CNLiveBalanceRequest handleDataWithModel:model name:strongSelf.model.iconBean.nickName isAdd:strongSelf.type == TradingRecordDetailTypeDefault]; | |
| 74 | 85 | } |
| 86 | + [strongSelf.tableView reloadData]; | |
| 87 | + | |
| 75 | 88 | }]; |
| 76 | 89 | |
| 77 | 90 | } | ... | ... |
Example/CNLiveBalanceModule/CNLIVEAppDelegate.m
| ... | ... | @@ -62,7 +62,7 @@ |
| 62 | 62 | }]; |
| 63 | 63 | [[NSUserDefaults standardUserDefaults] setObject:@"RkFYeLkl/u5S7tW8UcOkT3rfLTP/Ua8NIkdEsKlcolvl/yxTMNbAYXmmJyhKGpkj" forKey:@"CNLiveAuthToken"]; |
| 64 | 64 | |
| 65 | - CNLiveBalanceController *vc = [[CNLiveBalanceController alloc] initWithType:@"1" ID:CNUserShareModel.uid]; | |
| 65 | + CNLiveBalanceController *vc = [[CNLiveBalanceController alloc] initWithType:@"2" ID:@"CNUserShareModel.uid"]; | |
| 66 | 66 | UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc]; |
| 67 | 67 | self.window.rootViewController = nav;//设置根视图控制器 |
| 68 | 68 | [self.window makeKeyAndVisible]; | ... | ... |