瀏覽代碼

一些接口对接,

iOS-Abel 1 年之前
父節點
當前提交
e3ca7f9bf5
共有 35 個文件被更改,包括 838 次插入185 次删除
  1. 56 8
      Asteria.xcodeproj/project.pbxproj
  2. 0 1
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASCouponsListViewController.h
  3. 44 15
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASCouponsListViewController.m
  4. 100 21
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASGiftCardListViewController.m
  5. 0 31
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASGiftCardModel.h
  6. 0 22
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASGiftCardModel.m
  7. 36 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/m/ASCouponsModel.h
  8. 19 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/m/ASCouponsModel.m
  9. 47 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/m/ASGiftCardModel.h
  10. 41 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/m/ASGiftCardModel.m
  11. 3 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASCouponListCell.h
  12. 11 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASCouponListCell.m
  13. 0 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/v/ASGiftCardAvailabelCell.h
  14. 3 3
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASGiftCardAvailabelCell.m
  15. 0 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/v/ASGiftCardTableView.h
  16. 0 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/v/ASGiftCardTableView.m
  17. 21 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/vm/ASCouponsListViewModel.h
  18. 44 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/vm/ASCouponsListViewModel.m
  19. 23 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/vm/ASGiftCardListViewModel.h
  20. 68 0
      Asteria/Fuction/UserCenter/ConponsAndGiftCard/vm/ASGiftCardListViewModel.m
  21. 84 16
      Asteria/Fuction/UserCenter/Points/ASPointDetailViewController.m
  22. 2 2
      Asteria/Fuction/UserCenter/Points/ASPointsHomeViewController.m
  23. 23 0
      Asteria/Fuction/UserCenter/Points/ASPointsViewModel.h
  24. 70 0
      Asteria/Fuction/UserCenter/Points/ASPointsViewModel.m
  25. 4 5
      Asteria/Fuction/UserCenter/Points/model/ASPointDetailModel.h
  26. 0 8
      Asteria/Fuction/UserCenter/Points/model/ASPointDetailModel.m
  27. 4 4
      Asteria/Fuction/UserCenter/Points/view/ASPointDetailCell.m
  28. 0 1
      Asteria/Fuction/UserCenter/UserCenterHome/ASUserCenterViewController.m
  29. 66 20
      Asteria/Fuction/UserCenter/VipCenter/ASVipCenterViewController.m
  30. 3 0
      Asteria/Fuction/UserManager/ASUserInfoManager.h
  31. 16 1
      Asteria/Fuction/UserManager/ASUserInfoManager.m
  32. 2 0
      Asteria/Fuction/UserManager/ASVipModel.h
  33. 7 2
      Asteria/NetTools/ASNetApis.h
  34. 28 16
      Asteria/NetTools/ASNetTools.m
  35. 13 9
      Asteria/Tabber/AS_TabBarViewController.m

+ 56 - 8
Asteria.xcodeproj/project.pbxproj

@@ -15,6 +15,8 @@
 		8120211B2B15F03B0026B8B5 /* ASVipModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8120211A2B15F03B0026B8B5 /* ASVipModel.m */; };
 		8120211E2B15F2B30026B8B5 /* ASVipUrlTempModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8120211D2B15F2B30026B8B5 /* ASVipUrlTempModel.m */; };
 		812021212B16CD630026B8B5 /* ASSginViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 812021202B16CD630026B8B5 /* ASSginViewModel.m */; };
+		812021252B185A610026B8B5 /* ASCouponsListViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 812021242B185A610026B8B5 /* ASCouponsListViewModel.m */; };
+		812021282B185C000026B8B5 /* ASCouponsModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 812021272B185C000026B8B5 /* ASCouponsModel.m */; };
 		8127ADDB2B1193A300464D27 /* ASNetTools.m in Sources */ = {isa = PBXBuildFile; fileRef = 8127ADDA2B1193A300464D27 /* ASNetTools.m */; };
 		8134C1AD2A13094F006EB0EC /* Target_userCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 8134C1AC2A13094F006EB0EC /* Target_userCenter.m */; };
 		8134C1B42A1358F3006EB0EC /* ASSginView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8134C1B32A1358F3006EB0EC /* ASSginView.m */; };
@@ -156,6 +158,8 @@
 		81E5EE902A498FC90075695F /* ASVipCenterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 81E5EE8F2A498FC90075695F /* ASVipCenterViewController.m */; };
 		81E5EE942A4A760D0075695F /* ASVipCenterLineItemView.m in Sources */ = {isa = PBXBuildFile; fileRef = 81E5EE932A4A760D0075695F /* ASVipCenterLineItemView.m */; };
 		81E5EE972A4A822D0075695F /* ASVipCenterCollectCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 81E5EE962A4A822D0075695F /* ASVipCenterCollectCell.m */; };
+		81E73EBD2B1AABF300C10938 /* ASGiftCardListViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 81E73EBC2B1AABF300C10938 /* ASGiftCardListViewModel.m */; };
+		81E73EC02B1AC49D00C10938 /* ASPointsViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 81E73EBF2B1AC49D00C10938 /* ASPointsViewModel.m */; };
 		81EC47662A33035D00516573 /* ASHomeNewInCellTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 81EC47652A33035D00516573 /* ASHomeNewInCellTableViewCell.m */; };
 		81EC47692A33073100516573 /* ASHomeNewInProductItemView.m in Sources */ = {isa = PBXBuildFile; fileRef = 81EC47682A33073100516573 /* ASHomeNewInProductItemView.m */; };
 		81EC476C2A33131100516573 /* ASHomeNewInSubCollectCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 81EC476B2A33131100516573 /* ASHomeNewInSubCollectCell.m */; };
@@ -275,6 +279,10 @@
 		8120211F2B16CD630026B8B5 /* ASSginViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASSginViewModel.h; sourceTree = "<group>"; };
 		812021202B16CD630026B8B5 /* ASSginViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASSginViewModel.m; sourceTree = "<group>"; };
 		812021222B16D2D40026B8B5 /* ASUserNotifyStatic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASUserNotifyStatic.h; sourceTree = "<group>"; };
+		812021232B185A610026B8B5 /* ASCouponsListViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASCouponsListViewModel.h; sourceTree = "<group>"; };
+		812021242B185A610026B8B5 /* ASCouponsListViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASCouponsListViewModel.m; sourceTree = "<group>"; };
+		812021262B185C000026B8B5 /* ASCouponsModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASCouponsModel.h; sourceTree = "<group>"; };
+		812021272B185C000026B8B5 /* ASCouponsModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASCouponsModel.m; sourceTree = "<group>"; };
 		8127ADD92B1193A300464D27 /* ASNetTools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASNetTools.h; sourceTree = "<group>"; };
 		8127ADDA2B1193A300464D27 /* ASNetTools.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASNetTools.m; sourceTree = "<group>"; };
 		8127ADDC2B11973400464D27 /* ASNetApis.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASNetApis.h; sourceTree = "<group>"; };
@@ -543,6 +551,10 @@
 		81E5EE932A4A760D0075695F /* ASVipCenterLineItemView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASVipCenterLineItemView.m; sourceTree = "<group>"; };
 		81E5EE952A4A822D0075695F /* ASVipCenterCollectCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASVipCenterCollectCell.h; sourceTree = "<group>"; };
 		81E5EE962A4A822D0075695F /* ASVipCenterCollectCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASVipCenterCollectCell.m; sourceTree = "<group>"; };
+		81E73EBB2B1AABF300C10938 /* ASGiftCardListViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASGiftCardListViewModel.h; sourceTree = "<group>"; };
+		81E73EBC2B1AABF300C10938 /* ASGiftCardListViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASGiftCardListViewModel.m; sourceTree = "<group>"; };
+		81E73EBE2B1AC49D00C10938 /* ASPointsViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASPointsViewModel.h; sourceTree = "<group>"; };
+		81E73EBF2B1AC49D00C10938 /* ASPointsViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASPointsViewModel.m; sourceTree = "<group>"; };
 		81EC47642A33035D00516573 /* ASHomeNewInCellTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASHomeNewInCellTableViewCell.h; sourceTree = "<group>"; };
 		81EC47652A33035D00516573 /* ASHomeNewInCellTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASHomeNewInCellTableViewCell.m; sourceTree = "<group>"; };
 		81EC47672A33073100516573 /* ASHomeNewInProductItemView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASHomeNewInProductItemView.h; sourceTree = "<group>"; };
@@ -739,6 +751,8 @@
 				811F42452A40533C00DA68F1 /* ASPointsHomeViewController.m */,
 				81DFA5652A46D60900DA708B /* ASPointDetailViewController.h */,
 				81DFA5662A46D60900DA708B /* ASPointDetailViewController.m */,
+				81E73EBE2B1AC49D00C10938 /* ASPointsViewModel.h */,
+				81E73EBF2B1AC49D00C10938 /* ASPointsViewModel.m */,
 				81DFA56E2A46D8F600DA708B /* model */,
 				81DFA5642A46D5DF00DA708B /* view */,
 			);
@@ -1339,14 +1353,9 @@
 				81DFA5742A47D97C00DA708B /* ASCouponsListViewController.m */,
 				816D0C982AF3901C00395B5B /* ASGiftCardListViewController.h */,
 				816D0C992AF3901C00395B5B /* ASGiftCardListViewController.m */,
-				816D0C9B2AF3988300395B5B /* ASGiftCardAvailabelCell.h */,
-				816D0C9C2AF3988300395B5B /* ASGiftCardAvailabelCell.m */,
-				81DFA5762A47F28D00DA708B /* ASCouponListCell.h */,
-				81DFA5772A47F28D00DA708B /* ASCouponListCell.m */,
-				81CE28922AF490C20012AA45 /* ASGiftCardTableView.h */,
-				81CE28932AF490C20012AA45 /* ASGiftCardTableView.m */,
-				81CE28952AF4953C0012AA45 /* ASGiftCardModel.h */,
-				81CE28962AF4953C0012AA45 /* ASGiftCardModel.m */,
+				81E73EB82B1AAB4900C10938 /* vm */,
+				81E73EB92B1AAB5400C10938 /* v */,
+				81E73EBA2B1AAB5F00C10938 /* m */,
 			);
 			path = ConponsAndGiftCard;
 			sourceTree = "<group>";
@@ -1425,6 +1434,41 @@
 			path = Views;
 			sourceTree = "<group>";
 		};
+		81E73EB82B1AAB4900C10938 /* vm */ = {
+			isa = PBXGroup;
+			children = (
+				812021232B185A610026B8B5 /* ASCouponsListViewModel.h */,
+				812021242B185A610026B8B5 /* ASCouponsListViewModel.m */,
+				81E73EBB2B1AABF300C10938 /* ASGiftCardListViewModel.h */,
+				81E73EBC2B1AABF300C10938 /* ASGiftCardListViewModel.m */,
+			);
+			path = vm;
+			sourceTree = "<group>";
+		};
+		81E73EB92B1AAB5400C10938 /* v */ = {
+			isa = PBXGroup;
+			children = (
+				816D0C9B2AF3988300395B5B /* ASGiftCardAvailabelCell.h */,
+				816D0C9C2AF3988300395B5B /* ASGiftCardAvailabelCell.m */,
+				81DFA5762A47F28D00DA708B /* ASCouponListCell.h */,
+				81DFA5772A47F28D00DA708B /* ASCouponListCell.m */,
+				81CE28922AF490C20012AA45 /* ASGiftCardTableView.h */,
+				81CE28932AF490C20012AA45 /* ASGiftCardTableView.m */,
+			);
+			path = v;
+			sourceTree = "<group>";
+		};
+		81E73EBA2B1AAB5F00C10938 /* m */ = {
+			isa = PBXGroup;
+			children = (
+				81CE28952AF4953C0012AA45 /* ASGiftCardModel.h */,
+				81CE28962AF4953C0012AA45 /* ASGiftCardModel.m */,
+				812021262B185C000026B8B5 /* ASCouponsModel.h */,
+				812021272B185C000026B8B5 /* ASCouponsModel.m */,
+			);
+			path = m;
+			sourceTree = "<group>";
+		};
 		9A1247912A1B07F400126226 /* Tool */ = {
 			isa = PBXGroup;
 			children = (
@@ -2046,9 +2090,11 @@
 				81354BEE2A287AB50082C93A /* KWMineHomeOrderListCell.m in Sources */,
 				81601FE62A2DB19300E4A8F1 /* ASHomeViewController.m in Sources */,
 				81354BF22A287B120082C93A /* KWMineHomeOrderModel.m in Sources */,
+				81E73EBD2B1AABF300C10938 /* ASGiftCardListViewModel.m in Sources */,
 				9AD345F82A08D60F005CA070 /* ZFPlayerGestureControl.m in Sources */,
 				81C326712A37020A002EF442 /* ASProductListMenuHeaderView.m in Sources */,
 				81601FF92A2DC78300E4A8F1 /* WMZBannerControl.m in Sources */,
+				81E73EC02B1AC49D00C10938 /* ASPointsViewModel.m in Sources */,
 				81717C912A3BE39C00648139 /* ASProductSortFilterView.m in Sources */,
 				81C7962E2A539F4D003083B8 /* ASMessageListCell.m in Sources */,
 				81717D382A3D322700648139 /* KWNoHisWordsCell.m in Sources */,
@@ -2092,6 +2138,7 @@
 				814F5CEF2A11B1F2003847A9 /* ASUserCenterViewController.m in Sources */,
 				81717D1C2A3C4AE000648139 /* KWSearchSubTypeModel.m in Sources */,
 				8160201F2A2F11AB00E4A8F1 /* ASHomeTipCollectCell.m in Sources */,
+				812021282B185C000026B8B5 /* ASCouponsModel.m in Sources */,
 				816020042A2DCC0200E4A8F1 /* ASHomeBannerModel.m in Sources */,
 				81717D3F2A3D5EAD00648139 /* ASDefualtAlertV.m in Sources */,
 				819900222A020A6F006FE68C /* LYTools.m in Sources */,
@@ -2158,6 +2205,7 @@
 				81C7963F2A551FB0003083B8 /* ASInfomationSetController.m in Sources */,
 				9AD346062A08D60F005CA070 /* ZFReachabilityManager.m in Sources */,
 				81717CA52A3C0A5000648139 /* KWProductFilterItemCell.m in Sources */,
+				812021252B185A610026B8B5 /* ASCouponsListViewModel.m in Sources */,
 				9AD345FE2A08D60F005CA070 /* UIScrollView+ZFPlayer.m in Sources */,
 				9A65DE512A132FB700BB1269 /* LoginThirdAuthV.m in Sources */,
 				81717D142A3C4AE000648139 /* APCategoryViewController.m in Sources */,

+ 0 - 1
Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASCouponsListViewController.h

@@ -11,7 +11,6 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface ASCouponsListViewController : ASBaseViewController
 
-@property (nonatomic, assign) BOOL isCard;
 
 @end
 

+ 44 - 15
Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASCouponsListViewController.m

@@ -7,6 +7,7 @@
 
 #import "ASCouponsListViewController.h"
 #import "ASCouponListCell.h"
+#import "ASCouponsListViewModel.h"
 
 @interface ASCouponsListViewController () <UITableViewDelegate,UITableViewDataSource>
 
@@ -14,26 +15,38 @@
 @property (nonatomic, strong) UITableView *tableV;
 
 
+@property (nonatomic, assign) NSInteger page;
+@property (nonatomic, strong) ASCouponsListViewModel *vm;
+
+
 @end
 
 @implementation ASCouponsListViewController
 
 - (void)viewDidLoad {
     [super viewDidLoad];
+    self.page = 1;
+    self.vm = [ASCouponsListViewModel new];
     [self loadSubVs];
     [self configSubVs];
-    
+    [self.tableV.mj_header beginRefreshing];
     
 }
 
-- (void)configSubVs {
-    self.titleStr = self.isCard ? @"My Giftcard" : @"Coupons";
-    [self setNavRightSearch:^{
-        
+// MARK: - net
+- (void)loadNetData {
+    [MBProgressHUD showHUDAddedTo:self.view animated:true];
+    __weak typeof(self) weakSelf = self;
+    [self.vm getCouponList:self.page com:^(BOOL hasNext, NSString * _Nonnull msg) {
+        [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
+        [weakSelf.tableV.mj_header endRefreshing];
+        if (hasNext) {
+            [weakSelf.tableV.mj_footer endRefreshing];
+        } else {
+            [weakSelf.tableV.mj_footer endRefreshingWithNoMoreData];
+        }
+        [weakSelf.tableV reloadData];
     }];
-    self.statusBgV.backgroundColor = _E0FFF5;
-    self.customNavBar.backgroundColor = _F0FFFA;
-    
 }
 
 // MARK: - loadSubVs
@@ -59,6 +72,27 @@
     });
 }
 
+- (void)configSubVs {
+    self.titleStr = @"Coupons";
+    [self setNavRightSearch:^{
+        
+    }];
+    self.statusBgV.backgroundColor = _E0FFF5;
+    self.customNavBar.backgroundColor = _F0FFFA;
+    
+    __weak typeof(self) weakSelf = self;
+    self.tableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
+        weakSelf.page = 1;
+        [weakSelf loadNetData];
+    }];
+    
+    self.tableV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
+        weakSelf.page += 1;
+        [weakSelf loadNetData];
+    }];
+    
+}
+
 // MARK: - subVs
 - (UIView *)colorBgV {
     if (!_colorBgV) {
@@ -85,20 +119,15 @@
 
 // MARK: - UITableViewDelegate,UITableViewDataSource
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-    return 10;
+    return self.vm.couponList.count;
 }
 
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     ASCouponListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASCouponListCell" forIndexPath:indexPath];
     __weak typeof(self) weakSelf = self;
     [cell setCopyCallBack:^{
-        if (!weakSelf.isCard) {
-            [weakSelf.view makeToast:@"Code Copied"];
-        }
+        [weakSelf.view makeToast:@"Code Copied"];
     }];
-    if (self.isCard) {
-        [cell setGiftCardStyle];
-    }
     return cell;
 }
 

+ 100 - 21
Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASGiftCardListViewController.m

@@ -7,9 +7,14 @@
 
 #import "ASGiftCardListViewController.h"
 #import "ASGiftCardTableView.h"
+#import "ASGiftCardListViewModel.h"
 
 @interface ASGiftCardListViewController ()<UIScrollViewDelegate>
 
+@property (nonatomic, strong) ASGiftCardListViewModel *vm;
+@property (nonatomic, assign) NSInteger unUsePage;
+@property (nonatomic, assign) NSInteger cantUsePage;
+
 @property (nonatomic, strong) UIView *topBgV;
 @property (nonatomic, strong) UIView *bottomBgV;
 
@@ -21,12 +26,18 @@
 @property (nonatomic, strong) ASGiftCardTableView *allTableV;
 @property (nonatomic, strong) ASGiftCardTableView *usedTableV;
 
+@property (nonatomic, strong) UIView *unUseTableHeadV;
+@property (nonatomic, strong) UILabel *unUseTipLb;
+
 @end
 
 @implementation ASGiftCardListViewController
 
 - (void)viewDidLoad {
     [super viewDidLoad];
+    self.vm = [ASGiftCardListViewModel new];
+    self.unUsePage = 1;
+    self.cantUsePage = 1;
     [self loadSubVs];
     [self configSubVs];
     
@@ -34,31 +45,10 @@
 
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
-    [self loadData];
     [self checkEmpty];
 }
 
 
-- (void)loadData {
-    NSMutableArray *allArr = [NSMutableArray array];
-    NSMutableArray *usedArr = [NSMutableArray array];
-    if (arc4random()%2 == 1) {
-        for (int i=0;i<(arc4random()%100+3);i++) {
-            [allArr addObject:[ASGiftCardModel demoData]];
-        }
-        for (int i=0;i<(arc4random()%200+5);i++) {
-            ASGiftCardModel *m = [ASGiftCardModel demoData];
-            m.state = arc4random()%3;// == 1 ? ASGiftCardStateUsed : ASGiftCardStateExpired;
-            [usedArr addObject:m];
-        }
-    }
-    self.allTableV.dataArr = allArr;
-    self.usedTableV.dataArr = usedArr;
-    [self setEmptyTip:@"No Giftcard Yet"];
-    [self.allTableV reloadData];
-    [self.usedTableV reloadData];
-    
-}
 
 - (void)checkEmpty {
     if (_allTableV.dataArr.count == 0 && self.availabelBt.isSelected) {
@@ -70,14 +60,71 @@
     }
 }
 
+// MARK: - nets
+- (void)getUnuseListData {
+    [MBProgressHUD showHUDAddedTo:self.view animated:true];
+    __weak typeof(self) weakSelf = self;
+    [self.vm getUnuseCardList:self.unUsePage com:^(BOOL hasNext, NSString * _Nonnull msg) {
+        [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
+        [weakSelf.allTableV.mj_header endRefreshing];
+        if (hasNext) {
+            [weakSelf.allTableV.mj_footer endRefreshing];
+        } else {
+            [weakSelf.allTableV.mj_footer endRefreshingWithNoMoreData];
+        }
+        weakSelf.allTableV.dataArr = weakSelf.vm.unUseCardList;
+        [weakSelf checkEmpty];
+        [weakSelf.allTableV reloadData];
+    }];
+}
+- (void)getCantUseListData {
+    [MBProgressHUD showHUDAddedTo:self.view animated:true];
+    __weak typeof(self) weakSelf = self;
+    [self.vm getCantUseCardList:self.cantUsePage com:^(BOOL hasNext, NSString * _Nonnull msg) {
+        [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
+        [weakSelf.usedTableV.mj_header endRefreshing];
+        if (hasNext) {
+            [weakSelf.usedTableV.mj_footer endRefreshing];
+        } else {
+            [weakSelf.usedTableV.mj_footer endRefreshingWithNoMoreData];
+        }
+        weakSelf.usedTableV.dataArr = weakSelf.vm.cantUseCardList;
+        [weakSelf checkEmpty];
+        [weakSelf.usedTableV reloadData];
+    }];
+}
+
 // MARK: - loadSubVs
 - (void)configSubVs {
     self.view.backgroundColor = _E0FFF5;
     self.customNavBar.backgroundColor = _F0FFFA;
     self.titleStr = @"My Giftcard";
+    
+    __weak typeof(self) weakSelf = self;
     [self setNavRightSearch:^{
         
     }];
+    
+    self.allTableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
+        weakSelf.unUsePage = 1;
+        [weakSelf getUnuseListData];
+    }];
+    self.allTableV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
+        weakSelf.unUsePage += 1;
+        [weakSelf getUnuseListData];
+    }];
+    
+    self.usedTableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
+        weakSelf.cantUsePage = 1;
+        [weakSelf getCantUseListData];
+    }];
+    self.usedTableV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
+        weakSelf.cantUsePage += 1;
+        [weakSelf getCantUseListData];
+    }];
+    
+    [self.allTableV.mj_header beginRefreshing];
+    [self.usedTableV.mj_header beginRefreshing];
 }
 
 - (void)loadSubVs {
@@ -91,6 +138,18 @@
     [self.scrollV addSubview:self.allTableV];
     [self.scrollV addSubview:self.usedTableV];
     
+    [self.unUseTableHeadV addSubview:self.unUseTipLb];
+    
+    NSString *tipStr = @"Gift Card Will Be Applied Automatically,Go to Cart/CheckOut Page to Check.";
+    CGRect rect = [tipStr boundingRectWithSize:CGSizeMake(SCREEN_WIDTH-40, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:nil context:nil];
+    self.unUseTableHeadV.frame = CGRectMake(0, 0, SCREEN_WIDTH, rect.size.height + 28);
+    [self.unUseTipLb mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.unUseTableHeadV).offset(8);
+        make.leading.equalTo(self.unUseTableHeadV).offset(20);
+        make.trailing.equalTo(self.unUseTableHeadV).offset(-20);
+        make.height.equalTo(@(rect.size.height));
+    }];
+    self.allTableV.tableHeaderView = self.unUseTableHeadV;
     
     [self.topBgV mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.customNavBar.mas_bottom);
@@ -256,6 +315,26 @@
     return _usedTableV;
 }
 
+- (UIView *)unUseTableHeadV {
+    if (!_unUseTableHeadV) {
+        UIView *v = [UIView baseV];
+        v.backgroundColor = UIColor.clearColor;
+        _unUseTableHeadV = v;
+    }
+    return _unUseTableHeadV;
+}
+
+- (UILabel *)unUseTipLb {
+    if (!_unUseTipLb) {
+        UILabel *lb = [UILabel baseLb];
+        lb.numberOfLines = 0;
+        lb.font = [UIFont fontWithName:Rob_Regular size:12];
+        lb.textColor = Col_000;
+        _unUseTipLb = lb;
+    }
+    return _unUseTipLb;
+}
+
 
 // MARK: - scrollview delegate
 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {

+ 0 - 31
Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASGiftCardModel.h

@@ -1,31 +0,0 @@
-//
-//  ASGiftCardModel.h
-//  Asteria
-//
-//  Created by iOS on 2023/11/3.
-//
-
-#import <Foundation/Foundation.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-typedef enum : NSUInteger {
-    ASGiftCardStateNormal = 0,
-    ASGiftCardStateUsed,
-    ASGiftCardStateExpired,
-} ASGiftCardState;
-
-@interface ASGiftCardModel : NSObject
-
-@property (nonatomic, copy) NSString *Id;
-@property (nonatomic, copy) NSString *price;
-@property (nonatomic, copy) NSString *des;
-@property (nonatomic, copy) NSString *time;
-@property (nonatomic, assign) ASGiftCardState state;
-
-
-+ (ASGiftCardModel *)demoData;
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 22
Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASGiftCardModel.m

@@ -1,22 +0,0 @@
-//
-//  ASGiftCardModel.m
-//  Asteria
-//
-//  Created by iOS on 2023/11/3.
-//
-
-#import "ASGiftCardModel.h"
-
-@implementation ASGiftCardModel
-
-+ (ASGiftCardModel *)demoData {
-    ASGiftCardModel *m = [ASGiftCardModel new];
-    m.price = @"$5";
-    m.time = @"2022 5:18 pm";
-    m.Id = [NSString stringWithFormat:@"%u", (arc4random()%1000)];
-    m.des = @"For All Product";
-    
-    return m;
-}
-
-@end

+ 36 - 0
Asteria/Fuction/UserCenter/ConponsAndGiftCard/m/ASCouponsModel.h

@@ -0,0 +1,36 @@
+//
+//  ASCouponsModel.h
+//  Asteria
+//
+//  Created by iOS on 2023/11/30.
+//
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface ASCouponsModel : NSObject
+
+@property (nonatomic, copy) NSString *Id;
+@property (nonatomic, copy) NSString *customer_id;
+@property (nonatomic, copy) NSString *type;
+@property (nonatomic, copy) NSString *point;
+@property (nonatomic, copy) NSString *product_id;
+@property (nonatomic, copy) NSString *code;
+@property (nonatomic, copy) NSString *style;
+@property (nonatomic, copy) NSString *activity_time;
+@property (nonatomic, copy) NSString *month;
+@property (nonatomic, copy) NSString *value;
+@property (nonatomic, copy) NSString *used;
+@property (nonatomic, copy) NSString *detail;
+@property (nonatomic, copy) NSString *product_type;
+@property (nonatomic, copy) NSString *expired;
+@property (nonatomic, copy) NSString *created;
+@property (nonatomic, copy) NSString *updated;
+
+@property (nonatomic, copy) NSString *title;
+@property (nonatomic, copy) NSString *desc;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 19 - 0
Asteria/Fuction/UserCenter/ConponsAndGiftCard/m/ASCouponsModel.m

@@ -0,0 +1,19 @@
+//
+//  ASCouponsModel.m
+//  Asteria
+//
+//  Created by iOS on 2023/11/30.
+//
+
+#import "ASCouponsModel.h"
+
+@implementation ASCouponsModel
+
++ (NSDictionary *)mj_replacedKeyFromPropertyName {
+    return @{
+        @"Id": @"id",
+    };
+}
+
+
+@end

+ 47 - 0
Asteria/Fuction/UserCenter/ConponsAndGiftCard/m/ASGiftCardModel.h

@@ -0,0 +1,47 @@
+//
+//  ASGiftCardModel.h
+//  Asteria
+//
+//  Created by iOS on 2023/11/3.
+//
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+typedef enum : NSUInteger {
+    ASGiftCardStateNormal = 0,
+    ASGiftCardStateUsed,
+    ASGiftCardStateExpired,
+} ASGiftCardState;
+
+@interface ASGiftCardModel : NSObject
+
+@property (nonatomic, copy) NSString *gitfcard_id;
+@property (nonatomic, copy) NSString *customer_id;
+@property (nonatomic, copy) NSString *gitfcard_template_id;
+/// 礼品卡金额
+@property (nonatomic, copy) NSString *giftcard_amount;
+@property (nonatomic, copy) NSString *quote_id;
+@property (nonatomic, copy) NSString *order_id;
+/// 添加时间
+@property (nonatomic, copy) NSString *addtime;
+@property (nonatomic, copy) NSString *usetime;
+@property (nonatomic, copy) NSString *endtime;
+/// 使用状态:  1未使用    2 已使用  3已过期
+@property (nonatomic, copy) NSString *status;
+@property (nonatomic, copy) NSString *return_time;
+@property (nonatomic, copy) NSString *template_id;
+
+@property (nonatomic, copy) NSString *time;
+
+
+
+
+@property (nonatomic, assign) ASGiftCardState state;
+
+- (NSString *)timeStr;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 41 - 0
Asteria/Fuction/UserCenter/ConponsAndGiftCard/m/ASGiftCardModel.m

@@ -0,0 +1,41 @@
+//
+//  ASGiftCardModel.m
+//  Asteria
+//
+//  Created by iOS on 2023/11/3.
+//
+
+#import "ASGiftCardModel.h"
+
+@implementation ASGiftCardModel
+
+-(ASGiftCardState)state {
+    if ([self.status isEqualToString:@"2"]) {
+        return ASGiftCardStateUsed;
+    }
+    if ([self.status isEqualToString:@"3"]) {
+        return ASGiftCardStateExpired;
+    }
+    return ASGiftCardStateNormal;
+}
+
+- (NSString *)timeStr {
+    NSInteger elseTime = self.time.integerValue;
+    if (elseTime <= 0) {
+        return @"";
+    }
+    NSInteger h = elseTime/3600;
+    NSInteger m = (elseTime-h*3600)/60;
+    NSInteger s = elseTime%60;
+    NSString *timeStr = @"";
+    if (h>0) {
+        timeStr = [NSString stringWithFormat:@"%02ldh:%02ldM:%02ldS", h, m, s];
+    } else if (m > 0) {
+        timeStr = [NSString stringWithFormat:@"%02ldM:%02ldS", m, s];
+    } else {
+        timeStr = [NSString stringWithFormat:@"%02ldS", s];
+    }
+    return timeStr;
+}
+
+@end

+ 3 - 0
Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASCouponListCell.h

@@ -6,6 +6,7 @@
 //
 
 #import <UIKit/UIKit.h>
+#import "ASCouponsModel.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -13,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (nonatomic, copy) btnClickBlock copyCallBack;
 
+- (void)setData:(ASCouponsModel *)model;
+
 - (void)setGiftCardStyle;
 - (void)setVipCouponStyle;
 

+ 11 - 0
Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASCouponListCell.m

@@ -33,6 +33,17 @@
 
 @implementation ASCouponListCell
 
+
+- (void)setData:(ASCouponsModel *)model {
+    self.titleLb.text = [NSString stringWithFormat:@"%@", model.title];//@"$10 off";
+    self.ruleLb.text = [NSString stringWithFormat:@"%@", model.description];
+    self.dateLb.text = [NSString stringWithFormat:@"DATE:%@", model.activity_time];
+    
+    self.codeLb.text = model.code;
+    
+    [self setStatus:model.used.integerValue != 1 ];
+}
+
 - (void)awakeFromNib {
     [super awakeFromNib];
     // Initialization code

Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASGiftCardAvailabelCell.h → Asteria/Fuction/UserCenter/ConponsAndGiftCard/v/ASGiftCardAvailabelCell.h


+ 3 - 3
Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASGiftCardAvailabelCell.m

@@ -61,9 +61,9 @@
 }
 
 - (void)setData:(ASGiftCardModel *)m {
-    self.priceLb.text = m.price;
-    self.desLb.text = m.des;
-    self.timeLb.text = [NSString stringWithFormat:@"Expires in: %@", m.time];
+    self.priceLb.text = m.giftcard_amount;
+    self.desLb.text = @"For All Product";
+    self.timeLb.text = [NSString stringWithFormat:@"Expires in: %@", m.timeStr];
     
     
     self.state = m.state;

Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASGiftCardTableView.h → Asteria/Fuction/UserCenter/ConponsAndGiftCard/v/ASGiftCardTableView.h


Asteria/Fuction/UserCenter/ConponsAndGiftCard/ASGiftCardTableView.m → Asteria/Fuction/UserCenter/ConponsAndGiftCard/v/ASGiftCardTableView.m


+ 21 - 0
Asteria/Fuction/UserCenter/ConponsAndGiftCard/vm/ASCouponsListViewModel.h

@@ -0,0 +1,21 @@
+//
+//  ASCouponsListViewModel.h
+//  Asteria
+//
+//  Created by iOS on 2023/11/30.
+//
+
+#import <Foundation/Foundation.h>
+#import "ASCouponsModel.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface ASCouponsListViewModel : NSObject
+
+@property (nonatomic, strong) NSMutableArray<ASCouponsModel *> *couponList;
+
+- (void)getCouponList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 44 - 0
Asteria/Fuction/UserCenter/ConponsAndGiftCard/vm/ASCouponsListViewModel.m

@@ -0,0 +1,44 @@
+//
+//  ASCouponsListViewModel.m
+//  Asteria
+//
+//  Created by iOS on 2023/11/30.
+//
+
+#import "ASCouponsListViewModel.h"
+
+@implementation ASCouponsListViewModel
+
+- (instancetype)init
+{
+    self = [super init];
+    if (self) {
+        self.couponList = [NSMutableArray array];
+    }
+    return self;
+}
+
+- (void)getCouponList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com {
+    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
+    dic[@"page"] = [NSString stringWithFormat:@"%ld", page];
+    [ASNetTools.shared getWithPath:getUserCouponUrl param:dic success:^(id _Nonnull json) {
+        NSInteger pagesize = [NSString stringWithFormat:@"%@", json[@"pageSize"]].integerValue;
+        NSArray *list = json[@"list"];
+        NSMutableArray *arr = [ASCouponsModel mj_objectArrayWithKeyValuesArray:list];
+        if (page == 1) {
+            self.couponList = arr;
+        } else {
+            [self.couponList addObjectsFromArray:arr];
+        }
+        if (arr.count >= pagesize){
+            com(true, @"");
+        } else {
+            com(false, @"");
+        }
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        com(false, msg);
+    }];
+}
+
+
+@end

+ 23 - 0
Asteria/Fuction/UserCenter/ConponsAndGiftCard/vm/ASGiftCardListViewModel.h

@@ -0,0 +1,23 @@
+//
+//  ASGiftCardListViewModel.h
+//  Asteria
+//
+//  Created by iOS on 2023/12/2.
+//
+
+#import <Foundation/Foundation.h>
+#import "ASGiftCardModel.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface ASGiftCardListViewModel : NSObject
+
+@property (nonatomic, strong) NSMutableArray<ASGiftCardModel *> *unUseCardList;
+@property (nonatomic, strong) NSMutableArray<ASGiftCardModel *> *cantUseCardList;
+
+- (void)getUnuseCardList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com;
+- (void)getCantUseCardList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 68 - 0
Asteria/Fuction/UserCenter/ConponsAndGiftCard/vm/ASGiftCardListViewModel.m

@@ -0,0 +1,68 @@
+//
+//  ASGiftCardListViewModel.m
+//  Asteria
+//
+//  Created by iOS on 2023/12/2.
+//
+
+#import "ASGiftCardListViewModel.h"
+
+@implementation ASGiftCardListViewModel
+
+- (instancetype)init
+{
+    self = [super init];
+    if (self) {
+        self.unUseCardList = [NSMutableArray array];
+        self.cantUseCardList = [NSMutableArray array];
+    }
+    return self;
+}
+
+- (void)getUnuseCardList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com {
+    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
+    dic[@"page"] = [NSString stringWithFormat:@"%ld", page];
+    dic[@"status"] = @"1";
+    [ASNetTools.shared getWithPath:getUserGiftCardUrl param:dic success:^(id _Nonnull json) {
+        NSInteger pagesize = [NSString stringWithFormat:@"%@", json[@"pageSize"]].integerValue;
+        NSArray *list = json[@"list"];
+        NSMutableArray *arr = [ASGiftCardModel mj_objectArrayWithKeyValuesArray:list];
+        if (page == 1) {
+            self.unUseCardList = arr;
+        } else {
+            [self.unUseCardList addObjectsFromArray:arr];
+        }
+        if (arr.count >= pagesize){
+            com(true, @"");
+        } else {
+            com(false, @"");
+        }
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        com(false, msg);
+    }];
+}
+
+- (void)getCantUseCardList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com {
+    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
+    dic[@"page"] = [NSString stringWithFormat:@"%ld", page];
+    dic[@"status"] = @"2";
+    [ASNetTools.shared getWithPath:getUserGiftCardUrl param:dic success:^(id _Nonnull json) {
+        NSInteger pagesize = [NSString stringWithFormat:@"%@", json[@"pageSize"]].integerValue;
+        NSArray *list = json[@"list"];
+        NSMutableArray *arr = [ASGiftCardModel mj_objectArrayWithKeyValuesArray:list];
+        if (page == 1) {
+            self.unUseCardList = arr;
+        } else {
+            [self.unUseCardList addObjectsFromArray:arr];
+        }
+        if (arr.count >= pagesize){
+            com(true, @"");
+        } else {
+            com(false, @"");
+        }
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        com(false, msg);
+    }];
+}
+
+@end

+ 84 - 16
Asteria/Fuction/UserCenter/Points/ASPointDetailViewController.m

@@ -7,9 +7,14 @@
 
 #import "ASPointDetailViewController.h"
 #import "ASPointDetailTableView.h"
+#import "ASPointsViewModel.h"
 
 @interface ASPointDetailViewController () <UIScrollViewDelegate>
 
+@property (nonatomic, strong) ASPointsViewModel *vm;
+@property (nonatomic, assign) NSInteger allPage;
+@property (nonatomic, assign) NSInteger usedPage;
+
 @property (nonatomic, strong) UIView *topBgV;
 @property (nonatomic, strong) UIView *bottomBgV;
 
@@ -28,25 +33,63 @@
 
 - (void)viewDidLoad {
     [super viewDidLoad];
+    self.vm = [ASPointsViewModel new];
+    self.allPage = 1;
+    self.usedPage = 1;
     [self loadSubVs];
     [self configSubVs];
-    
-    [self loadData];
 }
 
-- (void)loadData {
-    NSMutableArray *allArr = [NSMutableArray array];
-    NSMutableArray *usedArr = [NSMutableArray array];
-    for (int i=0;i<(arc4random()%100+3);i++) {
-        [allArr addObject:[ASPointDetailModel demoData]];
-    }
-    for (int i=0;i<(arc4random()%200+5);i++) {
-        [usedArr addObject:[ASPointDetailModel demoData]];
+- (void)viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
+    [self checkEmpty];
+}
+
+
+
+- (void)checkEmpty {
+    if (_allTableV.dataArr.count == 0 && self.allBt.isSelected) {
+        [self showEmptyV: self.allTableV];
+    } else if (_usedTableV.dataArr.count == 0 && self.usedBt.isSelected) {
+        [self showEmptyV: self.usedTableV];
+    } else {
+        [self hiddenEmpty];
     }
-    self.allTableV.dataArr = allArr;
-    self.usedTableV.dataArr = usedArr;
-    [self.allTableV reloadData];
-    [self.usedTableV reloadData];
+}
+
+
+// MARK: - nets
+- (void)getAllListData {
+    [MBProgressHUD showHUDAddedTo:self.view animated:true];
+    __weak typeof(self) weakSelf = self;
+    [self.vm getAllList:self.allPage com:^(BOOL hasNext, NSString * _Nonnull msg) {
+        [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
+        [weakSelf.allTableV.mj_header endRefreshing];
+        if (hasNext) {
+            [weakSelf.allTableV.mj_footer endRefreshing];
+        } else {
+            [weakSelf.allTableV.mj_footer endRefreshingWithNoMoreData];
+        }
+        weakSelf.allTableV.dataArr = weakSelf.vm.allList;
+        [weakSelf checkEmpty];
+        [weakSelf.allTableV reloadData];
+    }];
+}
+- (void)getUsedListData {
+    [MBProgressHUD showHUDAddedTo:self.view animated:true];
+    __weak typeof(self) weakSelf = self;
+    [self.vm getUsedList:self.usedPage com:^(BOOL hasNext, NSString * _Nonnull msg) {
+        [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
+        [weakSelf.usedTableV.mj_header endRefreshing];
+        if (hasNext) {
+            [weakSelf.usedTableV.mj_footer endRefreshing];
+        } else {
+            [weakSelf.usedTableV.mj_footer endRefreshingWithNoMoreData];
+        }
+        weakSelf.usedTableV.dataArr = weakSelf.vm.usedList;
+        [weakSelf checkEmpty];
+        [weakSelf.usedTableV reloadData];
+    }];
 }
 
 // MARK: - loadSubVs
@@ -54,9 +97,30 @@
     self.view.backgroundColor = _E0FFF5;
     self.customNavBar.backgroundColor = _F0FFFA;
     self.titleStr = @"Points Details";
+    __weak typeof(self) weakSelf = self;
     [self setNavRightSearch:^{
         
     }];
+    self.allTableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
+        weakSelf.allPage = 1;
+        [weakSelf getAllListData];
+    }];
+    self.allTableV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
+        weakSelf.allPage += 1;
+        [weakSelf getAllListData];
+    }];
+    
+    self.usedTableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
+        weakSelf.usedPage = 1;
+        [weakSelf getUsedListData];
+    }];
+    self.usedTableV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
+        weakSelf.usedPage += 1;
+        [weakSelf getUsedListData];
+    }];
+    
+    [self.allTableV.mj_header beginRefreshing];
+    [self.usedTableV.mj_header beginRefreshing];
 }
 
 - (void)loadSubVs {
@@ -125,12 +189,13 @@
         self.usedBt.selected = true;
         [self.scrollV setContentOffset:CGPointMake(KScreenWidth, 0) animated:true];
     } else {
-        self.allBt.selected = false;
-        self.usedBt.selected = true;
+        self.allBt.selected = true;
+        self.usedBt.selected = false;
         [self.scrollV setContentOffset:CGPointMake(0, 0) animated:true];
     }
     [self setBtStatus:self.allBt];
     [self setBtStatus:self.usedBt];
+    [self checkEmpty];
 }
 
 - (void)setBtStatus:(UIButton *)bt {
@@ -242,6 +307,7 @@
     self.usedBt.selected = index == 1;
     [self setBtStatus:self.allBt];
     [self setBtStatus:self.usedBt];
+    [self checkEmpty];
 }
 
 - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
@@ -250,6 +316,8 @@
     self.usedBt.selected = index == 1;
     [self setBtStatus:self.allBt];
     [self setBtStatus:self.usedBt];
+    [self checkEmpty];
+    
 }
 
 @end

+ 2 - 2
Asteria/Fuction/UserCenter/Points/ASPointsHomeViewController.m

@@ -32,8 +32,8 @@
     [self setNavRightSearch:^{
        // TODO: - to Search VC
     }];
-    
-    [self.headV setData:@"321241"];
+    NSString *points = ASUserInfoManager.shared.userPoints;
+    [self.headV setData:points];
     __weak typeof(self) weakSelf = self;
     [self.headV setRuleCallBack:^{
         UIViewController *vc = [CTMediator.sharedInstance getWebViewVc:@{

+ 23 - 0
Asteria/Fuction/UserCenter/Points/ASPointsViewModel.h

@@ -0,0 +1,23 @@
+//
+//  ASPointsViewModel.h
+//  Asteria
+//
+//  Created by iOS on 2023/12/2.
+//
+
+#import <Foundation/Foundation.h>
+#import "ASPointDetailModel.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface ASPointsViewModel : NSObject
+
+@property (nonatomic, strong) NSMutableArray<ASPointDetailModel *> *allList;
+@property (nonatomic, strong) NSMutableArray<ASPointDetailModel *> *usedList;
+
+- (void)getAllList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com;
+- (void)getUsedList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 70 - 0
Asteria/Fuction/UserCenter/Points/ASPointsViewModel.m

@@ -0,0 +1,70 @@
+//
+//  ASPointsViewModel.m
+//  Asteria
+//
+//  Created by iOS on 2023/12/2.
+//
+
+#import "ASPointsViewModel.h"
+
+@implementation ASPointsViewModel
+
+- (instancetype)init
+{
+    self = [super init];
+    if (self) {
+        self.allList = [NSMutableArray array];
+        self.usedList = [NSMutableArray array];
+    }
+    return self;
+}
+
+- (void)getAllList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com {
+    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
+    dic[@"page"] = [NSString stringWithFormat:@"%ld", page];
+    dic[@"obtained"] = @"0";
+    dic[@"used"] = @"0";
+    [ASNetTools.shared getWithPath:getPointsDetailUrl param:dic success:^(id _Nonnull json) {
+        NSInteger pagesize = [NSString stringWithFormat:@"%@", json[@"pageSize"]].integerValue;
+        NSArray *list = json[@"list"];
+        NSMutableArray *arr = [ASPointDetailModel mj_objectArrayWithKeyValuesArray:list];
+        if (page == 1) {
+            self.allList = arr;
+        } else {
+            [self.allList addObjectsFromArray:arr];
+        }
+        if (arr.count >= pagesize){
+            com(true, @"");
+        } else {
+            com(false, @"");
+        }
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        com(false, msg);
+    }];
+}
+
+- (void)getUsedList:(NSInteger)page com:(void(^)(BOOL hasNext, NSString *msg))com{
+    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
+    dic[@"page"] = [NSString stringWithFormat:@"%ld", page];
+    dic[@"used"] = @"1";
+    dic[@"obtained"] = @"0";
+    [ASNetTools.shared getWithPath:getPointsDetailUrl param:dic success:^(id _Nonnull json) {
+        NSInteger pagesize = [NSString stringWithFormat:@"%@", json[@"pageSize"]].integerValue;
+        NSArray *list = json[@"list"];
+        NSMutableArray *arr = [ASPointDetailModel mj_objectArrayWithKeyValuesArray:list];
+        if (page == 1) {
+            self.usedList = arr;
+        } else {
+            [self.usedList addObjectsFromArray:arr];
+        }
+        if (arr.count >= pagesize){
+            com(true, @"");
+        } else {
+            com(false, @"");
+        }
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        com(false, msg);
+    }];
+}
+
+@end

+ 4 - 5
Asteria/Fuction/UserCenter/Points/model/ASPointDetailModel.h

@@ -11,12 +11,11 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface ASPointDetailModel : NSObject
 
-@property (nonatomic, copy) NSString *title;
-@property (nonatomic, copy) NSString *time;
-@property (nonatomic, copy) NSString *point;
-@property (nonatomic, copy) NSString *elsePoint;
+@property (nonatomic, copy) NSString *points_delta;
+@property (nonatomic, copy) NSString *points_balance;
+@property (nonatomic, copy) NSString *comment;
+@property (nonatomic, copy) NSString *created_at;
 
-+ (ASPointDetailModel *)demoData;
 
 @end
 

+ 0 - 8
Asteria/Fuction/UserCenter/Points/model/ASPointDetailModel.m

@@ -9,13 +9,5 @@
 
 @implementation ASPointDetailModel
 
-+ (ASPointDetailModel *)demoData {
-    ASPointDetailModel *m = [ASPointDetailModel new];
-    m.title = @"DAILY FRIST LOGIN";
-    m.time = @"Sep 6, 2022 5:18 pm";
-    m.point = @"+10";
-    m.elsePoint = @"5600";
-    return m;
-}
 
 @end

+ 4 - 4
Asteria/Fuction/UserCenter/Points/view/ASPointDetailCell.m

@@ -21,11 +21,11 @@
 @implementation ASPointDetailCell
 
 - (void)setData:(ASPointDetailModel *)model {
-    self.titleLb.text = model.title;
+    self.titleLb.text = model.comment;
     
-    self.dateLb.text = model.time;
-    self.pointsLb.text = [NSString stringWithFormat:@"%@ Points",model.point];
-    self.elsePointsLb.text = [NSString stringWithFormat:@"My points:%@",model.elsePoint];
+    self.dateLb.text = model.created_at;
+    self.pointsLb.text = [NSString stringWithFormat:@"%@ Points",model.points_delta];
+    self.elsePointsLb.text = [NSString stringWithFormat:@"My points:%@",model.points_balance];
 }
 
 

+ 0 - 1
Asteria/Fuction/UserCenter/UserCenterHome/ASUserCenterViewController.m

@@ -69,7 +69,6 @@
         switch (tag) {
             case 0: {
                 ASCouponsListViewController *vc = [[ASCouponsListViewController alloc] init];
-                vc.isCard = false;
                 [weakSelf.navigationController pushViewController:vc animated:true];
             }
                 break;

+ 66 - 20
Asteria/Fuction/UserCenter/VipCenter/ASVipCenterViewController.m

@@ -11,6 +11,7 @@
 #import "ASVipCenterCollectCell.h"
 #import "ASVipCouponsViewController.h"
 #import "ASBirthdayTreatViewController.h"
+#import "ASInfomationSetController.h"
 
 @interface ASVipCenterViewController () <UICollectionViewDelegate,UICollectionViewDataSource>
 
@@ -24,10 +25,12 @@
 
 @property (nonatomic, strong) NSMutableArray <ASVipCenterLineItemView *>*bottomVArr;
 
-@property (nonatomic, strong) NSArray *bottomTitleArr;
+//@property (nonatomic, strong) NSMutableArray *bottomTitleArr;
 
 @property (nonatomic, strong) NSArray *vipImgArr;
 
+@property (nonatomic, strong) UIStackView *bottomStv;
+
 
 @end
 
@@ -41,19 +44,24 @@
         (id)Col_FFF.CGColor
         ] startP:CGPointMake(0.5, 0.25) endP:CGPointMake(0.5, 1)];
     
-    self.bottomTitleArr = @[@"EXCLUSIVE $100 COUPON", @"BIRTHDAY TREAT"];
+//    self.bottomTitleArr = [NSMutableArray arrayWithObjects:@"EXCLUSIVE $100 COUPON", @"BIRTHDAY TREAT", nil];
     self.vipImgArr = @[@"vip_bg1",@"vip_bg2",@"vip_bg3",@"vip_bg4",@"vip_bg5"];
     [self loadSubVs];
     [self.view bringSubviewToFront:self.customNavBar];
     [self configSubVs];
-    [self demoData];
+    [self setData];
     
 }
 
-- (void)demoData {
-    self.userInfoV.usefualLb.text = @"Growth Value 7220/10000";
-    self.control.numberOfPages = self.vipImgArr.count;
-    self.control.currentPage = 0;
+- (void)setData {
+    [self.userInfoV setData];
+    ASVipModel *curVipM = ASUserInfoManager.shared.curVipInfo;
+    ASVipModel *nexVipM = ASUserInfoManager.shared.nextVipInfo;
+    self.userInfoV.usefualLb.text = [NSString stringWithFormat:@"Growth Value %ld/%ld", ASUserInfoManager.shared.pointAmount.integerValue, nexVipM.exppoints.integerValue];
+    NSArray *arr = ASUserInfoManager.shared.vipInfoArr;
+    self.control.numberOfPages = arr.count > 0 ? arr.count : 0;
+    NSInteger curPage = curVipM.level.integerValue-1;
+    self.control.currentPage = curPage >= 0 ? curPage : 0;
 }
 
 - (void)configSubVs {
@@ -75,8 +83,8 @@
     [self.contentV addSubview:self.userInfoV];
     [self.contentV addSubview:self.collectV];
     [self.contentV addSubview:self.control];
-    UIStackView *stv = [self getBottomV];
-    [self.contentV addSubview:stv];
+    self.bottomStv = [self getBottomV:ASUserInfoManager.shared.curVipInfo];
+    [self.contentV addSubview:self.bottomStv];
     
     [self.scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.customNavBar.mas_bottom);
@@ -108,7 +116,7 @@
         make.top.equalTo(self.collectV.mas_bottom).offset(20);
     }];
     
-    [stv mas_makeConstraints:^(MASConstraintMaker *make) {
+    [self.bottomStv mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.control.mas_bottom).offset(20);
         make.leading.trailing.equalTo(self.contentV);
         make.bottom.equalTo(self.contentV.mas_bottom).offset(-80);
@@ -180,29 +188,35 @@
         [_control setPageIndicatorTintColor:[[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.3] ];
         [_control setCurrentPageIndicatorTintColor:[UIColor colorWithHexString:@"#000000"] ];
         _control.transform = CGAffineTransformScale(_control.transform, 1.15, 1.15);
+        _control.userInteractionEnabled = false;
     }
     return  _control;
 }
 
-- (UIStackView *)getBottomV {
+- (UIStackView *)getBottomV:(ASVipModel *)vipM {
     UIStackView *stv = [UIStackView baseStackV:true];
     stv.spacing = 0;
     stv.distribution = UIStackViewDistributionFillEqually;
     
     self.bottomVArr = [NSMutableArray array];
-    for (int i=0; i<self.bottomTitleArr.count; i++) {
-        NSString *title = self.bottomTitleArr[i];
+    for (int i=0; i<vipM.privilege.count; i++) {
+        ASVipPriSubModel *tempM = vipM.privilege[i];
+        NSString *title = [NSString stringWithFormat:@"%@ %@", tempM.title, tempM.desc];
         ASVipCenterLineItemView *v = [[ASVipCenterLineItemView alloc] initWithFrame:CGRectZero];
         [v setData:title canGoNext:true];
         v.tag = 90000+i;
-        __weak typeof(v) weakV = v;
         v.selectCallBack = ^{
-            if (weakV.tag%100 == 0) {
+            if (tempM.type.integerValue == 1) { // 优惠券
                 ASVipCouponsViewController *vc = [ASVipCouponsViewController new];
                 [self.navigationController pushViewController:vc animated:true];
-            } else {
+            } else if (tempM.type.integerValue == 2) { // 生日
+                if (ASUserInfoManager.shared.birthStatus.integerValue == -1) {
+                    ASInfomationSetController *vc = [ASInfomationSetController new];
+                    [self.navigationController pushViewController:vc animated:true];
+                    return;
+                }
                 ASBirthdayTreatViewController *vc = [ASBirthdayTreatViewController new];
-                vc.isBirthday = arc4random()%2 == 1;
+                vc.isBirthday = ASUserInfoManager.shared.birthStatus.integerValue == 2;
                 [self.navigationController pushViewController:vc animated:true];
             }
         };
@@ -215,14 +229,23 @@
 
 // MARK: - collectV delegate datesource
 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
-    return self.vipImgArr.count;
+    return ASUserInfoManager.shared.vipInfoArr.count;
 }
 
 - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
     ASVipCenterCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ASVipCenterCollectCell" forIndexPath:indexPath];
-    [cell setData:self.vipImgArr[indexPath.row] desStr:@"INTEGRAL TO 0-1000"];
+    NSArray *arr = ASUserInfoManager.shared.vipInfoArr;
+    if (arr.count <= indexPath.row) {
+        return cell;
+    }
+    ASVipModel *model = arr[indexPath.row];
+    if (model.nextExppoints != nil && model.nextExppoints.integerValue > 0) {
+        [cell setData:self.vipImgArr[indexPath.row%self.vipImgArr.count] desStr:[NSString stringWithFormat:@"INTEGRAL TO %@-%@", model.exppoints, model.nextExppoints]];
+    } else {
+        [cell setData:self.vipImgArr[indexPath.row%self.vipImgArr.count] desStr:[NSString stringWithFormat:@"INTEGRAL TO %ld", model.exppoints.integerValue + 1]];
+    }
     cell.desLb.textColor = Col_000;
-    if (indexPath.row == self.vipImgArr.count-1) {
+    if (indexPath.row == arr.count-1) {
         cell.desLb.textColor = _FFE797;
     }
     return cell;
@@ -231,11 +254,34 @@
 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
     NSInteger page = (NSInteger)scrollView.contentOffset.x/SCREEN_WIDTH;
     self.control.currentPage = page;
+    [self reSetCurrentBottom];
 }
 
 - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
     NSInteger page = (NSInteger)scrollView.contentOffset.x/SCREEN_WIDTH;
     self.control.currentPage = page;
+    [self reSetCurrentBottom];
+}
+
+- (void)reSetCurrentBottom {
+    NSArray *arr = ASUserInfoManager.shared.vipInfoArr;
+    if (arr.count <= self.control.currentPage) {
+        return;
+    }
+    ASVipModel *model = arr[self.control.currentPage];
+    if (self.bottomStv && self.bottomStv.superview != nil) {
+        for (UIView *item in self.bottomStv.arrangedSubviews) {
+            [self.bottomStv removeArrangedSubview:item];
+        }
+        [self.bottomStv removeFromSuperview];
+    }
+    self.bottomStv = [self getBottomV:model];
+    [self.contentV addSubview:self.bottomStv];
+    [self.bottomStv mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.control.mas_bottom).offset(20);
+        make.leading.trailing.equalTo(self.contentV);
+        make.bottom.equalTo(self.contentV.mas_bottom).offset(-80);
+    }];
 }
 
 

+ 3 - 0
Asteria/Fuction/UserManager/ASUserInfoManager.h

@@ -21,6 +21,9 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, strong) ASVipModel *curVipInfo;
 @property (nonatomic, strong) ASVipModel *nextVipInfo;
 
+@property (nonatomic, strong) NSString *birthDay;
+@property (nonatomic, strong) NSString *birthStatus;
+
 /// 以获取总积分
 @property (nonatomic, copy) NSString *pointAmount;
 /// 用户当前可用积分

+ 16 - 1
Asteria/Fuction/UserManager/ASUserInfoManager.m

@@ -37,6 +37,7 @@
 - (void)getInfo {
     [self baseInfoNet];
     [self vipInfoNet];
+    [self birthInfoNet];
 }
 
 - (void)baseInfoNet {
@@ -49,6 +50,16 @@
     }];
 }
 
+- (void)birthInfoNet {
+    [ASNetTools.shared getWithPath:userBirthUrl param:@{} success:^(id _Nonnull json) {
+        self.birthDay = [NSString stringWithFormat:@"%@", json[@"birthDay"]];
+        self.birthStatus = [NSString stringWithFormat:@"%@", json[@"status"]];
+        NSLog(@"----userInfo:%@-----id:%@----issub:%u----address:%@----", self.userInfo, self.userInfo.Id, self.userInfo.is_subscribed, self.userInfo.addresses);
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        [Current_normalTool.currentNav.topViewController.view makeToast:msg];
+    }];
+}
+
 - (void)vipInfoNet {
     [ASNetTools.shared getWithPath:vipInfoUrl param:@{} success:^(id _Nonnull json) {
         
@@ -87,6 +98,10 @@
             }
             for (int i=0; i<sortedArr.count; i++) {
                 ASVipModel *vipM = [ASVipModel mj_objectWithKeyValues: tempModel.membergrade[sortedArr[i]]];
+                if (i+1<sortedArr.count) {
+                    ASVipModel *tempNext = [ASVipModel mj_objectWithKeyValues: tempModel.membergrade[sortedArr[i+1]]];
+                    vipM.nextExppoints = tempNext.exppoints;
+                }
                 if (cur.level.intValue > 0 && next.level.intValue <= 0) {
                     next = vipM;
                 }
@@ -110,7 +125,7 @@
 }
 
 - (BOOL)isLogin {
-    NSString *token = [NSUserDefaults.standardUserDefaults stringForKey:TokenKey];
+    NSString *token = [DataUtil loginToken];
     return !(token == nil || [token isEqualToString:@""]);
 }
 

+ 2 - 0
Asteria/Fuction/UserManager/ASVipModel.h

@@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, copy) NSString *desc;
 /// web使用    暂时无用
 @property (nonatomic, copy) NSString *url;
+@property (nonatomic, copy) NSString *type;
 
 @end
 
@@ -23,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, copy) NSString *level;
 @property (nonatomic, copy) NSString *level_name;
 @property (nonatomic, copy) NSString *exppoints;
+@property (nonatomic, copy) NSString *nextExppoints;
 @property (nonatomic, copy) NSArray<ASVipPriSubModel *> *privilege;
 @property (nonatomic, assign) BOOL is_cur;
 

+ 7 - 2
Asteria/NetTools/ASNetApis.h

@@ -8,8 +8,6 @@
 #ifndef ASNetApis_h
 #define ASNetApis_h
 
-#define TokenKey @"ASUserToken"
-
 #define BaseRequestrUrl(url) ([NSString stringWithFormat:@"%@%@",@"rest/V1/",url])
 
 // MARK: - host
@@ -33,5 +31,12 @@
 #define getSignStateUrl BaseRequestrUrl(@"sign/index")
 #define postSignUrl BaseRequestrUrl(@"sign/add")
 
+// MARK: 优惠券/礼品卡
+#define getUserCouponUrl BaseRequestrUrl(@"coupon/index")
+#define getUserGiftCardUrl BaseRequestrUrl(@"gift/index")
+
+// MARK: 积分
+#define getPointsDetailUrl BaseRequestrUrl(@"points/index")
+
 
 #endif /* ASNetApis_h */

+ 28 - 16
Asteria/NetTools/ASNetTools.m

@@ -10,6 +10,8 @@
 
 @interface ASNetTools ()
 
+@property (nonatomic, copy) NSString *currentToken;
+
 @property (nonatomic, strong) MKNetworkEngine *engine;
 @property (nonatomic, strong) NSMutableDictionary *defuatParam;
 
@@ -47,10 +49,11 @@
 }
 
 - (void)updateEngine {
-    NSString *token = [NSUserDefaults.standardUserDefaults stringForKey:TokenKey];
+    NSString *token = [DataUtil loginToken];
     if (!token) {
         token = @"";
     }
+    self.currentToken = token;
     self.engine = [[MKNetworkEngine alloc] initWithHostName:HostPath customHeaderFields:@{
         @"Authorization":token,
         @"powerby": @"longyitec",
@@ -59,12 +62,21 @@
     
 }
 
+- (void)checkToken {
+    
+    NSString *token = [DataUtil loginToken];
+    if (!token) {
+        token = @"";
+    }
+    if (![token isEqualToString:self.currentToken]) {
+        [self updateEngine];
+    }
+}
+
 // post请求
 - (void)postWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild {
     BOOL isSSL = true;
-//#if (DEBUG)
-//    isSSL = false;
-//#endif
+    [self checkToken];
     NSMutableDictionary *tempDic = [[NSMutableDictionary alloc] initWithDictionary:self.defuatParam];
     [tempDic addEntriesFromDictionary:param];
     MKNetworkOperation *op = [self.engine operationWithPath:path params:tempDic httpMethod:@"POST" ssl:isSSL];
@@ -96,7 +108,7 @@
                 NSString *status = result[@"status"];
                 NSString *msg = result[@"msg"];
                 if (error.code == 401) {
-                    [NSUserDefaults.standardUserDefaults setValue:@"" forKey:TokenKey];
+                    [DataUtil setLoginToken:@""];
                     [weakSelf updateEngine];
                     faild(status, msg);
                     return;
@@ -105,7 +117,7 @@
                 return;
             }
             if (error.code == 401) {
-                [NSUserDefaults.standardUserDefaults setValue:@"" forKey:TokenKey];
+                [DataUtil setLoginToken:@""];
                 [weakSelf updateEngine];
                 faild(@"-1", @"Plase Login");
                 return;
@@ -121,9 +133,7 @@
 // get 请求
 - (void)getWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild {
     BOOL isSSL = true;
-//#if (DEBUG)
-//    isSSL = false;
-//#endif
+    [self checkToken];
     NSMutableDictionary *tempDic = [[NSMutableDictionary alloc] initWithDictionary:self.defuatParam];
     [tempDic addEntriesFromDictionary:param];
     MKNetworkOperation *op = [self.engine operationWithPath:path params:tempDic httpMethod:@"GET" ssl:isSSL];
@@ -154,7 +164,7 @@
                 NSString *status = result[@"status"];
                 NSString *msg = result[@"msg"];
                 if (error.code == 401) {
-                    [NSUserDefaults.standardUserDefaults setValue:@"" forKey:TokenKey];
+                    [DataUtil setLoginToken:@""];
                     [weakSelf updateEngine];
                     faild(status, msg);
                     return;
@@ -163,7 +173,7 @@
                 return;
             }
             if (error.code == 401) {
-                [NSUserDefaults.standardUserDefaults setValue:@"" forKey:TokenKey];
+                [DataUtil setLoginToken:@""];
                 [weakSelf updateEngine];
                 faild(@"-1", @"Plase Login");
                 return;
@@ -183,6 +193,7 @@
 //#if (DEBUG)
 //    isSSL = false;
 //#endif
+    [self checkToken];
     NSMutableDictionary *tempDic = [[NSMutableDictionary alloc] initWithDictionary:self.defuatParam];
     [tempDic addEntriesFromDictionary:param];
     MKNetworkOperation *op = [self.engine operationWithPath:path params:tempDic httpMethod:@"PUT" ssl:isSSL];
@@ -214,7 +225,7 @@
                 NSString *status = result[@"status"];
                 NSString *msg = result[@"msg"];
                 if (error.code == 401) {
-                    [NSUserDefaults.standardUserDefaults setValue:@"" forKey:TokenKey];
+                    [DataUtil setLoginToken:@""];
                     [weakSelf updateEngine];
                     faild(status, msg);
                     return;
@@ -223,7 +234,7 @@
                 return;
             }
             if (error.code == 401) {
-                [NSUserDefaults.standardUserDefaults setValue:@"" forKey:TokenKey];
+                [DataUtil setLoginToken:@""];
                 [weakSelf updateEngine];
                 faild(@"-1", @"Plase Login");
                 return;
@@ -243,6 +254,7 @@
 //#if (DEBUG)
 //    isSSL = false;
 //#endif
+    [self checkToken];
     NSMutableDictionary *tempDic = [[NSMutableDictionary alloc] initWithDictionary:self.defuatParam];
     [tempDic addEntriesFromDictionary:param];
     MKNetworkOperation *op = [self.engine operationWithPath:path params:tempDic httpMethod:@"DELETE" ssl:isSSL];
@@ -274,7 +286,7 @@
                 NSString *status = result[@"status"];
                 NSString *msg = result[@"msg"];
                 if (error.code == 401) {
-                    [NSUserDefaults.standardUserDefaults setValue:@"" forKey:TokenKey];
+                    [DataUtil setLoginToken:@""];
                     [weakSelf updateEngine];
                     faild(status, msg);
                     return;
@@ -283,7 +295,7 @@
                 return;
             }
             if (error.code == 401) {
-                [NSUserDefaults.standardUserDefaults setValue:@"" forKey:TokenKey];
+                [DataUtil setLoginToken:@""];
                 [weakSelf updateEngine];
                 faild(@"-1", @"Plase Login");
                 return;
@@ -326,7 +338,7 @@
     };
     [ASNetTools.shared postWithPath:loginUrl param:param success:^(id _Nonnull result) {
         NSString *token = [NSString stringWithFormat:@"Bearer %@", result];
-        [NSUserDefaults.standardUserDefaults setValue:token forKey:TokenKey];
+        [DataUtil setLoginToken:token];
         [ASNetTools.shared updateEngine];
         [ASUserInfoManager.shared getInfo];
         NSLog(@"----url:%@-----result:%@------", loginUrl, result);

+ 13 - 9
Asteria/Tabber/AS_TabBarViewController.m

@@ -75,16 +75,20 @@
             
             return false;
         }
-        if ([vc isKindOfClass:[CTMediator.sharedInstance userCenterVcClass]] && !([ASUserInfoManager.shared isLogin])) {
-            UIViewController *vc1 = [[CTMediator sharedInstance] getUserCenterVc:@{}];
-            
-            [self.selectedViewController pushViewController:vc1 animated:true];
-            return false;
+        if ([vc isKindOfClass:[CTMediator.sharedInstance userCenterVcClass]]) {
+            if (![ASUserInfoManager.shared isLogin]) {
+                UIViewController *loginC = [[CTMediator sharedInstance] Login_LoginC:@{}];
+                
+                QMUINavigationController *uikitNavController = [[QMUINavigationController alloc] initWithRootViewController:loginC];
+                uikitNavController.navigationBar.hidden = YES;
+                uikitNavController.modalPresentationStyle =UIModalPresentationFullScreen;
+                [self.selectedViewController presentViewController:uikitNavController animated:YES completion:nil];
+                return false;
+            } else {
+                [ASUserInfoManager.shared getInfo];
+            }
         }
-//        NSString *name = [NSString stringWithFormat:@"%s", object_getClassName(vc)];
-//        if ([name isEqualToString:@"APCategoryViewController"]) {
-//            return <#expression#>;
-//        }
+        
     }
     return true;
 }