AS_LoginC.m 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. #import "AS_SignUpC.h"
  13. @interface AS_LoginC ()
  14. @property (nonatomic, strong) UIScrollView *scrollview;
  15. @property (nonatomic, strong) EamilTFmatchV *xxx_emailTFV;
  16. @property (nonatomic, strong) PassWordSecureBtnV *xxx_passwordV;
  17. @property (nonatomic, strong) UIButton *xxx_logInBtn;
  18. @property (nonatomic, strong) LoginThirdAuthV *xxx_authV;
  19. @end
  20. @implementation AS_LoginC
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. // Do any additional setup after loading the view.
  24. self.customNavBar.hidden = YES;
  25. self.navigationController.navigationBar.hidden = YES;
  26. }
  27. - (void)initSubviews{
  28. [super initSubviews];
  29. [self.view addSubview:self.scrollview];
  30. UIView *logNav = [self logNavView];
  31. [self.scrollview addSubview:logNav];
  32. UIImageView *Hi_imgV = [[UIImageView alloc]init];
  33. UIImage *hiImg = [UIImage imageNamed:@"login_HI"];
  34. Hi_imgV.image = hiImg;
  35. Hi_imgV.frame = CGRectMake(20, CGRectGetMaxY(logNav.frame)+30, KScreenWidth-40, hiImg.size.height/hiImg.size.width*(KScreenWidth-40));
  36. [self.scrollview addSubview:Hi_imgV];
  37. [self.scrollview addSubview:self.xxx_emailTFV];
  38. [self.scrollview addSubview:self.xxx_passwordV];
  39. [self.scrollview bringSubviewToFront:self.xxx_emailTFV];
  40. [self.scrollview addSubview:self.xxx_logInBtn];
  41. [self.scrollview addSubview:self.xxx_authV];
  42. UIView *bottomV = [self load_bottom_v];
  43. [self.scrollview addSubview:bottomV];
  44. self.xxx_emailTFV.mj_y = CGRectGetMaxY(Hi_imgV.frame)+35;
  45. self.xxx_passwordV.frame = CGRectFlatMake(20, CGRectGetMaxY(self.xxx_emailTFV.frame)+30, KScreenWidth-40, 50+20);
  46. self.xxx_logInBtn.frame = CGRectMake(20, CGRectGetMaxY(self.xxx_passwordV.frame)+10, KScreenWidth-40, 45);
  47. self.xxx_authV.mj_y = CGRectGetMaxY(self.xxx_logInBtn.frame)+30;
  48. bottomV.mj_y = CGRectGetMaxY(self.xxx_authV.frame)+30;
  49. }
  50. -(void)handle_closeEvent:(UIButton *)btn{
  51. [self.navigationController dismissViewControllerAnimated:YES completion:nil];
  52. }
  53. -(void)handle_xxx_logInBtnEvent:(UIButton *)btn{//进行登录操作
  54. ///登录的跳转
  55. if (self.xxx_emailTFV.xxx_emailTF.text.length == 0 || ![Current_normalTool xxx_isValidateEmail:self.xxx_emailTFV.xxx_emailTF.text]) {
  56. [self.view makeToast:@"* Please prvide an email address." duration:2 position:CSToastPositionCenter];
  57. return;
  58. }else if(self.xxx_passwordV.xxx_passwordTF.text.length == 0){
  59. [self.view makeToast:@"Please input a password" duration:2 position:CSToastPositionCenter];
  60. return;
  61. }
  62. NSString *urlStr = [NSString stringWithFormat:@"%@V1/integration/customer/token",AS_Server];
  63. NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
  64. params[@"username"] = self.xxx_emailTFV.xxx_emailTF.text;
  65. params[@"password"] = self.xxx_passwordV.xxx_passwordTF.text;
  66. // NSString *josnStr = [Current_normalTool jsonStringFromDictionary:params];
  67. // [PPNetworkHelper POST:urlStr parameters:params success:^(id responseObject) {
  68. // NSDictionary *tmpDic= responseObject;
  69. //
  70. // } failure:^(NSError *error) {
  71. // [self.view makeToast:@"Network request failed" duration:2 position:CSToastPositionCenter];
  72. // }];
  73. AFHTTPSessionManager *manager =[AFHTTPSessionManager manager];
  74. manager.requestSerializer = [AFJSONRequestSerializer serializer];
  75. manager.responseSerializer = [AFHTTPResponseSerializer serializer];
  76. manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json", @"text/plain", @"text/html", nil];
  77. [manager POST:urlStr parameters:params headers:nil progress:^(NSProgress * _Nonnull uploadProgress) {
  78. } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
  79. NSString * jsonStr = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
  80. NSDictionary *temDic = [Current_normalTool dicFromjsonStr:jsonStr];
  81. NSLog(@"%@",temDic);
  82. } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
  83. }];
  84. }
  85. //注册页面
  86. -(void)handle_signUpEvent:(UIButton *)btn{
  87. AS_SignUpC *upVC = [[AS_SignUpC alloc]init];
  88. [self.navigationController pushViewController:upVC animated:YES];
  89. }
  90. -(void)handle_forgetBtnEvent:(UIButton *)btn{
  91. }
  92. #pragma mark - **************** 懒加载 ****************
  93. -(UIView *)logNavView{
  94. IPhoneXHeigh
  95. UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, securitytop_Y)];
  96. UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  97. [closeBtn setImage:[UIImage imageNamed:@"common_close"] forState:UIControlStateNormal];
  98. [closeBtn addTarget:self action:@selector(handle_closeEvent:) forControlEvents:UIControlEventTouchUpInside];
  99. closeBtn.frame = CGRectMake(20, securitytop_Y-44, 44, 44);
  100. [topView addSubview:closeBtn];
  101. UIImageView *headImg = [[UIImageView alloc]init];
  102. UIImage *bannerImg = [UIImage imageNamed:@"common_headLogo"];
  103. headImg.image = bannerImg ;
  104. headImg.frame = CGRectMake((KScreenWidth- bannerImg.size.width)/2, (IPHONEX ? 44 : 20)+20 , bannerImg.size.width, bannerImg.size.height);
  105. [topView addSubview:headImg];
  106. closeBtn.centerY = topView.centerY;
  107. headImg.centerY = topView.centerY;
  108. return topView;
  109. }
  110. - (UIScrollView *)scrollview {
  111. if (!_scrollview) {
  112. _scrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
  113. }
  114. return _scrollview;
  115. }
  116. -(EamilTFmatchV *)xxx_emailTFV{
  117. if (!_xxx_emailTFV) {
  118. _xxx_emailTFV = [[EamilTFmatchV alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 50)];
  119. }
  120. return _xxx_emailTFV;
  121. }
  122. - (PassWordSecureBtnV *)xxx_passwordV {
  123. if (!_xxx_passwordV) {
  124. _xxx_passwordV = [[PassWordSecureBtnV alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(self.xxx_emailTFV.frame)+30, KScreenWidth-40, 50+20)];
  125. }
  126. return _xxx_passwordV;
  127. }
  128. - (UIButton *)xxx_logInBtn {
  129. if (!_xxx_logInBtn) {
  130. _xxx_logInBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  131. [_xxx_logInBtn setTitleColor:[UIColor colorWithHexString:@"#000000"] forState:UIControlStateNormal];
  132. _xxx_logInBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:16];
  133. [_xxx_logInBtn setTitle:@"LOG IN" forState:UIControlStateNormal];
  134. [_xxx_logInBtn addTarget:self action:@selector(handle_xxx_logInBtnEvent:) forControlEvents:UIControlEventTouchUpInside];
  135. _xxx_logInBtn.backgroundColor = ThemeColor;
  136. _xxx_logInBtn.layer.cornerRadius = 4;
  137. _xxx_logInBtn.clipsToBounds = YES;
  138. }
  139. return _xxx_logInBtn;
  140. }
  141. - (LoginThirdAuthV *)xxx_authV {
  142. if (!_xxx_authV) {
  143. _xxx_authV = [[LoginThirdAuthV alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 15+20+(36+10)*3)];
  144. }
  145. return _xxx_authV;
  146. }
  147. -(UIView *)load_bottom_v{
  148. UIView *bottomV = [[UIView alloc]initWithFrame:CGRectMake(20, 0, KScreenWidth-40, 32)];
  149. QMUILabel *disLab = [[QMUILabel alloc]init];
  150. disLab.text = @"Don't Have An Account?";
  151. disLab.font = [UIFont fontWithName:Rob_Regular size:12];
  152. [bottomV addSubview:disLab];
  153. UIButton *signUpBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  154. signUpBtn.backgroundColor = [UIColor clearColor];
  155. NSMutableAttributedString *sinAtr = [[NSMutableAttributedString alloc]initWithString:@"Sign Up" attributes:@{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}];
  156. [signUpBtn setAttributedTitle:sinAtr forState:UIControlStateNormal];
  157. [signUpBtn addTarget:self action:@selector(handle_signUpEvent:) forControlEvents:UIControlEventTouchUpInside];
  158. [signUpBtn setTitleColor:ThemeColor forState:UIControlStateNormal];
  159. signUpBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:12];
  160. [bottomV addSubview:signUpBtn];
  161. UIButton *forgetBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  162. forgetBtn.backgroundColor = [UIColor clearColor];
  163. NSMutableAttributedString *forgotAtr = [[NSMutableAttributedString alloc]initWithString:@"Forgot Your Password" attributes:@{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}];
  164. [forgetBtn setAttributedTitle:forgotAtr forState:UIControlStateNormal];
  165. [forgetBtn setTitleColor:ThemeColor forState:UIControlStateNormal];
  166. forgetBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:12];
  167. [forgetBtn addTarget:self action:@selector(handle_forgetBtnEvent:) forControlEvents:UIControlEventTouchUpInside];
  168. [bottomV addSubview:forgetBtn];
  169. [disLab mas_makeConstraints:^(MASConstraintMaker *make) {
  170. make.top.left.mas_equalTo(0);
  171. make.height.mas_equalTo(16);
  172. }];
  173. [signUpBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  174. make.centerY.equalTo(disLab);
  175. make.left.equalTo(disLab.mas_right).offset(3);
  176. make.height.mas_equalTo(20);
  177. make.width.mas_equalTo(45);
  178. }];
  179. [forgetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  180. make.left.mas_equalTo(0);
  181. make.top.equalTo(disLab.mas_bottom).offset(10);
  182. make.height.mas_equalTo(15);
  183. make.width.mas_equalTo(120);
  184. }];
  185. return bottomV;
  186. }
  187. @end