YMPasswordLoginViewController.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. //
  2. // YMPasswordLoginViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/5.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMPasswordLoginViewController.h"
  9. #import "YMPasswordLoginViewModel.h"
  10. #import "YMPasswordLoginView.h"
  11. @interface YMPasswordLoginViewController ()
  12. /// 密码登录VM
  13. @property (nonatomic, strong) YMPasswordLoginViewModel *viewModel;
  14. @property (nonatomic, strong) UIView *loginCoverBgv;
  15. @property (nonatomic, strong) UIView *cornerView;
  16. @property (nonatomic, strong) UIImageView *loginLogo;
  17. /// 登录封面
  18. @property (nonatomic, strong) UIImageView *loginCover;
  19. /// 登录提示标签
  20. @property (nonatomic, strong) UILabel *loginTipsLb;
  21. /// 密码登录视图
  22. @property (nonatomic, strong) YMPasswordLoginView *passwordLoginView;
  23. @end
  24. @implementation YMPasswordLoginViewController
  25. @dynamic viewModel;
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. self.ym_navigationStyle = YMBaseNavigationStyleClearBgBlackBackArrow;
  29. [OCNotificationCenter addObserver:self selector:@selector(receiveWechatAuth:) name:WECHAT_AUTHORIZATION_NOTIFICATION object:nil];
  30. }
  31. - (void)ym_setupViews{
  32. //self.view.backgroundColor = HexColorFromRGB(0xDCADEF);
  33. [self.view addSubview:self.loginCoverBgv];
  34. [self.loginCoverBgv addSubview:self.loginCover];
  35. [self.loginCoverBgv addSubview:self.cornerView];
  36. [self.loginCoverBgv addSubview:self.loginLogo];
  37. // [self.loginCover addSubview:self.loginTipsLb];
  38. [self.view addSubview:self.passwordLoginView];
  39. [self.view setNeedsUpdateConstraints];
  40. [self.view updateConstraintsIfNeeded];
  41. }
  42. - (void)updateViewConstraints{
  43. [self.loginCoverBgv mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.top.equalTo(self.view);
  45. make.left.equalTo(self.view);
  46. make.size.equalTo(CGSizeMake(KScreenWidth, KScreenWidth*438/376));
  47. }];
  48. [self.loginCover mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.edges.equalTo(self.loginCoverBgv);
  50. }];
  51. [self.cornerView mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.bottom.equalTo(self.loginCoverBgv);
  53. make.left.equalTo(self.loginCoverBgv);
  54. make.right.equalTo(self.loginCoverBgv);
  55. make.height.mas_equalTo(adapt(27));
  56. }];
  57. [self.loginLogo mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.bottom.equalTo(self.cornerView.mas_top).offset(adapt(15));
  59. make.centerX.equalTo(self.loginCover);
  60. make.width.mas_equalTo(adapt(191));
  61. make.height.mas_equalTo(adapt(108));
  62. }];
  63. // [self.loginTipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  64. // make.bottom.equalTo(self.loginCover).offset(-36);
  65. // make.left.equalTo(self.loginCover).offset(28);
  66. // }];
  67. [self.passwordLoginView mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.top.equalTo(self.view);
  69. make.left.equalTo(self.view);
  70. make.right.equalTo(self.view);
  71. make.bottom.equalTo(self.view);
  72. }];
  73. [super updateViewConstraints];
  74. }
  75. - (void)ym_bindViewModel{
  76. [self.passwordLoginView ym_bindViewModel:self.viewModel];
  77. }
  78. - (void)receiveWechatAuth:(NSNotification *)notice{
  79. NSString *code = [notice.userInfo stringValueForKey:@"authCode" defaultValue:@""];
  80. [self.viewModel getWechatLoginAuthWithCode:code];
  81. }
  82. - (UIView *)loginCoverBgv {
  83. if (!_loginCoverBgv) {
  84. _loginCoverBgv = [[UIView alloc]init];
  85. _loginCoverBgv.backgroundColor = UIColor.clearColor;
  86. }
  87. return _loginCoverBgv;
  88. }
  89. - (UIImageView *)loginLogo{
  90. if (!_loginLogo) {
  91. _loginLogo = [[UIImageView alloc]init];
  92. _loginLogo.hidden = YES;
  93. _loginLogo.image = ImageByName(@"ym_login_register_logo");
  94. }
  95. return _loginLogo;
  96. }
  97. - (UIImageView *)loginCover{
  98. if (!_loginCover) {
  99. _loginCover = [[UIImageView alloc]init];
  100. _loginCover.image = ImageByName(@"ym_login_register_cover");
  101. _loginCover.contentMode=UIViewContentModeScaleAspectFill;
  102. }
  103. return _loginCover;
  104. }
  105. - (UIView *)cornerView{
  106. if (!_cornerView) {
  107. _cornerView = [[UIView alloc]init];
  108. _cornerView.hidden = YES;
  109. _cornerView.backgroundColor = HexColorFromRGB(0xFFFFFF);
  110. [_cornerView addRectCorner:UIRectCornerTopLeft|UIRectCornerTopRight radius:22];
  111. _cornerView.layer.masksToBounds = true;
  112. }
  113. return _cornerView;
  114. }
  115. - (UILabel *)loginTipsLb {
  116. if (!_loginTipsLb) {
  117. _loginTipsLb = [[UILabel alloc]init];
  118. _loginTipsLb.font = LCBoldFont(24);
  119. _loginTipsLb.textColor = HexColorFromRGB(0x1B2739);
  120. _loginTipsLb.textAlignment = NSTextAlignmentLeft;
  121. _loginTipsLb.text = @"您好,\n欢迎登录";
  122. _loginTipsLb.numberOfLines = 0;
  123. }
  124. return _loginTipsLb;
  125. }
  126. - (YMPasswordLoginView *)passwordLoginView{
  127. if (!_passwordLoginView) {
  128. _passwordLoginView = [[YMPasswordLoginView alloc]init];
  129. _passwordLoginView.backgroundColor = UIColor.clearColor;
  130. //[_passwordLoginView addRectCorner:UIRectCornerTopLeft|UIRectCornerTopRight radius:adapt(22)];
  131. }
  132. return _passwordLoginView;
  133. }
  134. - (void)dealloc{
  135. // [NSNotification WECHAT_AUTHORIZATION_NOTIFICATION]
  136. [[NSNotificationCenter defaultCenter] removeObserver:self name:WECHAT_AUTHORIZATION_NOTIFICATION object:nil];
  137. }
  138. @end