YMServicePolicyPopupView.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. //
  2. // YMServicePolicyPopupView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/8.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMServicePolicyPopupView.h"
  9. @interface YMServicePolicyPopupView ()
  10. /** 标题标签*/
  11. @property (nonatomic, strong) UILabel *titleLb;
  12. /** 容器滚动视图*/
  13. @property (nonatomic, strong) UIScrollView *contentScrollView;
  14. /** 容器视图*/
  15. @property (nonatomic, strong) UIView *contentView;
  16. /** 提示文本*/
  17. @property (nonatomic, strong) YYLabel *tipsLb;
  18. /** 按钮视图*/
  19. @property (nonatomic, strong) UIView *buttonView;
  20. /** 取消按钮*/
  21. @property (nonatomic, strong) UIButton *cancelBtn;
  22. /** 确认按钮*/
  23. @property (nonatomic, strong) UIButton *confirmBtn;
  24. @end
  25. @implementation YMServicePolicyPopupView
  26. - (void)ym_setupViews{
  27. self.backgroundColor = HexColorFromRGB(0xFFFFFF);
  28. [self addSubview:self.titleLb];
  29. [self addSubview:self.contentScrollView];
  30. [self.contentScrollView addSubview:self.contentView];
  31. [self.contentView addSubview:self.tipsLb];
  32. [self addSubview:self.buttonView];
  33. [self.buttonView addSubview:self.cancelBtn];
  34. [self.buttonView addSubview:self.confirmBtn];
  35. [self setNeedsUpdateConstraints];
  36. [self updateConstraintsIfNeeded];
  37. NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
  38. [self configurationWithTitleStr:@"用户协议和隐私政策" ContentStr:stringFormat(@"欢迎您使用“%@”!%@非常重视保护用户(以下简称“您”)的个人信息和隐私,我们根据监管要求更新了《用户服务协议》和《%@隐私政策》;并希望通过以下《%@隐私政策(摘要)》帮助您直观、简洁地了解我们在必要范围内收集和使用您的个人信息类型和业务场景,以及我们处理您个人信息的基本规则。\n%@隐私政策(摘要)\n一、我们如何收集和使用个人信息\n1.帮助您完成注册、登录及认证\n注册%@账号时,您需要提供手机号码、验证码匹配结果、昵称、头像、生日,如果您使用第三方账号进行登录,需要您提供第三方账号的昵称、头像、性别。在注册、登录或后续的使用过程中,您也可以向我们补充额外信息(如您的性别、星座、所在地、职业、学历、身高、体重、年收入、交友宣言、兴趣爱好、您本人的真实头像),有助于我们提供更好的服务,同时增进您与其他用户之间的互动、了解。如果您不提供这些信息,并不会影响您使用%@的基本功能。依据相关法律法规的规定,或为了满足实名认证的需要,保障用户账号安全,在您使用%@实名认证、身份认证、兑换金币功能时,我们需要对您进行身份验证,并收集您的以下身份认证信息:姓名、身份证号码、电话号码、面部特征值(静态或动态)、与实名认证一致的收款账户以及兑换金币记录信息。如果您拒绝向我们提供上述信息,我们将无法向您提供相关的功能及服务。\n2.为您提供信息发布与互动服务\n在您使用%@进行上传/发布信息以及进行相关行为(即上传发布音视频、图文内容、点赞、评论、关注、收藏、送礼)时,我们将收集您上传、发布及形成的信息并有权展示您的昵称、头像和发布内容。当您使用%@向其他用户打赏、送礼时,我们将收集您的头像、昵称及送礼数据,并向其他用户进行展示。当您使用上传头像、进行真人认证、发布语音个人签名、发布动态(包括图文与视频内容)时,我们还会根据您所发布的内容请求您授权相机、照片、麦克风以及存储权限;请你知悉,权限的开启或授权是您使用上述功能的前提,如您关闭或拒绝授权将无法使用上述功能,但不会影响您使用其他功能与服务。\n请您注意,您在使用我们提供的服务时所提供的所有个人信息,除非您删除或通过系统设置拒绝我们收集,否则将在您使用我们的服务期间持续授权我们使用。在您注销账号时,我们将停止使用并删除您的个人信息,或采取匿名化处理,使其不再与您关联到一起。\n二、我们如何共享您的个人信息\n我们会委托第三方服务提供商处理我们收集的您的个人信息,以便其为我们提供基础设施技术、数据分析、广告投放、营销决策等产品或技术支持,上述委托处理行为受《%@隐私政策》中所声明目的约束,并且我们会以合同方式对上述的第三方进行监督,以确保您的个人信息安全。\n三、您的权利\n在您使用%@期间,您可以通过相应页面提示或《%@隐私政策》载明的方式联系我们,以访问、更正、删除您的个人信息,以及行使改变授权同意的范围与注销账号的权利,我们将及时响应您的请求。如果您需要您的个人信息副本,您可以通过我们提供的方式联系我们,在核实您的身份后,我们将向您提供您在我们服务中的个人信息副本(包括基础资料、身份信息),但法律法规另有规定的或《%@隐私政策》另有约定的除外。\n四、未成年人保护\n我们的产品和范围仅面向18周岁以上的成年人,任何不满18周岁的未成年人不得创建自己的用户账号及/或使用我们的服务。如果我们发现或审核出任何未成年人注册或使用我们的产品,我们将采取注销账号、删除信息等措施禁止、限制未成年人使用。\n五、如何联系我们\n如果您对本隐私政策或个人信息保护有任何问题,您可以将您的书面疑问、意见或建议联系在线客服或发送邮件至:cxhylive@163.com。一般情况下,我们将在十五个工作日内回复。如果您对我们的回复或处理不满意,您还可以向履行个人信息保护职责的部门进行投诉、举报。",appName,appName,appName,appName,appName,appName,appName,appName,appName,appName,appName,appName,appName,appName)];
  39. }
  40. - (void)updateConstraints{
  41. [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.top.equalTo(self).offset(adapt(20));
  43. make.left.equalTo(self).offset(adapt(20));
  44. make.right.equalTo(self).offset(adapt(-20));
  45. }];
  46. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.top.equalTo(self.titleLb.mas_bottom).offset(adapt(20));
  48. make.left.equalTo(self);
  49. make.right.equalTo(self);
  50. }];
  51. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.edges.equalTo(self.contentScrollView);
  53. make.width.equalTo(self.contentScrollView.mas_width);
  54. }];
  55. [self.tipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.top.equalTo(self.contentView);
  57. make.left.equalTo(self.contentView).offset(adapt(20));
  58. make.right.equalTo(self.contentView).offset(adapt(-20));
  59. make.bottom.equalTo(self.contentView);
  60. }];
  61. [self.buttonView mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.top.equalTo(self.contentScrollView.mas_bottom).offset(adapt(10));
  63. make.left.equalTo(self);
  64. make.right.equalTo(self);
  65. make.bottom.equalTo(self).offset(adapt(-15)).priorityHigh();
  66. }];
  67. NSArray *btnArr = @[self.cancelBtn,self.confirmBtn];
  68. // 实现masonry水平固定控件宽度方法
  69. // axisType 横排还是竖排
  70. // fixedSpacing 两个控件间隔
  71. // leadSpacing 第一个控件与边缘的间隔
  72. // tailSpacing 最后一个控件与边缘的间隔
  73. [btnArr mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:adapt(15) leadSpacing:adapt(20) tailSpacing:adapt(20)];
  74. // 设置array的垂直方向的约束
  75. [btnArr mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.top.equalTo(self.buttonView).offset(adapt(10));
  77. make.bottom.equalTo(self.buttonView).offset(adapt(-10));
  78. make.height.mas_equalTo(adapt(40));
  79. }];
  80. [super updateConstraints];
  81. }
  82. - (void)configurationWithTitleStr:(NSString*)titleStr ContentStr:(NSString *)contentStr{
  83. self.titleLb.text = titleStr;
  84. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:contentStr];
  85. attributedString.yy_font = LCFont(14);
  86. attributedString.yy_color = HexColorFromRGB(0x333333);
  87. attributedString.yy_lineSpacing = 5;
  88. attributedString.yy_alignment = NSTextAlignmentLeft;
  89. NSString *userAgreementHighlightStr = @"《用户服务协议》";
  90. NSArray *userAgreementArray = [self rangeOfSubString:userAgreementHighlightStr inString:contentStr];
  91. for (NSInteger i = 0; i < userAgreementArray.count; i++) {
  92. NSValue *value = userAgreementArray[i];
  93. //添加下划线
  94. // YYTextDecoration* deco = [YYTextDecoration decorationWithStyle:(YYTextLineStyleSingle) width:[NSNumber numberWithInt:1] color:HEXCOLOR(0xFF0000)];
  95. // [attributedString yy_setTextUnderline:deco range:value.rangeValue];
  96. [attributedString yy_setTextHighlightRange:value.rangeValue
  97. color:HexColorFromRGB(0x1ACEE2)
  98. backgroundColor:[UIColor clearColor]
  99. tapAction:^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect){
  100. if (self.userProtocolBlock) {
  101. self.userProtocolBlock();
  102. }
  103. }];
  104. }
  105. NSString *privacyAgreementHighlightStr = stringFormat(@"《%@隐私政策》",[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]);
  106. NSArray *privacyAgreementArray = [self rangeOfSubString:privacyAgreementHighlightStr inString:contentStr];
  107. for (NSInteger i = 0; i < privacyAgreementArray.count; i++) {
  108. NSValue *value = privacyAgreementArray[i];
  109. //添加下划线
  110. // YYTextDecoration* deco = [YYTextDecoration decorationWithStyle:(YYTextLineStyleSingle) width:[NSNumber numberWithInt:1] color:HEXCOLOR(0xFF0000)];
  111. // [attributedString yy_setTextUnderline:deco range:value.rangeValue];
  112. [attributedString yy_setTextHighlightRange:value.rangeValue
  113. color:HexColorFromRGB(0x1ACEE2)
  114. backgroundColor:[UIColor clearColor]
  115. tapAction:^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect){
  116. // [YoMiRouter openURL:YoMi_NSStringFormat(@"%@%@", ROUTER_URL_PREFIX, ROUTER_AGREEMENT_INFO_ARTICLE_VC) withUserInfo:@{@"articleType":@(privacyPolicyType)} completion:nil];
  117. if (self.privacyPolicyBlock) {
  118. self.privacyPolicyBlock();
  119. }
  120. }];
  121. }
  122. self.tipsLb.attributedText = attributedString;
  123. CGSize introSize = CGSizeMake(kFrameWidth*0.88 - 20*2, CGFLOAT_MAX);
  124. YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:introSize text:attributedString];
  125. self.tipsLb.textLayout = layout;
  126. CGFloat attributedHeight = layout.textBoundingSize.height;
  127. [self.tipsLb mas_updateConstraints:^(MASConstraintMaker *make) {
  128. make.height.mas_equalTo(attributedHeight);
  129. }];
  130. CGFloat titleLbHeight = [self.titleLb systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
  131. CGFloat buttonViewHeight = [self.buttonView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
  132. CGFloat judgeHeight = adapt(300);
  133. CGFloat tipsHeight = attributedHeight > judgeHeight ? judgeHeight : attributedHeight;
  134. self.frame = CGRectMake(0, 0, kFrameWidth*0.88, adapt(20) + titleLbHeight + adapt(20) + tipsHeight + adapt(10) + buttonViewHeight + adapt(20));
  135. }
  136. #pragma mark - 获取字符串的所在位置
  137. //获取一个字符在字符串中出现的所有位置 返回一个被NSValue包装的NSRange数组
  138. - (NSArray *)rangeOfSubString:(NSString *)subStr inString:(NSString *)string {
  139. if (subStr == nil && [subStr isEqualToString:@""]) {
  140. return nil;
  141. }
  142. NSMutableArray *rangeArray = [NSMutableArray array];
  143. NSString *string1 = [string stringByAppendingString:subStr];
  144. NSString *temp;
  145. for (int i = 0; i < string.length; i ++) {
  146. temp = [string1 substringWithRange:NSMakeRange(i, subStr.length)];
  147. if ([temp isEqualToString:subStr]) {
  148. NSRange range = {i,subStr.length};
  149. [rangeArray addObject:[NSValue valueWithRange:range]];
  150. }
  151. }
  152. return rangeArray;
  153. }
  154. #pragma mark - lazyload
  155. - (UILabel *)titleLb{
  156. if (!_titleLb) {
  157. _titleLb = [[UILabel alloc]init];
  158. _titleLb.font = LCFont(18);
  159. _titleLb.textColor = HexColorFromRGB(0x1B2739);
  160. _titleLb.textAlignment = NSTextAlignmentCenter;
  161. _titleLb.text = @"提示";
  162. }
  163. return _titleLb;
  164. }
  165. - (UIScrollView *)contentScrollView{
  166. if (!_contentScrollView) {
  167. _contentScrollView = [[UIScrollView alloc] init];
  168. _contentScrollView.alwaysBounceVertical = YES;
  169. _contentScrollView.showsVerticalScrollIndicator = NO;
  170. _contentScrollView.showsHorizontalScrollIndicator = NO;
  171. _contentScrollView.backgroundColor = HexColorFromRGB(0xFFFFFF);
  172. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  173. }
  174. return _contentScrollView;
  175. }
  176. - (UIView *)contentView{
  177. if (!_contentView) {
  178. _contentView = [[UIView alloc]init];
  179. }
  180. return _contentView;
  181. }
  182. - (YYLabel *)tipsLb{
  183. if (!_tipsLb) {
  184. _tipsLb = [[YYLabel alloc]init];
  185. _tipsLb.font = LCFont(14);
  186. _tipsLb.textAlignment = NSTextAlignmentLeft;
  187. }
  188. return _tipsLb;
  189. }
  190. - (UIView *)buttonView{
  191. if (!_buttonView) {
  192. _buttonView = [[UIView alloc]init];
  193. }
  194. return _buttonView;
  195. }
  196. - (UIButton *)cancelBtn {
  197. if(!_cancelBtn){
  198. _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  199. _cancelBtn.titleLabel.font = LCFont(15);
  200. [_cancelBtn setTitle:@"不同意" forState:UIControlStateNormal];
  201. [_cancelBtn setTitleColor:HexColorFromRGB(0x555555) forState:UIControlStateNormal];
  202. _cancelBtn.backgroundColor = HexColorFromRGB(0xF5F5F5);
  203. _cancelBtn.layer.cornerRadius = adapt(10);
  204. WS(weakSelf)
  205. [[[_cancelBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  206. if (weakSelf.buttonBlock) {
  207. weakSelf.buttonBlock(NO);
  208. }
  209. }];
  210. }
  211. return _cancelBtn;
  212. }
  213. - (UIButton *)confirmBtn {
  214. if(!_confirmBtn){
  215. _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  216. _confirmBtn.titleLabel.font = LCFont(15);
  217. [_confirmBtn setTitle:@"同意" forState:UIControlStateNormal];
  218. [_confirmBtn setTitleColor:HexColorFromRGB(0x000000) forState:UIControlStateNormal];
  219. _confirmBtn.backgroundColor = MAINGRIDColor2;
  220. _confirmBtn.layer.cornerRadius = adapt(10);
  221. WS(weakSelf)
  222. [[[_confirmBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  223. if (weakSelf.buttonBlock) {
  224. weakSelf.buttonBlock(YES);
  225. }
  226. }];
  227. }
  228. return _confirmBtn;
  229. }
  230. @end