AS_LoginC.m 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. //
  2. // AS_LoginC.m
  3. // Asteria
  4. //
  5. // Created by 王猛 on 2023/5/15.
  6. //
  7. #import "AS_LoginC.h"
  8. #import "EamilTFmatchV.h"
  9. #import "PassWordSecureBtnV.h"
  10. #import "LoginThirdAuthV.h"
  11. #import <AFNetworking/AFNetworking.h>
  12. @interface AS_LoginC ()
  13. @property (nonatomic, strong) UIScrollView *scrollview;
  14. @property (nonatomic, strong) EamilTFmatchV *xxx_emailTFV;
  15. @property (nonatomic, strong) PassWordSecureBtnV *xxx_passwordV;
  16. @property (nonatomic, strong) UIButton *xxx_logInBtn;
  17. @property (nonatomic, strong) LoginThirdAuthV *xxx_authV;
  18. @end
  19. @implementation AS_LoginC
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. // Do any additional setup after loading the view.
  23. self.customNavBar.hidden = YES;
  24. self.navigationController.navigationBar.hidden = YES;
  25. }
  26. - (void)initSubviews{
  27. [super initSubviews];
  28. [self.view addSubview:self.scrollview];
  29. UIView *logNav = [self logNavView];
  30. [self.scrollview addSubview:logNav];
  31. UIImageView *Hi_imgV = [[UIImageView alloc]init];
  32. UIImage *hiImg = [UIImage imageNamed:@"login_HI"];
  33. Hi_imgV.image = hiImg;
  34. Hi_imgV.frame = CGRectMake(20, CGRectGetMaxY(logNav.frame)+60, KScreenWidth-40, hiImg.size.height/hiImg.size.width*(KScreenWidth-40));
  35. [self.scrollview addSubview:Hi_imgV];
  36. [self.scrollview addSubview:self.xxx_emailTFV];
  37. [self.scrollview addSubview:self.xxx_passwordV];
  38. [self.scrollview bringSubviewToFront:self.xxx_emailTFV];
  39. [self.scrollview addSubview:self.xxx_logInBtn];
  40. [self.scrollview addSubview:self.xxx_authV];
  41. self.xxx_emailTFV.mj_y = CGRectGetMaxY(Hi_imgV.frame)+35;
  42. self.xxx_passwordV.frame = CGRectFlatMake(20, CGRectGetMaxY(self.xxx_emailTFV.frame)+30, KScreenWidth-40, 50+20);
  43. self.xxx_logInBtn.frame = CGRectMake(20, CGRectGetMaxY(self.xxx_passwordV.frame)+10, KScreenWidth-40, 45);
  44. self.xxx_authV.mj_y = CGRectGetMaxY(self.xxx_logInBtn.frame)+30;
  45. }
  46. -(void)handle_closeEvent:(UIButton *)btn{
  47. [self dismissViewControllerAnimated:YES completion:nil];
  48. }
  49. -(void)handle_xxx_logInBtnEvent:(UIButton *)btn{//进行登录操作
  50. ///登录的跳转
  51. if (self.xxx_emailTFV.xxx_emailTF.text.length == 0 || ![Current_normalTool xxx_isValidateEmail:self.xxx_emailTFV.xxx_emailTF.text]) {
  52. [self.view makeToast:@"* Please prvide an email address." duration:2 position:CSToastPositionCenter];
  53. return;
  54. }else if(self.xxx_passwordV.xxx_passwordTF.text.length == 0){
  55. [self.view makeToast:@"Please input a password" duration:2 position:CSToastPositionCenter];
  56. return;
  57. }
  58. NSString *urlStr = [NSString stringWithFormat:@"%@V1/integration/customer/token",AS_Server];
  59. NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
  60. params[@"username"] = self.xxx_emailTFV.xxx_emailTF.text;
  61. params[@"password"] = self.xxx_passwordV.xxx_passwordTF.text;
  62. // NSString *josnStr = [Current_normalTool jsonStringFromDictionary:params];
  63. // [PPNetworkHelper POST:urlStr parameters:params success:^(id responseObject) {
  64. // NSDictionary *tmpDic= responseObject;
  65. //
  66. // } failure:^(NSError *error) {
  67. // [self.view makeToast:@"Network request failed" duration:2 position:CSToastPositionCenter];
  68. // }];
  69. AFHTTPSessionManager *manager =[AFHTTPSessionManager manager];
  70. manager.requestSerializer = [AFJSONRequestSerializer serializer];
  71. manager.responseSerializer = [AFHTTPResponseSerializer serializer];
  72. manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json", @"text/plain", @"text/html", nil];
  73. [manager POST:urlStr parameters:params headers:nil progress:^(NSProgress * _Nonnull uploadProgress) {
  74. } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
  75. NSString * jsonStr = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
  76. NSDictionary *temDic = [Current_normalTool dicFromjsonStr:jsonStr];
  77. NSLog(@"%@",temDic);
  78. } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
  79. }];
  80. }
  81. #pragma mark - **************** 懒加载 ****************
  82. -(UIView *)logNavView{
  83. IPhoneXHeigh
  84. UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, securitytop_Y)];
  85. UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  86. [closeBtn setImage:[UIImage imageNamed:@"common_close"] forState:UIControlStateNormal];
  87. [closeBtn addTarget:self action:@selector(handle_closeEvent:) forControlEvents:UIControlEventTouchUpInside];
  88. closeBtn.frame = CGRectMake(20, securitytop_Y-44, 44, 44);
  89. [topView addSubview:closeBtn];
  90. UIImageView *headImg = [[UIImageView alloc]init];
  91. UIImage *bannerImg = [UIImage imageNamed:@"common_headLogo"];
  92. headImg.image = bannerImg ;
  93. headImg.frame = CGRectMake((KScreenWidth- bannerImg.size.width)/2, (IPHONEX ? 44 : 20)+20 , bannerImg.size.width, bannerImg.size.height);
  94. [topView addSubview:headImg];
  95. return topView;
  96. }
  97. - (UIScrollView *)scrollview {
  98. if (!_scrollview) {
  99. _scrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
  100. }
  101. return _scrollview;
  102. }
  103. -(EamilTFmatchV *)xxx_emailTFV{
  104. if (!_xxx_emailTFV) {
  105. _xxx_emailTFV = [[EamilTFmatchV alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 50)];
  106. }
  107. return _xxx_emailTFV;
  108. }
  109. - (PassWordSecureBtnV *)xxx_passwordV {
  110. if (!_xxx_passwordV) {
  111. _xxx_passwordV = [[PassWordSecureBtnV alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(self.xxx_emailTFV.frame)+30, KScreenWidth-40, 50+20)];
  112. }
  113. return _xxx_passwordV;
  114. }
  115. - (UIButton *)xxx_logInBtn {
  116. if (!_xxx_logInBtn) {
  117. _xxx_logInBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  118. [_xxx_logInBtn setTitleColor:[UIColor colorWithHexString:@"#000000"] forState:UIControlStateNormal];
  119. _xxx_logInBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:16];
  120. [_xxx_logInBtn setTitle:@"LOG IN" forState:UIControlStateNormal];
  121. [_xxx_logInBtn addTarget:self action:@selector(handle_xxx_logInBtnEvent:) forControlEvents:UIControlEventTouchUpInside];
  122. _xxx_logInBtn.backgroundColor = ThemeColor;
  123. _xxx_logInBtn.layer.cornerRadius = 4;
  124. _xxx_logInBtn.clipsToBounds = YES;
  125. }
  126. return _xxx_logInBtn;
  127. }
  128. - (LoginThirdAuthV *)xxx_authV {
  129. if (!_xxx_authV) {
  130. _xxx_authV = [[LoginThirdAuthV alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 15+20+(36+10)*3)];
  131. }
  132. return _xxx_authV;
  133. }
  134. @end