Browse Source

feat:设置币种接口联调

“wangdongchao” 1 year ago
parent
commit
92b9422905

+ 24 - 3
Asteria/Fuction/Category/vc/ASCategoryViewController.m

@@ -57,7 +57,28 @@
     }];
     }];
 }
 }
 
 
-
+//设置币种
+- (void)requestSetCurrency:(NSString *)currency {
+    
+    NSDictionary *param = @{@"currency_code":currency};
+    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+    K_WEAK_SELF;
+    [self.vm setAllCurrencyToService:param complete:^(BOOL isSuc, NSString * _Nonnull msg) {
+        K_STRONG_SELF;
+        [MBProgressHUD hideHUDForView:self.view animated:YES];
+        if (isSuc) {
+            [self.view makeToast:@"Success" duration:2 position:CSToastPositionCenter];
+            [ASCurrencyManager.shared setSelectCurrency:currency];
+            [self.rightTableV reloadData];
+        } else {
+            if (AS_String_valid(msg)) {
+                [self.view makeToast:msg duration:2 position:CSToastPositionCenter];
+            } else {
+                [self.view makeToast:@"failed" duration:2 position:CSToastPositionCenter];
+            }
+        }
+    }];
+}
 
 
 - (void)loadSubVs {
 - (void)loadSubVs {
     self.statusBgV.backgroundColor = _E0FFF5;
     self.statusBgV.backgroundColor = _E0FFF5;
@@ -141,8 +162,8 @@
         [_rightTableV setCallBackSection:^(NSInteger index) {
         [_rightTableV setCallBackSection:^(NSInteger index) {
             KWSubTypeSectionModel *m = weak_self.rightTableV.arr[index];
             KWSubTypeSectionModel *m = weak_self.rightTableV.arr[index];
             if (m.isMoneyType) {
             if (m.isMoneyType) {
-                [ASCurrencyManager.shared setSelectCurrency:m.title];
-                [weak_self.rightTableV reloadData];
+                [weak_self requestSetCurrency:m.title];
+                
                 return;
                 return;
             }
             }
             [weak_self toResult:m.title type:m.Id keyWord:@""];
             [weak_self toResult:m.title type:m.Id keyWord:@""];

+ 2 - 0
Asteria/Fuction/Category/vm/ASCategoriesViewModel.h

@@ -16,6 +16,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 - (void)getAllCateGories:(NSString *)baseID com:(void(^)(BOOL isSuc, NSString *msg))comp;
 - (void)getAllCateGories:(NSString *)baseID com:(void(^)(BOOL isSuc, NSString *msg))comp;
 
 
+- (void)setAllCurrencyToService:(NSDictionary *)param complete:(void(^)(BOOL isSuc, NSString *msg))completeBlock;
+
 @end
 @end
 
 
 NS_ASSUME_NONNULL_END
 NS_ASSUME_NONNULL_END

+ 10 - 0
Asteria/Fuction/Category/vm/ASCategoriesViewModel.m

@@ -34,6 +34,16 @@
     }];
     }];
 }
 }
 
 
+- (void)setAllCurrencyToService:(NSDictionary *)param complete:(void(^)(BOOL isSuc, NSString *msg))completeBlock {
+
+    [ASNetTools.shared formData_postWithPath:setAllCurrencyUrl param:param success:^(id _Nonnull json) {
+        BOOL isSuccess = [json boolValue];
+        completeBlock(isSuccess, @"");
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        completeBlock(NO, msg);
+    }];
+}
+
 - (void)addCurrencyData {
 - (void)addCurrencyData {
     NSMutableArray *subArr = [[NSMutableArray alloc] init];
     NSMutableArray *subArr = [[NSMutableArray alloc] init];
     for (NSString *dic in ASCurrencyManager.shared.avaiCurencys) {
     for (NSString *dic in ASCurrencyManager.shared.avaiCurencys) {

+ 2 - 0
Asteria/NetTools/ASNetApis.h

@@ -47,6 +47,8 @@
 
 
 // MARK: - 分类列表
 // MARK: - 分类列表
 #define getAllCategoriesUrl BaseRequestrUrl(@"rewrite/categories")
 #define getAllCategoriesUrl BaseRequestrUrl(@"rewrite/categories")
+//设置币种
+#define setAllCurrencyUrl   BaseRequestrUrl(@"currency")
 // 热词
 // 热词
 #define getHotList BaseRequestrUrl(@"hot/index")
 #define getHotList BaseRequestrUrl(@"hot/index")
 // 联想词
 // 联想词

+ 2 - 0
Asteria/NetTools/ASNetTools.m

@@ -396,12 +396,14 @@
     NSMutableDictionary *tempDic = [[NSMutableDictionary alloc] initWithDictionary:self.defuatParam];
     NSMutableDictionary *tempDic = [[NSMutableDictionary alloc] initWithDictionary:self.defuatParam];
     [tempDic addEntriesFromDictionary:param];
     [tempDic addEntriesFromDictionary:param];
     MKNetworkOperation *op = [self.engine operationWithPath:path params:tempDic httpMethod:@"POST" ssl:isSSL];
     MKNetworkOperation *op = [self.engine operationWithPath:path params:tempDic httpMethod:@"POST" ssl:isSSL];
+    
     [op setPostDataEncoding:MKNKPostDataEncodingTypeJSON];
     [op setPostDataEncoding:MKNKPostDataEncodingTypeJSON];
     __weak typeof(self) weakSelf = self;
     __weak typeof(self) weakSelf = self;
     [op onCompletion:^(MKNetworkOperation *completedOperation) {
     [op onCompletion:^(MKNetworkOperation *completedOperation) {
         dispatch_async(dispatch_get_main_queue(), ^{
         dispatch_async(dispatch_get_main_queue(), ^{
             NSString *json = [op responseJSON];
             NSString *json = [op responseJSON];
             id temp = [json mj_JSONObject];
             id temp = [json mj_JSONObject];
+            NSLog(@"---Post-----url:\n%@\n-----param:\n%@\n-----data:\n%@\n--",path, param, temp);
             if ([temp isKindOfClass:[NSDictionary class]]) {
             if ([temp isKindOfClass:[NSDictionary class]]) {
                 NSDictionary *result = (NSDictionary *)temp;
                 NSDictionary *result = (NSDictionary *)temp;
                 NSString *status = [NSString stringWithFormat:@"%@", result[@"status"]];
                 NSString *status = [NSString stringWithFormat:@"%@", result[@"status"]];