Browse Source

首页顶部数据接口对接
增加接口域名和解析配置

Abel 1 năm trước cách đây
mục cha
commit
eec85ba1c5

+ 12 - 0
Asteria.xcodeproj/project.pbxproj

@@ -128,6 +128,8 @@
 		8193491C2BF1EB6F009FDDB2 /* ASOrderListSubController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8193491B2BF1EB6F009FDDB2 /* ASOrderListSubController.m */; };
 		819349212BF218B6009FDDB2 /* ASOrderListViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 819349202BF218B6009FDDB2 /* ASOrderListViewModel.m */; };
 		819349262BF34722009FDDB2 /* ASOrderListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 819349252BF34722009FDDB2 /* ASOrderListCell.m */; };
+		819349302BF59000009FDDB2 /* ASHomeViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8193492F2BF59000009FDDB2 /* ASHomeViewModel.m */; };
+		819349352BF5A679009FDDB2 /* ASJumpModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 819349342BF5A679009FDDB2 /* ASJumpModel.m */; };
 		8193D5C82BEA299F00B9AB11 /* ASAddressListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8193D5C72BEA299F00B9AB11 /* ASAddressListViewController.m */; };
 		8193D5CB2BEA2A0800B9AB11 /* ASMineAddressModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8193D5CA2BEA2A0800B9AB11 /* ASMineAddressModel.m */; };
 		8193D5CE2BEA2B8E00B9AB11 /* ASAddressViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8193D5CD2BEA2B8E00B9AB11 /* ASAddressViewModel.m */; };
@@ -578,6 +580,10 @@
 		819349202BF218B6009FDDB2 /* ASOrderListViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASOrderListViewModel.m; sourceTree = "<group>"; };
 		819349242BF34722009FDDB2 /* ASOrderListCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASOrderListCell.h; sourceTree = "<group>"; };
 		819349252BF34722009FDDB2 /* ASOrderListCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASOrderListCell.m; sourceTree = "<group>"; };
+		8193492E2BF58FFF009FDDB2 /* ASHomeViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASHomeViewModel.h; sourceTree = "<group>"; };
+		8193492F2BF59000009FDDB2 /* ASHomeViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASHomeViewModel.m; sourceTree = "<group>"; };
+		819349332BF5A679009FDDB2 /* ASJumpModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASJumpModel.h; sourceTree = "<group>"; };
+		819349342BF5A679009FDDB2 /* ASJumpModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASJumpModel.m; sourceTree = "<group>"; };
 		8193D5C62BEA299F00B9AB11 /* ASAddressListViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASAddressListViewController.h; sourceTree = "<group>"; };
 		8193D5C72BEA299F00B9AB11 /* ASAddressListViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASAddressListViewController.m; sourceTree = "<group>"; };
 		8193D5C92BEA2A0800B9AB11 /* ASMineAddressModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASMineAddressModel.h; sourceTree = "<group>"; };
@@ -1551,6 +1557,10 @@
 			children = (
 				81C326682A36F035002EF442 /* ASProductListViewModel.h */,
 				81C326692A36F035002EF442 /* ASProductListViewModel.m */,
+				8193492E2BF58FFF009FDDB2 /* ASHomeViewModel.h */,
+				8193492F2BF59000009FDDB2 /* ASHomeViewModel.m */,
+				819349332BF5A679009FDDB2 /* ASJumpModel.h */,
+				819349342BF5A679009FDDB2 /* ASJumpModel.m */,
 			);
 			path = vm;
 			sourceTree = "<group>";
@@ -2895,6 +2905,7 @@
 				812021252B185A610026B8B5 /* ASCouponsListViewModel.m in Sources */,
 				9AD345FE2A08D60F005CA070 /* UIScrollView+ZFPlayer.m in Sources */,
 				9A65DE512A132FB700BB1269 /* LoginThirdAuthV.m in Sources */,
+				819349302BF59000009FDDB2 /* ASHomeViewModel.m in Sources */,
 				9A788C442A08A663003E0025 /* Target_Goods.m in Sources */,
 				8131A2902B38FF3B00A191BE /* APInputAlertView.m in Sources */,
 				9A5F52962B5F59EA007D3791 /* GoodsSizeCountCell.m in Sources */,
@@ -2980,6 +2991,7 @@
 				81DFA5782A47F28D00DA708B /* ASCouponListCell.m in Sources */,
 				8160201C2A2F101C00E4A8F1 /* ASHomeTipCell.m in Sources */,
 				9A8BED332B6B86A30080DA36 /* MyCartCouponCell.m in Sources */,
+				819349352BF5A679009FDDB2 /* ASJumpModel.m in Sources */,
 				81717D1E2A3C4AE000648139 /* KWSearchMainTypeTableView.m in Sources */,
 				81EC47662A33035D00516573 /* ASHomeNewInCellTableViewCell.m in Sources */,
 				9AD346162A08D60F005CA070 /* UIImageView+ZFCache.m in Sources */,

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

@@ -6,6 +6,7 @@
 //
 
 #import <UIKit/UIKit.h>
+#import "ASJumpModel.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -36,6 +37,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 - (void)toLoginVC;
 
+- (void)jumpWithModel:(ASJumpModel *)model;
+
 @end
 
 NS_ASSUME_NONNULL_END

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

@@ -31,6 +31,10 @@
 
 @implementation ASBaseViewController
 
+- (void)jumpWithModel:(ASJumpModel *)model {
+    
+}
+
 - (void)toHomeVc {
     if (self.navigationController != nil) {
         [self.navigationController popToRootViewControllerAnimated:false];

+ 34 - 32
Asteria/Fuction/Home/ASHomeViewController.m

@@ -17,10 +17,12 @@
 #import "ASHomeActiveView.h"
 #import "ASProductListViewController.h"
 #import "ASProductListViewModel.h"
+#import "ASHomeViewModel.h"
 
 @interface ASHomeViewController ()<UITableViewDelegate,UITableViewDataSource>
 
 @property (nonatomic, strong) ASProductListViewModel *topVm;
+@property (nonatomic, strong) ASHomeViewModel *vm;
 
 @property (nonatomic, strong) UITableView *tableV;
 @property (nonatomic, strong) NSArray <ASHomeMainListModel*>*listArr;
@@ -33,7 +35,7 @@
 
 - (void)viewDidLoad {
     [super viewDidLoad];
-    
+    self.vm = [ASHomeViewModel new];
     self.topVm = [ASProductListViewModel new];
     
     __block typeof(self) wSelf = self;
@@ -50,7 +52,6 @@
 
 - (void)demoData {
     _listArr = [ASHomeMainListModel homeDemoDatas];
-    
 }
 
 - (void)getTopLinkData {
@@ -60,6 +61,13 @@
     }];
 }
 
+- (void)getHomeTopData {
+    __weak typeof(self) weakSelf = self;
+    [self.vm getHomeTopData:^{
+        [weakSelf.tableV reloadData];
+    }];
+}
+
 - (void)updateTopLinkData {
     if (self.topVm.topLinks.count > 0) {
         self.activeV = [[ASHomeActiveView alloc] initWithFrame:CGRectZero];
@@ -86,6 +94,7 @@
     __weak typeof(self) weakSelf = self;
     self.tableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
         [weakSelf getTopLinkData];
+        [weakSelf getHomeTopData];
         
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1), dispatch_get_main_queue(), ^{
             
@@ -108,13 +117,20 @@
 // MARK: - UITableViewDataSource
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
 {
-    return self.listArr.count + 1;
+    return self.listArr.count + 2;
 }
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {
     
     switch (section) {
+        case 0:// banner
+            return self.vm.banners.count > 0 ? 1 : 0;
+            break;
+        case 1:// category
+            return self.vm.categorys.count > 0 ? 1 : 0;
+            break;
+            
         default:
             return 1;
     }
@@ -126,45 +142,32 @@
         ASHomeBannerCell *bcell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeBannerCell" forIndexPath:indexPath];
         @weakify(self);
         bcell.selectCallBack = ^(NSInteger index, NSString * _Nonnull title, NSString * _Nonnull typeId, id  _Nonnull model) {
-            if (model == nil || ![model isKindOfClass:[ASHomeBannerModel class]]) {
-                return;
-            }
-            ASHomeBannerModel *m = (ASHomeBannerModel *)model;
-            if (m.type == 1) {
-//                [self goto_WKM_GoodsDetailsC:m.tapUrl];
+            if (model == nil || ![model isKindOfClass:[ASJumpModel class]]) {
                 return;
             }
-            if (m.type == 2) {
-//                NSString *typeId = m.tapUrl;
-//                [self pushToProductList:@"Products" typeid:typeId];
-                return;
-            }
-            if ([m.tapUrl.lowercaseString hasPrefix:@"http"]) {
-//                [self toWebVC:m.tapUrl name:@"Alipearl"];
-            }
+            ASJumpModel *m = (ASJumpModel *)model;
+            [weak_self jumpWithModel:m];
         };
-        NSMutableArray *arr = [NSMutableArray array];
-        for (int i=0; i<6; i++) {
-            ASHomeBannerModel *m = [ASHomeBannerModel demoModelWithType:i%3];
-            [arr addObject:m];
-        }
-        [bcell showData:arr];
+        
+        [bcell showData:self.vm.banners];
         return  bcell;
     }
+    if (indexPath.section == 1) { // category
+        ASCategaryListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASCategaryListCell" forIndexPath:indexPath];
+        cell.arr = self.vm.categorys;
+        cell.selectCategory = ^(ASJumpModel * _Nonnull model, NSIndexPath * _Nonnull index) {
+            // TODO: - to productlist
+            [self jumpWithModel:model];
+        };
+        return cell;
+    }
     if (self.listArr.count <= indexPath.row) {
         return [UITableViewCell new];
     }
     ASHomeMainListModel *m = self.listArr[indexPath.section-1];
     switch (m.showType) {
         case 1: { // 分类
-            ASCategaryListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASCategaryListCell" forIndexPath:indexPath];
-            cell.arr = m.titleArr;
-            cell.selectCategory = ^(ASHomeCategoryModel * _Nonnull model, NSIndexPath * _Nonnull index) {
-                // TODO: - to productlist
-                [self pushToProductList:model.typeId title:model.title];
-                [ASNetTools debugRegist];
-            };
-            return cell;
+            
         }
         case 2: { // tips
             ASHomeTipCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeTipCell" forIndexPath:indexPath];
@@ -173,7 +176,6 @@
         case 3: {// bestSell
             ASHomeBestSellCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeBestSellCell" forIndexPath:indexPath];
             cell.productClick = ^(NSInteger i, ASProductBaseModel * _Nonnull m) {
-                [ASNetTools login];
             };
             cell.model = m;
             return cell;

+ 3 - 3
Asteria/Fuction/Home/Views/ASCategaryListCell.h

@@ -6,14 +6,14 @@
 //
 
 #import <UIKit/UIKit.h>
-#import "ASHomeCategoryModel.h"
+#import "ASJumpModel.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
 @interface ASCategaryListCell : UITableViewCell
 
-@property (nonatomic, strong) NSArray <ASHomeCategoryModel *>*arr;
-@property (nonatomic, copy) void(^selectCategory)(ASHomeCategoryModel *model,NSIndexPath *index);
+@property (nonatomic, strong) NSArray <ASJumpModel *>*arr;
+@property (nonatomic, copy) void(^selectCategory)(ASJumpModel *model,NSIndexPath *index);
 
 @end
 

+ 5 - 4
Asteria/Fuction/Home/Views/ASCategaryListCell.m

@@ -7,6 +7,7 @@
 
 #import "ASCategaryListCell.h"
 #import "ASCategaryCollectCell.h"
+#import "ASJumpModel.h"
 
 @interface ASCategaryListCell () <UICollectionViewDelegate,UICollectionViewDataSource>
 
@@ -16,7 +17,7 @@
 
 @implementation ASCategaryListCell
 
-- (void)setArr:(NSArray<ASHomeCategoryModel *> *)arr {
+- (void)setArr:(NSArray<ASJumpModel *> *)arr {
     _arr = arr;
     [self.collV reloadData];
 }
@@ -80,8 +81,8 @@
     if (self.arr.count <= indexPath.row) {
         return cell;
     }
-    ASHomeCategoryModel *m = self.arr[indexPath.row];
-    [cell.imgV sd_setImageWithURL:[NSURL URLWithString:m.imgUrl]];
+    ASJumpModel *m = self.arr[indexPath.row];
+    [cell.imgV sd_setImageWithURL:[NSURL URLWithString:m.image]];
     cell.titleLb.text = m.title;
     return cell;
 }
@@ -90,7 +91,7 @@
     if (self.arr.count <= indexPath.row) {
         return ;
     }
-    ASHomeCategoryModel *m = self.arr[indexPath.row];
+    ASJumpModel *m = self.arr[indexPath.row];
     if (self.selectCategory) {
         self.selectCategory(m, indexPath);
     }

+ 2 - 2
Asteria/Fuction/Home/Views/ASHomeBannerCell.h

@@ -6,14 +6,14 @@
 //
 
 #import <UIKit/UIKit.h>
-#import "ASHomeBannerModel.h"
+#import "ASJumpModel.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
 @interface ASHomeBannerCell : UITableViewCell
 
 @property (nonatomic, copy) void(^selectCallBack)(NSInteger index, NSString *title, NSString *typeId,id model);
-- (void)showData:(NSArray <ASHomeBannerModel*>*)arr;
+- (void)showData:(NSArray <ASJumpModel*>*)arr;
 
 
 @end

+ 5 - 5
Asteria/Fuction/Home/Views/ASHomeBannerCell.m

@@ -17,13 +17,13 @@
 
 @implementation ASHomeBannerCell
 
-- (void)showData:(NSArray <ASHomeBannerModel*>*)arr {
+- (void)showData:(NSArray <ASJumpModel*>*)arr {
     self.control.numberOfPages = arr.count;
     self.control.currentPage = 0;
     
     NSMutableArray *images = [NSMutableArray array];
-    for (ASHomeBannerModel *m in arr) {
-        [images addObject:m.imgUrl];
+    for (ASJumpModel *m in arr) {
+        [images addObject:m.image];
     }
     @weakify(self);
     CGFloat h = (KScreenWidth-10-30)/335*445;
@@ -39,8 +39,8 @@
         if (arr.count <= index) {
             return;
         }
-        ASHomeBannerModel *temp = arr[index];
-        weak_self.selectCallBack(index, temp.title, temp.tapUrl, temp);
+        ASJumpModel *temp = arr[index];
+        weak_self.selectCallBack(index, temp.title, temp.link, temp);
     })
     .wEventScrollEndSet(^(id anyID, NSInteger index, BOOL isCenter, UICollectionViewCell *cell) {
 //            NSLog(@"滚动到第%ld个,内容:%@",index,anyID);

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

@@ -0,0 +1,23 @@
+//
+//  ASHomeViewModel.h
+//  Asteria
+//
+//  Created by iOS on 2024/5/16.
+//
+
+#import <Foundation/Foundation.h>
+#import "ASJumpModel.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface ASHomeViewModel : NSObject
+
+@property (nonatomic, strong) NSMutableArray<ASJumpModel *> *banners;
+@property (nonatomic, strong) NSMutableArray<ASJumpModel *> *categorys;
+
+-(void)getHomeTopData:(btnClickBlock)success;
+
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 47 - 0
Asteria/Fuction/Home/vm/ASHomeViewModel.m

@@ -0,0 +1,47 @@
+//
+//  ASHomeViewModel.m
+//  Asteria
+//
+//  Created by iOS on 2024/5/16.
+//
+
+#import "ASHomeViewModel.h"
+
+@implementation ASHomeViewModel
+
+- (NSMutableArray<ASJumpModel *> *)banners {
+    if (!_banners) {
+        NSMutableArray *arr = [NSMutableArray array];
+        _banners = arr;
+    }
+    return _banners;
+}
+
+- (NSMutableArray<ASJumpModel *> *)categorys {
+    if (!_categorys) {
+        NSMutableArray *arr = [NSMutableArray array];
+        _categorys = arr;
+    }
+    return _categorys;
+}
+
+-(void)getHomeTopData:(btnClickBlock)success {
+    __weak typeof(self) weakSelf = self;
+    [ASNetTools.shared getMsgWithPath:homeTop param:@{} success:^(id _Nonnull json) {
+        NSLog(@"------url:%@---json:%@------", getHotList, 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);
+        weakSelf.banners = [NSMutableArray array];
+        weakSelf.categorys = [NSMutableArray array];
+        success();
+    }];
+}
+
+
+@end

+ 23 - 0
Asteria/Fuction/Home/vm/ASJumpModel.h

@@ -0,0 +1,23 @@
+//
+//  ASJumpModel.h
+//  Asteria
+//
+//  Created by iOS on 2024/5/16.
+//
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface ASJumpModel : NSObject
+
+@property (nonatomic, copy) NSString *title;
+@property (nonatomic, copy) NSString *name;
+@property (nonatomic, copy) NSString *link;
+/// 跳转类型   0 web  1商品详情  2商品列表   3koc  4:注册页
+@property (nonatomic, copy) NSString *type;
+@property (nonatomic, copy) NSString *image;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 12 - 0
Asteria/Fuction/Home/vm/ASJumpModel.m

@@ -0,0 +1,12 @@
+//
+//  ASJumpModel.m
+//  Asteria
+//
+//  Created by iOS on 2024/5/16.
+//
+
+#import "ASJumpModel.h"
+
+@implementation ASJumpModel
+
+@end

+ 5 - 0
Asteria/NetTools/ASNetApis.h

@@ -11,6 +11,7 @@
 
 #define RequestAllUrl(baseUrl) ([NSString stringWithFormat:@"https://%@/%@",HostPath,baseUrl])
 
+#define MsgRequestrUrl(url) ([NSString stringWithFormat:@"%@%@",@"api/",url])
 #define BaseRequestrUrl(url) ([NSString stringWithFormat:@"%@%@",@"rest/V1/",url])
 #define BaseWebUrl(url) ([NSString stringWithFormat:@"%@%@",@"rest/V1/",url])
 
@@ -19,6 +20,7 @@
 // MARK: - host
 #if (DEBUG)
 #define HostPath @"www.bilisar.com"  //测试
+#define MsgHostPath @"message.bilisar.com"
 //#define HostPath @"pc.bilisar.com"  //正式
 #else
 #define HostPath @"pc.bilisar.com" //正式
@@ -29,6 +31,9 @@
 #define ProductImgPath @"/media/catalog/product"
 #define CategoryImgPath @"/media/catalog/category/"
 
+// MARK: - Home
+#define homeTop MsgRequestrUrl(@"appindex/getIndexOne")
+
 /// 国家列表
 #define CountryList BaseRequestrUrl(@"directory/countries")
 

+ 15 - 0
Asteria/NetTools/ASNetTools.h

@@ -18,7 +18,22 @@ NS_ASSUME_NONNULL_BEGIN
 // 登录或者退出登录时调用;
 - (void)updateEngine;
 
+// MARK: - message和自定义请求
+/// post请求
+- (void)postMsgWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild;
+///formData
+- (void)formDataMsg_postWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild;
+
+/// get请求
+- (void)getMsgWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild;
+
+/// put请求
+- (void)putMsgWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild;
+
+/// delete请求
+- (void)delMsgWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild;
 
+// MARK: - 主站请求
 /// post请求
 - (void)postWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild;
 ///formData

+ 317 - 1
Asteria/NetTools/ASNetTools.m

@@ -13,6 +13,7 @@
 @property (nonatomic, copy) NSString *currentToken;
 
 @property (nonatomic, strong) MKNetworkEngine *engine;
+@property (nonatomic, strong) MKNetworkEngine *msgEngine;
 @property (nonatomic, strong) NSMutableDictionary *defuatParam;
 
 @end
@@ -59,6 +60,11 @@
         @"powerby": @"longyitec",
         @"Content-Type": @"application/json;charset=utf-8"
     }];
+    self.msgEngine = [[MKNetworkEngine alloc] initWithHostName:MsgHostPath customHeaderFields:@{
+        @"Authorization":token,
+        @"powerby": @"longyitec",
+        @"Content-Type": @"application/json;charset=utf-8"
+    }];
     
 }
 
@@ -73,6 +79,316 @@
     }
 }
 
+// MARK: - message Api
+// post请求
+- (void)postMsgWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild {
+    BOOL isSSL = true;
+    [self checkToken];
+    NSMutableDictionary *tempDic = [[NSMutableDictionary alloc] initWithDictionary:self.defuatParam];
+    [tempDic addEntriesFromDictionary:param];
+    MKNetworkOperation *op = [self.msgEngine operationWithPath:path params:tempDic httpMethod:@"POST" ssl:isSSL];
+    [op setPostDataEncoding:MKNKPostDataEncodingTypeJSON];
+    __weak typeof(self) weakSelf = self;
+    [op onCompletion:^(MKNetworkOperation *completedOperation) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSString *json = [op responseJSON];
+            id temp = [json mj_JSONObject];
+            NSLog(@"---Get-----url:\n%@\n-----data:\n%@\n--",path, temp);
+            if ([temp isKindOfClass:[NSDictionary class]]) {
+                NSDictionary *result = (NSDictionary *)temp;
+                NSString *code = [NSString stringWithFormat:@"%@", result[@"code"]];
+                id data = result[@"data"];
+                if ([code isEqualToString:@"200"]) {
+                    success(data);
+                } else {
+                    NSString *msg = result[@"msg"];
+                    faild(code, msg);
+                }
+            }
+            
+        });
+    } onError:^(NSError *error) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSString *json = [op responseJSON];
+            id temp = [json mj_JSONObject];
+            if ([temp isKindOfClass:[NSDictionary class]]) {
+                NSDictionary *result = (NSDictionary *)temp;
+                NSString *status = result[@"code"];
+                NSString *msg = result[@"msg"];
+                if (error.code == 401) {
+                    [DataUtil setLoginToken:@""];
+                    [weakSelf updateEngine];
+                    faild(status, msg);
+                    return;
+                }
+                faild(status, msg);
+                return;
+            }
+            if (error.code == 401) {
+                [DataUtil setLoginToken:@""];
+                [weakSelf updateEngine];
+                faild(@"-1", @"Plase Login");
+                return;
+            }
+            faild([NSString stringWithFormat:@"%ld", error.code], error.localizedDescription);
+        });
+    }];
+//    dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{
+        [self.msgEngine enqueueOperation:op];
+//    });
+}
+
+// formData的post请求
+- (void)formDataMsg_postWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild {
+    BOOL isSSL = true;
+    [self checkToken];
+    NSMutableDictionary *tempDic = [[NSMutableDictionary alloc] initWithDictionary:self.defuatParam];
+    [tempDic addEntriesFromDictionary:param];
+    MKNetworkOperation *op = [self.msgEngine operationWithPath:path params:tempDic httpMethod:@"POST" ssl:isSSL];
+    ///form-data 的请求格式
+    NSData *data = [NSJSONSerialization dataWithJSONObject:param options:NSJSONWritingPrettyPrinted error:nil];
+    
+    for (NSString *key in param.allKeys) {
+           // 循环拿到所有参数进行拼接
+//        NSString * searchStr = [param[key] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
+        
+        NSString * searchStr = param[key];
+        NSData *data =[searchStr dataUsingEncoding:NSUTF8StringEncoding];
+        [op addData:data forKey:key];
+       }
+    __weak typeof(self) weakSelf = self;
+    [op onCompletion:^(MKNetworkOperation *completedOperation) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSString *json = [op responseJSON];
+            id temp = [json mj_JSONObject];
+            NSLog(@"---Get-----url:\n%@\n-----data:\n%@\n--",path, temp);
+            if ([temp isKindOfClass:[NSDictionary class]]) {
+                NSDictionary *result = (NSDictionary *)temp;
+                NSString *code = [NSString stringWithFormat:@"%@", result[@"code"]];
+                id data = result[@"data"];
+                if ([code isEqualToString:@"200"]) {
+                    success(data);
+                } else {
+                    NSString *msg = result[@"msg"];
+                    faild(code, msg);
+                }
+            }
+            
+        });
+    } onError:^(NSError *error) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSString *json = [op responseJSON];
+            id temp = [json mj_JSONObject];
+            if ([temp isKindOfClass:[NSDictionary class]]) {
+                NSDictionary *result = (NSDictionary *)temp;
+                NSString *status = result[@"code"];
+                NSString *msg = result[@"msg"];
+                if (error.code == 401) {
+                    [DataUtil setLoginToken:@""];
+                    [weakSelf updateEngine];
+                    faild(status, msg);
+                    return;
+                }
+                faild(status, msg);
+                return;
+            }
+            if (error.code == 401) {
+                [DataUtil setLoginToken:@""];
+                [weakSelf updateEngine];
+                faild(@"-1", @"Plase Login");
+                return;
+            }
+            faild([NSString stringWithFormat:@"%ld", error.code], error.localizedDescription);
+        });
+    }];
+//    dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{
+        [self.msgEngine enqueueOperation:op];
+//    });
+}
+
+// get 请求
+- (void)getMsgWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild {
+    BOOL isSSL = true;
+    [self checkToken];
+    NSMutableDictionary *tempDic = [[NSMutableDictionary alloc] initWithDictionary:self.defuatParam];
+    [tempDic addEntriesFromDictionary:param];
+    MKNetworkOperation *op = [self.msgEngine operationWithPath:path params:tempDic httpMethod:@"GET" ssl:isSSL];
+    __weak typeof(self) weakSelf = self;
+    [op onCompletion:^(MKNetworkOperation *completedOperation) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSString *json = [op responseJSON];
+            id temp = [json mj_JSONObject];
+            NSLog(@"---Get-----url:\n%@\n-----data:\n%@\n--",path, temp);
+            if ([temp isKindOfClass:[NSDictionary class]]) {
+                NSDictionary *result = (NSDictionary *)temp;
+                NSString *code = [NSString stringWithFormat:@"%@", result[@"code"]];
+                id data = result[@"data"];
+                if ([code isEqualToString:@"200"]) {
+                    success(data);
+                } else {
+                    NSString *msg = result[@"msg"];
+                    faild(code, msg);
+                }
+            }
+            
+        });
+    } onError:^(NSError *error) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSString *json = [op responseJSON];
+            id temp = [json mj_JSONObject];
+            if ([temp isKindOfClass:[NSDictionary class]]) {
+                NSDictionary *result = (NSDictionary *)temp;
+                NSString *status = result[@"code"];
+                NSString *msg = result[@"msg"];
+                if (error.code == 401) {
+                    [DataUtil setLoginToken:@""];
+                    [weakSelf updateEngine];
+                    faild(status, msg);
+                    return;
+                }
+                faild(status, msg);
+                return;
+            }
+            if (error.code == 401) {
+                [DataUtil setLoginToken:@""];
+                [weakSelf updateEngine];
+                faild(@"-1", @"Plase Login");
+                return;
+            }
+            faild([NSString stringWithFormat:@"%ld", error.code], error.localizedDescription);
+        });
+    }];
+    [self.msgEngine enqueueOperation:op];
+//    dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{
+//    });
+
+}
+
+// put 请求
+- (void)putMsgWithPath:(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.msgEngine operationWithPath:path params:tempDic httpMethod:@"PUT" ssl:isSSL];
+    [op setPostDataEncoding:MKNKPostDataEncodingTypeJSON];
+    __weak typeof(self) weakSelf = self;
+    [op onCompletion:^(MKNetworkOperation *completedOperation) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSString *json = [op responseJSON];
+            id temp = [json mj_JSONObject];
+            NSLog(@"---Get-----url:\n%@\n-----data:\n%@\n--",path, temp);
+            if ([temp isKindOfClass:[NSDictionary class]]) {
+                NSDictionary *result = (NSDictionary *)temp;
+                NSString *code = [NSString stringWithFormat:@"%@", result[@"code"]];
+                id data = result[@"data"];
+                if ([code isEqualToString:@"200"]) {
+                    success(data);
+                } else {
+                    NSString *msg = result[@"msg"];
+                    faild(code, msg);
+                }
+            }
+            
+        });
+    } onError:^(NSError *error) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSString *json = [op responseJSON];
+            id temp = [json mj_JSONObject];
+            if ([temp isKindOfClass:[NSDictionary class]]) {
+                NSDictionary *result = (NSDictionary *)temp;
+                NSString *status = result[@"code"];
+                NSString *msg = result[@"msg"];
+                if (error.code == 401) {
+                    [DataUtil setLoginToken:@""];
+                    [weakSelf updateEngine];
+                    faild(status, msg);
+                    return;
+                }
+                faild(status, msg);
+                return;
+            }
+            if (error.code == 401) {
+                [DataUtil setLoginToken:@""];
+                [weakSelf updateEngine];
+                faild(@"-1", @"Plase Login");
+                return;
+            }
+            faild([NSString stringWithFormat:@"%ld", error.code], error.localizedDescription);
+        });
+    }];
+//    dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{
+        [self.msgEngine enqueueOperation:op];
+//    });
+
+}
+
+// del 请求
+- (void)delMsgWithPath:(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.msgEngine operationWithPath:path params:tempDic httpMethod:@"DELETE" ssl:isSSL];
+    [op setPostDataEncoding:MKNKPostDataEncodingTypeJSON];
+    __weak typeof(self) weakSelf = self;
+    [op onCompletion:^(MKNetworkOperation *completedOperation) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSString *json = [op responseJSON];
+            id temp = [json mj_JSONObject];
+            NSLog(@"---Get-----url:\n%@\n-----data:\n%@\n--",path, temp);
+            if ([temp isKindOfClass:[NSDictionary class]]) {
+                NSDictionary *result = (NSDictionary *)temp;
+                NSString *code = [NSString stringWithFormat:@"%@", result[@"code"]];
+                id data = result[@"data"];
+                if ([code isEqualToString:@"200"]) {
+                    success(data);
+                } else {
+                    NSString *msg = result[@"msg"];
+                    faild(code, msg);
+                }
+            }
+            
+        });
+    } onError:^(NSError *error) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSString *json = [op responseJSON];
+            id temp = [json mj_JSONObject];
+            if ([temp isKindOfClass:[NSDictionary class]]) {
+                NSDictionary *result = (NSDictionary *)temp;
+                NSString *status = result[@"code"];
+                NSString *msg = result[@"msg"];
+                if (error.code == 401) {
+                    [DataUtil setLoginToken:@""];
+                    [weakSelf updateEngine];
+                    faild(status, msg);
+                    return;
+                }
+                faild(status, msg);
+                return;
+            }
+            if (error.code == 401) {
+                [DataUtil setLoginToken:@""];
+                [weakSelf updateEngine];
+                faild(@"-1", @"Plase Login");
+                return;
+            }
+            faild([NSString stringWithFormat:@"%ld", error.code], error.localizedDescription);
+        });
+    }];
+//    dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{
+        [self.msgEngine enqueueOperation:op];
+//    });
+
+}
+
+// MARK: - api V1
 // post请求
 - (void)postWithPath:(NSString *)path param:(NSDictionary *)param success:(void(^)(id))success faild:(void(^)(NSString *code, NSString *msg))faild {
     BOOL isSSL = true;
@@ -380,7 +696,7 @@
 }
 
 
-
+// MARK: - debug
 + (void)debugRegist {
     NSDictionary *param = @{
         @"customer": @{