123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- //
- // YMGoddessCertifiedProtocolViewController.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/3/2.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMGoddessCertifiedProtocolViewController.h"
- #import "YMGoddessCertifiedProtocolView.h"
- @interface YMGoddessCertifiedProtocolViewController ()
- /// 女神认证协议VM
- @property (nonatomic, strong) YMGoddessCertifiedProtocolViewModel *viewModel;
- /// 网页文章视图
- @property (nonatomic, strong) YMGoddessCertifiedProtocolView *webArticleView;
- /// 同意协议按钮
- @property (nonatomic, strong) UIButton *consentAgreementBtn;
- @end
- @implementation YMGoddessCertifiedProtocolViewController
- @dynamic viewModel;
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- if (self.viewModel.webViewLoadTitle == YES && OCStringIsEmpty(self.viewModel.webViewTitle)) {
- //webView已获取title,但返回时无法获取title,可能是内存不足原因造成,此时需重新加载同时避免第一次进入时重新加载
- [self.viewModel.refreshUISubject sendNext:@(YMRefreshUI)];
- }
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- if (!OCStringIsEmpty(self.viewModel.webViewTitle)) {
- self.viewModel.webViewLoadTitle = YES;
- }
- }
- - (void)ym_setupViews{
- [self.view addSubview:self.webArticleView];
- [self.view addSubview:self.consentAgreementBtn];
- [self.view setNeedsUpdateConstraints];
- [self.view updateConstraintsIfNeeded];
- }
- - (void)updateViewConstraints{
-
- [self.webArticleView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view).offset(kYMNavHeight);
- make.left.equalTo(self.view);
- make.right.equalTo(self.view);
- }];
-
- [self.consentAgreementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.webArticleView.mas_bottom).offset(adapt(10));
- make.left.equalTo(self.view).offset(adapt(24));
- make.right.equalTo(self.view).offset(adapt(-24));
- make.bottom.equalTo(self.view).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
- make.height.mas_equalTo(adapt(45));
- }];
-
- [super updateViewConstraints];
- }
- - (void)ym_bindViewModel{
- [self.webArticleView ym_bindViewModel:self.viewModel];
- }
- - (YMGoddessCertifiedProtocolView *)webArticleView{
- if (!_webArticleView) {
- _webArticleView = [[YMGoddessCertifiedProtocolView alloc]init];
- }
- return _webArticleView;
- }
- - (UIButton *)consentAgreementBtn{
- if (!_consentAgreementBtn) {
- _consentAgreementBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _consentAgreementBtn.titleLabel.font = LCBoldFont(18);
- [_consentAgreementBtn setTitle:@"同意女神服务协议" forState:UIControlStateNormal];
- [_consentAgreementBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
- [_consentAgreementBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
- _consentAgreementBtn.layer.cornerRadius = adapt(45)/2;
- _consentAgreementBtn.layer.masksToBounds = YES;
- WS(weakSelf)
- [[[_consentAgreementBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- @weakify(self);
- [LCHttpHelper requestWithURLString:AgreeBigCastProtocol parameters:@{@"agreement":@1} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {
- [weakSelf.viewModel gotoCustomCamera];
- // // [ZCHUDHelper showTitle:@"已同意女神服务协议"];
- // if (self.agreeProtocolBlock != nil) {
- // self.agreeProtocolBlock();
- // }
- // [self.navigationController popViewControllerAnimated:YES];
- }
- } failure:^(NSError *error) {
-
- }];
-
-
- }];
- }
- return _consentAgreementBtn;
- }
- @end
|