Kaynağa Gözat

首页跳转添加处理

Abel 1 yıl önce
ebeveyn
işleme
2ffce1ab0a

+ 3 - 0
Asteria/ASUI/CustomView/productView/ASProductBaseModel.m

@@ -54,6 +54,9 @@
 }
 
 - (NSString *)img {
+    if ([_img hasPrefix:@"http"]) {
+        return _img;
+    }
     return [NSString stringWithFormat:@"https://%@%@%@",HostPath, ProductImgPath, _img];
 }
 

+ 9 - 0
Asteria/ASUI/SimpleBase/ASBaseViewController.h

@@ -8,6 +8,7 @@
 #import <UIKit/UIKit.h>
 #import "ASJumpModel.h"
 
+
 NS_ASSUME_NONNULL_BEGIN
 
 @interface ASBaseViewController : UIViewController
@@ -39,6 +40,14 @@ NS_ASSUME_NONNULL_BEGIN
 
 - (void)jumpWithModel:(ASJumpModel *)model;
 
+- (void)toWebVC:(NSString *)urlStr name:(NSString *)name;
+
+-(void)pushToProductList:(NSString *)name typeid:(NSString *)typeId;
+
+
+-(void)goto_WKM_GoodsDetailsC:(NSString *)entity_id;
+-(void)action_GoodsSizeC:(NSString *)entity_id;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 90 - 0
Asteria/ASUI/SimpleBase/ASBaseViewController.m

@@ -7,6 +7,7 @@
 
 #import "ASBaseViewController.h"
 #import "AppDelegate.h"
+#import "GoodsInformationM.h"
 
 @interface ASBaseViewController ()
 
@@ -31,10 +32,99 @@
 
 @implementation ASBaseViewController
 
+/// 跳转类型   0 web  1商品详情  2商品列表   3koc  4:注册页
 - (void)jumpWithModel:(ASJumpModel *)model {
+    if (model.type.intValue == 1) {
+        [self goto_WKM_GoodsDetailsC:model.link];
+        return;
+    }
+    if (model.type.intValue == 2) {
+        NSString *typeId = model.link;
+        [self pushToProductList:model.title typeid:typeId];
+        return;
+    }
+    if (model.type.intValue == 4) {
+        [self toLoginVC];
+        return;
+    }
+//    if (model.type.intValue == 3) {
+//        if (![self checkLogin:true]) {
+//            return;
+//        }
+//        __weak typeof(self) weak_self = self;
+//        [MBProgressHUD showHUDAddedTo:self.view animated:true];
+//        [[KWBalanceInfoManager shareInstance] updateApplyStatus:^(BOOL flag) {
+//            [MBProgressHUD hideHUDForView:weak_self.view animated:true];
+//            if (![KWBalanceInfoManager shareInstance].isApply) {
+//                KWBrandAMBViewController *vc = [KWBrandAMBViewController new];
+//                [weak_self.navigationController pushViewController:vc animated:true];
+//            } else {
+//                APKocTotalViewController *vc = [[APKocTotalViewController alloc] init];
+//                [weak_self.navigationController pushViewController:vc animated:true];
+//            }
+//        }];
+//        return;
+//    }
+    if ([model.link.lowercaseString hasPrefix:@"http"]) {
+        [self toWebVC:model.link name:model.title];
+    }
+}
+
+- (void)toWebVC:(NSString *)urlStr name:(NSString *)name {
+    [Fuction_Tool push_BaseWebUrl:urlStr  webTitle:name];
+}
+
+-(void)pushToProductList:(NSString *)name typeid:(NSString *)typeId {
+    if (typeId == nil || [typeId isEqualToString:@""]) {
+        return;
+    }
+    if (name == nil || [name isEqualToString:@""]) {
+        name = @"Products";
+    }
+    UIViewController *vc = [CTMediator.sharedInstance getProductListVc:@{
+        @"type":typeId,  //String
+        @"title":name,//String
+    }];
+    [self.navigationController pushViewController:vc animated:true];
+    
+    
+}
+
+
+-(void)goto_WKM_GoodsDetailsC:(NSString *)entity_id {
+    UIViewController *viewController = [[CTMediator sharedInstance] Goods_GoodsDetailsC:@{@"entity_id":entity_id}];
+    [self.navigationController pushViewController:viewController animated:YES];
+    
+}
+
+-(void)action_GoodsSizeC:(NSString *)entity_id {
+    if (!ASUserInfoManager.shared.isLogin) {
+        [self toLoginVC];
+        return;
+    }
+    NSMutableDictionary *params = [NSMutableDictionary dictionary];
+    [params setObject:entity_id forKey:@"productId"];
+    [params setObject:ASCurrencyManager.shared.currentCur forKey:@"currencyCode"];
+    [MBProgressHUD showHUDAddedTo:self.view animated:true];
+    __weak typeof(self) weakSelf = self;
+    [ASNetTools.shared getWithPath:getProdectDetail param:params success:^(id _Nonnull json) {
+        [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
+        GoodsInformationM *model = [GoodsInformationM mj_objectWithKeyValues:json];
+        if (model == nil || model.Id == nil || model.Id.isEmpty) {
+            return;
+        }
+        UIViewController *viewController = [[CTMediator sharedInstance] Goods_GoodsSizeC:@{@"model":model}];
+        viewController.modalPresentationStyle = UIModalPresentationFullScreen;
+        [weakSelf presentViewController:viewController animated:YES completion:nil];
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        [self.view makeToast:msg];
+        [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
+    }];
+    
     
 }
 
+
 - (void)toHomeVc {
     if (self.navigationController != nil) {
         [self.navigationController popToRootViewControllerAnimated:false];

+ 2 - 0
Asteria/Fuction/Category/m/KWSearchSubTypeModel.h

@@ -6,6 +6,7 @@
 //
 
 #import <Foundation/Foundation.h>
+#import "ASJumpModel.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -61,6 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, copy) NSString *code;
 @property (nonatomic, copy) NSString *h_ext;
 
+- (ASJumpModel *)toJumpM;
 
 @end
 NS_ASSUME_NONNULL_END

+ 9 - 0
Asteria/Fuction/Category/m/KWSearchSubTypeModel.m

@@ -116,5 +116,14 @@
     };
 }
 
+- (ASJumpModel *)toJumpM {
+    ASJumpModel *m = [ASJumpModel new];
+    m.title = self.title;
+    m.type = self.type;
+    m.link = self.code;
+    m.image = self.thumbnail_url;
+    return m;
+}
+
 
 @end

+ 10 - 3
Asteria/Fuction/Goods/Revies/GoodsReviewsWriteC.m

@@ -75,7 +75,7 @@ RY_baseVMprotocol>
         tipslab.frame = CGRectMake(10, CGRectGetMaxY(self.orderlengthTF.frame)+20+i*40, 70, 40);
         
         HCSStarRatingView *reviews_startV = [[HCSStarRatingView alloc]initWithFrame:CGRectMake(10+70+10, CGRectGetMaxY(self.orderlengthTF.frame)+20+i*40,160, 40)];
-        reviews_startV.value =0;
+        reviews_startV.value =5;
         reviews_startV.filledStarImage = IMAGE(@"reviews_full_star");
         reviews_startV.emptyStarImage = IMAGE(@"reviews_empty_star");
         reviews_startV.maximumValue = 5;
@@ -121,8 +121,12 @@ RY_baseVMprotocol>
     } NoAC:nil ViewController:self];
 }
 -(void)tool_deleteImgChange:(NSInteger )index{
-    [self.xxx_imgUrlAry removeObjectAtIndex:index];
-    [self.xxx_selectImgAry removeObjectAtIndex:index];
+    if (index < self.xxx_imgUrlAry.count) {
+        [self.xxx_imgUrlAry removeObjectAtIndex:index];
+    }
+    if (index < self.xxx_selectImgAry.count) {
+        [self.xxx_selectImgAry removeObjectAtIndex:index];
+    }
     for (int i = 0; i<self.xxx_upLoadImgAry.count; i++) {
         GoodWritUpImgV * imgV =  self.xxx_upLoadImgAry[i];
         imgV.hidden = NO;
@@ -240,6 +244,9 @@ RY_baseVMprotocol>
 }
 
 -(void)handle_postCommentEvent:(UIButton *)btn{
+    if (!ASUserInfoManager.shared.isLogin) {
+        return;
+    }
     if(self.writeTextV.text.length == 0 || self.orderlengthTF.text.length == 0 || self.buyernameTF.text.length == 0){
         [self.view makeToast:@"Please complete the score first" duration:2 position:CSToastPositionCenter];
         return;

+ 88 - 33
Asteria/Fuction/Home/ASHomeViewController.m

@@ -25,7 +25,6 @@
 @property (nonatomic, strong) ASHomeViewModel *vm;
 
 @property (nonatomic, strong) UITableView *tableV;
-@property (nonatomic, strong) NSArray <ASHomeMainListModel*>*listArr;
 
 @property (nonatomic, strong, nullable) ASHomeActiveView *activeV;
 
@@ -43,17 +42,12 @@
         // TODO: 跳转搜索模块
     }];
     [self addSubV];
-    [self demoData];
     [self.tableV.mj_header beginRefreshing];
     
     [self updateTopLinkData];
 }
 
 
-- (void)demoData {
-    _listArr = [ASHomeMainListModel homeDemoDatas];
-}
-
 - (void)getTopLinkData {
     __weak typeof(self) weakSelf = self;
     [self.topVm getTopLinkList:^{
@@ -61,6 +55,14 @@
     }];
 }
 
+- (void)getHomeListData {
+    __weak typeof(self) weakSelf = self;
+    [self.vm getHomeListData:^{
+        [weakSelf.tableV.mj_header endRefreshing];
+        [weakSelf.tableV reloadData];
+    }];
+}
+
 - (void)getHomeTopData {
     __weak typeof(self) weakSelf = self;
     [self.vm getHomeTopData:^{
@@ -71,8 +73,10 @@
 - (void)updateTopLinkData {
     if (self.topVm.topLinks.count > 0) {
         self.activeV = [[ASHomeActiveView alloc] initWithFrame:CGRectZero];
+        __weak typeof(self) weakSelf = self;
         [self.activeV setTapTopBlock:^(KWSearchHotKeyModel * _Nullable m) {
             NSLog(@"---toplink:-%@--", m.code);
+            [weakSelf jumpWithModel:[m toJumpM]];
         }];
         self.tableV.tableHeaderView = self.activeV;
         [self.activeV setTopData:self.topVm.topLinks];
@@ -95,12 +99,8 @@
     self.tableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
         [weakSelf getTopLinkData];
         [weakSelf getHomeTopData];
+        [weakSelf getHomeListData];
         
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1), dispatch_get_main_queue(), ^{
-            
-            [self.tableV.mj_header endRefreshing];
-            [self.tableV reloadData];
-        });
     }];
 }
 
@@ -117,7 +117,7 @@
 // MARK: - UITableViewDataSource
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
 {
-    return self.listArr.count + 2;
+    return self.vm.listData.count + 3;
 }
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
@@ -130,9 +130,43 @@
         case 1:// category
             return self.vm.categorys.count > 0 ? 1 : 0;
             break;
-            
+        case 2:// tips
+            return 1;
         default:
+        {
+            if (self.vm.listData.count < section-3) {
+                return  0;
+            }
+            ASHomeMainListModel *m = self.vm.listData[section-3];
+            NSInteger showtype = m.showType;
+            switch (showtype) {
+                case 1:// best seller
+                    return m.productList.count > 0 ? 1 : 0;
+                case 2:// new in
+                    return m.productList.count > 0 ? 1 : 0;
+                case 3://
+                    return m.imgUrl.length > 0 ? 1 : 0;
+                case 4:// New Arrivals
+                    return m.productList.count > 0 ? 1 : 0;
+                case 5:// 单图活动
+                    return m.imgUrl.length > 0 ? 1 : 0;
+                case 6:// shop by looking
+                    return m.titleArr.count > 0 ? 1 : 0;
+                case 7:// memship
+                    return m.imgUrl.length > 0 ? 1 : 0;
+//                case 8:// video Active
+//                    return m.videoUrl.length > 0 ? 1 : 0;
+//                case 9:// You may also like
+//                    return m.productList.count > 0 ? 1 : 0;
+//                case 10:// today deals
+//                    return m.productList.count > 0 ? 1 : 0;
+//                case 11: // 带背景色和图片的 cycle cell
+//                    return m.productList.count > 0 ? 1 : 0;
+                default:
+                    return 0;
+            }
             return 1;
+        }
     }
     return 1;
 }
@@ -161,53 +195,74 @@
         };
         return cell;
     }
-    if (self.listArr.count <= indexPath.row) {
+    if (indexPath.section == 2) {
+        ASHomeTipCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeTipCell" forIndexPath:indexPath];
+        return cell;
+    }
+    if (self.vm.listData.count <= indexPath.section-3) {
         return [UITableViewCell new];
     }
-    ASHomeMainListModel *m = self.listArr[indexPath.section-1];
+    ASHomeMainListModel *m = self.vm.listData[indexPath.section-3];
+    __weak typeof(self) weakSelf = self;
     switch (m.showType) {
-        case 1: { // 分类
-            
-        }
-        case 2: { // tips
-            ASHomeTipCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeTipCell" forIndexPath:indexPath];
-            return cell;
-        }
-        case 3: {// bestSell
+        case 1: {// bestSell
             ASHomeBestSellCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeBestSellCell" forIndexPath:indexPath];
             cell.productClick = ^(NSInteger i, ASProductBaseModel * _Nonnull m) {
+                [weakSelf goto_WKM_GoodsDetailsC:m.Id];
             };
             cell.model = m;
             return cell;
         }
-        case 4: {
+        case 2: {
             ASHomeNewInCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeNewInCellTableViewCell" forIndexPath:indexPath];
+            cell.productClick = ^(NSInteger i, ASProductBaseModel * _Nonnull model) {
+                [weakSelf goto_WKM_GoodsDetailsC: model.Id];
+            };
+            cell.addCartBlock = ^(NSInteger i, ASProductBaseModel * _Nonnull model) {
+                [weakSelf action_GoodsSizeC: model.Id];
+            };
             [cell setData:m];
             return cell;
         }
+        case 3: {
+            ASHomeImgCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeImgCell" forIndexPath:indexPath];
+            cell.tapImgBlock = ^{
+                [weakSelf jumpWithModel:[m toJumpM]];
+            };
+            [cell setImgStr:m.imgUrl];
+            return cell;
+        }
         case 5: {
             ASHomeImgCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeImgCell" forIndexPath:indexPath];
             cell.tapImgBlock = ^{
-                // TODO: -
+                [weakSelf jumpWithModel:[m toJumpM]];
             };
             [cell setImgStr:m.imgUrl];
             return cell;
         }
-        case 6: {
+        case 7: {
+            ASHomeImgCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeImgCell" forIndexPath:indexPath];
+            cell.tapImgBlock = ^{
+                [weakSelf jumpWithModel:[m toJumpM]];
+            };
+            [cell setImgStr:m.imgUrl];
+            return cell;
+        }
+        case 4: {
             ASHomeFlashDealCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeFlashDealCell" forIndexPath:indexPath];
-            cell.productClick = ^(NSInteger i, ASProductBaseModel * _Nonnull m) {
-                
+            cell.productClick = ^(NSInteger i, ASProductBaseModel * _Nonnull model) {
+                [weakSelf goto_WKM_GoodsDetailsC:model.Id];
             };
-            cell.proAddCartClick = ^(NSInteger i, ASProductBaseModel * _Nonnull m) {
-                
+            cell.proAddCartClick = ^(NSInteger i, ASProductBaseModel * _Nonnull model) {
+                [weakSelf action_GoodsSizeC:model.Id];
             };
             cell.model = m;
             return cell;
         }
-        case 7: {
+        case 6: {
             ASHomeLookingCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeLookingCell" forIndexPath:indexPath];
-            cell.itemClick = ^(NSInteger i, ASHomeCategoryModel * _Nonnull m) {
-                
+            cell.itemClick = ^(NSInteger i, ASHomeCategoryModel * _Nonnull model) {
+                [weakSelf jumpWithModel:[model toJumpM]];
             };
             cell.model = m;
             return cell;

+ 2 - 0
Asteria/Fuction/Home/ASProductListViewController.m

@@ -277,8 +277,10 @@
 - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
     if (indexPath.section == 0 && [kind isEqualToString:UICollectionElementKindSectionHeader]) {
         ASProductListActiveHeaderView *v = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"ASProductListActiveHeaderView" forIndexPath:indexPath];
+        __weak typeof(self) weakSelf = self;
         [v setTopLinkData:self.vm.topLinks tapBlock:^(KWSearchHotKeyModel * _Nullable m) {
             NSLog(@"---toplink:-%@--", m.code);
+            [weakSelf jumpWithModel:[m toJumpM]];
         }];
         return v;
     }

+ 4 - 0
Asteria/Fuction/Home/Models/ASHomeCategoryModel.h

@@ -6,6 +6,7 @@
 //
 
 #import <Foundation/Foundation.h>
+#import "ASJumpModel.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -15,9 +16,12 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, copy) NSString *imgUrl;
 @property (nonatomic, copy) NSString *webUrl;
 @property (nonatomic, copy) NSString *typeId;
+@property (nonatomic, copy) NSString *type;
 
 + (ASHomeCategoryModel *)demoModel;
 
+- (ASJumpModel *)toJumpM;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 9 - 0
Asteria/Fuction/Home/Models/ASHomeCategoryModel.m

@@ -17,4 +17,13 @@
     return m;
 }
 
+- (ASJumpModel *)toJumpM {
+    ASJumpModel *m = [ASJumpModel new];
+    m.title = self.title;
+    m.type = self.type;
+    m.link = self.typeId;
+    m.image = self.imgUrl;
+    return m;
+}
+
 @end

+ 3 - 2
Asteria/Fuction/Home/Models/ASHomeMainListModel.h

@@ -8,6 +8,7 @@
 #import <Foundation/Foundation.h>
 #import "ASProductBaseModel.h"
 #import "ASHomeCategoryModel.h"
+#import "ASJumpModel.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -18,13 +19,13 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic,copy) NSString *subtitle;
 @property (nonatomic,copy) NSString *imgUrl;
 @property (nonatomic,copy) NSString *typeId;
-@property (nonatomic,copy) NSString *webUrl;
-@property (nonatomic,copy) NSString *videoUrl;
 @property (nonatomic,assign) NSTimeInterval endtime;
 @property (nonatomic,strong) NSArray<ASProductBaseModel *> *productList;
 @property (nonatomic,strong) NSMutableArray<ASHomeCategoryModel *> *titleArr;
 
+@property (nonatomic, copy) NSString *type;
 
+- (ASJumpModel *)toJumpM;
 
 + (NSArray <ASHomeMainListModel *>*)homeDemoDatas;
 

+ 22 - 1
Asteria/Fuction/Home/Models/ASHomeMainListModel.m

@@ -9,6 +9,28 @@
 
 @implementation ASHomeMainListModel
 
++ (NSDictionary *)mj_objectClassInArray{
+    
+    return @{
+        @"productList" : [ASProductBaseModel class],
+        @"titleArr" : [ASHomeCategoryModel class],
+        
+    };
+    
+    
+    
+}
+
+- (ASJumpModel *)toJumpM {
+    ASJumpModel *m = [ASJumpModel new];
+    m.title = self.title;
+    m.type = self.type;
+    m.link = self.typeId;
+    m.image = self.imgUrl;
+    return m;
+}
+
+
 + (NSArray <ASHomeMainListModel *>*)homeDemoDatas {
     ASHomeMainListModel *cateM = [ASHomeMainListModel cateList];
     ASHomeMainListModel *tipM = [ASHomeMainListModel tipList];
@@ -96,7 +118,6 @@
     ASHomeMainListModel *model = [ASHomeMainListModel new];
     model.showType = 5;
     model.title = @"wholesale";
-    model.webUrl = @"https://www.asteriahair.com/wholesale";
     model.imgUrl = @"https://img-qn.51miz.com/Element/00/64/88/86/ecec8108_E648886_37e0b3c6.jpg";
     return model;
 }

+ 0 - 1
Asteria/Fuction/Home/Views/ASHomeFlashDealCell.m

@@ -21,7 +21,6 @@
 - (void)setModel:(ASHomeMainListModel *)model {
     [super setModel:model];
     self.titleLb.text = model.title;
-    
     NSTimeInterval elseTime = model.endtime - [[NSDate date] timeIntervalSince1970];
     if (elseTime <= 0) {
         [self.timerV setHidden:true];

+ 2 - 1
Asteria/Fuction/Home/Views/ASHomeLookingCell.m

@@ -27,6 +27,7 @@
 - (void)setModel:(ASHomeMainListModel *)model {
     _model = model;
     self.titleLb.text = model.title;
+    self.offsetV.hidden = model.titleArr.count <= 1;
     [self.collectV reloadData];
     
     
@@ -96,7 +97,7 @@
     }
     CGFloat offset = scrollView.contentOffset.x;
     CGFloat itemWidth = (KScreenWidth-20);
-    NSArray<ASProductBaseModel*> *arr = self.model.productList;
+    NSArray<ASHomeCategoryModel*> *arr = self.model.titleArr;
     if (arr.count > 0) {
         CGFloat maxOffset = (arr.count * (itemWidth + 10) - 10 ) - (KScreenWidth-20);
         self.offsetV.offset = offset/maxOffset;

+ 1 - 0
Asteria/Fuction/Home/Views/ASHomeNewInCellTableViewCell.h

@@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
 @interface ASHomeNewInCellTableViewCell : UITableViewCell
 
 @property (nonatomic, copy) void(^productClick)(NSInteger i, ASProductBaseModel *m);
+@property (nonatomic, copy) void(^addCartBlock)(NSInteger i, ASProductBaseModel *m);
 
 //
 -(void)setData:(ASHomeMainListModel *)model;

+ 7 - 0
Asteria/Fuction/Home/Views/ASHomeNewInCellTableViewCell.m

@@ -33,6 +33,7 @@
 -(void)setData:(ASHomeMainListModel *)model {
     self.model = model;
     self.titleLb.text = self.model.title;
+    self.offsetV.hidden = model.productList.count <= 1;
     [self.collectV reloadData];
 }
 
@@ -154,6 +155,12 @@
     NSArray<ASProductBaseModel*> *arr = self.model.productList;
     ASProductBaseModel *m = arr[indexPath.row];
     cell.model = m;
+    __weak typeof(self) weakSelf = self;
+    cell.contView.addCartBlock = ^(ASProductBaseModel * _Nonnull model) {
+        if (weakSelf.addCartBlock) {
+            weakSelf.addCartBlock(indexPath.row, model);
+        }
+    };
     return cell;
 }
 

+ 4 - 0
Asteria/Fuction/Home/vm/ASHomeViewModel.h

@@ -7,6 +7,7 @@
 
 #import <Foundation/Foundation.h>
 #import "ASJumpModel.h"
+#import "ASHomeMainListModel.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -15,7 +16,10 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, strong) NSMutableArray<ASJumpModel *> *banners;
 @property (nonatomic, strong) NSMutableArray<ASJumpModel *> *categorys;
 
+@property (nonatomic, strong) NSMutableArray<ASHomeMainListModel *> *listData;
+
 -(void)getHomeTopData:(btnClickBlock)success;
+-(void)getHomeListData:(btnClickBlock)success;
 
 
 @end

+ 17 - 3
Asteria/Fuction/Home/vm/ASHomeViewModel.m

@@ -28,20 +28,34 @@
 -(void)getHomeTopData:(btnClickBlock)success {
     __weak typeof(self) weakSelf = self;
     [ASNetTools.shared getMsgWithPath:homeTop param:@{} success:^(id _Nonnull json) {
-        NSLog(@"------url:%@---json:%@------", getHotList, json);
+        NSLog(@"------url:%@---json:%@------", homeTop, json);
         NSMutableArray *arr = [ASJumpModel mj_objectArrayWithKeyValuesArray:json[@"banner"]];
-        weakSelf.banners = arr;
         NSMutableArray *cateArr = [ASJumpModel mj_objectArrayWithKeyValuesArray:json[@"category"]];
         weakSelf.banners = arr;
         weakSelf.categorys = cateArr;
         success();
     } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
-        NSLog(@"------url:%@---code:%@---msg:%@---", getHotList, code, msg);
+        NSLog(@"------url:%@---code:%@---msg:%@---", homeTop, code, msg);
         weakSelf.banners = [NSMutableArray array];
         weakSelf.categorys = [NSMutableArray array];
         success();
     }];
 }
 
+-(void)getHomeListData:(btnClickBlock)success {
+    __weak typeof(self) weakSelf = self;
+    [ASNetTools.shared getMsgWithPath:HomeList param:@{} success:^(id _Nonnull json) {
+        NSLog(@"------url:%@---json:%@------", HomeList, json);
+        NSMutableArray *arr = [ASHomeMainListModel mj_objectArrayWithKeyValuesArray:json];
+        weakSelf.listData = arr;
+        
+        success();
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        NSLog(@"------url:%@---code:%@---msg:%@---", HomeList, code, msg);
+        weakSelf.listData = [NSMutableArray array];
+        success();
+    }];
+}
+
 
 @end

+ 2 - 0
Asteria/NetTools/ASNetApis.h

@@ -33,12 +33,14 @@
 
 // MARK: - Home
 #define homeTop MsgRequestrUrl(@"appindex/getIndexOne")
+#define HomeList MsgRequestrUrl(@"appindex/getIndexTwo")
 
 /// 国家列表
 #define CountryList BaseRequestrUrl(@"directory/countries")
 
 // MARK: - 商品列表
 #define getProductListUrl BaseRequestrUrl(@"rewrite/categories/%@/products")
+#define getProdectDetail BaseRequestrUrl(@"rewrite/product/getProductsById")
 
 // MARK: - 货币
 #define getAllCurrencyUrl BaseRequestrUrl(@"directory/currency")