YMRegisterView.m 23 KB

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