ForgetPasswordView.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. //
  2. // ForgetPasswordView.m
  3. // FunSDKDemo
  4. //
  5. // Created by wujiangbo on 2018/10/30.
  6. // Copyright © 2018年 wujiangbo. All rights reserved.
  7. //
  8. #import "ForgetPasswordView.h"
  9. #import <Masonry/Masonry.h>
  10. #import "Header.h"
  11. @implementation ForgetPasswordView
  12. -(instancetype)initWithFrame:(CGRect)frame
  13. {
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. self.backgroundColor = [UIColor whiteColor];
  17. [self addSubview:self.userPhone];
  18. [self addSubview:self.inputCode];
  19. [self addSubview:self.getCode];
  20. [self addSubview:self.checkBtn];
  21. [self addSubview:self.confirmPwdView];
  22. //按确定后 下一步显示的View
  23. self.confirmPwdView.hidden = YES;
  24. [self.confirmPwdView addSubview:self.userNameLabel];
  25. [self.confirmPwdView addSubview:self.pwdField];
  26. [self.confirmPwdView addSubview:self.confirmResettingPwdbtn];
  27. //布局
  28. [self configSubView];
  29. }
  30. return self;
  31. }
  32. #pragma mark - 控件布局
  33. -(void)configSubView
  34. {
  35. [self.userPhone mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.width.equalTo(self).multipliedBy(0.8);
  37. make.height.equalTo(@45);
  38. make.top.equalTo(@80);
  39. make.centerX.equalTo(self);
  40. }];
  41. [self.inputCode mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.width.equalTo(self.userPhone.mas_width).offset(-100);
  43. make.height.equalTo(@45);
  44. make.top.equalTo(self.userPhone.mas_bottom).offset(20);
  45. make.left.equalTo(self.userPhone.mas_left);
  46. }];
  47. [self.getCode mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.width.equalTo(@100);
  49. make.height.equalTo(@45);
  50. make.top.equalTo(self.inputCode.mas_top);
  51. make.right.equalTo(self.userPhone.mas_right);
  52. }];
  53. [self.checkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.width.equalTo(self).multipliedBy(0.8);
  55. make.height.equalTo(@45);
  56. make.top.equalTo(self.getCode.mas_bottom).offset(60);
  57. make.centerX.equalTo(self);
  58. }];
  59. [self.confirmPwdView mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.width.equalTo(self);
  61. make.height.equalTo(self).offset(-45);
  62. make.top.equalTo(@64);
  63. make.left.equalTo(self);
  64. }];
  65. [self.userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.width.equalTo(self.confirmPwdView.mas_width).multipliedBy(0.8);
  67. make.height.equalTo(@35);
  68. make.top.equalTo(@40);
  69. make.centerX.equalTo(self.confirmPwdView.mas_centerX);
  70. }];
  71. [self.pwdField mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.width.equalTo(self.confirmPwdView.mas_width).multipliedBy(0.8);
  73. make.height.equalTo(@45);
  74. make.top.equalTo(self.userNameLabel.mas_bottom).offset(20);
  75. make.centerX.equalTo(self.confirmPwdView.mas_centerX);
  76. }];
  77. [self.confirmResettingPwdbtn mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.width.equalTo(self.confirmPwdView.mas_width).multipliedBy(0.8);
  79. make.height.equalTo(@45);
  80. make.top.equalTo(self.pwdField.mas_bottom).offset(20);
  81. make.centerX.equalTo(self.confirmPwdView.mas_centerX);
  82. }];
  83. }
  84. #pragma mark - touch Event 按钮点击事件
  85. //点击空白处关闭键盘
  86. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
  87. [self endEditing:YES];//结束编辑模式
  88. }
  89. //密码显示
  90. -(void)showPassword:(UIButton *)sender
  91. {
  92. self.pwdField.secureTextEntry = !self.pwdField.secureTextEntry;
  93. sender.selected = !sender.selected;
  94. }
  95. //获取验证码
  96. -(void)getCode:(UIButton *)sender
  97. {
  98. if (self.getCodeBtnClicked) {
  99. self.getCodeBtnClicked(self.userPhone.text);
  100. }
  101. }
  102. //校验验证码
  103. -(void)chekeCodeInfo:(UIButton *)sender
  104. {
  105. if (self.checkCodeBtnClicked) {
  106. self.checkCodeBtnClicked(self.userPhone.text,self.inputCode.text);
  107. }
  108. }
  109. //重置密码
  110. -(void)resetPwd:(UIButton *)sender
  111. {
  112. if (self.resettingPwdBtnClicked) {
  113. self.resettingPwdBtnClicked(self.userPhone.text, self.pwdField.text);
  114. }
  115. }
  116. #pragma mark - lazyload
  117. -(UITextField *)userPhone {
  118. if (!_userPhone) {
  119. _userPhone = [[UITextField alloc] init];
  120. _userPhone.placeholder = TS("phone_num");
  121. }
  122. return _userPhone;
  123. }
  124. -(UITextField *)inputCode {
  125. if (!_inputCode) {
  126. _inputCode = [[UITextField alloc] init];
  127. _inputCode.placeholder = TS("input_code");
  128. }
  129. return _inputCode;
  130. }
  131. -(UIButton *)getCode {
  132. if (!_getCode) {
  133. _getCode = [[UIButton alloc] init];
  134. [_getCode setTitle:TS("get_code") forState:UIControlStateNormal];
  135. [_getCode setBackgroundColor:GlobalMainColor];
  136. _getCode.titleLabel.numberOfLines = 2 ;
  137. _getCode.titleLabel.font = [UIFont systemFontOfSize:15];
  138. [_getCode addTarget:self action:@selector(getCode:) forControlEvents:UIControlEventTouchUpInside];
  139. }
  140. return _getCode;
  141. }
  142. -(UIButton *)checkBtn {
  143. if (!_checkBtn) {
  144. _checkBtn = [[UIButton alloc] init];
  145. [_checkBtn setTitle:TS("verify_pwd") forState:UIControlStateNormal];
  146. [_checkBtn setBackgroundColor:GlobalMainColor];
  147. _checkBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  148. [_checkBtn addTarget:self action:@selector(chekeCodeInfo:) forControlEvents:UIControlEventTouchUpInside];
  149. }
  150. return _checkBtn;
  151. }
  152. - (UIView *)confirmPwdView{
  153. if (!_confirmPwdView) {
  154. _confirmPwdView = [[UIView alloc] init];
  155. _confirmPwdView.backgroundColor = [UIColor colorWithRed:239.0/255.0 green:239.0/255.0 blue:244.0/255.0 alpha:1];
  156. }
  157. return _confirmPwdView;
  158. }
  159. - (UILabel *)userNameLabel{
  160. if (!_userNameLabel) {
  161. _userNameLabel = [[UILabel alloc] init];
  162. _userNameLabel.text = TS("forget_username_is");
  163. _userNameLabel.textAlignment = NSTextAlignmentLeft;
  164. _userNameLabel.font = [UIFont systemFontOfSize:16];
  165. }
  166. return _userNameLabel;
  167. }
  168. -(UITextField *)pwdField {
  169. if (!_pwdField) {
  170. _pwdField = [[UITextField alloc]init];
  171. _pwdField.placeholder = TS("reset_user_psd");
  172. _pwdField.borderStyle = UITextBorderStyleRoundedRect;
  173. UIButton *showPwd = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];
  174. [showPwd setImage:[UIImage imageNamed:@"icon_hide_nor.png"] forState:UIControlStateNormal];
  175. [showPwd setImage:[UIImage imageNamed:@"icon_hide_sel.png"] forState:UIControlStateSelected];
  176. [showPwd addTarget:self action:@selector(showPassword:) forControlEvents:UIControlEventTouchUpInside];
  177. _pwdField.secureTextEntry = YES;
  178. _pwdField.rightView = showPwd;
  179. _pwdField.rightViewMode = UITextFieldViewModeAlways;
  180. }
  181. return _pwdField;
  182. }
  183. - (UIButton *)confirmResettingPwdbtn {
  184. if (!_confirmResettingPwdbtn) {
  185. _confirmResettingPwdbtn = [[UIButton alloc] init];
  186. [_confirmResettingPwdbtn setTitle:TS("Sure_Reset") forState:UIControlStateNormal];
  187. _confirmResettingPwdbtn.titleLabel.font = [UIFont systemFontOfSize:15];
  188. [_confirmResettingPwdbtn setBackgroundColor:GlobalMainColor];
  189. [_confirmResettingPwdbtn addTarget:self action:@selector(resetPwd:) forControlEvents:UIControlEventTouchUpInside];
  190. }
  191. return _confirmResettingPwdbtn;
  192. }
  193. @end