DspLoginVC.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. //
  2. // DspLoginVC.m
  3. // YBVideo
  4. //
  5. // Created by YunBao on 2018/6/8.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import "DspLoginVC.h"
  9. /******shark sdk *********/
  10. #import <ShareSDK/ShareSDK.h>
  11. #import <ShareSDKConnector/ShareSDKConnector.h>
  12. #import "JPUSHService.h"
  13. #import "AppDelegate.h"
  14. #import "AFNetworking.h"
  15. #import "YBTabBarController.h"
  16. #import "PubH5.h"
  17. #import "YBLookVideoVC.h"
  18. #import "RegAlertView.h"
  19. #import "CountryCodeVC.h"
  20. @interface DspLoginVC ()
  21. {
  22. int cutdown;
  23. NSString *invationUid;
  24. NSDictionary *rulesDic;
  25. BOOL loginAgreementBool;
  26. }
  27. @property(nonatomic,strong)NSArray *platformsarray;
  28. @property (strong, nonatomic) UIWindow *window;
  29. @property(nonatomic,strong)NSTimer *cutTimer;
  30. @property (nonatomic, strong)NSString *countrycode;
  31. @end
  32. @implementation DspLoginVC
  33. - (void)getP{
  34. UIPasteboard *p = [UIPasteboard generalPasteboard];
  35. for (NSDictionary *dict in p.items) {
  36. NSLog(@"Dict: %@", dict);
  37. NSString *plainText = [dict valueForKey:@"public.utf8-plain-text"];
  38. if(plainText&&[plainText containsString:@"yunbaokj-code#"]){
  39. NSRange codeRange = [plainText rangeOfString:@"yunbaokj-code#"];
  40. NSUInteger index = codeRange.location + codeRange.length;
  41. NSString *code = [plainText substringFromIndex:index];
  42. if(code&&code.length>0)
  43. {
  44. invationUid = code;
  45. // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"邀请码" message:code preferredStyle:UIAlertControllerStyleAlert];
  46. //
  47. // UIAlertAction *okBtn = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  48. // }];
  49. //
  50. // [alert addAction:okBtn];
  51. // [self presentViewController:alert animated:YES completion:nil];
  52. }
  53. }
  54. }
  55. }
  56. -(void)viewWillAppear:(BOOL)animated{
  57. [super viewWillAppear:animated];
  58. self.navigationController.navigationBarHidden = YES;
  59. //指示器消失
  60. [PublicView indictorHide];
  61. [self getLoginThird];
  62. [[PublicObj publicInstance]addCusDelayedRemove];
  63. }
  64. -(void)viewWillDisappear:(BOOL)animated{
  65. [super viewWillDisappear:animated];
  66. //指示器消失
  67. [PublicView indictorHide];
  68. self.navigationController.navigationBarHidden = YES;
  69. }
  70. //获取三方登录方式
  71. -(void)getLoginThird{
  72. YBWeakSelf;
  73. [YBNetworking postWithUrl:@"Home.getLogin" Dic:nil Suc:^(int code, id info, NSString *msg) {
  74. if (code == 0) {
  75. NSDictionary *infoDic = [info firstObject];
  76. if ([infoDic valueForKey:@"login_type_ios"]&&[[infoDic valueForKey:@"login_type_ios"] isKindOfClass:[NSArray class]]) {
  77. weakSelf.platformsarray = [infoDic valueForKey:@"login_type_ios"];
  78. }else{
  79. weakSelf.platformsarray = [infoDic valueForKey:@"login_type"];
  80. }
  81. rulesDic = [infoDic valueForKey:@"login_alert"];
  82. dispatch_async(dispatch_get_main_queue(), ^{
  83. [self setthirdview];
  84. [self showPrivateRule];
  85. });
  86. }
  87. //指示器消失
  88. [PublicView indictorHide];
  89. } Fail:^(id fail) {
  90. //指示器消失
  91. [PublicView indictorHide];
  92. }];
  93. }
  94. //添加登陆方式
  95. -(void)setthirdview{
  96. //进入此方法钱,清除所有按钮,防止重复添加
  97. for (UIButton *btn in _platformView.subviews) {
  98. [btn removeFromSuperview];
  99. }
  100. //如果返回为空,登陆方式字样隐藏
  101. if (_platformsarray.count == 0) {
  102. _otherView.hidden = YES;
  103. }
  104. else{
  105. _otherView.hidden = NO;
  106. }
  107. //注意:此处涉及到精密计算,轻忽随意改动
  108. CGFloat w = 50;
  109. CGFloat x;
  110. CGFloat centerX = _window_width/2;
  111. if (_platformsarray.count % 2 == 0) {
  112. x = centerX - _platformsarray.count/2*w - (_platformsarray.count - 1)*10;
  113. }
  114. else{
  115. x = centerX - (_platformsarray.count - 1)/2*w - w/2 - (_platformsarray.count - 1)*10;
  116. }
  117. for (int i=0; i<_platformsarray.count; i++) {
  118. UIButton *btn = [UIButton buttonWithType:0];
  119. btn.tag = 1000 + i;
  120. [btn setImage:[UIImage imageNamed:_platformsarray[i]] forState:UIControlStateNormal];
  121. [btn setTitle:_platformsarray[i] forState:UIControlStateNormal];
  122. [btn setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
  123. [btn addTarget:self action:@selector(thirdlogin:) forControlEvents:UIControlEventTouchUpInside];
  124. btn.frame = CGRectMake(x,0,w,w);
  125. x+=w+20;
  126. [_platformView addSubview:btn];
  127. }
  128. }
  129. //若要添加登陆方式,在此处添加
  130. -(void)thirdlogin:(UIButton *)sender{
  131. if (loginAgreementBool == NO) {
  132. [MBProgressHUD showError:YZMsg(@"请仔细阅读用户协议并勾选")];
  133. return;
  134. }
  135. /*
  136. 1 qq
  137. 2 wx
  138. 3 facebook
  139. 4 twitter
  140. 5 ios
  141. */
  142. SSDKPlatformType logType;
  143. if ([sender.titleLabel.text isEqual:@"qq"]) {
  144. logType = SSDKPlatformTypeQQ;
  145. }else if ([sender.titleLabel.text isEqual:@"wx"]) {
  146. logType = SSDKPlatformTypeWechat;
  147. }else if ([sender.titleLabel.text isEqual:@"facebook"]) {
  148. logType = SSDKPlatformTypeFacebook;
  149. }else if ([sender.titleLabel.text isEqual:@"twitter"]) {
  150. logType = SSDKPlatformTypeTwitter;
  151. }else if ([sender.titleLabel.text isEqual:@"ios"]){
  152. logType = SSDKPlatformTypeAppleAccount;
  153. }else{
  154. logType = SSDKPlatformTypeAny;
  155. }
  156. [self login:sender.titleLabel.text platforms:logType];
  157. }
  158. -(void)forwardGround{
  159. //指示器消失
  160. [PublicView indictorHide];
  161. }
  162. - (void)viewDidLoad {
  163. [super viewDidLoad];
  164. _topSpace.constant = statusbarHeight+25;
  165. _topTitleL.text = YZMsg(@"注册登录后体验更多精彩瞬间");
  166. _phoneTF.placeholder = YZMsg(@"请输入手机号码");
  167. _codeTF.placeholder = YZMsg(@"请输入验证码");
  168. [_codeBtn setTitle:YZMsg(@"获取验证码") forState:UIControlStateNormal];
  169. [_loginBtn setTitle:YZMsg(@"立即登录") forState:0];
  170. _midTitleL.text = YZMsg(@"其他登录方式");
  171. _codeDesL.text = YZMsg(@"*短信验证保障账户安全的同时短信费用将由平台支付");
  172. self.countrycode = @"86";
  173. self.naviView.hidden = YES;
  174. _phoneTF.placeCol = RGB_COLOR(@"#646464", 1);
  175. _codeTF.placeCol = RGB_COLOR(@"#646464", 1);
  176. invationUid = @"";
  177. cutdown = 60;
  178. self.platformsarray = [NSArray array];
  179. //[self getP];
  180. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forwardGround) name:UIApplicationWillEnterForegroundNotification object:nil];
  181. AFNetworkReachabilityManager *netManager = [AFNetworkReachabilityManager sharedManager];
  182. [netManager startMonitoring]; //开始监听 防止第一次安装不显示
  183. [netManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status){
  184. if (status == AFNetworkReachabilityStatusNotReachable)
  185. {
  186. [self getLoginThird];
  187. return;
  188. }else if (status == AFNetworkReachabilityStatusUnknown || status == AFNetworkReachabilityStatusNotReachable){
  189. NSLog(@"nonetwork-------");
  190. [self getLoginThird];
  191. }else if ((status == AFNetworkReachabilityStatusReachableViaWWAN)||(status == AFNetworkReachabilityStatusReachableViaWiFi)){
  192. [self getLoginThird];
  193. NSLog(@"wifi-------");
  194. }
  195. }];
  196. self.navigationController.interactivePopGestureRecognizer.delegate = (id) self;
  197. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ChangeBtnBackground) name:UITextFieldTextDidChangeNotification object:nil];
  198. [_xyBtn setImage:[UIImage imageNamed:@"xieyi_sel"] forState:UIControlStateSelected];
  199. [_xyBtn setImage:[UIImage imageNamed:@"xieyi"] forState:UIControlStateNormal];
  200. }
  201. -(void)login:(NSString *)types platforms:(SSDKPlatformType)platform{
  202. //指示器显示
  203. [PublicView indictorShow];
  204. [ShareSDK cancelAuthorize:platform result:nil];
  205. [ShareSDK getUserInfo:platform
  206. onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error) {
  207. //指示器消失
  208. [PublicView indictorHide];
  209. if (state == SSDKResponseStateSuccess) {
  210. NSLog(@"uid=%@",user.uid);
  211. NSLog(@"%@",user.credential);
  212. NSLog(@"token=%@",user.credential.token);
  213. NSLog(@"nickname=%@",user.nickname);
  214. [self RequestLogin:user LoginType:types];
  215. } else if (state == 2 || state == 3) {
  216. if ([types isEqual:@"ios"] && [PublicObj getSysVersion] < 13) {
  217. [MBProgressHUD showPop:YZMsg(@"ios13以下系统暂不支持苹果登录")];
  218. }
  219. }
  220. }];
  221. }
  222. -(void)ChangeBtnBackground {
  223. }
  224. -(void)RequestLogin:(SSDKUser *)user LoginType:(NSString *)LoginType
  225. {
  226. NSString *icon = nil;
  227. if ([LoginType isEqualToString:@"qq"]) {
  228. icon = [user.rawData valueForKey:@"figureurl_qq_2"];
  229. } else {
  230. icon = user.icon;
  231. }
  232. if (!icon) {
  233. icon = @"";
  234. }
  235. NSString *userName = minstr(user.nickname);
  236. if ([PublicObj checkNull:userName]) {
  237. userName = @"";
  238. }
  239. NSString *unionid = user.uid;
  240. if ([LoginType isEqual:@"wx"]) {
  241. unionid = [user.rawData valueForKey:@"unionid"];
  242. }
  243. NSString *accessToken = user.credential.token;
  244. /* 改为接口传递pushid
  245. NSString *pushid;
  246. if ([JPUSHService registrationID]) {
  247. pushid = [JPUSHService registrationID];
  248. }else{
  249. pushid = @"";
  250. }
  251. */
  252. NSDictionary *dic =@{
  253. @"openid":[self encodeString:unionid],
  254. @"type":[self encodeString:LoginType],
  255. @"nicename":[self encodeString:userName],
  256. @"avatar":[self encodeString:icon],
  257. @"source":@"ios",
  258. @"mobileid":[PublicObj getDeviceUUID],
  259. @"access_token":accessToken,
  260. //@"pushid":pushid,
  261. };
  262. YBWeakSelf;
  263. [YBNetworking postWithUrl:@"Login.userLoginByThird" Dic:dic Suc:^(int code, id info, NSString *msg) {
  264. if(code == 0) {
  265. NSDictionary *infoDic = [info firstObject];
  266. [Config saveUnified:infoDic];
  267. [self LoginJM];
  268. /*
  269. NSString *aliasStr = [NSString stringWithFormat:@"%@PUSH",[Config getOwnID]];
  270. [JPUSHService setAlias:aliasStr callbackSelector:nil object:nil];
  271. */
  272. //判断第一次登陆
  273. NSString *isreg = minstr([infoDic valueForKey:@"isreg"]);
  274. [Config saveisreg:isreg];
  275. [Config saveFirstBonus:@"1"];
  276. [weakSelf login];
  277. }else{
  278. [MBProgressHUD showError:msg];
  279. }
  280. //指示器消失
  281. [PublicView indictorHide];
  282. } Fail:^(id fail) {
  283. [MBProgressHUD showError:YZMsg(@"请重试")];
  284. //指示器消失
  285. [PublicView indictorHide];
  286. }];
  287. }
  288. -(NSString*)encodeString:(NSString*)unencodedString{
  289. NSString*encodedString=(NSString*)
  290. CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
  291. (CFStringRef)unencodedString,
  292. NULL,
  293. (CFStringRef)@"!*'();:@&=+$,/?%#[]",
  294. kCFStringEncodingUTF8));
  295. return encodedString;
  296. }
  297. - (void)didReceiveMemoryWarning {
  298. [super didReceiveMemoryWarning];
  299. }
  300. - (IBAction)clickCountryBtn:(UIButton *)sender {
  301. YBWeakSelf;
  302. CountryCodeVC *codeVC = [[CountryCodeVC alloc]init];
  303. codeVC.codeEvent = ^(NSDictionary *codeDic) {
  304. NSString *codeStr = [NSString stringWithFormat:@"+%@",minstr([codeDic valueForKey:@"tel"])];
  305. [weakSelf.countryBtn setTitle:codeStr forState:0];
  306. weakSelf.countrycode = minstr([codeDic valueForKey:@"tel"]);
  307. };
  308. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:codeVC animated:YES];
  309. }
  310. //- (IBAction)clickPrivateBtn:(UIButton *)sender {
  311. // PubH5 *VC = [[PubH5 alloc]init];
  312. // NSString *paths = [h5url stringByAppendingString:@"/portal/page/index?id=26"];
  313. // VC.url = paths;
  314. // [self.navigationController pushViewController:VC animated:YES];
  315. //}
  316. - (IBAction)clickGetCodeBtn:(UIButton *)sender {
  317. cutdown = 60;
  318. /* 都改为服务端判断
  319. if (_phoneTF.text.length == 0) {
  320. [MBProgressHUD showPop:YZMsg(@"请填写手机号")];
  321. return;
  322. }
  323. if (_phoneTF.text.length !=11) {
  324. [MBProgressHUD showPop:YZMsg(@"手机号输入错误")];
  325. return;
  326. }*/
  327. [_codeTF becomeFirstResponder];
  328. sender.userInteractionEnabled = NO;
  329. YBWeakSelf;
  330. // NSString *postUrl = [NSString stringWithFormat:@"Login.getLoginCode&mobile=%@",_phoneTF.text];
  331. NSDictionary *signdic = @{@"mobile":_phoneTF.text,@"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]]};
  332. NSString *sign = [PublicObj sortString:signdic];
  333. NSDictionary *parDic = @{@"country_code":self.countrycode,
  334. @"mobile":_phoneTF.text,
  335. @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]],
  336. @"sign":sign
  337. };
  338. [YBNetworking postWithUrl:@"Login.getLoginCode" Dic:parDic Suc:^(int code, id info, NSString *msg) {
  339. if (code == 0) {
  340. sender.userInteractionEnabled = YES;
  341. if (!weakSelf.cutTimer) {
  342. weakSelf.cutTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(doCutTimer) userInfo:nil repeats:YES];
  343. }
  344. [MBProgressHUD showPop:YZMsg(@"发送成功")];
  345. }else{
  346. sender.userInteractionEnabled = YES;
  347. [MBProgressHUD showPop:msg];
  348. }
  349. sender.userInteractionEnabled = YES;
  350. } Fail:^(id fail) {
  351. sender.userInteractionEnabled = YES;
  352. }];
  353. }
  354. -(void)doCutTimer {
  355. [_codeBtn setTitle:[NSString stringWithFormat:@"%ds",cutdown] forState:UIControlStateNormal];
  356. [_codeBtn setTitleColor:RGB_COLOR(@"#646464", 1) forState:0];
  357. _codeBtn.userInteractionEnabled = NO;
  358. if (cutdown<=0) {
  359. [_codeBtn setTitle:YZMsg(@"获取验证码") forState:UIControlStateNormal];
  360. [_codeBtn setTitleColor:RGB_COLOR(@"#B4B4B4", 1) forState:0];
  361. _codeBtn.userInteractionEnabled = YES;
  362. [_cutTimer invalidate];
  363. _cutTimer = nil;
  364. cutdown = 60;
  365. }
  366. cutdown-=1;
  367. }
  368. - (IBAction)clickPhoneLogin:(UIButton *)sender {
  369. if (loginAgreementBool == NO) {
  370. [MBProgressHUD showError:YZMsg(@"请仔细阅读用户协议并勾选")];
  371. return;
  372. }
  373. [self.view endEditing:YES];
  374. //指示器显示
  375. [PublicView indictorShow];
  376. /* 改为接口传递pushid
  377. NSString *pushid;
  378. if ([JPUSHService registrationID]) {
  379. pushid = [JPUSHService registrationID];
  380. }else{
  381. pushid = @"";
  382. }
  383. */
  384. NSDictionary *Login = @{
  385. @"user_login":_phoneTF.text,
  386. @"code":_codeTF.text,
  387. @"source":@"ios",
  388. @"mobileid":[PublicObj getDeviceUUID],
  389. @"country_code":self.countrycode
  390. //@"pushid":pushid,
  391. };
  392. YBWeakSelf;
  393. [YBNetworking postWithUrl:@"Login.userLogin" Dic:Login Suc:^(int code, id info, NSString *msg) {
  394. if(code == 0) {
  395. NSDictionary *infoDic = [info objectAtIndex:0];
  396. [Config saveUnified:infoDic];
  397. /*
  398. NSString *aliasStr = [NSString stringWithFormat:@"%@PUSH",[Config getOwnID]];
  399. [JPUSHService setAlias:aliasStr callbackSelector:nil object:nil];
  400. */
  401. [self LoginJM];
  402. //判断第一次登陆
  403. NSString *isreg = minstr([infoDic valueForKey:@"isreg"]);
  404. [Config saveisreg:isreg];
  405. [Config saveFirstBonus:@"1"];
  406. [weakSelf login];
  407. }else {
  408. [MBProgressHUD showPop:msg];
  409. }
  410. //指示器消失
  411. [PublicView indictorHide];
  412. } Fail:^(id fail) {
  413. //指示器消失
  414. [PublicView indictorHide];
  415. }];
  416. }
  417. - (IBAction)clickBackBtn:(UIButton *)sender {
  418. if ([_youke isEqualToString:@"不是游客"]) {
  419. [Config saveUnified:[PublicObj visitorDic]];
  420. YBTabBarController *root = [[YBTabBarController alloc]initWithAlert:NO];
  421. YBNavigationController *navroot = [[YBNavigationController alloc]initWithRootViewController:root];
  422. UIApplication *app =[UIApplication sharedApplication];
  423. AppDelegate *app2 = (AppDelegate *)app.delegate;
  424. [app2.window removeAllSubViews];
  425. app2.window.rootViewController = navroot;
  426. }else{
  427. if (_isOverdue) {
  428. [PublicObj resetVC:[[YBTabBarController alloc]initWithAlert:NO]];
  429. }else{
  430. [self dismissViewControllerAnimated:YES completion:nil];
  431. [self.navigationController popViewControllerAnimated:YES];
  432. }
  433. }
  434. }
  435. -(void)LoginJM{
  436. [[YBImManager shareInstance] imLogin];
  437. }
  438. -(void)login{
  439. [[NSNotificationCenter defaultCenter]postNotificationName:@"showHomeVideoRed" object:nil];
  440. AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
  441. [PublicObj updatePushId:app.jgRegistrationID];
  442. // //进入全功能模式
  443. // [Config saveTranslate:YES];
  444. //
  445. // [[NSNotificationCenter defaultCenter]postNotificationName:@"hideBottomFunBtn" object:nil];
  446. [YBInviteCode checkAgent];
  447. [Config saveSignOfDelVideo:@"1"];
  448. // 需要弹青少年提示
  449. [YBYoungManager shareInstance].needShowPop = YES;
  450. [[YBBaseAppDelegate sharedAppDelegate] popViewController:NO];
  451. /*
  452. YBTabBarController *root = [[YBTabBarController alloc]initWithAlert:YES];
  453. //[self.navigationController pushViewController:root animated:YES];
  454. UIApplication *app =[UIApplication sharedApplication];
  455. AppDelegate *app2 = (AppDelegate*)app.delegate;
  456. UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:root];
  457. [app2.window removeAllSubViews];
  458. app2.window.rootViewController = nav;
  459. */
  460. }
  461. //键盘的隐藏
  462. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
  463. [self.view endEditing:YES];
  464. }
  465. -(void)showAler:(int)code {
  466. if (code == -1) {
  467. [[YBBaseAppDelegate sharedAppDelegate]popViewController:YES];
  468. }
  469. }
  470. -(void)showPrivateRule {
  471. //弹窗 === 改为 YBPrivateVC 显示 又改回来了【20-7-3】
  472. YBWeakSelf;
  473. if (_showAlert) {
  474. _showAlert = NO;
  475. [RegAlertView showRegAler:rulesDic complete:^(int code) {
  476. [weakSelf showAler:code];
  477. }];
  478. }
  479. _privateL.hidden = NO;
  480. _privateL.text = minstr([rulesDic valueForKey:@"login_title"]);//@"登录即代表你同意";
  481. _privateL.textColor = RGB_COLOR(@"#323232", 1);
  482. _privateL.font = SYS_Font(15);
  483. _privateL.numberOfLines = 0;
  484. NSArray *ppA = [NSArray arrayWithArray:[rulesDic valueForKey:@"message"]];
  485. // for (int i=0; i<ppA.count; i++) {
  486. // NSDictionary *subDic = ppA[i];
  487. // if (i==0) {
  488. // _privateL.text = [NSString stringWithFormat:@"%@%@",_privateL.text,[subDic valueForKey:@"title"]];
  489. // }else{
  490. // _privateL.text = [NSString stringWithFormat:@"%@和%@",_privateL.text,[subDic valueForKey:@"title"]];
  491. // }
  492. // }
  493. NSMutableAttributedString *textAtt = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",_privateL.text]];
  494. [textAtt addAttribute:NSForegroundColorAttributeName value:RGB_COLOR(@"#6F6F6F", 1) range:textAtt.yy_rangeOfAll];
  495. for (int i=0; i<ppA.count; i++) {
  496. NSDictionary *subDic = ppA[i];
  497. NSRange clickRange = [[textAtt string]rangeOfString:minstr([subDic valueForKey:@"title"])];
  498. //RGB_COLOR(@"#5C94E7", 1)
  499. [textAtt yy_setTextHighlightRange:clickRange color:Pink_Cor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  500. NSLog(@"协议");
  501. if ([PublicObj checkNull:minstr([subDic valueForKey:@"url"])]) {
  502. [MBProgressHUD showError:YZMsg(@"链接不存在")];
  503. return;
  504. }
  505. PubH5 *h5vc = [[PubH5 alloc]init];
  506. h5vc.url = minstr([subDic valueForKey:@"url"]);;
  507. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:h5vc animated:YES];
  508. }];
  509. }
  510. textAtt.yy_alignment = NSTextAlignmentCenter;
  511. _privateL.attributedText = textAtt;
  512. // CGFloat widthss = [PublicObj widthOfString:minstr([rulesDic valueForKey:@"login_title"]) andFont:[UIFont systemFontOfSize:14] andHeight:30];
  513. [_xyBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  514. make.right.equalTo(_privateL.mas_left).offset(-5);
  515. make.centerY.equalTo(_privateL.mas_centerY);
  516. make.height.width.mas_equalTo(12);
  517. }];
  518. }
  519. - (IBAction)protolBtnClick:(UIButton *)sender {
  520. loginAgreementBool = !loginAgreementBool;
  521. if (loginAgreementBool) {
  522. _xyBtn.selected = YES;
  523. }else{
  524. _xyBtn.selected = NO;
  525. }
  526. }
  527. @end