YMRegisterView.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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. @interface YMRegisterView ()
  11. /// 注册VM
  12. @property (nonatomic, strong) YMRegisterViewModel *viewModel;
  13. /// 背景图
  14. @property (nonatomic, strong) UIImageView *bgImgv;
  15. /// 注册提示
  16. @property (nonatomic, strong) UILabel *registerTipsLb;
  17. /// 分割线
  18. @property (nonatomic, strong) UIView *line1;
  19. /// 分割线
  20. @property (nonatomic, strong) UIView *line2;
  21. /// 分割线
  22. @property (nonatomic, strong) UIView *line3;
  23. /// 手机视图
  24. @property (nonatomic, strong) UIView *mobileView;
  25. /// 手机号标签
  26. @property (nonatomic, strong) UILabel *mobileLb;
  27. /// 手机号输入框
  28. @property (nonatomic, strong) UITextField *mobileInputBox;
  29. /// 验证码视图
  30. @property (nonatomic, strong) UIView *verifyCodeView;
  31. /// 验证码标签
  32. @property (nonatomic, strong) UILabel *verifyCodeLb;
  33. /// 验证码输入框
  34. @property (nonatomic, strong) UITextField *verifyCodeInputBox;
  35. /// 获取验证码
  36. @property (nonatomic, strong) YMCaptchaCountdownButton *getVerifyCodeBtn;
  37. /// 密码视图
  38. @property (nonatomic, strong) UIView *passwordView;
  39. /// 密码标签
  40. @property (nonatomic, strong) UILabel *passwordLb;
  41. /// 密码输入框
  42. @property (nonatomic, strong) UITextField *passwordInputBox;
  43. /// 协议视图
  44. @property (nonatomic, strong) UIView *agreementView;
  45. /// 单选按钮
  46. @property (nonatomic, strong) UIButton *radioBtn;
  47. /// 协议标签
  48. @property (nonatomic, strong) YYLabel *agreementLb;
  49. /// 确定按钮
  50. @property (nonatomic, strong) UIButton *registerBtn;
  51. @end
  52. @implementation YMRegisterView
  53. - (instancetype)initWithFrame:(CGRect)frame{
  54. self = [super initWithFrame:frame];
  55. if (self) {
  56. }
  57. return self;
  58. }
  59. - (void)ym_setupViews{
  60. [self addSubview:self.bgImgv];
  61. [self addSubview:self.registerTipsLb];
  62. [self addSubview:self.mobileView];
  63. [self.mobileView addSubview:self.mobileLb];
  64. [self.mobileView addSubview:self.mobileInputBox];
  65. [self addSubview:self.verifyCodeView];
  66. [self.verifyCodeView addSubview:self.verifyCodeLb];
  67. [self.verifyCodeView addSubview:self.verifyCodeInputBox];
  68. [self.verifyCodeView addSubview:self.getVerifyCodeBtn];
  69. [self addSubview:self.passwordView];
  70. [self.passwordView addSubview:self.passwordLb];
  71. [self.passwordView addSubview:self.passwordInputBox];
  72. [self addSubview:self.agreementView];
  73. [self.agreementView addSubview:self.radioBtn];
  74. [self.agreementView addSubview:self.agreementLb];
  75. [self addSubview:self.registerBtn];
  76. self.line1 = [UIView new];
  77. self.line2 = [UIView new];
  78. self.line3 = [UIView new];
  79. for (UIView *line in @[self.line1,self.line2,self.line3]) {
  80. line.backgroundColor = HexColorFromRGBA(0x7E868E,0.24);
  81. }
  82. [self.mobileView addSubview:self.line1];
  83. [self.verifyCodeView addSubview:self.line2];
  84. [self.passwordView addSubview:self.line3];
  85. [self setNeedsUpdateConstraints];
  86. [self updateConstraintsIfNeeded];
  87. }
  88. - (void)updateConstraints{
  89. [self.bgImgv mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.top.left.right.equalTo(self);
  91. make.height.mas_equalTo(adapt(360));
  92. }];
  93. [self.registerTipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.top.equalTo(self).offset(adapt(24));
  95. make.left.equalTo(self).offset(adapt(30));
  96. make.right.equalTo(self).offset(adapt(-30));
  97. make.height.mas_equalTo(adapt(60));
  98. }];
  99. [self.mobileView mas_makeConstraints:^(MASConstraintMaker *make) {
  100. make.top.equalTo(self.registerTipsLb.mas_bottom).offset(adapt(16));
  101. make.left.equalTo(self).offset(adapt(30));
  102. make.right.equalTo(self).offset(adapt(-30));
  103. make.height.mas_equalTo(adapt(55));
  104. }];
  105. [self.mobileLb mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.left.equalTo(self.mobileView);
  107. make.centerY.equalTo(self.mobileView);
  108. make.width.mas_equalTo(adapt(70));
  109. }];
  110. [self.mobileInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
  111. make.left.equalTo(self.mobileLb.mas_right).offset(adapt(10));
  112. make.right.equalTo(self.passwordView).offset(adapt(-10));
  113. make.centerY.equalTo(self.mobileLb);
  114. make.height.mas_equalTo(adapt(55));
  115. }];
  116. [self.line1 mas_makeConstraints:^(MASConstraintMaker *make) {
  117. make.centerY.equalTo(self.mobileView);
  118. make.left.equalTo(self.mobileLb.mas_right);
  119. make.height.mas_equalTo(adapt(34));
  120. make.width.mas_equalTo(1);
  121. }];
  122. [self.verifyCodeView mas_makeConstraints:^(MASConstraintMaker *make) {
  123. make.top.equalTo(self.mobileView.mas_bottom).offset(adapt(16));
  124. make.left.equalTo(self.mobileView.mas_left);
  125. make.right.equalTo(self.mobileView.mas_right);
  126. make.height.mas_equalTo(adapt(55));
  127. }];
  128. [self.verifyCodeLb mas_makeConstraints:^(MASConstraintMaker *make) {
  129. make.left.equalTo(self.verifyCodeView);
  130. make.centerY.equalTo(self.verifyCodeView);
  131. make.width.mas_equalTo(adapt(70));
  132. }];
  133. [self.verifyCodeInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
  134. make.left.equalTo(self.verifyCodeLb.mas_right).offset(adapt(10));
  135. make.centerY.equalTo(self.verifyCodeLb);
  136. make.height.mas_equalTo(adapt(55));
  137. }];
  138. [self.verifyCodeInputBox setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
  139. [self.getVerifyCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  140. make.left.equalTo(self.verifyCodeInputBox.mas_right).offset(adapt(10));
  141. make.right.equalTo(self.verifyCodeView).offset(-20);
  142. make.top.equalTo(self.verifyCodeView);
  143. make.bottom.equalTo(self.verifyCodeView);
  144. }];
  145. [self.line2 mas_makeConstraints:^(MASConstraintMaker *make) {
  146. make.centerY.equalTo(self.verifyCodeView);
  147. make.left.equalTo(self.verifyCodeLb.mas_right);
  148. make.height.mas_equalTo(adapt(34));
  149. make.width.mas_equalTo(1);
  150. }];
  151. [self.passwordView mas_makeConstraints:^(MASConstraintMaker *make) {
  152. make.top.equalTo(self.verifyCodeView.mas_bottom).offset(adapt(16));
  153. make.left.equalTo(self.mobileView.mas_left);
  154. make.right.equalTo(self.mobileView.mas_right);
  155. make.height.mas_equalTo(adapt(55));
  156. }];
  157. [self.passwordLb mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.left.equalTo(self.passwordView);
  159. make.centerY.equalTo(self.passwordView);
  160. make.width.mas_equalTo(adapt(70));
  161. }];
  162. [self.passwordInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
  163. make.left.equalTo(self.passwordLb.mas_right).offset(adapt(10));
  164. make.centerY.equalTo(self.passwordLb);
  165. make.right.equalTo(self.passwordView).offset(adapt(-10));
  166. make.height.mas_equalTo(adapt(30));
  167. }];
  168. [self.line3 mas_makeConstraints:^(MASConstraintMaker *make) {
  169. make.centerY.equalTo(self.passwordView);
  170. make.left.equalTo(self.passwordLb.mas_right);
  171. make.height.mas_equalTo(adapt(34));
  172. make.width.mas_equalTo(1);
  173. }];
  174. [self.registerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  175. make.top.equalTo(self.passwordView.mas_bottom).offset(adapt(16));
  176. make.left.equalTo(self.mobileView.mas_left);
  177. make.right.equalTo(self.mobileView.mas_right);
  178. make.height.mas_equalTo(adapt(55));
  179. }];
  180. [self.agreementView mas_makeConstraints:^(MASConstraintMaker *make) {
  181. make.centerX.equalTo(self.mas_centerX);
  182. make.bottom.equalTo(self).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  183. }];
  184. [self.radioBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  185. make.centerY.equalTo(self.agreementLb.mas_centerY);
  186. make.left.equalTo(self.agreementView).offset(adapt(5));
  187. make.width.height.mas_equalTo(adapt(17));
  188. }];
  189. [self.agreementLb mas_makeConstraints:^(MASConstraintMaker *make) {
  190. make.top.equalTo(self.agreementView).offset(adapt(10));
  191. make.left.equalTo(self.radioBtn.mas_right).offset(adapt(5));
  192. make.right.equalTo(self.agreementView).offset(adapt(-5));
  193. make.bottom.equalTo(self.agreementView).offset(adapt(-10));
  194. }];
  195. [super updateConstraints];
  196. }
  197. - (void)ym_bindViewModel:(YMRegisterViewModel *)viewModel{
  198. if (!viewModel) {
  199. return;
  200. }
  201. _viewModel = viewModel;
  202. RAC(self.viewModel , mobile) = [[RACSignal merge:@[RACObserve(self.mobileInputBox, text),self.mobileInputBox.rac_textSignal]] takeUntil:self.rac_willDeallocSignal];
  203. RAC(self.viewModel , verifyCode) = [[RACSignal merge:@[RACObserve(self.verifyCodeInputBox, text),self.verifyCodeInputBox.rac_textSignal]]takeUntil:self.rac_willDeallocSignal];
  204. RAC(self.viewModel , password) = [[RACSignal merge:@[RACObserve(self.passwordInputBox, text),self.passwordInputBox.rac_textSignal]]takeUntil:self.rac_willDeallocSignal];
  205. [self.viewModel.validRegisterSignal subscribeNext:^(id _Nullable value) {
  206. self.registerBtn.enabled = [value boolValue];
  207. if ([value boolValue]) {
  208. self.registerBtn.alpha = 1;
  209. } else {
  210. self.registerBtn.alpha = 0.5;
  211. }
  212. }];
  213. }
  214. - (UIImageView *)bgImgv {
  215. if (!_bgImgv) {
  216. _bgImgv = [[UIImageView alloc]init];
  217. _bgImgv.image = ImageByName(@"ym_login_phone_bg");
  218. }
  219. return _bgImgv;
  220. }
  221. - (UIView *)mobileView{
  222. if (!_mobileView) {
  223. _mobileView = [[UIView alloc]init];
  224. _mobileView.backgroundColor = UIColor.whiteColor;
  225. [_mobileView addRectCorner:(UIRectCornerAllCorners) radius:adapt(55) / 2.0];
  226. }
  227. return _mobileView;
  228. }
  229. - (UILabel *)registerTipsLb {
  230. if (!_registerTipsLb) {
  231. _registerTipsLb = [[UILabel alloc]init];
  232. _registerTipsLb.hidden = NO;
  233. _registerTipsLb.font = LCBoldFont(24);
  234. _registerTipsLb.textColor = HexColorFromRGB(0xEE538F);
  235. _registerTipsLb.textAlignment = NSTextAlignmentLeft;
  236. _registerTipsLb.text = @"您好,\n欢迎注册";
  237. _registerTipsLb.numberOfLines = 0;
  238. }
  239. return _registerTipsLb;
  240. }
  241. - (UILabel *)mobileLb{
  242. if (!_mobileLb) {
  243. _mobileLb = [[UILabel alloc]init];
  244. _mobileLb.font = LCFont(14);
  245. _mobileLb.textColor = HexColorFromRGB(0x1B2739);
  246. _mobileLb.textAlignment = NSTextAlignmentCenter;
  247. _mobileLb.text = @"手机号";
  248. }
  249. return _mobileLb;
  250. }
  251. - (UITextField *)mobileInputBox{
  252. if (!_mobileInputBox) {
  253. NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
  254. style.minimumLineHeight = 0;
  255. NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入手机号"];
  256. placeholderAttributed.yy_paragraphStyle = style;
  257. placeholderAttributed.yy_font = LCFont(14);
  258. placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
  259. _mobileInputBox = [[UITextField alloc]init];
  260. _mobileInputBox.attributedPlaceholder = placeholderAttributed;
  261. _mobileInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
  262. _mobileInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
  263. _mobileInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
  264. _mobileInputBox.keyboardType = UIKeyboardTypePhonePad;
  265. _mobileInputBox.ba_maxLength = 11;
  266. // @weakify(self)
  267. [[[_mobileInputBox rac_textSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  268. // @strongify(self)
  269. }];
  270. }
  271. return _mobileInputBox;
  272. }
  273. - (UIView *)verifyCodeView{
  274. if (!_verifyCodeView) {
  275. _verifyCodeView = [[UIView alloc]init];
  276. _verifyCodeView.backgroundColor = UIColor.whiteColor;
  277. [_verifyCodeView addRectCorner:(UIRectCornerAllCorners) radius:adapt(55) / 2.0];
  278. }
  279. return _verifyCodeView;
  280. }
  281. - (UILabel *)verifyCodeLb{
  282. if (!_verifyCodeLb) {
  283. _verifyCodeLb = [[UILabel alloc]init];
  284. _verifyCodeLb.font = LCFont(14);
  285. _verifyCodeLb.textColor = HexColorFromRGB(0x1B2739);
  286. _verifyCodeLb.textAlignment = NSTextAlignmentCenter;
  287. _verifyCodeLb.text = @"验证码";
  288. }
  289. return _verifyCodeLb;
  290. }
  291. - (UITextField *)verifyCodeInputBox{
  292. if (!_verifyCodeInputBox) {
  293. NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
  294. style.minimumLineHeight = 0;
  295. NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入手机验证码"];
  296. placeholderAttributed.yy_paragraphStyle = style;
  297. placeholderAttributed.yy_font = LCFont(14);
  298. placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
  299. _verifyCodeInputBox = [[UITextField alloc]init];
  300. _verifyCodeInputBox.attributedPlaceholder = placeholderAttributed;
  301. _verifyCodeInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
  302. _verifyCodeInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
  303. _verifyCodeInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
  304. _verifyCodeInputBox.keyboardType = UIKeyboardTypeDecimalPad;
  305. // @weakify(self)
  306. [[[_verifyCodeInputBox rac_textSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  307. // @strongify(self)
  308. }];
  309. }
  310. return _verifyCodeInputBox;
  311. }
  312. - (YMCaptchaCountdownButton *)getVerifyCodeBtn{
  313. if (!_getVerifyCodeBtn) {
  314. _getVerifyCodeBtn = [YMCaptchaCountdownButton buttonWithType:UIButtonTypeCustom];
  315. _getVerifyCodeBtn.titleLabel.font = LCFont(14);
  316. [_getVerifyCodeBtn setTitleColor:HexColorFromRGB(0xFF6893) forState:UIControlStateNormal];
  317. [_getVerifyCodeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
  318. [_getVerifyCodeBtn countDownButtonHandler:^(YMCaptchaCountdownButton *sender, NSInteger tag) {
  319. if (OCStringIsEmpty(self.mobileInputBox.text)) {
  320. [ZCHUDHelper showTitle:@"请输入手机号"];
  321. return;
  322. }
  323. [self.mobileInputBox resignFirstResponder];
  324. [self.verifyCodeInputBox resignFirstResponder];
  325. [self.passwordInputBox resignFirstResponder];
  326. [self.viewModel getVerifyCodeHandler:^(NSDictionary * _Nonnull dic, NSError * _Nullable error) {
  327. sender.enabled = NO;
  328. [sender startCountDownWithSecond:59];
  329. [sender countDownChanging:^NSString *(YMCaptchaCountdownButton *countDownButton, NSUInteger second) {
  330. NSString *title = [NSString stringWithFormat:@"重新发送(%zds)",second];
  331. return title;
  332. }];
  333. [sender countDownFinished:^NSString *(YMCaptchaCountdownButton *countDownButton, NSUInteger second) {
  334. countDownButton.enabled = YES;
  335. return @"重新发送";
  336. }];
  337. }];
  338. }];
  339. }
  340. return _getVerifyCodeBtn;
  341. }
  342. - (UIView *)passwordView{
  343. if (!_passwordView) {
  344. _passwordView = [[UIView alloc]init];
  345. _passwordView.backgroundColor = UIColor.whiteColor;
  346. [_passwordView addRectCorner:(UIRectCornerAllCorners) radius:adapt(55) / 2.0];
  347. }
  348. return _passwordView;
  349. }
  350. - (UILabel *)passwordLb{
  351. if (!_passwordLb) {
  352. _passwordLb = [[UILabel alloc]init];
  353. _passwordLb.font = LCFont(14);
  354. _passwordLb.textColor = HexColorFromRGB(0x1B2739);
  355. _passwordLb.textAlignment = NSTextAlignmentCenter;
  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. [[[_radioBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  394. sender.selected = !sender.selected;
  395. }];
  396. }
  397. return _radioBtn;
  398. }
  399. - (YYLabel *)agreementLb{
  400. if (!_agreementLb) {
  401. _agreementLb = [[YYLabel alloc] init];
  402. _agreementLb.numberOfLines = 0;
  403. _agreementLb.preferredMaxLayoutWidth = kFrameWidth - 55;
  404. NSString *agreementText = @"同意《用户协议》与《隐私政策》";
  405. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
  406. paragraphStyle.alignment = NSTextAlignmentLeft;
  407. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:agreementText];
  408. attributedString.yy_font = LCFont(12);
  409. attributedString.yy_color = HexColorFromRGBA(0x000000,0.65);
  410. attributedString.yy_paragraphStyle = paragraphStyle;
  411. //设置高亮色和点击事件
  412. [attributedString yy_setTextHighlightRange:[agreementText rangeOfString:@"《用户协议》"] color:HexColorFromRGB(0x6D82FD) backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  413. YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
  414. ParamsUrl:[NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserProtocolH5]
  415. }];
  416. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
  417. RouterViewModel:webArticleVM
  418. } completion:nil];
  419. }];
  420. //设置高亮色和点击事件
  421. [attributedString yy_setTextHighlightRange:[[attributedString string] rangeOfString:@"《隐私政策》"] color:HexColorFromRGB(0x6D82FD) backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  422. YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
  423. ParamsUrl:[NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserPrivacyH5]
  424. }];
  425. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
  426. RouterViewModel:webArticleVM
  427. } completion:nil];
  428. }];
  429. _agreementLb.attributedText = attributedString;
  430. }
  431. return _agreementLb;
  432. }
  433. - (UIButton *)registerBtn{
  434. if (!_registerBtn) {
  435. _registerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  436. _registerBtn.titleLabel.font = LCBoldFont(15);
  437. [_registerBtn setTitle:@"注册" forState:UIControlStateNormal];
  438. [_registerBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  439. [_registerBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  440. _registerBtn.layer.cornerRadius = adapt(55)/2;
  441. _registerBtn.backgroundColor = UIColor.whiteColor;
  442. WS(weakSelf)
  443. [[[_registerBtn 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 registerRequest];
  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 registerRequest];
  482. }];
  483. }
  484. return _registerBtn;
  485. }
  486. @end