YMGoddessCertifiedProtocolViewController.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // YMGoddessCertifiedProtocolViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/3/2.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMGoddessCertifiedProtocolViewController.h"
  9. #import "YMGoddessCertifiedProtocolView.h"
  10. @interface YMGoddessCertifiedProtocolViewController ()
  11. /// 女神认证协议VM
  12. @property (nonatomic, strong) YMGoddessCertifiedProtocolViewModel *viewModel;
  13. /// 网页文章视图
  14. @property (nonatomic, strong) YMGoddessCertifiedProtocolView *webArticleView;
  15. /// 同意协议按钮
  16. @property (nonatomic, strong) UIButton *consentAgreementBtn;
  17. @end
  18. @implementation YMGoddessCertifiedProtocolViewController
  19. @dynamic viewModel;
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. // Do any additional setup after loading the view.
  23. }
  24. - (void)viewWillAppear:(BOOL)animated {
  25. [super viewWillAppear:animated];
  26. if (self.viewModel.webViewLoadTitle == YES && OCStringIsEmpty(self.viewModel.webViewTitle)) {
  27. //webView已获取title,但返回时无法获取title,可能是内存不足原因造成,此时需重新加载同时避免第一次进入时重新加载
  28. [self.viewModel.refreshUISubject sendNext:@(YMRefreshUI)];
  29. }
  30. }
  31. - (void)viewWillDisappear:(BOOL)animated {
  32. [super viewWillDisappear:animated];
  33. if (!OCStringIsEmpty(self.viewModel.webViewTitle)) {
  34. self.viewModel.webViewLoadTitle = YES;
  35. }
  36. }
  37. - (void)ym_setupViews{
  38. [self.view addSubview:self.webArticleView];
  39. [self.view addSubview:self.consentAgreementBtn];
  40. [self.view setNeedsUpdateConstraints];
  41. [self.view updateConstraintsIfNeeded];
  42. }
  43. - (void)updateViewConstraints{
  44. [self.webArticleView mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.equalTo(self.view).offset(kYMNavHeight);
  46. make.left.equalTo(self.view);
  47. make.right.equalTo(self.view);
  48. }];
  49. [self.consentAgreementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.equalTo(self.webArticleView.mas_bottom).offset(adapt(10));
  51. make.left.equalTo(self.view).offset(adapt(24));
  52. make.right.equalTo(self.view).offset(adapt(-24));
  53. make.bottom.equalTo(self.view).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  54. make.height.mas_equalTo(adapt(45));
  55. }];
  56. [super updateViewConstraints];
  57. }
  58. - (void)ym_bindViewModel{
  59. [self.webArticleView ym_bindViewModel:self.viewModel];
  60. }
  61. - (YMGoddessCertifiedProtocolView *)webArticleView{
  62. if (!_webArticleView) {
  63. _webArticleView = [[YMGoddessCertifiedProtocolView alloc]init];
  64. }
  65. return _webArticleView;
  66. }
  67. - (UIButton *)consentAgreementBtn{
  68. if (!_consentAgreementBtn) {
  69. _consentAgreementBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  70. _consentAgreementBtn.titleLabel.font = LCBoldFont(18);
  71. [_consentAgreementBtn setTitle:@"同意女神服务协议" forState:UIControlStateNormal];
  72. [_consentAgreementBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  73. [_consentAgreementBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  74. _consentAgreementBtn.layer.cornerRadius = adapt(45)/2;
  75. _consentAgreementBtn.layer.masksToBounds = YES;
  76. WS(weakSelf)
  77. [[[_consentAgreementBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  78. @weakify(self);
  79. [LCHttpHelper requestWithURLString:AgreeBigCastProtocol parameters:@{@"agreement":@1} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  80. @strongify(self);
  81. NSDictionary* dict = (NSDictionary*)responseObject;
  82. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  83. if (code==0) {
  84. [weakSelf.viewModel gotoCustomCamera];
  85. // // [ZCHUDHelper showTitle:@"已同意女神服务协议"];
  86. // if (self.agreeProtocolBlock != nil) {
  87. // self.agreeProtocolBlock();
  88. // }
  89. // [self.navigationController popViewControllerAnimated:YES];
  90. }
  91. } failure:^(NSError *error) {
  92. }];
  93. }];
  94. }
  95. return _consentAgreementBtn;
  96. }
  97. @end