Commit f1a9ea07f9e884fc7d75526afc69e05e3dd1221d

Authored by yanglingyu
1 parent 7e2ee220

首页网络请求调整

CNLiveCMineModule/Classes/CNCMine/Present/CNMinePresent.m
@@ -347,7 +347,7 @@ @@ -347,7 +347,7 @@
347 CNMineModel *toolsModel = [CNMineModel mj_objectWithKeyValues:toolDic]; 347 CNMineModel *toolsModel = [CNMineModel mj_objectWithKeyValues:toolDic];
348 return toolsModel; 348 return toolsModel;
349 } 349 }
350 -+ (void)requestMineDataSourceWithBlock:(void (^)( CNScoreModel * _Nonnull))completerBlock 350 ++ (void)requestMineDataSourceWithBlock:(void (^)( CNScoreModel *))completerBlock
351 { 351 {
352 if (![CNLiveNetworking isNetworking]) { 352 if (![CNLiveNetworking isNetworking]) {
353 [QMUITips showWithText:@"无法连接网络" inView:AppKeyWindow hideAfterDelay:1.5]; 353 [QMUITips showWithText:@"无法连接网络" inView:AppKeyWindow hideAfterDelay:1.5];
@@ -360,6 +360,9 @@ @@ -360,6 +360,9 @@
360 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:cn_API_Manageshop(@"/Api/Index3/myOrderCount") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { 360 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:cn_API_Manageshop(@"/Api/Index3/myOrderCount") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
361 if (error) { 361 if (error) {
362 [QMUITips showWithText:@"接口请求错误" inView:AppKeyWindow hideAfterDelay:1.5]; 362 [QMUITips showWithText:@"接口请求错误" inView:AppKeyWindow hideAfterDelay:1.5];
  363 + if (completerBlock) {
  364 + completerBlock(nil);
  365 + }
363 return; 366 return;
364 } 367 }
365 CNScoreModel *model = [CNScoreModel mj_objectWithKeyValues:responseObject]; 368 CNScoreModel *model = [CNScoreModel mj_objectWithKeyValues:responseObject];
CNLiveCMineModule/Classes/CNCMine/View/CNListCollectionView.m
@@ -269,7 +269,7 @@ static NSString *CNWalletCellID = @"CNWalletCellID"; @@ -269,7 +269,7 @@ static NSString *CNWalletCellID = @"CNWalletCellID";
269 269
270 weakself 270 weakself
271 view.secretBlock = ^(BOOL isSecret) { 271 view.secretBlock = ^(BOOL isSecret) {
272 - weakSelf.model = [CNMinePresent dataSourceWalletModel:self.integral couponNum:weakSelf.model.lists[1][@"number"] balance:self.money]; 272 + weakSelf.model = [CNMinePresent dataSourceWalletModel:weakSelf.integral couponNum:weakSelf.model.lists[1][@"number"] balance:weakSelf.money];
273 }; 273 };
274 return view; 274 return view;
275 } 275 }
CNLiveCMineModule/Classes/CNCMine/ViewController/CNLiveMineVC.m
@@ -43,17 +43,25 @@ static NSString *const CNSobotNotification_NewMessage = @"CNSobotNotification_Ne @@ -43,17 +43,25 @@ static NSString *const CNSobotNotification_NewMessage = @"CNSobotNotification_Ne
43 43
44 @implementation CNLiveMineVC 44 @implementation CNLiveMineVC
45 - (void)loadData{ 45 - (void)loadData{
  46 +
  47 + weakself
46 [CNMinePresent requestMineDataSourceWithBlock:^(CNScoreModel * _Nonnull model) { 48 [CNMinePresent requestMineDataSourceWithBlock:^(CNScoreModel * _Nonnull model) {
47 - [self.bgScrollView.mj_header endRefreshing];  
48 - self.carCount = model.cart_count;  
49 - self.orderView.model = [CNMinePresent dataSourceOrdersModel:model.pay_order_count willShip:model.send_order_count willReceipt:model.confirm_order_count];  
50 - self.packageView.integral = model.integral;  
51 - self.packageView.money = model.money;  
52 - self.packageView.model = [CNMinePresent dataSourceWalletModel:model.integral couponNum:model.coupon_count balance:model.money];  
53 - self.toolView.model = [CNMinePresent datasourceToolModel:CNToolDatasourceTypeFirst carNum:model.cart_count]; 49 + [weakSelf.bgScrollView.mj_header endRefreshing];
  50 + if (model) {
  51 + weakSelf.carCount = model.cart_count;
  52 + weakSelf.orderView.model = [CNMinePresent dataSourceOrdersModel:model.pay_order_count willShip:model.send_order_count willReceipt:model.confirm_order_count];
  53 + weakSelf.packageView.integral = model.integral;
  54 + weakSelf.toolView.model = [CNMinePresent datasourceToolModel:CNToolDatasourceTypeFirst carNum:model.cart_count];
  55 + }
  56 + [CNWalletPresent requestBalanceWithType:@"1" responseBlock:^(NSString * _Nonnull balance) {
  57 + weakSelf.packageView.money = balance;
  58 + weakSelf.packageView.model = [CNMinePresent dataSourceWalletModel:weakSelf.packageView.integral couponNum:model.coupon_count balance:weakSelf.packageView.money];
  59 + }];
54 }]; 60 }];
  61 +
  62 +
55 [CNWalletPresent requestActivityListBlock:^(NSArray * _Nonnull activities) { 63 [CNWalletPresent requestActivityListBlock:^(NSArray * _Nonnull activities) {
56 - self.activityView.dataSource = activities; 64 + weakSelf.activityView.dataSource = activities;
57 }]; 65 }];
58 } 66 }
59 67
CNLiveCMineModule/Classes/CNWallet/Present/CNWalletPresent.m
@@ -53,12 +53,14 @@ @@ -53,12 +53,14 @@
53 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNGetBalanceUrl Param:params CacheType:NO CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { 53 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNGetBalanceUrl Param:params CacheType:NO CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
54 if (error) { 54 if (error) {
55 [QMUITips showError:error.localizedDescription inView:AppKeyWindow hideAfterDelay:1.5]; 55 [QMUITips showError:error.localizedDescription inView:AppKeyWindow hideAfterDelay:1.5];
  56 + if(responseBlock)responseBlock(@"0");
56 return; 57 return;
57 58
58 } 59 }
59 if (responseObject[@"data"][@"balance"]) { 60 if (responseObject[@"data"][@"balance"]) {
60 if(responseBlock)responseBlock(responseObject[@"data"][@"balance"]); 61 if(responseBlock)responseBlock(responseObject[@"data"][@"balance"]);
61 }else{ 62 }else{
  63 + if(responseBlock)responseBlock(@"0");
62 [QMUITips showError:responseObject[@"errorMessage"] inView:AppKeyWindow hideAfterDelay:1.5]; 64 [QMUITips showError:responseObject[@"errorMessage"] inView:AppKeyWindow hideAfterDelay:1.5];
63 } 65 }
64 66
Example/CNLiveCMineModule/CNLIVEAppDelegate.m
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 28
29 [super application:application didFinishLaunchingWithOptions:launchOptions]; 29 [super application:application didFinishLaunchingWithOptions:launchOptions];
30 30
31 - [CNUserInfoManager manager].userInfoModel.uid = @"12857262";//@"10510277";//11174272//12857262 31 + [CNUserInfoManager manager].userInfoModel.uid = @"10510277";//@"10510277";//11174272//12857262
32 32
33 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 33 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
34 self.window.backgroundColor = [UIColor whiteColor]; 34 self.window.backgroundColor = [UIColor whiteColor];