Commit 33d7b9feb0ba5f2734a6533fbe7257ccf4b614f9

Authored by zhangxiaowen
1 parent 13383471

no message

CNLiveIntegralModule/Classes/Controller/CNLiveIntegralDetailsController.m
... ... @@ -20,6 +20,8 @@
20 20 #import "CNLiveUserAgreementManager.h"
21 21 #import "CNLiveRefreshHeader.h"
22 22 #import "CNLiveRefreshFooter.h"
  23 +#import "CNLiveCategory.h"
  24 +#import "CNLiveBaseKit.h"
23 25  
24 26 #import "CNLiveIntegralDetailsTableViewCell.h"
25 27 #import "CNLiveScoreModel.h"
... ... @@ -46,47 +48,54 @@
46 48 [CNLiveNetworking setAllowRequestDefaultArgument:YES];
47 49 [CNLiveNetworking setupShowDataResult:NO];
48 50 [QMUITips showLoadingInView:[UIApplication sharedApplication].keyWindow];
  51 + __weak typeof(self) weakSelf = self;
49 52 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNIntegralDetailsUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  53 +
  54 + __strong typeof(weakSelf) strongSelf = weakSelf;
  55 + if(!strongSelf) return ;
50 56 [QMUITips hideAllTipsInView:[UIApplication sharedApplication].keyWindow];
51   - [self hideEmptyView];
52   - [self.tableView.mj_header endRefreshing];
53   - [self.tableView.mj_footer endRefreshing];
  57 +
  58 + [strongSelf.tableView.mj_header endRefreshing];
  59 + [strongSelf.tableView.mj_footer endRefreshing];
  60 + strongSelf.isRefreshing = NO;
54 61  
55 62 if (error) {
56   - if (self.data.count == 0) {
57   - if (error.code == -1001||error.code == -1003||error.code == -1009) {
58   - [self showEmptyViewWithImage:[UIImage imageNamed:@"dd_wlcw"] text:@"无法连接网络" detailText:@"别紧张,试试看刷新页面~" buttonTitle:@" 重试 " buttonAction:@selector(loadData)];
59   - [self setCNAPIErrorEmptyView];
60   - self.tableView.mj_footer.hidden = self.data.count == 0;
61   - }
  63 + if (error.code == -1001||error.code == -1003||error.code == -1009) {
  64 + [strongSelf.tableView showEmptyViewWithType:CNLiveCustomTipsTypeNoNet noData:strongSelf.data.count == 0 block:^{
  65 + [self.tableView.mj_header beginRefreshing];
  66 +
  67 + }];
  68 + }else{
  69 + [strongSelf.tableView showEmptyViewWithType:CNLiveCustomTipsTypeLoadFail noData:strongSelf.data.count == 0 block:^{
  70 + [self.tableView.mj_header beginRefreshing];
62 71  
  72 + }];
63 73 }
  74 + strongSelf.tableView.emptyView.top = 0;
  75 + strongSelf.tableView.mj_footer.hidden = self.data.count == 0;
64 76 return;
65 77 }
66 78 if ([responseObject isKindOfClass:[NSDictionary class]] && [responseObject[@"errorCode"] isEqualToString:@"0"]) {
67   - if(self.pageNo == 1 && self.data.count>0){
68   - [self.data removeAllObjects];
  79 + if(strongSelf.pageNo == 1 && strongSelf.data.count>0){
  80 + [strongSelf.data removeAllObjects];
69 81 }
70   - self.isRefreshing = NO;
71   - self.pageNo++;
  82 + strongSelf.pageNo++;
72 83 NSArray *arr = [CNLiveScoreModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"][@"list"]];
73   - [self.data addObjectsFromArray:arr];
  84 + [strongSelf.data addObjectsFromArray:arr];
74 85 if (arr.count < 15) {
75   - [self.tableView.mj_footer endRefreshingWithNoMoreData];
  86 + [strongSelf.tableView.mj_footer endRefreshingWithNoMoreData];
76 87  
77 88 } else {
78   - [self.tableView.mj_footer endRefreshing];
  89 + [strongSelf.tableView.mj_footer endRefreshing];
79 90  
80 91 }
81 92 }
82   - self.tableView.mj_footer.hidden = self.data.count == 0;
83   - [self.tableView reloadData];
  93 + strongSelf.tableView.mj_footer.hidden = strongSelf.data.count == 0;
  94 + [strongSelf.tableView reloadData];
84 95  
85   - if (self.data.count == 0) {//显示empty
86   -// [self showEmptyViewWithImage:[UIImage imageNamed:@"zhuangtai_kong"] text:@"您现在没有相关内容哦" detailText:@"" buttonTitle:@"" buttonAction:nil];
87   -// [self setCNNoDataEmptyView];
88   - self.tableView.tableFooterView = nil;
89   - }
  96 + [strongSelf.tableView showEmptyViewWithType:CNLiveCustomTipsTypeNoData noData:strongSelf.data.count == 0 block:nil];
  97 + strongSelf.tableView.emptyView.top = 0;
  98 +
90 99 }];
91 100  
92 101 }
... ... @@ -199,7 +208,7 @@
199 208 __weak __typeof(self)weakSelf = self;
200 209 CNLiveRefreshHeader *header = [CNLiveRefreshHeader headerWithRefreshingBlock:^{
201 210 weakSelf.pageNo = 1;
202   - [weakSelf loadMoreData];
  211 + [weakSelf loadData];
203 212 }];
204 213 _tableView.mj_header = header;
205 214 CNLiveRefreshFooter *footer = [CNLiveRefreshFooter footerWithRefreshingBlock:^{
... ...
Example/CNLiveIntegralModule.xcodeproj/project.pbxproj
... ... @@ -207,7 +207,7 @@
207 207 6003F586195388D20070C39A /* Sources */,
208 208 6003F587195388D20070C39A /* Frameworks */,
209 209 6003F588195388D20070C39A /* Resources */,
210   - 7148D6BFD50DE630902E3EF2 /* [CP] Embed Pods Frameworks */,
  210 + 4C70DA34FB6E827DD499274A /* [CP] Embed Pods Frameworks */,
211 211 );
212 212 buildRules = (
213 213 );
... ... @@ -320,7 +320,7 @@
320 320 shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
321 321 showEnvVarsInLog = 0;
322 322 };
323   - 7148D6BFD50DE630902E3EF2 /* [CP] Embed Pods Frameworks */ = {
  323 + 4C70DA34FB6E827DD499274A /* [CP] Embed Pods Frameworks */ = {
324 324 isa = PBXShellScriptBuildPhase;
325 325 buildActionMask = 2147483647;
326 326 files = (
... ...