YMRegisterView.m 26 KB

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