BogoYouthModeViewController.m 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //
  2. // BogoYouthModeViewController.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/9/11.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoYouthModeViewController.h"
  9. #import "BogoYouthModePassWordViewController.h"
  10. #import "BogoNetworkKit.h"
  11. @interface BogoYouthModeViewController ()
  12. @property (weak, nonatomic) IBOutlet UILabel *contentL;
  13. @property (weak, nonatomic) IBOutlet UILabel *subTitle;
  14. @end
  15. @implementation BogoYouthModeViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. // Do any additional setup after loading the view from its nib.
  19. [self.subTitle setLocalizedString];
  20. self.navigationItem.title = ASLocalizedString(@"青少年模式");
  21. [self backBtnWithBlock];
  22. // [self setUpView];
  23. [self setModel];
  24. }
  25. -(void)setModel{
  26. [[BogoNetwork shareInstance]GET:@"young/getInfo" param:nil success:^(BogoNetworkResponseModel * _Nonnull result) {
  27. // _contentL.text = result.data;
  28. [self setUpViewWithContentStr:result.data];
  29. } failure:^(NSString * _Nonnull error) {
  30. [self setUpViewWithContentStr:@""];
  31. }];
  32. }
  33. - (void)backBtnWithBlock
  34. {
  35. // 返回按钮
  36. [self setupBackBtnWithBlock:nil];
  37. }
  38. -(void)setUpViewWithContentStr:(NSString *)content{
  39. if (!StrValid(content)) {
  40. _contentL.text = ASLocalizedString(@"青少年模式是711Live App为促进青少年健康成长做出的设置。若您手机被未成年使用,建议您开启此模式。\n开启青少年模式后,将无法正常使用App功能,只能观看短视频。\n每日开启青少年模式使用40分钟需要输入监护密码\n开启青少年模式需要先设置独立密码,用户需要牢记密码,如果忘记可通过手机验证码重置密码,需要输入正确密码才能关闭");
  41. }
  42. NSDictionary *options = @{NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType,
  43. NSCharacterEncodingDocumentAttribute : @(NSUTF8StringEncoding)};
  44. NSData *data = [content dataUsingEncoding:NSUTF8StringEncoding];
  45. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  46. paragraphStyle.lineSpacing = 4; //设置行间距
  47. paragraphStyle.lineBreakMode = _contentL.lineBreakMode;
  48. paragraphStyle.alignment = NSTextAlignmentLeft;
  49. // NSString *content =ASLocalizedString( @"为呵护未成年人健康成长,布谷直播特别推出青少年模式,该模式下部分功能无法正常使用。请监护人主动选择,并设置监护密码。");
  50. // NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:_contentL.text];
  51. NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithData:data options:options documentAttributes:nil error:nil];
  52. NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:14.0],
  53. NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#333333"],
  54. NSParagraphStyleAttributeName:paragraphStyle};
  55. [attStr setAttributes:attributes range:NSMakeRange(0, attStr.length)];
  56. _contentL.attributedText = attStr;
  57. }
  58. - (IBAction)clickOpenBtn:(UIButton *)sender {
  59. BogoYouthModePassWordViewController *vc = [[BogoYouthModePassWordViewController alloc]initWithYounthType:BOGO_YOUNTH_TYPE_PASSWORD_SET];
  60. [self.navigationController pushViewController:vc animated:YES];
  61. }
  62. //- (void)setModel:(BogoCommodityDetailModel *)model{
  63. // _model = model;
  64. // if (!_isLoad && model) {
  65. // NSString *htmls = [NSString stringWithFormat:@"<html> \n"
  66. // "<head> \n"
  67. // "<style type=\"text/css\"> \n"
  68. // "body {font-size:15px;}\n"
  69. // "</style> \n"
  70. // "</head> \n"
  71. // "<body>"
  72. // "<script type='text/javascript'>"
  73. // "window.onload = function(){\n"
  74. // "var $img = document.getElementsByTagName('img');\n"
  75. // "for(var p in $img){\n"
  76. // " $img[p].style.width = '100%%';\n"
  77. // "$img[p].style.height ='auto'\n"
  78. // "}\n"
  79. // "}"
  80. // "</script>%@"
  81. // "</body>"
  82. // "</html>",model.detail];
  83. // [self.webView loadHTMLString:htmls baseURL:nil];
  84. // _isLoad = YES;
  85. // }
  86. //}
  87. //
  88. //- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
  89. // [webView evaluateJavaScript:@"document.body.scrollWidth"completionHandler:^(id _Nullable result,NSError * _Nullable error){
  90. // CGFloat ratio = CGRectGetWidth(webView.frame) /[result floatValue];
  91. // NSLog(@"scrollWidth高度:%.2f",[result floatValue]);
  92. // [webView evaluateJavaScript:@"document.body.scrollHeight"completionHandler:^(id _Nullable result,NSError * _Nullable error){
  93. // NSLog(@"scrollHeight高度:%.2f",[result floatValue]*ratio);
  94. // CGFloat height = [result floatValue]*ratio;
  95. // self.webView.frame = CGRectMake(0, 40, FD_ScreenWidth, height);
  96. // self.webView.scrollView.frame = CGRectMake(0, 0, FD_ScreenWidth, height);
  97. // self.webView.scrollView.contentSize = CGSizeMake(FD_ScreenWidth, height);
  98. // if (self.delegate && [self.delegate respondsToSelector:@selector(detailCell:didFinishLoad:)]) {
  99. // [self.delegate detailCell:self didFinishLoad:height];
  100. // }
  101. // }];
  102. // }];
  103. //}
  104. //
  105. //- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  106. // [super setSelected:selected animated:animated];
  107. //
  108. // // Configure the view for the selected state
  109. //}
  110. //
  111. //- (WKWebView *)webView{
  112. // if (!_webView) {
  113. // WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc]init];
  114. // _webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 40, FD_ScreenWidth, self.contentView.fd_height) configuration:config];
  115. // _webView.navigationDelegate = self;
  116. // _webView.scrollView.scrollEnabled = NO;
  117. // }
  118. // return _webView;
  119. //}
  120. @end