ScanPageVC.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. //
  2. // ScanPageVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/4/19.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "ScanPageVC.h"
  9. #import "CDZQRScanView.h"
  10. #import "ScanResultVC.h"
  11. #import "MyWebViewVC.h"
  12. #import <Photos/Photos.h>
  13. #import "DES3Util.h"
  14. #import <BMKLocationkit/BMKLocationComponent.h>//引入定位功能所有的头文件(新)
  15. #import "AFNetworking.h"
  16. #import "MBProgressHUD+DS.h"
  17. #import "MapManager.h"
  18. #define KWidth (kSize.width/2.0 + 30)
  19. typedef NS_ENUM(NSInteger, ScanType) {
  20. //惠智/多伦等模拟设备登录
  21. Huizhi_mn,
  22. //兴中正模拟设备登录
  23. Xzz_mn
  24. };
  25. @interface ScanPageVC ()<BMKLocationManagerDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,CDZQRScanDelegate>
  26. {
  27. //闪光灯
  28. UIView *flashlightView;
  29. UILabel *flashlightStateLabel;
  30. UIButton *flashlightBtn;
  31. //扫描结果
  32. NSString *dataString;
  33. //扫码类型
  34. ScanType locationType;
  35. //地图定位
  36. CLLocationCoordinate2D myCoordinate;
  37. }
  38. @property (nonatomic ,strong) CDZQRScanView *scanView;
  39. @property (nonatomic ,strong) UIImagePickerController *imagePicker;
  40. //扫码区域上方提示文字
  41. @property (nonatomic, strong) UILabel *topTitle;
  42. #pragma mark - 底部几个功能:开启闪光灯、相册、我的二维码
  43. //底部显示的功能项
  44. @property (nonatomic, strong) UIView *bottomItemsView;
  45. //相册
  46. @property (nonatomic, strong) UIButton *btnPhoto;
  47. //闪光灯
  48. @property (nonatomic, strong) UIButton *btnFlash;
  49. //闪关灯开启状态记录
  50. @property(nonatomic,assign)BOOL isOpenFlash;
  51. @end
  52. @implementation ScanPageVC
  53. - (void)viewDidLoad {
  54. [super viewDidLoad];
  55. //vc的基本设置
  56. self.view.backgroundColor = [UIColor blackColor];
  57. self.title = @"二维码扫描";
  58. [self configNavigationBar];
  59. //
  60. [self.view addSubview:self.scanView];
  61. //
  62. [self drawTitle];
  63. //
  64. [self drawBottomItems];
  65. }
  66. - (void)changeFlash {
  67. [self.scanView changeTorch];
  68. self.isOpenFlash = !self.isOpenFlash;
  69. if (self.isOpenFlash) {
  70. [_btnFlash setImage:[UIImage imageNamed:@"qrcode_scan_btn_flash_down"] forState:UIControlStateNormal];
  71. }
  72. else {
  73. [_btnFlash setImage:[UIImage imageNamed:@"qrcode_scan_btn_flash_nor"] forState:UIControlStateNormal];
  74. }
  75. }
  76. -(void)viewWillAppear:(BOOL)animated
  77. {
  78. [super viewWillAppear:animated];
  79. [self.scanView startScanning];
  80. }
  81. -(void)viewWillDisappear:(BOOL)animated
  82. {
  83. [super viewWillDisappear:animated];
  84. [self.scanView stopScanning];
  85. }
  86. -(void)scanBlock:(MyBlockType)block
  87. {
  88. scanBlock = block;
  89. }
  90. #pragma mark - 绘制扫描区域
  91. - (void)drawTitle
  92. {
  93. if (!_topTitle)
  94. {
  95. CGRect scanRect = self.scanView.scanRect;
  96. self.topTitle = [[UILabel alloc]init];
  97. _topTitle.bounds = CGRectMake(0, 0, scanRect.size.width*2/3, 0);
  98. _topTitle.font = [UIFont systemFontOfSize:15];
  99. _topTitle.textAlignment = NSTextAlignmentCenter;
  100. _topTitle.numberOfLines = 0;
  101. _topTitle.text = @"将取景框对准二维码即可自动扫描";
  102. _topTitle.textColor = [UIColor whiteColor];
  103. [_topTitle sizeToFit];
  104. _topTitle.center = CGPointMake(CGRectGetWidth(self.view.frame)/2, CGRectGetMinY(scanRect)-_topTitle.height/2-15);
  105. [self.view addSubview:_topTitle];
  106. }
  107. }
  108. - (void)drawBottomItems
  109. {
  110. if (_bottomItemsView) {
  111. return;
  112. }
  113. CGFloat bottomBarH = 100;
  114. self.bottomItemsView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.view.frame)-bottomBarH-kNavOffSet-kSafeAreaBottomHeight,
  115. CGRectGetWidth(self.view.frame), bottomBarH+kSafeAreaBottomHeight)];
  116. _bottomItemsView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
  117. [self.view addSubview:_bottomItemsView];
  118. CGSize size = CGSizeMake(65, 87);
  119. self.btnFlash = [[UIButton alloc]init];
  120. _btnFlash.bounds = CGRectMake(0, 0, size.width, size.height);
  121. _btnFlash.center = CGPointMake(CGRectGetWidth(_bottomItemsView.frame)/2, bottomBarH/2);
  122. [_btnFlash setImage:[UIImage imageNamed:@"qrcode_scan_btn_flash_nor"] forState:UIControlStateNormal];
  123. [_btnFlash addTarget:self action:@selector(changeFlash) forControlEvents:UIControlEventTouchUpInside];
  124. self.btnPhoto = [[UIButton alloc]init];
  125. _btnPhoto.bounds = _btnFlash.bounds;
  126. _btnPhoto.center = CGPointMake(CGRectGetWidth(_bottomItemsView.frame)*2/3, bottomBarH/2);
  127. [_btnPhoto setImage:[UIImage imageNamed:@"qrcode_scan_btn_photo_nor"] forState:UIControlStateNormal];
  128. [_btnPhoto setImage:[UIImage imageNamed:@"qrcode_scan_btn_photo_down"] forState:UIControlStateHighlighted];
  129. [_btnPhoto addTarget:self action:@selector(openLibary) forControlEvents:UIControlEventTouchUpInside];
  130. [_bottomItemsView addSubview:_btnFlash];
  131. // [_bottomItemsView addSubview:_btnPhoto];
  132. }
  133. #pragma mark - imagePickerDelegate
  134. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(nonnull NSDictionary<NSString *,id> *)info{
  135. [picker dismissViewControllerAnimated:YES completion:nil];
  136. UIImage *image = info[UIImagePickerControllerOriginalImage];
  137. NSString *result = [self messageFromQRCodeImage:image];
  138. if (result.length == 0) {
  139. [self showAlert:@"未识别到二维码"];
  140. return;
  141. }
  142. [self showAlert:result];
  143. }
  144. #pragma mark - 扫描结果 scanViewDelegate
  145. - (void)scanView:(CDZQRScanView *)scanView pickUpMessage:(NSString *)message
  146. {
  147. [scanView stopScanning];
  148. if ([message containsString:@"#DECODE#"] && message.length > 8) {
  149. //程序内某些验证
  150. NSString *testString = [DES3Util decrypt:[message substringFromIndex:8]];
  151. NSLog(@"\n原完整内容: %@ \n解密后: #DECODE#%@",message,testString);
  152. testString = @"#LNJP#huizhi@@BFEBFBFF000206A7@@1530258491165";
  153. if (testString == nil) {
  154. [self showResultString:@"二维码内容格式错误(#DECODE#+异常字符串)" title:nil];
  155. return;
  156. }
  157. //集中理论计时签到/签退
  158. if ([testString containsString:@"#LNJP#theory"]) {
  159. if ([_type isEqualToString:@"2"]) {
  160. [self showResultString:@"二维码类型错误,请扫描\"模拟设备登录\"二维码" title:@"模拟设备登录"];
  161. return;
  162. }
  163. NSArray *array = [testString componentsSeparatedByString:@"@@"];
  164. testString = [testString substringFromIndex:6];
  165. NSDictionary *dic = @{@"scanType":[array lastObject],@"dataString":[DES3Util encrypt:testString]};
  166. if (scanBlock) {
  167. [self.navigationController popViewControllerAnimated:YES];
  168. scanBlock(dic);
  169. }
  170. return;
  171. }
  172. //模拟终端登录 #DECODE#LNJP#simulatorLogin@@132456@@BFEBFBFF000206A7
  173. if ([testString containsString:@"#LNJP#simulatorLogin"]) {
  174. dataString = testString;
  175. if (scanBlock) {
  176. if ([self.type isEqualToString:@"2"]) {//来自模拟vc
  177. locationType = Xzz_mn;
  178. [self getMyLocation];
  179. }else if ([self.type isEqualToString:@"1"]){//来自homebase
  180. locationType = Xzz_mn;
  181. [self getMyLocation];
  182. }else{
  183. [self showResultString:@"二维码类型错误" title:nil];
  184. }
  185. }
  186. return;
  187. }
  188. //惠智模拟计时 #LNJP#huizhi@@BFEBFBFF000206A7@@1530258491165
  189. //多伦
  190. if ([testString containsString:@"#LNJP#huizhi"] || [testString containsString:@"#LNJP#other"]) {
  191. dataString = testString;
  192. locationType = Huizhi_mn;
  193. [self getMyLocation];
  194. return;
  195. }
  196. [self showResultString:message title:@"扫描结果"];
  197. return;
  198. }
  199. if([self.type isEqualToString:@"2"]){
  200. [self showResultString:@"二维码类型错误,请扫描\"模拟设备登录\"二维码" title:@"模拟设备登录"];
  201. return;
  202. }
  203. //进某网址
  204. if ([self.type isEqualToString:@"1"]) {
  205. if ([message hasPrefix:@"http://"] || [message hasPrefix:@"https://"]) {
  206. MyWebViewVC *vc = [MyWebViewVC new];
  207. vc.urlString = message;
  208. NSArray *vcs = self.navigationController.childViewControllers;
  209. NSMutableArray *arr = [NSMutableArray arrayWithArray:vcs];
  210. [arr replaceObjectAtIndex:vcs.count-1 withObject:vc];
  211. [self.navigationController setViewControllers:arr animated:YES];
  212. return;
  213. }
  214. [self showResultString:message title:@"扫描结果"];
  215. }
  216. }
  217. #pragma mark - 打开相册
  218. - (void)openLibary{
  219. if (![self isLibaryAuthStatusCorrect]) {
  220. [self showAlert:@"需要相册权限"];
  221. return;
  222. }
  223. [self presentViewController:self.imagePicker animated:YES completion:nil];
  224. }
  225. - (NSString *)messageFromQRCodeImage:(UIImage *)image{
  226. if (!image) {
  227. return nil;
  228. }
  229. CIContext *context = [CIContext contextWithOptions:nil];
  230. CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:context options:@{CIDetectorAccuracy:CIDetectorAccuracyHigh}];
  231. CIImage *ciImage = [CIImage imageWithCGImage:image.CGImage];
  232. NSArray *features = [detector featuresInImage:ciImage];
  233. if (features.count == 0) {
  234. return nil;
  235. }
  236. CIQRCodeFeature *feature = features.firstObject;
  237. return feature.messageString;
  238. }
  239. - (BOOL)isLibaryAuthStatusCorrect{
  240. PHAuthorizationStatus authStatus = [PHPhotoLibrary authorizationStatus];
  241. if (authStatus == PHAuthorizationStatusNotDetermined || authStatus == PHAuthorizationStatusAuthorized) {
  242. return YES;
  243. }
  244. return NO;
  245. }
  246. #pragma mark - 定位
  247. -(void)getMyLocation{
  248. BOOL isOpenTwo = [RQ_USER_MANAGER.currentUser.mnqTwoOpen isEqualToString:@"0"];
  249. BOOL isOpenThree = [RQ_USER_MANAGER.currentUser.mnqThreeOpen isEqualToString:@"0"];
  250. if (isOpenThree && isOpenTwo) {
  251. showMsgByAlert(self, @"暂未开启模拟计时");
  252. return;
  253. }
  254. //开启百度定位 DistanceFilter:将被通知任何移动(若=10,表示超出10米才会回调位置信息)
  255. [[MapManager sharedManager] updateLocationWithDistanceFilter:1 CompleteBlock:^(BOOL success, CLLocation * _Nonnull location, BMKLocation * _Nullable bmkLocation) {
  256. if (success) {
  257. self->myCoordinate = location.coordinate;
  258. if (self->locationType == Xzz_mn) {
  259. [self MNQLogin];
  260. }else if(self->locationType == Huizhi_mn){
  261. [self HuiZhiMNQLogin];
  262. }
  263. }
  264. }];
  265. }
  266. #pragma mark - 模拟设备登录
  267. - (void)MNQLogin{
  268. //dataString #LNJP#simulatorLogin @@ BFEBFBFF000206A7
  269. NSArray *arr = [dataString componentsSeparatedByString:@"@@"];
  270. NSString *account = RQ_USER_MANAGER.currentUser.loginCode;
  271. NSString *urlStr = [NSString stringWithFormat:@"%@lnmn/admin/phoneLogin",@"http://122.lnjppt.com/"];//@"http://192.168.1.237:8083/"
  272. NSMutableString *paramStr = [NSMutableString new];
  273. [paramStr appendString:[NSString stringWithFormat:@"%@",account]];//uname
  274. [paramStr appendString:[NSString stringWithFormat:@";%@",arr[1]]];//mnqSn
  275. [paramStr appendString:[NSString stringWithFormat:@";%@",RQ_USER_MANAGER.currentUser.city]];//dqbh
  276. [paramStr appendString:[NSString stringWithFormat:@";%f",myCoordinate.longitude]];//lng
  277. [paramStr appendString:[NSString stringWithFormat:@";%f",myCoordinate.latitude]];//lat
  278. //设置请求管理器
  279. AFHTTPSessionManager *afSessionManager = [AFHTTPSessionManager manager];
  280. afSessionManager.requestSerializer = [AFJSONRequestSerializer serializer];
  281. afSessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];
  282. afSessionManager.responseSerializer.acceptableContentTypes = [afSessionManager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
  283. afSessionManager.requestSerializer.timeoutInterval = 15;
  284. NSLog(@"%@",urlStr);
  285. [MBProgressHUD showMessage:@"正在登录模拟设备" ToView:self.view];
  286. [afSessionManager POST:urlStr parameters:@{@"params":[DES3Util encrypt:paramStr]} headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
  287. //请求成功
  288. [MBProgressHUD hideHUDForView:self.view];
  289. if (responseObject == nil) {
  290. [self showResultString:@"服务异常:无数据返回" title:@"登录失败"];
  291. return;
  292. }
  293. NSDictionary *root = [NSJSONSerialization JSONObjectWithData:responseObject
  294. options:NSJSONReadingMutableContainers
  295. error:nil];
  296. /*
  297. code=0—登录成功
  298. code=1—用户不存在
  299. code=2—未绑定报名信息
  300. code=3—当前培训阶段无法参与模拟训练
  301. code=4—当前模拟设备未绑定
  302. code=5—该设备已有学员在训练中
  303. code=6—模拟教室信息不存在
  304. code=7—您当前不在模拟教室有效范围内
  305. */
  306. if (![root[@"code"] isEqualToString:@"0"]) {
  307. [self showResultString:root[@"msg"] title:@"登录失败"];
  308. return;
  309. }
  310. //A 在 码I 计时; B 在 码II 计时; C 未计时,码III 未计时
  311. /*
  312. C扫码I/II,服务器返回code=1;
  313. A扫码I,服务器返回code=0;
  314. */
  315. NSLog(@"模拟设备登录成功123---urlString---><>%@,\n%@",urlStr,root);
  316. if ([self.type isEqualToString:@"2"]) {//function个人界面
  317. [self.navigationController popViewControllerAnimated:NO];
  318. if (scanBlock) {
  319. scanBlock(@"success");
  320. }
  321. }else if([self.type isEqualToString:@"1"]){//如果是homebase进来的
  322. [self.navigationController popViewControllerAnimated:NO];
  323. if (scanBlock) {
  324. scanBlock(@{@"scanType":@"MNQTrain"});
  325. }
  326. }
  327. } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
  328. NSLog(@"请求失败123----><>%@",error);
  329. [MBProgressHUD hideHUDForView:self.view];
  330. NSString *reason = @"请求失败";
  331. if ([error.localizedDescription isEqualToString:@"The request timed out."]) {
  332. //,@"请求超时"
  333. reason = @"连接超时,请检查手机网络";
  334. }
  335. [self showResultString:reason title:@"登录失败"];
  336. }];
  337. }
  338. #pragma mark - 惠智模拟设备登录
  339. - (void)HuiZhiMNQLogin{
  340. //dataString #LNJP#simulatorLogin @@ BFEBFBFF000206A7 @@ 时间戳
  341. NSArray *arr = [dataString componentsSeparatedByString:@"@@"];
  342. NSString *account = RQ_USER_MANAGER.currentUser.loginCode;
  343. NSString *urlStr = [NSString stringWithFormat:@"%@appservice/lnsimulator/phoneLogin",@"http://app.lnjppt.com/"];//@"http://218.85.55.253:9091/ln" @"http://192.168.1.3:8081/ln"
  344. NSMutableString *paramStr = [NSMutableString new];
  345. // [paramStr appendString:arr[1]];//uuid
  346. [paramStr appendString:[NSString stringWithFormat:@"%@",account]];//uname
  347. [paramStr appendString:[NSString stringWithFormat:@";%@",arr[1]]];//mnqSn
  348. [paramStr appendString:[NSString stringWithFormat:@";%@",RQ_USER_MANAGER.currentUser.city]];//dqbh
  349. [paramStr appendString:[NSString stringWithFormat:@";%f",myCoordinate.longitude]];//lng
  350. [paramStr appendString:[NSString stringWithFormat:@";%f",myCoordinate.latitude]];//lat
  351. [paramStr appendString:[NSString stringWithFormat:@";%@",arr[2]]];
  352. // NSTimeInterval timeI = [[NSDate date] timeIntervalSince1970] * 1000;
  353. // [paramStr appendString:[NSString stringWithFormat:@";%.0f",timeI]];
  354. //设置请求管理器
  355. AFHTTPSessionManager *afSessionManager = [AFHTTPSessionManager manager];
  356. afSessionManager.requestSerializer = [AFJSONRequestSerializer serializer];
  357. afSessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];
  358. afSessionManager.responseSerializer.acceptableContentTypes = [afSessionManager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
  359. afSessionManager.requestSerializer.timeoutInterval = 15;
  360. NSLog(@"%@ \n params:{%@}",urlStr,paramStr);
  361. [MBProgressHUD showMessage:@"正在登录模拟设备" ToView:self.view];
  362. [afSessionManager POST:urlStr parameters:@{@"params":[DES3Util encrypt:paramStr]} headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
  363. //请求成功
  364. [MBProgressHUD hideHUDForView:self.view];
  365. if (responseObject == nil) {
  366. [self showResultString:@"服务异常:无数据返回" title:@"登录失败"];
  367. return;
  368. }
  369. NSDictionary *root = [NSJSONSerialization JSONObjectWithData:responseObject
  370. options:NSJSONReadingMutableContainers
  371. error:nil];
  372. NSLog(@"惠智/多伦:%@---->: %@",urlStr,root);
  373. if ([root[@"code"] isEqualToString:@"90"]) {
  374. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:root[@"msg"] preferredStyle:UIAlertControllerStyleAlert];
  375. [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  376. [RQ_USER_MANAGER isShouldLogin];
  377. }]];
  378. [self presentViewController:alertFind animated:true completion:nil];
  379. return;
  380. }
  381. if (![root[@"code"] isEqualToString:@"0"]) {
  382. [self showResultString:root[@"msg"] title:@"登录失败"];
  383. return;
  384. }
  385. NSString *carNum = nil;
  386. NSDictionary *body = root[@"body"];
  387. if (body && [body isKindOfClass:[NSDictionary class]]) {
  388. NSDictionary *map = body[@"map"];
  389. if (map && [map isKindOfClass:[NSDictionary class]]) {
  390. carNum = [NSString stringWithFormat:@"%@",map[@"carnum"]];
  391. }
  392. }
  393. NSString *successStr = @"模拟设备已登录";
  394. if (carNum && carNum.length != 0) {
  395. successStr = [NSString stringWithFormat:@"%@,欢迎您!\n已成功登录模拟设备【%@】,祝您体验愉快",RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.userName)? RQ_USER_MANAGER.currentUser.userName : @"",carNum];
  396. }
  397. [self showResultString:successStr title:@"登录成功"];
  398. } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
  399. NSLog(@"请求失败123----><>%@",error);
  400. [MBProgressHUD hideHUDForView:self.view];
  401. NSString *reason = @"请求失败";
  402. if ([error.localizedDescription isEqualToString:@"The request timed out."]) {
  403. //,@"请求超时"
  404. reason = @"连接超时,请检查手机网络";
  405. }
  406. [self showResultString:reason title:@"登录失败"];
  407. }];
  408. }
  409. #pragma mark - alert 提示
  410. -(void)showResultString:(NSString *)str title:(NSString *)title{
  411. ScanResultVC *vc = [ScanResultVC new];
  412. vc.resultStr = str;
  413. vc.navigationItem.title = title;
  414. if (self == nil) {//请求网络数据到一半,返回首页
  415. return;
  416. }
  417. NSArray *vcs = self.navigationController.childViewControllers;
  418. NSMutableArray *arr = [NSMutableArray arrayWithArray:vcs];
  419. [arr replaceObjectAtIndex:vcs.count-1 withObject:vc];
  420. [self.navigationController setViewControllers:arr animated:YES];
  421. }
  422. - (void)showAlert:(NSString *)message {
  423. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:message preferredStyle:UIAlertControllerStyleAlert];
  424. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"好" style:UIAlertActionStyleCancel handler:nil];
  425. [alert addAction:cancelAction];
  426. [self presentViewController:alert animated:YES completion:nil];
  427. }
  428. #pragma mark - get
  429. - (CDZQRScanView *)scanView{
  430. if (!_scanView) {
  431. _scanView = [[CDZQRScanView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet-kSafeAreaBottomHeight)];
  432. _scanView.delegate = self;
  433. _scanView.showBorderLine = YES;
  434. _scanView.scanLineColor = [UIColor cyanColor];
  435. _scanView.cornerLineColor = [UIColor whiteColor];
  436. // CGSize scanSize = CGSizeMake(_scanView.width * 2/3, _scanView.width * 2/3);
  437. // _scanView.scanRect = CGRectMake((_scanView.size.width - scanSize.width)/2, (_scanView.size.height - 100 - scanSize.height)/2, scanSize.width, scanSize.height);
  438. }
  439. return _scanView;
  440. }
  441. - (UIImagePickerController *)imagePicker{
  442. if (!_imagePicker) {
  443. _imagePicker = [[UIImagePickerController alloc]init];
  444. _imagePicker.delegate = self;
  445. _imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  446. }
  447. return _imagePicker;
  448. }
  449. - (void)didReceiveMemoryWarning {
  450. [super didReceiveMemoryWarning];
  451. }
  452. @end