TipsQRCodeForChangeDeviceViewController.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. //
  2. // TipsQRCodeForChangeDeviceViewController.m
  3. // 隐私保护
  4. //
  5. // Created by APPLE on 2023/9/19.
  6. //
  7. #import "TipsQRCodeForChangeDeviceViewController.h"
  8. #import <Masonry.h>
  9. #import "UIView+View.h"
  10. #import "QRCodeScanForChangeDeviceViewController.h"
  11. @interface TipsQRCodeForChangeDeviceViewController ()
  12. @end
  13. @implementation TipsQRCodeForChangeDeviceViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. // Do any additional setup after loading the view.
  17. [self drawAnyView];
  18. [self.view bringSubviewToFront:self.navBarBGView];
  19. [self.navBarBGView setBackgroundColor:[UIColor clearColor]];
  20. }
  21. - (void)backBtnPressed
  22. {
  23. [super backBtnPressed];
  24. if(_isRootVCType){
  25. //发个通知
  26. [[NSNotificationCenter defaultCenter] postNotificationName:scanChangeDeviceBackNotification object:nil];
  27. }
  28. }
  29. - (void)drawAnyView{
  30. [self.navigationBar setHidden:YES];
  31. [self.toolBar setHidden:YES];
  32. [self.navBarBGView setHidden:NO];
  33. [self.titleLabel setText:NSLocalizedString(@"my_set_no_change_phone",nil)];
  34. [self initBaseUIFun];
  35. // /*背景视图*/
  36. // UIImageView *bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guide_qrcode_bg_icon"]];
  37. // [bgImageView setContentMode:(UIViewContentModeScaleToFill)];
  38. // [self.view addSubview:bgImageView];
  39. // [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. // make.top.mas_equalTo(0);
  41. // make.bottom.mas_equalTo(0);
  42. // make.left.mas_equalTo(0);
  43. // make.right.mas_equalTo(0);
  44. // }];
  45. //
  46. // UIButton *qrcodeBtn = [[UIButton alloc] init];
  47. // [qrcodeBtn setBackgroundColor:[UIColor clearColor]];
  48. // [qrcodeBtn setBackgroundImage:[UIImage imageNamed:@"guide_qrcode_icon"] forState:(UIControlStateNormal)];
  49. // [self.view addSubview:qrcodeBtn];
  50. // [qrcodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  51. // make.top.mas_equalTo((363.f/812.f)*self.view.height - 80.f);
  52. // make.centerX.equalTo(self.view.mas_centerX);
  53. // make.width.mas_equalTo(160);
  54. // make.height.mas_equalTo(160);
  55. // }];
  56. //
  57. // [qrcodeBtn addTarget:self
  58. // action:@selector(qrcodeBtnPressed)
  59. // forControlEvents:(UIControlEventTouchUpInside)];
  60. //
  61. // /*提示文字*/
  62. // UILabel *tipsLabel = [[UILabel alloc] init];
  63. // [tipsLabel setFont:[UIFont systemFontOfSize:14]];
  64. // [tipsLabel setTextColor:HW666666Color];
  65. // [tipsLabel setTextAlignment:(NSTextAlignmentCenter)];
  66. // [self.view addSubview:tipsLabel];
  67. // [tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  68. // make.top.equalTo(qrcodeBtn.mas_bottom).offset(8);
  69. // make.left.mas_equalTo(60);
  70. // make.right.mas_equalTo(-60);
  71. // }];
  72. // [tipsLabel setText:NSLocalizedString(@"guide_qrcoede_tips",nil)];
  73. //
  74. // /*扫一扫按钮*/
  75. // UIButton *qrcodeSmallBtn = [[UIButton alloc] init];
  76. // qrcodeSmallBtn.frame = CGRectMake(0, 0, 120.f, 36.f);
  77. //
  78. // // gradient
  79. // CAGradientLayer *gl = [CAGradientLayer layer];
  80. // gl.frame = CGRectMake(0,0,120.f,36.f);
  81. // gl.startPoint = CGPointMake(0, 0.5);
  82. // gl.endPoint = CGPointMake(1, 0.5);
  83. // gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  84. // gl.locations = @[@(0), @(1.0f)];
  85. //
  86. // [qrcodeSmallBtn.layer addSublayer:gl];
  87. // [qrcodeSmallBtn addTarget:self action:@selector(qrcodeBtnPressed) forControlEvents:(UIControlEventTouchUpInside)];
  88. // [qrcodeSmallBtn setTitle:NSLocalizedString(@"guide_qrcoede_btn_title",nil) forState:(UIControlStateNormal)];
  89. // [qrcodeSmallBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  90. // [qrcodeSmallBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  91. // [qrcodeSmallBtn.layer setCornerRadius:18.f];
  92. // qrcodeSmallBtn.clipsToBounds = YES;
  93. // [self.view addSubview:qrcodeSmallBtn];
  94. // [qrcodeSmallBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  95. // make.centerX.equalTo(self.view.mas_centerX);
  96. // make.width.mas_equalTo(120.f);
  97. // make.top.equalTo(tipsLabel.mas_bottom).offset(20);
  98. // make.height.mas_equalTo(36.f);
  99. // }];
  100. }
  101. - (void)initBaseUIFun
  102. {
  103. self.view.backgroundColor = [UIColor whiteColor];
  104. // NSString *curTitleStr = NSLocalizedString(@"scan_Tip_title",nil);
  105. //
  106. // /*标题*/
  107. // UILabel *titleLabel = [[UILabel alloc] init];
  108. // [titleLabel setFont:[UIFont systemFontOfSize:18]];
  109. // [titleLabel setTextColor:HW333333Color];
  110. // [titleLabel setTextAlignment:(NSTextAlignmentCenter)];
  111. // [self.view addSubview:titleLabel];
  112. // [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  113. // make.top.equalTo(self.titleLabel.mas_top).offset(0);
  114. // make.left.mas_equalTo(10);
  115. // make.right.mas_equalTo(-10);
  116. // make.height.mas_equalTo(25.0);
  117. // }];
  118. // [titleLabel setText:curTitleStr];
  119. //
  120. UIScrollView *bgScorllV = [[UIScrollView alloc] init];
  121. bgScorllV.showsHorizontalScrollIndicator = NO;
  122. //bgScorllV.backgroundColor = [UIColor redColor];
  123. [self.view addSubview:bgScorllV];
  124. [bgScorllV mas_makeConstraints:^(MASConstraintMaker *make) {
  125. make.top.equalTo(self.titleLabel.mas_bottom).offset(30);
  126. make.left.mas_equalTo(0);
  127. make.right.mas_equalTo(0);
  128. make.bottom.mas_equalTo(-100.0);
  129. }];
  130. NSString *languageCode = [NSLocale preferredLanguages][0];
  131. NSString *imageNameStr = @"scan_tip_en";
  132. CGFloat imageW = 345.0;
  133. CGFloat imageH = 598.0;
  134. if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
  135. {
  136. imageNameStr = @"scan_tip_Hans";
  137. }
  138. else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
  139. {
  140. imageNameStr = @"scan_tip_Hant";
  141. }
  142. else if([languageCode rangeOfString:@"ja-"].location != NSNotFound)
  143. {
  144. imageNameStr = @"scan_tip_ja";
  145. imageH = 672.0;
  146. }
  147. UIImageView * bgImageV = [[UIImageView alloc] init];
  148. bgImageV.image = [UIImage imageNamed:imageNameStr];
  149. [bgScorllV addSubview:bgImageV];
  150. [bgImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  151. make.centerX.mas_equalTo(0);
  152. make.top.mas_equalTo(0);
  153. make.width.mas_equalTo(imageW);
  154. make.height.mas_equalTo(imageH);
  155. }];
  156. bgScorllV.contentSize = CGSizeMake(imageW, imageH);
  157. /*扫一扫按钮*/
  158. UIButton *qrcodeSmallBtn = [[UIButton alloc] init];
  159. // gradient
  160. CAGradientLayer *gl = [CAGradientLayer layer];
  161. gl.frame = CGRectMake(0,0,345.f,48.f);
  162. gl.startPoint = CGPointMake(0, 0.5);
  163. gl.endPoint = CGPointMake(1, 0.5);
  164. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  165. gl.locations = @[@(0), @(1.0f)];
  166. [qrcodeSmallBtn.layer addSublayer:gl];
  167. [qrcodeSmallBtn addTarget:self action:@selector(qrcodeBtnPressed) forControlEvents:(UIControlEventTouchUpInside)];
  168. [qrcodeSmallBtn setTitle:NSLocalizedString(@"scan_Tip_title_button",nil) forState:(UIControlStateNormal)];
  169. [qrcodeSmallBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  170. [qrcodeSmallBtn.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
  171. [qrcodeSmallBtn.layer setCornerRadius:8.f];
  172. qrcodeSmallBtn.clipsToBounds = YES;
  173. [self.view addSubview:qrcodeSmallBtn];
  174. [qrcodeSmallBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  175. make.centerX.equalTo(self.view.mas_centerX);
  176. make.width.mas_equalTo(345.f);
  177. make.top.equalTo(bgScorllV.mas_bottom).offset(15);
  178. make.height.mas_equalTo(48.f);
  179. }];
  180. }
  181. - (void)qrcodeBtnPressed{
  182. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  183. {
  184. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  185. return;
  186. }
  187. QRCodeScanForChangeDeviceViewController *nextVC = [[QRCodeScanForChangeDeviceViewController alloc] init];
  188. [self.navigationController pushViewController:nextVC animated:YES];
  189. nextVC.didScanErrorFun = ^(NSInteger code) {
  190. self->_isNeedToShowAleatType = YES;
  191. self->_getSNMsgcode = code;
  192. };
  193. }
  194. /*
  195. #pragma mark - Navigation
  196. // In a storyboard-based application, you will often want to do a little preparation before navigation
  197. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  198. // Get the new view controller using [segue destinationViewController].
  199. // Pass the selected object to the new view controller.
  200. }
  201. */
  202. - (void)viewDidAppear:(BOOL)animated
  203. {
  204. [super viewDidAppear:animated];
  205. if(_isNeedToShowAleatType){
  206. [self showAlertFun];
  207. }
  208. }
  209. - (void)showAlertFun
  210. {
  211. NSString *linkErrTitle = NSLocalizedString(@"scan_sn_data_error_title",nil);
  212. NSString *linkErrTip = NSLocalizedString(@"scan_sn_data_error_content",nil);
  213. if(_getSNMsgcode == 202){
  214. linkErrTitle = NSLocalizedString(@"get_sn_msg_202_title",nil);
  215. linkErrTip = NSLocalizedString(@"get_sn_msg_202_content",nil);
  216. }else if (_getSNMsgcode == 201){
  217. linkErrTitle = NSLocalizedString(@"get_sn_msg_201_title",nil);
  218. linkErrTip = NSLocalizedString(@"get_sn_msg_201_content",nil);
  219. }
  220. ComontAlretViewController *linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:linkErrTitle
  221. msg:linkErrTip
  222. imageStr:nil
  223. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  224. okTitle:nil isOkBtnHighlight:NO
  225. didClickOk:^{
  226. } didClickCancel:^{
  227. }];
  228. linkFailAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  229. //[linkFailAlretVC setMsgTextAlignment:NSTextAlignmentLeft];
  230. [self presentViewController:linkFailAlretVC animated:YES completion:^{
  231. linkFailAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  232. }];
  233. }
  234. @end