AS_LoginC.m 9.4 KB

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