RQURLParameters.m 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // RQURLParameters.m
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/16.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #import "RQURLParameters.h"
  9. #import "RQHTTPService.h"
  10. @implementation SBURLExtendsParameters
  11. + (instancetype)extendsParameters
  12. {
  13. return [[self alloc] init];
  14. }
  15. - (instancetype)init
  16. {
  17. self = [super init];
  18. if (self) {
  19. }
  20. return self;
  21. }
  22. - (NSString *)ver{
  23. static NSString *version = nil;
  24. if (version == nil) version = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
  25. return (version.length>0)?version:@"";
  26. }
  27. - (NSString *)token {
  28. // NSString *uid = self.uid;
  29. // if (RQStringIsNotEmpty(uid) && RQStringIsNotEmpty([RQHTTPService sharedInstance].token)){
  30. // NSString *t_token = [NSString stringWithFormat:@"%@-%@",uid,[RQHTTPService sharedInstance].token];
  31. // return t_token;
  32. // }
  33. return @"";//[RQHTTPService sharedInstance].token;
  34. }
  35. - (NSString *)deviceid {
  36. static NSString *deviceidStr = nil;
  37. if (deviceidStr == nil) deviceidStr = [SAMKeychain deviceId];
  38. return deviceidStr.length>0?deviceidStr:@"";
  39. }
  40. - (NSString *)platform{
  41. return @"iOS";
  42. }
  43. - (NSString *)channel{
  44. return @"AppStore";
  45. }
  46. - (NSString *)t {
  47. return [NSString stringWithFormat:@"%.f", [NSDate date].timeIntervalSince1970];
  48. }
  49. @end
  50. @implementation RQURLParameters
  51. + (instancetype)urlParametersWithMethod:(NSString *)method path:(NSString *)path parameters:(NSDictionary *)parameters {
  52. //控制-测试环境
  53. if(!isOfficial){
  54. path = [path stringByReplacingOccurrencesOfString:@"jsjp-admin.zzxcx.net" withString:@"jsjp-admin1.zzxcx.net"];
  55. // path = [path stringByReplacingOccurrencesOfString:@"https://jsjp-admin.zzxcx.net" withString:@"http://192.168.31.101:8080"];
  56. // path = [path stringByReplacingOccurrencesOfString:@"/jsjp-admin" withString:@""];
  57. // path = [path stringByReplacingOccurrencesOfString:@"userInfo/vip/info" withString:@"gzpt/userInfo/vip/info"];
  58. }
  59. return [[self alloc] initUrlParametersWithMethod:method path:path parameters:parameters];
  60. }
  61. - (instancetype)initUrlParametersWithMethod:(NSString *)method path:(NSString *)path parameters:(NSDictionary *)parameters {
  62. self = [super init];
  63. if (self) {
  64. self.method = method;
  65. self.path = path;
  66. self.parameters = parameters;
  67. self.extendsParameters = [[SBURLExtendsParameters alloc] init];
  68. }
  69. return self;
  70. }
  71. @end