TipsQRCodeViewController.m 9.5 KB

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