NetHttpsManager+Store.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // NetHttpsManager+Store.m
  3. // BuguLive
  4. //
  5. // Created by qitewei on 2025/8/20.
  6. // Copyright © 2025 xfg. All rights reserved.
  7. //
  8. #import "NetHttpsManager+Store.h"
  9. #import "AFNetworking.h"
  10. #import "AFHTTPSessionManager+Singlton.h"
  11. @implementation NetHttpsManager (Store)
  12. - (void)storeGETWithPath:(NSString *)path SuccessBlock:(SuccessBlock)GetSuccess FailureBlock:(FailureBlock)GetFailure {
  13. NSMutableDictionary *headers = [self getHeader];
  14. NSString *url = [self URLWithPath:path];
  15. [self GETWithUrl:url headers:headers SuccessBlock:GetSuccess FailureBlock:GetFailure];
  16. }
  17. - (void)storePOSTWithPath:(NSString *)path paramDict:(NSMutableDictionary *)paramDict SuccessBlock:(SuccessBlock)PostSuccess FailureBlock:(FailureBlock)PostFailure {
  18. if (![NetWorkManager isExistenceNetwork])
  19. {
  20. NSLog(@"请检查当前网络");
  21. }
  22. else
  23. {
  24. NSString *urlStr = [self URLWithPath:path];
  25. paramDict = [NetWorkManager getLocalParm:paramDict url:urlStr];
  26. [NetWorkManager myCookieStorage];
  27. AFHTTPSessionManager *manager = [AFHTTPSessionManager defaultNetManager];
  28. manager.requestSerializer.timeoutInterval = 30;
  29. [manager POST:urlStr parameters:paramDict headers:[self getHeader] progress:^(NSProgress * _Nonnull uploadProgress) {
  30. } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
  31. // NSLog(@"responseObject");
  32. // NSLog(@"%@",responseObject);
  33. [NetWorkManager doResult:responseObject url:urlStr paramDict:paramDict successBlock:PostSuccess successBlock2:nil failureBlock:PostFailure failureBlock2:nil];
  34. } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
  35. [NetWorkManager updateErrorToServiceWithUrl:urlStr paramDict:paramDict errorString:[NSString stringWithFormat:@"%@",error]];
  36. if (PostFailure)
  37. {
  38. PostFailure(error);
  39. }
  40. }];
  41. }
  42. }
  43. - (NSString *)URLWithPath:(NSString *)path {
  44. NSString *domain = @"http://goods.dynasty168.com/shopapi/merchants";
  45. return [NSString stringWithFormat:@"%@%@", domain, path];
  46. }
  47. - (NSMutableDictionary *)getHeader {
  48. NSString *token = [BogoNetwork shareInstance].token ?: @"";
  49. NSMutableDictionary *headers = [[NSMutableDictionary alloc] initWithDictionary:@{
  50. @"token":token
  51. }];
  52. [NetWorkManager tryAddLangParamDict2:headers];
  53. return headers;
  54. }
  55. @end