YMPasswordLoginView.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. //
  2. // YMPasswordLoginView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/4.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMPasswordLoginView.h"
  9. #import "YMPasswordLoginViewModel.h"
  10. @interface YMPasswordLoginView ()
  11. /// 密码登录VM
  12. @property (nonatomic, strong) YMPasswordLoginViewModel *viewModel;
  13. @property (nonatomic, strong) UIView *topView;
  14. @property (nonatomic, strong) UILabel *topLb1;
  15. @property (nonatomic, strong) UILabel *topLb2;
  16. @property (nonatomic, strong) UIImageView *bgImgv;
  17. /// 手机视图
  18. @property (nonatomic, strong) UIView *mobileView;
  19. /// 手机号标签
  20. @property (nonatomic, strong) UILabel *mobileLb;
  21. /// 手机号输入框
  22. @property (nonatomic, strong) UITextField *mobileInputBox;
  23. /// 密码视图
  24. @property (nonatomic, strong) UIView *passwordView;
  25. /// 密码标签
  26. @property (nonatomic, strong) UILabel *passwordLb;
  27. /// 密码输入框
  28. @property (nonatomic, strong) UITextField *passwordInputBox;
  29. @property (nonatomic, strong) UIView *lineView1;
  30. @property (nonatomic, strong) UIView *lineView2;
  31. /// 登录按钮
  32. @property (nonatomic, strong) UIButton *loginBtn;
  33. /** 忘记密码按钮*/
  34. @property (nonatomic, strong) UIButton *forgotPasswordBtn;
  35. /** 注册按钮*/
  36. @property (nonatomic, strong) UIButton *registerBtn;
  37. /** 登录方式堆叠视图*/
  38. @property (nonatomic, strong) UIStackView *loginMethodStackView;
  39. /// 微信登录按钮
  40. @property (nonatomic, strong) UIButton *wechatLoginBtn;
  41. /// 协议视图
  42. @property (nonatomic, strong) UIView *agreementView;
  43. /// 单选按钮
  44. @property (nonatomic, strong) UIButton *radioBtn;
  45. /// 协议标签
  46. @property (nonatomic, strong) YYLabel *agreementLb;
  47. @end
  48. @implementation YMPasswordLoginView
  49. - (void)ym_setupViews{
  50. [self addSubview:self.bgImgv];
  51. [self addSubview:self.topView];
  52. [self.topView addSubview:self.topLb1];
  53. [self.topView addSubview:self.topLb2];
  54. [self addSubview:self.mobileView];
  55. [self.mobileView addSubview:self.mobileLb];
  56. [self.mobileView addSubview:self.mobileInputBox];
  57. [self.mobileView addSubview:self.lineView1];
  58. [self addSubview:self.passwordView];
  59. [self.passwordView addSubview:self.passwordLb];
  60. [self.passwordView addSubview:self.passwordInputBox];
  61. [self.passwordView addSubview:self.lineView2];
  62. [self addSubview:self.loginBtn];
  63. [self addSubview:self.forgotPasswordBtn];
  64. [self addSubview:self.registerBtn];
  65. [self addSubview:self.loginMethodStackView];
  66. [self.loginMethodStackView addArrangedSubview:self.wechatLoginBtn];
  67. [self addSubview:self.agreementView];
  68. [self.agreementView addSubview:self.radioBtn];
  69. [self.agreementView addSubview:self.agreementLb];
  70. [self setNeedsUpdateConstraints];
  71. [self updateConstraintsIfNeeded];
  72. }
  73. - (void)updateConstraints{
  74. [self.bgImgv mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.top.left.right.equalTo(self);
  76. make.height.mas_equalTo(adapt(330));
  77. }];
  78. [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.top.equalTo(self).offset(adapt(30));
  80. make.left.equalTo(self).offset(adapt(30));
  81. make.right.equalTo(self).offset(adapt(-30));
  82. make.height.mas_equalTo(adapt(85));
  83. }];
  84. [self.topLb1 mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.top.equalTo(self.topView);
  86. make.left.equalTo(self.topView);
  87. make.right.equalTo(self.topView);
  88. }];
  89. [self.topLb2 mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.top.equalTo(self.topLb1.mas_bottom).offset(5);
  91. make.left.equalTo(self.topView);
  92. make.right.equalTo(self.topView);
  93. }];
  94. [self.mobileView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.top.equalTo(self.topView.mas_bottom);
  96. make.left.equalTo(self).offset(adapt(30));
  97. make.right.equalTo(self).offset(adapt(-30));
  98. make.height.mas_equalTo(adapt(55));
  99. }];
  100. [self.mobileLb mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.centerY.equalTo(self.mobileView);
  102. make.left.equalTo(self.mobileView);
  103. make.width.mas_equalTo(adapt(65));
  104. }];
  105. [self.mobileInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.top.equalTo(self.mobileView);
  107. make.left.equalTo(self.mobileLb.mas_right).offset(adapt(10));
  108. make.right.equalTo(self.mobileView);
  109. make.bottom.equalTo(self.mobileView);
  110. //make.height.mas_equalTo(adapt(30));
  111. }];
  112. [self.lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  113. make.centerY.equalTo(self.mobileView);
  114. make.left.equalTo(self.mobileLb.mas_right);
  115. make.height.mas_equalTo(adapt(34));
  116. make.width.mas_equalTo(1);
  117. }];
  118. [self.passwordView mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.top.equalTo(self.mobileView.mas_bottom).offset(adapt(16));
  120. make.left.equalTo(self.mobileView.mas_left);
  121. make.right.equalTo(self.mobileView.mas_right);
  122. make.height.mas_equalTo(adapt(55));
  123. }];
  124. [self.passwordLb mas_makeConstraints:^(MASConstraintMaker *make) {
  125. make.centerY.equalTo(self.passwordView);
  126. make.left.equalTo(self.passwordView);
  127. make.width.mas_equalTo(adapt(65));
  128. }];
  129. [self.passwordInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
  130. make.top.equalTo(self.passwordView);
  131. make.left.equalTo(self.passwordLb.mas_right).offset(adapt(10));
  132. make.right.equalTo(self.passwordView);
  133. make.bottom.equalTo(self.passwordView);
  134. //make.height.mas_equalTo(adapt(30));
  135. }];
  136. [self.lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
  137. make.centerY.equalTo(self.passwordView);
  138. make.left.equalTo(self.passwordLb.mas_right);
  139. make.height.mas_equalTo(adapt(34));
  140. make.width.mas_equalTo(1);
  141. }];
  142. [self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  143. make.top.equalTo(self.passwordView.mas_bottom).offset(adapt(16));
  144. make.left.equalTo(self.mobileView.mas_left);
  145. make.right.equalTo(self.mobileView.mas_right);
  146. make.height.mas_equalTo(55);
  147. }];
  148. [self.forgotPasswordBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  149. make.top.equalTo(self.loginBtn.mas_bottom).offset(adapt(16));
  150. make.left.equalTo(self.loginBtn.mas_left);
  151. make.height.mas_equalTo(adapt(25));
  152. }];
  153. [self.registerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  154. make.top.equalTo(self.loginBtn.mas_bottom).offset(adapt(16));
  155. make.right.equalTo(self.loginBtn.mas_right);
  156. make.height.mas_equalTo(adapt(25));
  157. }];
  158. [self.loginMethodStackView mas_makeConstraints:^(MASConstraintMaker *make) {
  159. make.centerX.equalTo(self.mas_centerX);
  160. make.bottom.equalTo(self.agreementView.mas_top).offset(adapt(-10));
  161. }];
  162. [self.wechatLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  163. make.width.height.mas_equalTo(53);
  164. make.bottom.equalTo(self.agreementView.mas_top).offset(adapt(-10));
  165. }];
  166. [self.agreementView mas_makeConstraints:^(MASConstraintMaker *make) {
  167. make.centerX.equalTo(self.mas_centerX);
  168. make.bottom.equalTo(self).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  169. }];
  170. [self.radioBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  171. make.centerY.equalTo(self.agreementLb.mas_centerY);
  172. make.left.equalTo(self.agreementView).offset(adapt(5));
  173. make.width.height.mas_equalTo(adapt(17));
  174. }];
  175. [self.agreementLb mas_makeConstraints:^(MASConstraintMaker *make) {
  176. make.top.equalTo(self.agreementView).offset(adapt(10));
  177. make.left.equalTo(self.radioBtn.mas_right).offset(adapt(5));
  178. make.right.equalTo(self.agreementView).offset(adapt(-5));
  179. make.bottom.equalTo(self.agreementView).offset(adapt(-10));
  180. }];
  181. [super updateConstraints];
  182. }
  183. - (void)ym_bindViewModel:(YMPasswordLoginViewModel *)viewModel{
  184. if (!viewModel) {
  185. return;
  186. }
  187. _viewModel = viewModel;
  188. RAC(self.viewModel , mobile) = [[RACSignal merge:@[RACObserve(self.mobileInputBox, text),self.mobileInputBox.rac_textSignal]] takeUntil:self.rac_willDeallocSignal];
  189. RAC(self.viewModel , password) = [[RACSignal merge:@[RACObserve(self.passwordInputBox, text),self.passwordInputBox.rac_textSignal]]takeUntil:self.rac_willDeallocSignal];
  190. RAC(self.loginBtn , enabled) = self.viewModel.validLoginSignal;
  191. [self.viewModel.validLoginSignal subscribeNext:^(id _Nullable value) {
  192. self.loginBtn.enabled = [value boolValue];
  193. if ([value boolValue]) {
  194. self.loginBtn.alpha = 1;
  195. } else {
  196. self.loginBtn.alpha = 0.5;
  197. }
  198. }];
  199. }
  200. - (UIImageView *)bgImgv {
  201. if (!_bgImgv) {
  202. _bgImgv = [[UIImageView alloc] initWithImage:ImageByName(@"ym_login_phone_bg")];
  203. }
  204. return _bgImgv;
  205. }
  206. - (UIView *)mobileView{
  207. if (!_mobileView) {
  208. _mobileView = [[UIView alloc]init];
  209. _mobileView.backgroundColor = UIColor.whiteColor;
  210. [_mobileView addRectCorner:(UIRectCornerAllCorners) radius:adapt(55) / 2.0];
  211. }
  212. return _mobileView;
  213. }
  214. - (UIView *)topView{
  215. if (!_topView) {
  216. _topView = [[UIView alloc]init];
  217. _topView.hidden = NO;
  218. }
  219. return _topView;
  220. }
  221. - (UILabel *)mobileLb{
  222. if (!_mobileLb) {
  223. _mobileLb = [[UILabel alloc]init];
  224. _mobileLb.font = LCBoldFont(16);
  225. _mobileLb.textColor = HexColorFromRGB(0x1B2739);
  226. _mobileLb.textAlignment = NSTextAlignmentCenter;
  227. _mobileLb.text = @"+86";
  228. }
  229. return _mobileLb;
  230. }
  231. - (UILabel *)topLb1{
  232. if (!_topLb1) {
  233. _topLb1 = [[UILabel alloc]init];
  234. _topLb1.font = LCBoldFont(27);
  235. _topLb1.textColor = HexColorFromRGB(0xEE538F);
  236. _topLb1.textAlignment = NSTextAlignmentLeft;
  237. _topLb1.text = @"Hello!";
  238. }
  239. return _topLb1;
  240. }
  241. - (UILabel *)topLb2{
  242. if (!_topLb2) {
  243. _topLb2 = [[UILabel alloc]init];
  244. _topLb2.font = LCBoldFont(17);
  245. _topLb2.textColor = HexColorFromRGB(0xEE538F);
  246. _topLb2.textAlignment = NSTextAlignmentLeft;
  247. _topLb2.text = @"你来啦~";
  248. }
  249. return _topLb2;
  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. }
  267. return _mobileInputBox;
  268. }
  269. - (UIView *)passwordView{
  270. if (!_passwordView) {
  271. _passwordView = [[UIView alloc]init];
  272. _passwordView.backgroundColor = UIColor.whiteColor;
  273. [_passwordView addRectCorner:(UIRectCornerAllCorners) radius:adapt(55) / 2.0];
  274. }
  275. return _passwordView;
  276. }
  277. - (UIView *)lineView1{
  278. if (!_lineView1) {
  279. _lineView1 = [[UIView alloc]init];
  280. _lineView1.backgroundColor = HexColorFromRGBA(0x7E868E,0.24);
  281. }
  282. return _lineView1;
  283. }
  284. - (UIView *)lineView2{
  285. if (!_lineView2) {
  286. _lineView2 = [[UIView alloc]init];
  287. _lineView2.backgroundColor = HexColorFromRGBA(0x7E868E,0.24);
  288. }
  289. return _lineView2;
  290. }
  291. - (UILabel *)passwordLb{
  292. if (!_passwordLb) {
  293. _passwordLb = [[UILabel alloc]init];
  294. _passwordLb.font = LCBoldFont(17);
  295. _passwordLb.textColor = HexColorFromRGB(0x1B2739);
  296. _passwordLb.textAlignment = NSTextAlignmentCenter;
  297. _passwordLb.text = @"密码";
  298. }
  299. return _passwordLb;
  300. }
  301. - (UITextField *)passwordInputBox{
  302. if (!_passwordInputBox) {
  303. NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
  304. style.minimumLineHeight = 0;
  305. NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入密码"];
  306. placeholderAttributed.yy_paragraphStyle = style;
  307. placeholderAttributed.yy_font = LCFont(14);
  308. placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
  309. _passwordInputBox = [[UITextField alloc]init];
  310. _passwordInputBox.attributedPlaceholder = placeholderAttributed;
  311. _passwordInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
  312. _passwordInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
  313. _passwordInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
  314. _passwordInputBox.keyboardType = UIKeyboardTypeDefault;
  315. _passwordInputBox.secureTextEntry = YES;
  316. }
  317. return _passwordInputBox;
  318. }
  319. - (UIButton *)loginBtn{
  320. if (!_loginBtn) {
  321. _loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  322. _loginBtn.titleLabel.font = LCBoldFont(19);
  323. [_loginBtn setTitle:@"登录" forState:UIControlStateNormal];
  324. [_loginBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  325. [_loginBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  326. _loginBtn.layer.cornerRadius = adapt(55) / 2.0;
  327. _loginBtn.layer.masksToBounds = YES;
  328. WS(weakSelf)
  329. [[[_loginBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  330. if (OCStringIsEmpty(weakSelf.mobileInputBox.text)) {
  331. [ZCHUDHelper showTitle:@"请输入手机号"];
  332. return;
  333. }
  334. if (OCStringIsEmpty(weakSelf.passwordInputBox.text)) {
  335. [ZCHUDHelper showTitle:@"请输入密码"];
  336. return;
  337. }
  338. if (!weakSelf.radioBtn.selected) {
  339. YMLoginRegistrAgreementPopupView *customView = [[YMLoginRegistrAgreementPopupView alloc]init];
  340. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:[YMGlobalUtils getCurrentVC].view popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
  341. popupView.priority = 999;
  342. popupView.cornerRadius = adapt(10);
  343. popupView.rectCorners = UIRectCornerAllCorners;
  344. popupView.positionStyle = YMPositionStyleCenter;
  345. popupView.isHideBg = NO;
  346. popupView.bgAlpha = 0.3;
  347. [popupView pop];
  348. @weakify(popupView)
  349. customView.buttonBlock = ^(BOOL isConfirm) {
  350. @strongify(popupView)
  351. if (isConfirm) {
  352. weakSelf.radioBtn.selected = YES;
  353. [weakSelf.viewModel accountPasswordLoginRequest];
  354. }
  355. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  356. };
  357. customView.dismissBlock = ^{
  358. @strongify(popupView)
  359. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  360. };
  361. return;
  362. }
  363. [weakSelf.viewModel accountPasswordLoginRequest];
  364. }];
  365. }
  366. return _loginBtn;
  367. }
  368. - (UIButton *)forgotPasswordBtn{
  369. if (!_forgotPasswordBtn) {
  370. _forgotPasswordBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  371. _forgotPasswordBtn.titleLabel.font = LCFont(12);
  372. [_forgotPasswordBtn setTitle:@"忘记密码?" forState:UIControlStateNormal];
  373. [_forgotPasswordBtn setTitleColor:HexColorFromRGB(0x000000) forState:UIControlStateNormal];
  374. WS(weakSelf)
  375. [[[_forgotPasswordBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  376. [weakSelf.viewModel gotoForgetPasswordVC];
  377. }];
  378. }
  379. return _forgotPasswordBtn;
  380. }
  381. - (UIButton *)registerBtn{
  382. if (!_registerBtn) {
  383. _registerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  384. _registerBtn.titleLabel.font = LCFont(12);
  385. [_registerBtn setTitle:@"新用户注册" forState:UIControlStateNormal];
  386. [_registerBtn setTitleColor:HexColorFromRGB(0x000000) forState:UIControlStateNormal];
  387. WS(weakSelf)
  388. [[[_registerBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  389. [weakSelf.viewModel gotoRegisterVC];
  390. }];
  391. }
  392. return _registerBtn;
  393. }
  394. - (UIStackView *)loginMethodStackView{
  395. if (!_loginMethodStackView) {
  396. _loginMethodStackView = [[UIStackView alloc]init];
  397. /**
  398. UILayoutConstraintAxisVertical 纵向
  399. UILayoutConstraintAxisHorizontal 横向
  400. */
  401. _loginMethodStackView.axis = UILayoutConstraintAxisHorizontal;
  402. /**
  403. UIStackViewAlignmentFill 将stackView充满
  404. 比如label,不管文字多少,将大小按照设置的非主轴方向充满
  405. ex: Vertical 就是水平铺满
  406. UIStackViewAlignmentLeading 在Vertical方向上生效,表示左对齐
  407. 比如label,文字自适应,如果小于非主轴方向的宽度,将不充满
  408. UIStackViewAlignmentTop 在Horizontal方向上生效,表示左对齐
  409. 比如label,文字自适应,如果小于非主轴方向的高度,将不充满
  410. 本质UIStackViewAlignmentTop = UIStackViewAlignmentLeading
  411. UIStackViewAlignmentTrailing 在Vertical方向上生效,表示右对齐
  412. 比如label,文字自适应,如果小于非主轴方向的宽度,将不充满
  413. UIStackViewAlignmentBottom 在Horizontal方向上生效,表示右对齐
  414. 比如label,文字自适应,如果小于非主轴方向的高度,将不充满
  415. 本质UIStackViewAlignmentBottom = UIStackViewAlignmentTrailing
  416. UIStackViewAlignmentLastBaseline 仅限于Horizontal
  417. 按照最高的一个视图的bottom对齐,最高的视图top对齐
  418. UIStackViewAlignmentCenter 中心对齐
  419. 不充满,沿主轴方向中心对齐
  420. */
  421. _loginMethodStackView.alignment = UIStackViewAlignmentCenter;
  422. _loginMethodStackView.spacing = adapt(10);
  423. }
  424. return _loginMethodStackView;
  425. }
  426. - (UIButton *)wechatLoginBtn{
  427. if (!_wechatLoginBtn) {
  428. _wechatLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  429. [_wechatLoginBtn setBackgroundImage:ImageByName(@"ym_login_wechat_login_icon") forState:UIControlStateNormal];
  430. WS(weakSelf)
  431. [[[_wechatLoginBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  432. if (!weakSelf.radioBtn.selected) {
  433. YMLoginRegistrAgreementPopupView *customView = [[YMLoginRegistrAgreementPopupView alloc]init];
  434. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
  435. popupView.priority = 999;
  436. popupView.cornerRadius = adapt(10);
  437. popupView.rectCorners = UIRectCornerAllCorners;
  438. popupView.positionStyle = YMPositionStyleCenter;
  439. popupView.isHideBg = NO;
  440. popupView.bgAlpha = 0.3;
  441. [popupView pop];
  442. @weakify(popupView)
  443. customView.buttonBlock = ^(BOOL isConfirm) {
  444. @strongify(popupView)
  445. if (isConfirm) {
  446. weakSelf.radioBtn.selected = YES;
  447. [weakSelf.viewModel sendWechatAuth];
  448. }
  449. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  450. };
  451. customView.dismissBlock = ^{
  452. @strongify(popupView)
  453. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  454. };
  455. return;
  456. }
  457. [weakSelf.viewModel sendWechatAuth];
  458. }];
  459. }
  460. return _wechatLoginBtn;
  461. }
  462. - (UIView *)agreementView{
  463. if (!_agreementView) {
  464. _agreementView = [[UIView alloc]init];
  465. }
  466. return _agreementView;
  467. }
  468. - (UIButton *)radioBtn{
  469. if (!_radioBtn) {
  470. _radioBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  471. [_radioBtn setBackgroundImage:ImageByName(@"ym_login_auth_normal_icon") forState:UIControlStateNormal];
  472. [_radioBtn setBackgroundImage:ImageByName(@"ym_login_auth_selected_icon") forState:UIControlStateSelected];
  473. [[[_radioBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  474. sender.selected = !sender.selected;
  475. }];
  476. }
  477. return _radioBtn;
  478. }
  479. - (YYLabel *)agreementLb{
  480. if (!_agreementLb) {
  481. _agreementLb = [[YYLabel alloc] init];
  482. _agreementLb.numberOfLines = 0;
  483. _agreementLb.preferredMaxLayoutWidth = kFrameWidth - adapt(55);
  484. NSString *agreementText = @"登录即代表同意《用户协议》与《隐私政策》";
  485. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
  486. paragraphStyle.alignment = NSTextAlignmentLeft;
  487. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:agreementText];
  488. attributedString.yy_font = LCFont(12);
  489. attributedString.yy_color = HexColorFromRGBA(0x000000,0.65);
  490. attributedString.yy_paragraphStyle = paragraphStyle;
  491. //设置高亮色和点击事件
  492. [attributedString yy_setTextHighlightRange:[agreementText rangeOfString:@"《用户协议》"] color:AGREEMENTColor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  493. YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
  494. ParamsUrl:[NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserProtocolH5]
  495. }];
  496. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
  497. RouterViewModel:webArticleVM
  498. } completion:nil];
  499. }];
  500. //设置高亮色和点击事件
  501. [attributedString yy_setTextHighlightRange:[[attributedString string] rangeOfString:@"《隐私政策》"] color:AGREEMENTColor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  502. YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
  503. ParamsUrl:[NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserPrivacyH5]
  504. }];
  505. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
  506. RouterViewModel:webArticleVM
  507. } completion:nil];
  508. }];
  509. _agreementLb.attributedText = attributedString;
  510. }
  511. return _agreementLb;
  512. }
  513. @end