YMRetrievePasswordView.m 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. //
  2. // YMRetrievePasswordView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/6.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMRetrievePasswordView.h"
  9. #import "YMRetrievePasswordViewModel.h"
  10. #import "YMCaptchaPopupView.h"
  11. #import "SMCaptchaPopupView.h"
  12. @interface YMRetrievePasswordView ()
  13. /// 找回密码VM
  14. @property (nonatomic, strong) YMRetrievePasswordViewModel *viewModel;
  15. /// 手机视图
  16. @property (nonatomic, strong) UIView *mobileView;
  17. /// 手机号标签
  18. @property (nonatomic, strong) UILabel *mobileLb;
  19. /// 手机号输入框
  20. @property (nonatomic, strong) UITextField *mobileInputBox;
  21. /// 验证码视图
  22. @property (nonatomic, strong) UIView *verifyCodeView;
  23. /// 验证码标签
  24. @property (nonatomic, strong) UILabel *verifyCodeLb;
  25. /// 验证码输入框
  26. @property (nonatomic, strong) UITextField *verifyCodeInputBox;
  27. /// 获取验证码
  28. @property (nonatomic, strong) YMCaptchaCountdownButton *getVerifyCodeBtn;
  29. /// 密码视图
  30. @property (nonatomic, strong) UIView *passwordView;
  31. /// 密码标签
  32. @property (nonatomic, strong) UILabel *passwordLb;
  33. /// 密码输入框
  34. @property (nonatomic, strong) UITextField *passwordInputBox;
  35. /// 协议视图
  36. @property (nonatomic, strong) UIView *agreementView;
  37. /// 单选按钮
  38. @property (nonatomic, strong) UIButton *radioBtn;
  39. /// 协议标签
  40. @property (nonatomic, strong) YYLabel *agreementLb;
  41. /// 确定按钮
  42. @property (nonatomic, strong) UIButton *confirmBtn;
  43. @end
  44. @implementation YMRetrievePasswordView
  45. - (void)ym_setupViews{
  46. [self addSubview:self.mobileView];
  47. [self.mobileView addSubview:self.mobileLb];
  48. [self.mobileView addSubview:self.mobileInputBox];
  49. [self addSubview:self.verifyCodeView];
  50. [self.verifyCodeView addSubview:self.verifyCodeLb];
  51. [self.verifyCodeView addSubview:self.verifyCodeInputBox];
  52. [self.verifyCodeView addSubview:self.getVerifyCodeBtn];
  53. [self addSubview:self.passwordView];
  54. [self.passwordView addSubview:self.passwordLb];
  55. [self.passwordView addSubview:self.passwordInputBox];
  56. [self addSubview:self.agreementView];
  57. [self.agreementView addSubview:self.radioBtn];
  58. [self.agreementView addSubview:self.agreementLb];
  59. [self addSubview:self.confirmBtn];
  60. [self setNeedsUpdateConstraints];
  61. [self updateConstraintsIfNeeded];
  62. }
  63. - (void)updateConstraints{
  64. [self.mobileView mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.top.equalTo(self).offset(adapt(24));
  66. make.left.equalTo(self).offset(adapt(28));
  67. make.right.equalTo(self).offset(adapt(-28));
  68. }];
  69. [self.mobileLb mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.top.equalTo(self.mobileView);
  71. make.left.equalTo(self.mobileView);
  72. }];
  73. [self.mobileInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.top.equalTo(self.mobileLb.mas_bottom).offset(adapt(10));
  75. make.left.equalTo(self.mobileView);
  76. make.right.equalTo(self.mobileView);
  77. make.bottom.equalTo(self.mobileView);
  78. make.height.mas_equalTo(adapt(30));
  79. }];
  80. [self.verifyCodeView mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.top.equalTo(self.mobileView.mas_bottom).offset(adapt(24));
  82. make.left.equalTo(self.mobileView.mas_left);
  83. make.right.equalTo(self.mobileView.mas_right);
  84. }];
  85. [self.verifyCodeLb mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.top.equalTo(self.verifyCodeView);
  87. make.left.equalTo(self.verifyCodeView);
  88. }];
  89. [self.verifyCodeInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.top.equalTo(self.verifyCodeLb.mas_bottom).offset(adapt(10));
  91. make.left.equalTo(self.verifyCodeView);
  92. make.bottom.equalTo(self.verifyCodeView);
  93. make.height.mas_equalTo(adapt(30));
  94. }];
  95. [self.getVerifyCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.top.equalTo(self.verifyCodeLb.mas_bottom).offset(adapt(10));
  97. make.left.equalTo(self.verifyCodeInputBox.mas_right).offset(adapt(5));
  98. make.right.equalTo(self.verifyCodeView);
  99. make.bottom.equalTo(self.verifyCodeView);
  100. make.width.mas_equalTo(adapt(100));
  101. }];
  102. [self.passwordView mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.top.equalTo(self.verifyCodeView.mas_bottom).offset(adapt(24));
  104. make.left.equalTo(self.mobileView.mas_left);
  105. make.right.equalTo(self.mobileView.mas_right);
  106. }];
  107. [self.passwordLb mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.top.equalTo(self.passwordView);
  109. make.left.equalTo(self.passwordView);
  110. }];
  111. [self.passwordInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.top.equalTo(self.passwordLb.mas_bottom).offset(adapt(10));
  113. make.left.equalTo(self.passwordView);
  114. make.right.equalTo(self.passwordView);
  115. make.bottom.equalTo(self.passwordView);
  116. make.height.mas_equalTo(adapt(30));
  117. }];
  118. [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.top.equalTo(self.passwordView.mas_bottom).offset(adapt(24));
  120. make.left.equalTo(self.mobileView.mas_left);
  121. make.right.equalTo(self.mobileView.mas_right);
  122. make.height.mas_equalTo(adapt(40));
  123. }];
  124. [self.agreementView mas_makeConstraints:^(MASConstraintMaker *make) {
  125. make.centerX.equalTo(self.mas_centerX);
  126. make.bottom.equalTo(self).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  127. }];
  128. [self.radioBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  129. make.centerY.equalTo(self.agreementLb.mas_centerY);
  130. make.left.equalTo(self.agreementView).offset(adapt(5));
  131. make.width.height.mas_equalTo(adapt(12));
  132. }];
  133. [self.agreementLb mas_makeConstraints:^(MASConstraintMaker *make) {
  134. make.top.equalTo(self.agreementView).offset(adapt(10));
  135. make.left.equalTo(self.radioBtn.mas_right).offset(adapt(5));
  136. make.right.equalTo(self.agreementView).offset(adapt(-5));
  137. make.bottom.equalTo(self.agreementView).offset(adapt(-10));
  138. }];
  139. [super updateConstraints];
  140. }
  141. - (void)ym_bindViewModel:(YMRetrievePasswordViewModel *)viewModel{
  142. if (!viewModel) {
  143. return;
  144. }
  145. _viewModel = viewModel;
  146. RAC(self.viewModel , mobile) = [[RACSignal merge:@[RACObserve(self.mobileInputBox, text),self.mobileInputBox.rac_textSignal]] takeUntil:self.rac_willDeallocSignal];
  147. RAC(self.viewModel , verifyCode) = [[RACSignal merge:@[RACObserve(self.verifyCodeInputBox, text),self.verifyCodeInputBox.rac_textSignal]]takeUntil:self.rac_willDeallocSignal];
  148. RAC(self.viewModel , password) = [[RACSignal merge:@[RACObserve(self.passwordInputBox, text),self.passwordInputBox.rac_textSignal]]takeUntil:self.rac_willDeallocSignal];
  149. [self.viewModel.validRetrievePasswordSignal subscribeNext:^(id _Nullable value) {
  150. self.confirmBtn.enabled = [value boolValue];
  151. if ([value boolValue]) {
  152. self.confirmBtn.alpha = 1;
  153. } else {
  154. self.confirmBtn.alpha = 0.5;
  155. }
  156. }];
  157. }
  158. - (UIView *)mobileView{
  159. if (!_mobileView) {
  160. _mobileView = [[UIView alloc]init];
  161. }
  162. return _mobileView;
  163. }
  164. - (UILabel *)mobileLb{
  165. if (!_mobileLb) {
  166. _mobileLb = [[UILabel alloc]init];
  167. _mobileLb.font = LCBoldFont(17);
  168. _mobileLb.textColor = HexColorFromRGB(0x1B2739);
  169. _mobileLb.textAlignment = NSTextAlignmentLeft;
  170. _mobileLb.text = @"手机号";
  171. }
  172. return _mobileLb;
  173. }
  174. - (UITextField *)mobileInputBox{
  175. if (!_mobileInputBox) {
  176. NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
  177. style.minimumLineHeight = 0;
  178. NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入手机号"];
  179. placeholderAttributed.yy_paragraphStyle = style;
  180. placeholderAttributed.yy_font = LCFont(14);
  181. placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
  182. _mobileInputBox = [[UITextField alloc]init];
  183. _mobileInputBox.attributedPlaceholder = placeholderAttributed;
  184. _mobileInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
  185. _mobileInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
  186. _mobileInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
  187. _mobileInputBox.keyboardType = UIKeyboardTypePhonePad;
  188. _mobileInputBox.ba_maxLength = 11;
  189. //@weakify(self)
  190. [[[_mobileInputBox rac_textSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  191. //@strongify(self)
  192. }];
  193. }
  194. return _mobileInputBox;
  195. }
  196. - (UIView *)verifyCodeView{
  197. if (!_verifyCodeView) {
  198. _verifyCodeView = [[UIView alloc]init];
  199. }
  200. return _verifyCodeView;
  201. }
  202. - (UILabel *)verifyCodeLb{
  203. if (!_verifyCodeLb) {
  204. _verifyCodeLb = [[UILabel alloc]init];
  205. _verifyCodeLb.font = LCBoldFont(17);
  206. _verifyCodeLb.textColor = HexColorFromRGB(0x1B2739);
  207. _verifyCodeLb.textAlignment = NSTextAlignmentLeft;
  208. _verifyCodeLb.text = @"短信验证码";
  209. }
  210. return _verifyCodeLb;
  211. }
  212. - (UITextField *)verifyCodeInputBox{
  213. if (!_verifyCodeInputBox) {
  214. NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
  215. style.minimumLineHeight = 0;
  216. NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入验证码"];
  217. placeholderAttributed.yy_paragraphStyle = style;
  218. placeholderAttributed.yy_font = LCFont(14);
  219. placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
  220. _verifyCodeInputBox = [[UITextField alloc]init];
  221. _verifyCodeInputBox.attributedPlaceholder = placeholderAttributed;
  222. _verifyCodeInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
  223. _verifyCodeInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
  224. _verifyCodeInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
  225. _verifyCodeInputBox.keyboardType = UIKeyboardTypeDecimalPad;
  226. //@weakify(self)
  227. [[[_verifyCodeInputBox rac_textSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  228. // @strongify(self)
  229. }];
  230. }
  231. return _verifyCodeInputBox;
  232. }
  233. - (YMCaptchaCountdownButton *)getVerifyCodeBtn{
  234. if (!_getVerifyCodeBtn) {
  235. _getVerifyCodeBtn = [YMCaptchaCountdownButton buttonWithType:UIButtonTypeCustom];
  236. _getVerifyCodeBtn.titleLabel.font = LCFont(14);
  237. [_getVerifyCodeBtn setTitleColor:MainColor forState:UIControlStateNormal];
  238. [_getVerifyCodeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
  239. @weakify(self)
  240. [_getVerifyCodeBtn countDownButtonHandler:^(YMCaptchaCountdownButton *sender, NSInteger tag) {
  241. @strongify(self)
  242. if (OCStringIsEmpty(self.mobileInputBox.text)) {
  243. [ZCHUDHelper showTitle:@"请输入手机号"];
  244. return;
  245. }
  246. [self.mobileInputBox resignFirstResponder];
  247. [self.verifyCodeInputBox resignFirstResponder];
  248. [self.passwordInputBox resignFirstResponder];
  249. [LCHttpHelper requestWithURLString:GetCaptchaType parameters:@{} needToken:NO type:HttpRequestTypePost success:^(id responseObject) {
  250. @strongify(self)
  251. NSDictionary* dict = (NSDictionary*)responseObject;
  252. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  253. if (code == 0) {
  254. int type = [dict[@"data"][@"type"]intValue];
  255. if (type==1) {
  256. YMCaptchaPopupView *view = [[YMCaptchaPopupView alloc] init];
  257. view.cancelButtonTappedBlock = ^{};
  258. @weakify(self)
  259. view.confirmButtonTappedBlock = ^(NSString * _Nonnull input) {
  260. @strongify(self)
  261. @weakify(self)
  262. [self.viewModel getVerifyCodeWithCapthca:input Handler:^(NSDictionary * _Nonnull dic, NSError * _Nullable error) {
  263. @strongify(self)
  264. sender.enabled = NO;
  265. [sender startCountDownWithSecond:59];
  266. [sender countDownChanging:^NSString *(YMCaptchaCountdownButton *countDownButton, NSUInteger second) {
  267. NSString *title = [NSString stringWithFormat:@"重新发送(%zds)",second];
  268. return title;
  269. }];
  270. [sender countDownFinished:^NSString *(YMCaptchaCountdownButton *countDownButton, NSUInteger second) {
  271. countDownButton.enabled = YES;
  272. return @"重新发送";
  273. }];
  274. }];
  275. };
  276. UIView *currentVCView = [LCTools getCurrentVC].view;
  277. if (currentVCView != nil && ![currentVCView isEqual:NSNull.null]) {
  278. [view showInView:currentVCView];
  279. }
  280. }else {
  281. SMCaptchaPopupView *smview = [[SMCaptchaPopupView alloc] init];
  282. smview.confirmButtonTappedBlock = ^(NSString * _Nonnull input) {
  283. @strongify(self)
  284. @weakify(self)
  285. [self.viewModel getVerifyCodeWithRid:input Handler:^(NSDictionary * _Nonnull dic, NSError * _Nullable error) {
  286. @strongify(self)
  287. sender.enabled = NO;
  288. [sender startCountDownWithSecond:59];
  289. [sender countDownChanging:^NSString *(YMCaptchaCountdownButton *countDownButton, NSUInteger second) {
  290. NSString *title = [NSString stringWithFormat:@"重新发送(%zds)",second];
  291. return title;
  292. }];
  293. [sender countDownFinished:^NSString *(YMCaptchaCountdownButton *countDownButton, NSUInteger second) {
  294. countDownButton.enabled = YES;
  295. return @"重新发送";
  296. }];
  297. }];
  298. };
  299. UIView *currentVCView = [LCTools getCurrentVC].view;
  300. if (currentVCView != nil && ![currentVCView isEqual:NSNull.null]) {
  301. [smview showInView:currentVCView];
  302. }
  303. }
  304. }else{
  305. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  306. }
  307. } failure:^(NSError *error) {
  308. [ZCHUDHelper showTitle:error.localizedDescription];
  309. }];
  310. // YMCaptchaPopupView *view = [[YMCaptchaPopupView alloc] init];
  311. // view.cancelButtonTappedBlock = ^{};
  312. // @weakify(self)
  313. // view.confirmButtonTappedBlock = ^(NSString * _Nonnull input) {
  314. // @strongify(self)
  315. // @weakify(self)
  316. //
  317. // [self.viewModel getVerifyCodeWithCapthca:input Handler:^(NSDictionary * _Nonnull dic, NSError * _Nullable error) {
  318. // @strongify(self)
  319. // sender.enabled = NO;
  320. //
  321. // [sender startCountDownWithSecond:59];
  322. //
  323. // [sender countDownChanging:^NSString *(YMCaptchaCountdownButton *countDownButton, NSUInteger second) {
  324. // NSString *title = [NSString stringWithFormat:@"重新发送(%zds)",second];
  325. // return title;
  326. // }];
  327. //
  328. // [sender countDownFinished:^NSString *(YMCaptchaCountdownButton *countDownButton, NSUInteger second) {
  329. // countDownButton.enabled = YES;
  330. // return @"重新发送";
  331. //
  332. // }];
  333. //
  334. // }];
  335. // };
  336. // UIView *currentVCView = [LCTools getCurrentVC].view;
  337. // if (currentVCView != nil && ![currentVCView isEqual:NSNull.null]) {
  338. // [view showInView:currentVCView];
  339. // }
  340. }];
  341. }
  342. return _getVerifyCodeBtn;
  343. }
  344. - (UIView *)passwordView{
  345. if (!_passwordView) {
  346. _passwordView = [[UIView alloc]init];
  347. }
  348. return _passwordView;
  349. }
  350. - (UILabel *)passwordLb{
  351. if (!_passwordLb) {
  352. _passwordLb = [[UILabel alloc]init];
  353. _passwordLb.font = LCBoldFont(17);
  354. _passwordLb.textColor = HexColorFromRGB(0x1B2739);
  355. _passwordLb.textAlignment = NSTextAlignmentLeft;
  356. _passwordLb.text = @"密码";
  357. }
  358. return _passwordLb;
  359. }
  360. - (UITextField *)passwordInputBox{
  361. if (!_passwordInputBox) {
  362. NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
  363. style.minimumLineHeight = 0;
  364. NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入密码"];
  365. placeholderAttributed.yy_paragraphStyle = style;
  366. placeholderAttributed.yy_font = LCFont(14);
  367. placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
  368. _passwordInputBox = [[UITextField alloc]init];
  369. _passwordInputBox.attributedPlaceholder = placeholderAttributed;
  370. _passwordInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
  371. _passwordInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
  372. _passwordInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
  373. _passwordInputBox.keyboardType = UIKeyboardTypeDefault;
  374. _passwordInputBox.secureTextEntry = YES;
  375. //@weakify(self)
  376. [[[_passwordInputBox rac_textSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  377. //@strongify(self)
  378. }];
  379. }
  380. return _passwordInputBox;
  381. }
  382. - (UIView *)agreementView{
  383. if (!_agreementView) {
  384. _agreementView = [[UIView alloc]init];
  385. }
  386. return _agreementView;
  387. }
  388. - (UIButton *)radioBtn{
  389. if (!_radioBtn) {
  390. _radioBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  391. [_radioBtn setBackgroundImage:ImageByName(@"ym_login_auth_normal_icon") forState:UIControlStateNormal];
  392. [_radioBtn setBackgroundImage:ImageByName(@"ym_login_auth_selected_icon") forState:UIControlStateSelected];
  393. // WS(weakSelf)
  394. [[[_radioBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  395. sender.selected = !sender.selected;
  396. }];
  397. }
  398. return _radioBtn;
  399. }
  400. - (YYLabel *)agreementLb{
  401. if (!_agreementLb) {
  402. _agreementLb = [[YYLabel alloc] init];
  403. _agreementLb.numberOfLines = 0;
  404. _agreementLb.preferredMaxLayoutWidth = kFrameWidth - 55;
  405. NSString *agreementText = @"同意《用户协议》与《隐私政策》";
  406. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
  407. paragraphStyle.alignment = NSTextAlignmentLeft;
  408. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:agreementText];
  409. attributedString.yy_font = LCFont(12);
  410. attributedString.yy_color = HexColorFromRGBA(0x000000,0.65);
  411. attributedString.yy_paragraphStyle = paragraphStyle;
  412. //设置高亮色和点击事件
  413. [attributedString yy_setTextHighlightRange:[agreementText rangeOfString:@"《用户协议》"] color:AGREEMENTColor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  414. YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
  415. ParamsUrl:[NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserProtocolH5]
  416. }];
  417. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
  418. RouterViewModel:webArticleVM
  419. } completion:nil];
  420. }];
  421. //设置高亮色和点击事件
  422. [attributedString yy_setTextHighlightRange:[[attributedString string] rangeOfString:@"《隐私政策》"] color:AGREEMENTColor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  423. YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
  424. ParamsUrl:[NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserPrivacyH5]
  425. }];
  426. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
  427. RouterViewModel:webArticleVM
  428. } completion:nil];
  429. }];
  430. _agreementLb.attributedText = attributedString;
  431. }
  432. return _agreementLb;
  433. }
  434. - (UIButton *)confirmBtn{
  435. if (!_confirmBtn) {
  436. _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  437. _confirmBtn.titleLabel.font = LCBoldFont(15);
  438. [_confirmBtn setTitle:@"确定" forState:UIControlStateNormal];
  439. [_confirmBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  440. [_confirmBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  441. _confirmBtn.layer.cornerRadius = adapt(40)/2;
  442. WS(weakSelf)
  443. [[[_confirmBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  444. if (OCStringIsEmpty(weakSelf.mobileInputBox.text)) {
  445. [ZCHUDHelper showTitle:@"请输入手机号"];
  446. return;
  447. }
  448. if (OCStringIsEmpty(weakSelf.verifyCodeInputBox.text)) {
  449. [ZCHUDHelper showTitle:@"请输入短信验证码"];
  450. return;
  451. }
  452. if (OCStringIsEmpty(weakSelf.passwordInputBox.text)) {
  453. [ZCHUDHelper showTitle:@"请输入密码"];
  454. return;
  455. }
  456. if (!weakSelf.radioBtn.selected) {
  457. YMLoginRegistrAgreementPopupView *customView = [[YMLoginRegistrAgreementPopupView alloc]init];
  458. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
  459. popupView.priority = 999;
  460. popupView.cornerRadius = adapt(10);
  461. popupView.rectCorners = UIRectCornerAllCorners;
  462. popupView.positionStyle = YMPositionStyleCenter;
  463. popupView.isHideBg = NO;
  464. popupView.bgAlpha = 0.3;
  465. [popupView pop];
  466. @weakify(popupView)
  467. customView.buttonBlock = ^(BOOL isConfirm) {
  468. @strongify(popupView)
  469. if (isConfirm) {
  470. weakSelf.radioBtn.selected = YES;
  471. [weakSelf.viewModel retrievePasswordRequest];
  472. }
  473. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  474. };
  475. customView.dismissBlock = ^{
  476. @strongify(popupView)
  477. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  478. };
  479. return;
  480. }
  481. [weakSelf.viewModel retrievePasswordRequest];
  482. }];
  483. }
  484. return _confirmBtn;
  485. }
  486. @end