YMPasswordLoginView.m 23 KB

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