SceneDelegate.m 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447
  1. //
  2. // SceneDelegate.m
  3. // 唔即云相册
  4. //
  5. // Created by 余衡武 on 2021/12/8.
  6. //
  7. #import "SceneDelegate.h"
  8. #import "HWWebViewController.h"
  9. #import "CalculatorViewController.h"
  10. #import "SetUsePWDViewController.h"
  11. #import "GuideViewController.h"
  12. #import "BaseNavigationController.h"
  13. #import "MySetViewController.h"
  14. #import "SafeForKey.h"
  15. #import "TipsQRCodeViewController.h"
  16. #import "SetPWDFirstViewController.h"
  17. #import "connectDeviceManager.h"
  18. #import "inputPWDViewController.h"
  19. #import "customLaunchView.h"
  20. #import "RSATool.h"
  21. #import "forgetPwdViewController.h"
  22. #import "TipsQRCodeForChangeDeviceViewController.h"
  23. #import "AFNetworkReachabilityManager.h"
  24. #import "ComontAlretViewController.h"
  25. #import "uploadFileManager.h"
  26. #import "downloadManager.h"
  27. #import "backupsFileManager.h"
  28. #import "iPhone.h"
  29. #import <WXApi.h>
  30. #import <TencentOpenAPI/QQApiInterface.h>
  31. #import <TencentOpenAPI/TencentOAuth.h>
  32. #import "NASMsgModel.h"
  33. #import "queryOneShareModel.h"
  34. #import "boxSaveFileManager.h"
  35. #import "boxDownloadFileManager.h"
  36. #import "NASViewController.h"
  37. #import "cloudPhoneViewController.h"
  38. #import "mineViewController.h"
  39. #import "lastFileManager.h"
  40. #import "customDownloadManager.h"
  41. #import "audioPlayListManager.h"
  42. #import "QRCodeScanForChangeDeviceViewController.h"
  43. #import "customToastVew.h"
  44. #import "DFPlayer.h"
  45. #import "UIInterface+HXRotation.h"
  46. #import "imageDetailsScrollViewController.h"
  47. #import "videoPlayByAVPlayerViewController.h"
  48. @interface SceneDelegate ()<SetUsePWDViewControllerDelegate,GuideViewControllerDelegate,UITabBarControllerDelegate>
  49. @property(nonatomic, strong) CalculatorViewController *calculatorVC;
  50. @property(nonatomic, strong) HWWebViewController *webVC;
  51. @property(nonatomic, strong) inputPWDViewController *inputVC;
  52. @property(nonatomic, strong) customLaunchView *customLaunchV;//
  53. //@property(nonatomic, strong) PlayerViewController *curPlayerVC;
  54. @property(nonatomic, strong) BaseNavigationController *preRootPlayerNav;
  55. @property(nonatomic, assign) bool isQRCodeType;//第一次 扫码进来的
  56. //@property(nonatomic, assign) bool isNeedToShowSecretKey;//扫码进来的SN 没有密码 则需要显示秘钥
  57. @property (nonatomic, assign) BOOL isLoginAgainType;// 单点登录 点重新登录进来的
  58. @property (nonatomic, assign) BOOL isNeedToStopWork;// 无网络报错
  59. @property (nonatomic, assign) BOOL isDidShowPwdType;// 是否显示密码界面了
  60. @property(nonatomic, copy) NSString *getShareStr;//拿到分享的字符串
  61. @property (nonatomic, assign) BOOL isFirstOpenInLaunch;//启动页停两秒
  62. //冷启动分享跳入用
  63. @property(nonatomic, strong) UISceneSession *session;
  64. @property(nonatomic, strong) UISceneConnectionOptions *connectionOptions;
  65. @end
  66. @implementation SceneDelegate
  67. - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions API_AVAILABLE(ios(13.0)){
  68. HLog(@"willConnectToSession")
  69. if (scene) {
  70. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(guideOk:) name:GuideOkNotification object:nil];
  71. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showLockViewFun:) name:lockBypwdNotification object:nil];
  72. //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setPwdVCFun:) name:setPwdNotification object:nil];
  73. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdFun:) name:forgetPwdNotification object:nil];
  74. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdBackFun:) name:forgetPwdBackNotification object:nil];
  75. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdDidSetPwdFun:) name:forgetPwdDidSetNotification object:nil];
  76. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scanChangeDeviceFun:) name:scanChangeDeviceNotification object:nil];
  77. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scanChangeDeviceBackFun:) name:scanChangeDeviceBackNotification object:nil];
  78. UIWindowScene *windowScene = (UIWindowScene *)scene;
  79. self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
  80. self.window.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
  81. _isFirstOpenInLaunch = YES;
  82. // 初始化数据库
  83. [self initBrowserWindow];
  84. // 加载主页面
  85. [self enterMainVCFromScene];
  86. //
  87. [self reportVersionInfoFun];
  88. [self.window makeKeyAndVisible];
  89. ksharedAppDelegate.window = self.window;
  90. //冷启动
  91. if(connectionOptions.URLContexts != nil){
  92. _session = session;
  93. _connectionOptions = connectionOptions;
  94. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  95. // mainBlock(^{
  96. // [self scene:scene openURLContexts:connectionOptions.URLContexts];
  97. // });
  98. // });
  99. }
  100. }
  101. }
  102. /** 主界面 - 内部使用 */
  103. - (void)enterMainVCFromScene {
  104. // ConnectTestViewController *qrCodeVCNav = [[ConnectTestViewController alloc] init];
  105. // self.window.rootViewController = qrCodeVCNav;
  106. // return;/*临时测试*/
  107. if(_isNeedToStopWork){
  108. return;
  109. }
  110. /*先判断本地有无设备 无设备时需要先扫码添加设备*/
  111. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  112. if (!deviceDict || ![[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
  113. //默认显示最近文件
  114. [HWDataManager setBoolWithKey:Const_last_file_show value:YES];
  115. /*扫码界面*/
  116. TipsQRCodeViewController *qrCodeVC = [[TipsQRCodeViewController alloc] init];
  117. BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
  118. self.window.rootViewController = qrCodeVCNav;
  119. _isQRCodeType = YES;
  120. return;
  121. }
  122. NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
  123. // GuideViewController
  124. BOOL haveGuide = [HWDataManager getBoolWithKey:Const_Have_Show_Guide];
  125. if (haveGuide) {
  126. ;
  127. }else {
  128. GuideViewController *guiDeVC = [[GuideViewController alloc] init];
  129. guiDeVC.delegate = self;
  130. guiDeVC.sn = SNStr;
  131. self.window.rootViewController = guiDeVC;
  132. return;
  133. }
  134. //BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
  135. #ifdef developJSQ
  136. NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  137. #else
  138. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  139. #endif
  140. //添加默认启动图片
  141. if(!_customLaunchV && maskModel == 0){
  142. _customLaunchV = [[customLaunchView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  143. [self.window addSubview:_customLaunchV];
  144. }
  145. if(maskModel == 0 && _isFirstOpenInLaunch){
  146. //20240612 产品觉得 启动页太快了 要停两秒
  147. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  148. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  149. {
  150. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  151. customToastVew *toastview = [customToastVew makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)];
  152. [toastview show];
  153. [self->_customLaunchV addSubview:toastview];
  154. return;
  155. }
  156. [self getDeviceMsgInMainVCWith:deviceDict];
  157. });
  158. _isFirstOpenInLaunch = NO;
  159. }
  160. else{
  161. //延时等网络状态
  162. if(_isFirstOpenInLaunch){
  163. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  164. [self getDeviceMsgInMainVCWith:deviceDict];
  165. });
  166. _isFirstOpenInLaunch = NO;
  167. }
  168. else{
  169. [self getDeviceMsgInMainVCWith:deviceDict];
  170. }
  171. }
  172. //[self showNetErrorAlertType2Fun];
  173. }
  174. - (void)getDeviceMsgInMainVCWith:(NSDictionary*)deviceDict
  175. {
  176. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  177. {
  178. BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
  179. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  180. if(!isPrivacyMode && maskModel == 0){
  181. return;
  182. }
  183. [self initMainTabbarFun];
  184. [self showCalculatorVC];
  185. return;
  186. }
  187. KWeakSelf
  188. //有设备了先去做链接准备 // 80bec9c5
  189. NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
  190. NSString *sdnId = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sdnId;
  191. if(SNStr && !sdnId){
  192. [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr needReconnect:YES didNetEnd:^(NSInteger didSuc) {
  193. if(didSuc == 0){
  194. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  195. mainBlock(^{
  196. [weakSelf showNetErrorAlertFun];
  197. [weakSelf enterMainVCFromSceneSecondStepFun];
  198. });
  199. });
  200. }
  201. else if(didSuc == 2
  202. ||didSuc == 201
  203. ||didSuc == 202){
  204. [weakSelf gotoScanAginByThridMsgErrorFun:didSuc];
  205. }
  206. else{
  207. [weakSelf enterMainVCFromSceneSecondStepFun];
  208. }
  209. }];
  210. }
  211. else{
  212. [self enterMainVCFromSceneSecondStepFun];
  213. }
  214. }
  215. - (void)enterMainVCFromSceneSecondStepFun
  216. {
  217. //确保通过SN号拿到密码了
  218. //非扫码进入 进入到这里很可能还没联网拿到设备最新信息
  219. if(![connectDeviceManager shareInstance].DeviceThirdIdMod){
  220. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  221. mainBlock(^{
  222. [self enterMainVCFromScene];
  223. });
  224. });
  225. return;
  226. }
  227. //是否已经有密码了 有就是输入密码 没有就是设置密码
  228. NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
  229. NSString * sdnId = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sdnId;
  230. if(!sdnId){
  231. HLog(@"没有拿到sdnId");
  232. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  233. mainBlock(^{
  234. [self enterMainVCFromScene];
  235. });
  236. });
  237. return;
  238. }
  239. if(_customLaunchV){
  240. [_customLaunchV removeFromSuperview];
  241. _customLaunchV = nil;
  242. }
  243. if(curPwd && curPwd.length > 0){
  244. /*设置密码*/
  245. // inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
  246. // BaseNavigationController *nextVCNav = [[BaseNavigationController alloc] initWithRootViewController:nextVC];
  247. // self.window.rootViewController = nextVCNav;
  248. }
  249. else{
  250. /*没有设置密码*/
  251. SetPWDFirstViewController *qrCodeVC = [[SetPWDFirstViewController alloc] init];
  252. BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
  253. self.window.rootViewController = qrCodeVCNav;
  254. return;
  255. }
  256. //下载配置先处理
  257. [boxDownloadFileManager shareInstance];
  258. [lastFileManager shareManager].uid = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
  259. [audioPlayListManager shareManager].uid = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
  260. //获取NAS相关信息
  261. [self getNASMsgFun];
  262. [self initMainTabbarFun];
  263. self.isLoginAgainType = NO;
  264. __block BOOL isPrivacyMode = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  265. //KWeakSelf
  266. if(!_isQRCodeType){
  267. if(isPrivacyMode)
  268. {
  269. [self showCalculatorVC];
  270. }
  271. else{
  272. [self HandleEnterNotPrivacyModeFun];
  273. [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
  274. //playerRootVC.isPwdVCShow = NO;
  275. //[playerRootVC setShowImgAndVoiceTypeFun:YES];
  276. //[weakSelf shareAwakenAppBy:weakSelf.getShareStr];
  277. if(self->_session && self->_connectionOptions){
  278. [self scene:self->_session openURLContexts:self->_connectionOptions.URLContexts];
  279. }
  280. }
  281. //_isQRCodeType = NO;
  282. }
  283. else{
  284. if(isPrivacyMode)
  285. {
  286. [self showCalculatorVC];
  287. }
  288. else{
  289. }
  290. }
  291. _isQRCodeType = NO;
  292. //数据埋点
  293. [[netWorkManager shareInstance] DataEmbeddingPointBy:1 withEventValue:@"Nas"];
  294. return;
  295. // if(_curPlayerVC){
  296. // //[_curPlayerVC disconnectVideoServer];
  297. //
  298. // _curPlayerVC.isNeedRecyclResource = YES;
  299. // [_curPlayerVC recyclResource];
  300. //
  301. // _curPlayerVC.liveStreamManager = nil;
  302. // [_curPlayerVC.navigationController popViewControllerAnimated:NO];
  303. // _curPlayerVC = nil;
  304. // }
  305. //
  306. // //每次进入
  307. // PlayerViewController *playerRootVC = [[PlayerViewController alloc] init];
  308. // if(self.isLoginAgainType){
  309. // playerRootVC.isLoginAgainType = self.isLoginAgainType;
  310. // }
  311. // playerRootVC.isPwdVCShow = YES;
  312. // _curPlayerVC = playerRootVC;
  313. //
  314. //// BaseNavigationController *playerNav = [[BaseNavigationController alloc] initWithRootViewController:playerRootVC];
  315. //// self.window.rootViewController = playerNav;
  316. //
  317. // UIViewController *vc = [UIViewController new];
  318. //
  319. // BaseNavigationController *playerNav = [[BaseNavigationController alloc] initWithRootViewController:vc];
  320. // [playerNav pushViewController:playerRootVC animated:NO];
  321. // self.window.rootViewController = playerNav;
  322. //
  323. // _preRootPlayerNav = playerNav;
  324. //
  325. // self.isLoginAgainType = NO;
  326. //
  327. // __block BOOL isPrivacyMode = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  328. //
  329. // KWeakSelf
  330. // if(!_isQRCodeType){
  331. //
  332. // if(isPrivacyMode)
  333. // {
  334. // [playerRootVC setShowImgAndVoiceTypeFun:NO];
  335. // [self showCalculatorVC];
  336. // }
  337. // else{
  338. // [self HandleEnterNotPrivacyModeFun];
  339. //
  340. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  341. // mainBlock(^{
  342. // [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
  343. // playerRootVC.isPwdVCShow = NO;
  344. // [playerRootVC setShowImgAndVoiceTypeFun:YES];
  345. // //[weakSelf shareAwakenAppBy:weakSelf.getShareStr];
  346. //
  347. // if(self->_session && self->_connectionOptions){
  348. // [self scene:self->_session openURLContexts:self->_connectionOptions.URLContexts];
  349. // }
  350. // });
  351. // });
  352. // }
  353. //
  354. // //_isQRCodeType = NO;
  355. // }
  356. // else{
  357. // if(isPrivacyMode)
  358. // {
  359. // [playerRootVC setShowImgAndVoiceTypeFun:NO];
  360. // [self showCalculatorVC];
  361. // }
  362. // else{
  363. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  364. // mainBlock(^{
  365. // playerRootVC.isPwdVCShow = NO;
  366. // [playerRootVC setShowImgAndVoiceTypeFun:YES];
  367. // });
  368. // });
  369. // }
  370. //
  371. // }
  372. //
  373. // _isQRCodeType = NO;
  374. //
  375. // //获取NAS相关信息
  376. // [self getNASMsgFun];
  377. //
  378. // [self initMainTabbarFun];
  379. }
  380. #pragma mark 1.4.1 新增tabbar
  381. - (void)initMainTabbarFun
  382. {
  383. UITabBarController *tabBarController = [[UITabBarController alloc] init];
  384. tabBarController.delegate = self;
  385. NASViewController *NASVC = [[NASViewController alloc] init];
  386. BaseNavigationController *NasNav = [[BaseNavigationController alloc] initWithRootViewController:NASVC];
  387. cloudPhoneViewController *cloudVC = [[cloudPhoneViewController alloc] init];
  388. BaseNavigationController *cloudPhoneNav = [[BaseNavigationController alloc] initWithRootViewController:cloudVC];
  389. mineViewController *mineVC = [[mineViewController alloc] init];
  390. BaseNavigationController *mineNav = [[BaseNavigationController alloc] initWithRootViewController:mineVC];
  391. NSArray *viewControllers = @[NasNav, cloudPhoneNav,mineNav]; // 添加更多视图控制器
  392. tabBarController.viewControllers = viewControllers;
  393. NSString*phoneTitle = NSLocalizedString(@"tabbar_cloud_phone",nil);
  394. NSString*myTitle = NSLocalizedString(@"tabbar_my_title",nil);
  395. NSArray *titleArr = @[@"NAS",phoneTitle,myTitle];
  396. NSArray *imageNArr = @[@"tabbar_nas_N", @"tabbar_phone_N",@"tabbar_my_N"];
  397. NSArray *imageHArr = @[@"tabbar_nas_H", @"tabbar_phone_H",@"tabbar_my_H"];
  398. for (int i=0; i<viewControllers.count; i++) {
  399. UITabBarItem * tabBarItem = [UITabBarItem new];
  400. tabBarItem.title = titleArr[i];
  401. tabBarItem.selectedImage = [[UIImage imageNamed:imageHArr[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  402. tabBarItem.image = [[UIImage imageNamed:imageNArr[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  403. UIViewController *curVC = viewControllers[i];
  404. curVC.tabBarItem = tabBarItem;
  405. }
  406. // tabBarController.tabBar.barTintColor = [UIColor hwColor:@"#F6F8FA"]; // 设置标签栏背景色
  407. // tabBarController.tabBar.tintColor = [UIColor hwColor:@"#01B7EA"]; // 设置选中标签项的颜色
  408. tabBarController.tabBar.backgroundColor = [UIColor whiteColor];
  409. [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor hwColor:@"#F6F8FA"],NSForegroundColorAttributeName, [UIFont systemFontOfSize:12.0],NSFontAttributeName,nil] forState:UIControlStateNormal];
  410. [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor hwColor:@"#01B7EA"],NSForegroundColorAttributeName, [UIFont systemFontOfSize:12.0],NSFontAttributeName,nil] forState:UIControlStateSelected];
  411. ksharedAppDelegate.mainTabBar = tabBarController;
  412. self.window.rootViewController = tabBarController;
  413. [self.window makeKeyAndVisible];
  414. }
  415. #pragma mark 处理进来是非隐私模式的情况
  416. - (void)HandleEnterNotPrivacyModeFun
  417. {
  418. #ifdef developJSQ
  419. NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  420. #else
  421. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  422. #endif
  423. if (maskModel != 0){
  424. [HWDataManager setIntegerWithKey:Const_Mask_View_Model value:0];
  425. [iTools lc_setAlternateIconName:@"AppIcon1"];
  426. }
  427. }
  428. - (void)setPwdOk{
  429. [self enterMainVCFromScene];
  430. // NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
  431. //
  432. // if (dataArray.count == 0) { // 浏览器没有窗口
  433. // // 加载首页
  434. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  435. // vc.webUrl = Const_HomeUrl;
  436. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  437. // self.window.rootViewController = nvc;
  438. //
  439. // }else {
  440. // // 浏览器当前窗口索引ID
  441. // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  442. // NSString *where = [NSString stringWithFormat:@"where %@=%ld",bg_sqlKey(@"ID"),(long)ID];
  443. // NSArray* finfAlls = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
  444. // BaseModel *model = finfAlls.firstObject;
  445. //
  446. // // 加载网页
  447. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  448. // vc.webUrl = model.webUrl;
  449. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  450. // self.window.rootViewController = nvc;
  451. // }
  452. }
  453. /** 登录界面 - 外部使用*/
  454. + (void)enterLoginVC {
  455. // SetPWDViewController *vc = [[SetPWDViewController alloc] init];
  456. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  457. // UIWindow *keyWindow = [iTools getKeyWindow];
  458. // keyWindow.rootViewController = nvc;
  459. }
  460. /** 主界面 - 外部使用 */
  461. + (void)enterMainVC {
  462. // AlbumHomeViewController *vc = [[AlbumHomeViewController alloc] init];
  463. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  464. // UIWindow *keyWindow = [iTools getKeyWindow];
  465. // keyWindow.rootViewController = nvc;
  466. }
  467. - (void)sceneDidDisconnect:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  468. HLog(@"sceneDidDisconnect");
  469. [[connectDeviceManager shareInstance] disconnect];
  470. }
  471. - (void)sceneDidBecomeActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  472. HLog(@"sceneDidBecomeActive")
  473. }
  474. - (void)sceneWillResignActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  475. HLog(@"sceneWillResignActive")
  476. }
  477. - (void)sceneWillEnterForeground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  478. HLog(@"sceneWillEnterForeground")
  479. }
  480. - (void)sceneDidEnterBackground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  481. HLog(@"sceneDidEnterBackground")
  482. BOOL isNeeddelayedType = NO;
  483. //这里强制竖屏 处理图片详情 和视频详情的横屏情况
  484. BaseNavigationController*mainNav = ksharedAppDelegate.mainTabBar.selectedViewController;
  485. if([mainNav isKindOfClass:[BaseNavigationController class]]){
  486. NSArray* vcArr = mainNav.viewControllers;
  487. if(vcArr.count >= 2){
  488. UIViewController *curVC = vcArr.lastObject;
  489. if([curVC isKindOfClass:[imageDetailsScrollViewController class]]
  490. ||[curVC isKindOfClass:[videoPlayByAVPlayerViewController class]]){
  491. //切换到竖屏
  492. [curVC hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
  493. ksharedAppDelegate.supportScreenRotateType = NO;
  494. isNeeddelayedType = YES;
  495. }
  496. }
  497. }
  498. if(isNeeddelayedType){
  499. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  500. [self showCalculatorVC];
  501. });
  502. }
  503. else{
  504. [self showCalculatorVC];
  505. }
  506. }
  507. - (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity {
  508. HLog(@"scene continueUserActivity")
  509. if([TencentOAuth CanHandleUniversalLink:userActivity.webpageURL]){
  510. [TencentOAuth HandleUniversalLink:userActivity.webpageURL];
  511. }
  512. else{
  513. [WXApi handleOpenUniversalLink:userActivity delegate:self];
  514. }
  515. }
  516. - (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
  517. HLog(@"scene openURLContexts")
  518. NSEnumerator *enumerator = [URLContexts objectEnumerator];
  519. UIOpenURLContext *context;
  520. while (context = [enumerator nextObject]) {
  521. NSLog(@"context.URL =====%@",context.URL);
  522. //openprivacyxapp://page?param1=value1&param2=value2
  523. NSString *curStr = context.URL.absoluteString;
  524. if([curStr rangeOfString:@"openprivacyxapp://page"].location != NSNotFound){
  525. _getShareStr = curStr;
  526. [self delayedHandlShareAwakenAppBy:curStr];
  527. break;
  528. }
  529. else{
  530. [WXApi handleOpenURL:context.URL delegate:self];
  531. }
  532. //NSLog(@"context.options.sourceApplication ===== %@",context.options.sourceApplication);
  533. }
  534. _session = nil;
  535. _connectionOptions = nil;
  536. }
  537. - (void)delayedHandlShareAwakenAppBy:(NSString*)curStr{
  538. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  539. [self shareAwakenAppBy:curStr];
  540. });
  541. }
  542. #pragma mark 初始化数据库-DB_BrowserWindows_TableName
  543. - (void)initBrowserWindow {
  544. // 浏览器当前所有窗口
  545. NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
  546. // 浏览器当前窗口索引ID
  547. NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  548. NSString *IDValue = [NSString stringWithFormat:@"%ld", ID];
  549. NSString *where = [NSString stringWithFormat:@"where %@=%@",bg_sqlKey(@"ID"),bg_sqlValue(IDValue)];
  550. NSArray *modelArr = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
  551. if (dataArray.count == 0) { // 浏览器没有窗口
  552. BaseModel *model = [[BaseModel alloc] init];
  553. model.ID = 0;
  554. model.name = @"主页";
  555. // model.iconFile = imageUrl;
  556. model.webUrl = Const_HomeUrl;
  557. // 写入数据库
  558. model.bg_tableName = DB_BrowserWindows_TableName;
  559. [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
  560. HLog(@"BaseModel写入:%@", isSuccess ? @"成功":@"失败");
  561. }];
  562. // 浏览器当前窗口索引ID
  563. [HWDataManager setIntegerWithKey:BrowserWindowsCurrentID value:0];
  564. }else if (modelArr.count == 0) { // 新建窗口
  565. BaseModel *model = [[BaseModel alloc] init];
  566. model.ID = ID;
  567. model.name = @"主页";
  568. // model.iconFile = imageUrl;
  569. model.webUrl = Const_HomeUrl;
  570. // 写入数据库
  571. model.bg_tableName = DB_BrowserWindows_TableName;
  572. [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
  573. HLog(@"BaseModel写入:%@", isSuccess ? @"成功":@"失败");
  574. }];
  575. }else { // 更新窗口数据
  576. // 浏览器当前窗口索引ID
  577. // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  578. //
  579. // BaseModel *model = [[BaseModel alloc] init];
  580. // model.ID = ID;
  581. // model.name = @"主页";
  582. //// model.iconFile = imageUrl;
  583. // model.webUrl = Const_HomeUrl;
  584. //
  585. // // 更新数据库
  586. // model.bg_tableName = DB_BrowserWindows_TableName;
  587. // [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
  588. // HLog(@"BaseModel更新: %@", isSuccess ? @"成功":@"失败");
  589. // }];
  590. }
  591. }
  592. #pragma mark 获取当前屏幕的截图
  593. //- (UIImage *)getScreenShotImage {
  594. // CGSize size = [UIScreen mainScreen].bounds.size;
  595. // CGFloat scale = [UIScreen mainScreen].scale;
  596. // UIGraphicsBeginImageContextWithOptions(size, YES, scale);
  597. // [self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
  598. // UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
  599. // UIGraphicsEndImageContext();
  600. // return image;
  601. //}
  602. #pragma mark 计算器伪装视图
  603. /*CalculatorViewController*/
  604. - (void)showCalculatorVC{
  605. if(ksharedAppDelegate.getSystemPermissType){
  606. HLog(@"检测到获取系统全进入后台");
  607. return;
  608. }
  609. BOOL haveGuide = [HWDataManager getBoolWithKey:Const_Have_Show_Guide];
  610. if (haveGuide) {
  611. ;
  612. }else {
  613. return;
  614. }
  615. BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
  616. if(!isPrivacyMode){
  617. return;
  618. }
  619. //修复扫描已经有密码的合作 点击跳过因为网络弹框再次覆盖一次密码(需要输入两次密码)
  620. BaseNavigationController*curTopNav = (BaseNavigationController*)[iTools appRootViewController];
  621. if([curTopNav isKindOfClass:[BaseNavigationController class]]){
  622. NSArray *vcArr = [curTopNav viewControllers];
  623. if(vcArr && vcArr.count >0){
  624. UIViewController *lastVC = vcArr.lastObject;
  625. if([lastVC isKindOfClass:[inputPWDViewController class]]){
  626. return;
  627. }
  628. }
  629. }
  630. /*无有效时长直接返回不加载任何加密界面*/
  631. NSString *PwdStr = nil;
  632. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  633. //实时拿到的密码 (每次打开或者更换设备 通过SN重新拿)
  634. if([connectDeviceManager shareInstance].DeviceThirdIdMod.data.password){
  635. NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
  636. NSString*desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
  637. if(desPwdStr){
  638. PwdStr = desPwdStr;
  639. }
  640. }
  641. else{
  642. //本地密码本地判断 密码改在服务器保持
  643. if ([[deviceDict allKeys] containsObject:Const_Have_Add_Device_PWD]){
  644. PwdStr = [deviceDict objectForKey:Const_Have_Add_Device_PWD];
  645. }
  646. }
  647. if (!PwdStr || [PwdStr isEqualToString:@""])
  648. {
  649. return;
  650. }
  651. // BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
  652. // if (!haveOpenMask){
  653. // //输入密码界面
  654. // [self closeCalculatorVC];
  655. // _inputVC = [[inputPWDViewController alloc] init];
  656. // [self.window addSubview:_inputVC.view];
  657. // return;
  658. // }
  659. BOOL haveVaildTime = [HWDataManager getBoolWithKey:Const_Have_No_VaildTime];
  660. if (haveVaildTime == YES){/*无有效时间*/
  661. return;
  662. }
  663. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus != AFNetworkReachabilityStatusNotReachable)
  664. {
  665. if(![connectDeviceManager shareInstance].DeviceThirdIdMod){
  666. return;
  667. }
  668. BOOL isPrivacyMode = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  669. if(!isPrivacyMode)
  670. {
  671. [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
  672. [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
  673. return;
  674. }
  675. }
  676. #ifdef developJSQ
  677. NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  678. #else
  679. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  680. #endif
  681. if (maskModel == 0){
  682. //输入密码界面
  683. [self closeCalculatorVC];
  684. _inputVC = [[inputPWDViewController alloc] init];
  685. [self.window addSubview:_inputVC.view];
  686. _isDidShowPwdType = YES;
  687. }
  688. else if (maskModel == 2){
  689. /*浏览器*/
  690. [self closeCalculatorVC];
  691. _webVC = [[HWWebViewController alloc] init];
  692. _webVC.pwd = PwdStr;
  693. _webVC.webUrl = @"https://baidu.com";
  694. [self.window addSubview:_webVC.view];
  695. _isDidShowPwdType = YES;
  696. }else{
  697. /*计算器*/
  698. [self closeCalculatorVC];
  699. _calculatorVC = [[CalculatorViewController alloc] init];
  700. _calculatorVC.pwd = PwdStr;
  701. [self.window addSubview:_calculatorVC.view];
  702. _isDidShowPwdType = YES;
  703. }
  704. [[NSNotificationCenter defaultCenter] postNotificationName:ShowPwdVCNotification object:nil];
  705. }
  706. - (void)closeCalculatorVC{
  707. ksharedAppDelegate.getSystemPermissType = NO;
  708. if (_calculatorVC){
  709. [_calculatorVC.view removeFromSuperview];
  710. }
  711. /*浏览器*/
  712. if (_webVC){
  713. [_webVC.view removeFromSuperview];
  714. }
  715. if(_inputVC){
  716. [_inputVC.view removeFromSuperview];
  717. }
  718. _isDidShowPwdType = NO;
  719. if(self->_session && self->_connectionOptions){
  720. [self scene:self->_session openURLContexts:self->_connectionOptions.URLContexts];
  721. }
  722. }
  723. - (NSString *)documentPathForAccount:(NSString *)account fileFolder:(NSString *)fileFolder {
  724. NSString *path = DocumentPath;
  725. if (account.length != 0) {
  726. path = [NSString stringWithFormat:@"%@/%@/",DocumentPath,account];
  727. }
  728. if ([fileFolder containsString:@"/"]) {
  729. NSString *path1 = [path stringByAppendingPathComponent:fileFolder];
  730. path1 = [path1 stringByDeletingLastPathComponent];
  731. NSError *error;
  732. if (![[NSFileManager defaultManager] fileExistsAtPath:path1]) {
  733. [[NSFileManager defaultManager] createDirectoryAtPath:path1 withIntermediateDirectories:YES attributes:nil error:&error];
  734. }
  735. }else{
  736. NSError *error;
  737. if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
  738. [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
  739. }
  740. }
  741. return [path stringByAppendingPathComponent:fileFolder];
  742. }
  743. - (void)startUseBtnBePressed{
  744. [self enterMainVCFromScene];
  745. // NSString *launchAppPWDPath = [self documentPathForAccount:@"" fileFolder:@"LaunchPWD"];
  746. // NSString *str = [[NSString alloc] initWithContentsOfFile:launchAppPWDPath encoding:(NSUTF8StringEncoding) error:nil];
  747. // if (!str || [str isEqualToString:@"0"])
  748. // {
  749. // SetUsePWDViewController *loginVC = [[SetUsePWDViewController alloc] init];
  750. // loginVC.delegate = self;
  751. // self.window.rootViewController = loginVC;
  752. //
  753. // return;
  754. // }
  755. //
  756. // NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
  757. //
  758. // if (dataArray.count == 0) { // 浏览器没有窗口
  759. // // 加载首页
  760. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  761. // vc.webUrl = Const_HomeUrl;
  762. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  763. // self.window.rootViewController = nvc;
  764. //
  765. // }else {
  766. // // 浏览器当前窗口索引ID
  767. // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  768. // NSString *where = [NSString stringWithFormat:@"where %@=%ld",bg_sqlKey(@"ID"),(long)ID];
  769. // NSArray* finfAlls = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
  770. // BaseModel *model = finfAlls.firstObject;
  771. //
  772. // // 加载网页
  773. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  774. // vc.webUrl = model.webUrl;
  775. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  776. // self.window.rootViewController = nvc;
  777. // }
  778. }
  779. - (void)loginOk{
  780. [self enterMainVCFromScene];
  781. }
  782. - (void)guideOk:(NSNotification*)not{
  783. NSString *object = not.object;
  784. if(object && [object isEqualToString:@"isLoginAgainType"]){
  785. self.isLoginAgainType = YES;
  786. }
  787. [self enterMainVCFromScene];
  788. //clear下载和上传的已经获取的数据
  789. [[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  790. [uploadFileManager shareInstance].databaseArr = [NSMutableArray new];
  791. [uploadFileManager shareInstance].fileModelDataArr = [NSMutableArray new];
  792. [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateWait;
  793. [[downloadManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  794. [downloadManager shareInstance].databaseArr = [NSMutableArray new];
  795. [downloadManager shareInstance].downLoadFileModelDataArr = [NSMutableArray new];
  796. [[backupsFileManager shareInstance] suspendBackupsFileFun];
  797. //frp的下载
  798. [[customDownloadManager shareManager] suspendAllDownloadTask];
  799. NSString *uid =[connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
  800. if(uid){
  801. }
  802. else{
  803. uid = @"";
  804. }
  805. [customDownloadManager shareManager].uid = uid;
  806. //盒子1音频在播放音乐,切换盒子2成功,仍在播放中
  807. [[DFPlayer sharedPlayer] df_deallocPlayer];
  808. [lastFileManager shareManager].uid = uid;
  809. [audioPlayListManager shareManager].uid = uid;
  810. }
  811. #pragma mark 上报版本号信息
  812. -(void)reportVersionInfoFun
  813. {
  814. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  815. NSString *vers = [iPhone appVersion];
  816. if(vers){
  817. [paraDict setValue:vers forKey:@"iosClientVersionNumber"];
  818. }
  819. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  820. if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
  821. NSString*snStr = deviceDict[Const_Have_Add_Device_SN];
  822. if(snStr){
  823. [paraDict setValue:snStr forKey:@"sn"];
  824. }
  825. else{
  826. return;
  827. }
  828. }
  829. else{
  830. return;;
  831. }
  832. // KWeakSelf
  833. [[netWorkManager shareInstance] CommonPostCallBackCode:reportVersionInfo Parameters:paraDict success:^(id _Nonnull responseObject) {
  834. } failure:^(NSError * _Nonnull error) {
  835. }];
  836. }
  837. #pragma mark 获取NAS相关信息
  838. -(void)getNASMsgFun
  839. {
  840. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  841. NSString *SNStr = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.changeSn;
  842. if(SNStr){
  843. [paraDict setValue:SNStr forKey:@"sn"];
  844. }
  845. else{
  846. return;;
  847. }
  848. KWeakSelf
  849. [[netWorkManager shareInstance] CommonGetWithCallBackCode:getIpFun Parameters:paraDict success:^(id _Nonnull responseObject){
  850. NASMsgModel *model = [[NASMsgModel alloc] initWithDictionary:responseObject error:nil];
  851. if(model){
  852. ksharedAppDelegate.NASMsgMod = model;
  853. }
  854. } failure:^(NSError * _Nonnull error) {
  855. }];
  856. }
  857. #pragma mark 主动上锁
  858. - (void)showLockViewFun:(NSNotification*)not
  859. {
  860. [self showCalculatorVC];
  861. }
  862. #pragma mark 进入设置密码
  863. //- (void)setPwdVCFun:(NSNotification*)not
  864. //{
  865. // _isNeedToShowSecretKey = YES;
  866. //}
  867. #pragma mark 忘记密码
  868. - (void)forgetPwdFun:(NSNotification*)not
  869. {
  870. /*忘记密码*/
  871. forgetPwdViewController *forgetPwdVC = [[forgetPwdViewController alloc] init];
  872. BaseNavigationController *forgetPwdVCNav = [[BaseNavigationController alloc] initWithRootViewController:forgetPwdVC];
  873. self.window.rootViewController = forgetPwdVCNav;
  874. }
  875. #pragma mark 忘记密码返回
  876. - (void)forgetPwdBackFun:(NSNotification*)not
  877. {
  878. // if(_preRootPlayerNav)
  879. // {
  880. // self.window.rootViewController = _preRootPlayerNav;
  881. // }
  882. // else{
  883. [self enterMainVCFromScene];
  884. //}
  885. [self showCalculatorVC];
  886. }
  887. #pragma mark 忘记密码设置密码完成
  888. - (void)forgetPwdDidSetPwdFun:(NSNotification*)not
  889. {
  890. // if(_preRootPlayerNav)
  891. // {
  892. // NSArray *vcArr = _preRootPlayerNav.viewControllers;
  893. // if(vcArr.count > 2){
  894. // [_preRootPlayerNav popToViewController:vcArr[1] animated:NO];
  895. // }
  896. // self.window.rootViewController = _preRootPlayerNav;
  897. // }
  898. // else{
  899. [self enterMainVCFromScene];
  900. //}
  901. [self closeCalculatorVC];
  902. _curPlayerVC.isPwdVCShow = NO;
  903. [_curPlayerVC setShowImgAndVoiceTypeFun:YES];
  904. [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
  905. }
  906. #pragma mark 扫码切换设备 scanChangeDeviceNotification
  907. - (void)scanChangeDeviceFun:(NSNotification*)not
  908. {
  909. //TipsQRCodeForChangeDeviceViewController *nextVC = [[TipsQRCodeForChangeDeviceViewController alloc] init];
  910. QRCodeScanForChangeDeviceViewController *nextVC = [[QRCodeScanForChangeDeviceViewController alloc] init];
  911. nextVC.isRootVCType = YES;
  912. BaseNavigationController *nextNav = [[BaseNavigationController alloc] initWithRootViewController:nextVC];
  913. self.window.rootViewController = nextNav;
  914. }
  915. #pragma mark 扫码切换设备点击返回
  916. - (void)scanChangeDeviceBackFun:(NSNotification*)not
  917. {
  918. // if(_preRootPlayerNav)
  919. // {
  920. // self.window.rootViewController = _preRootPlayerNav;
  921. // }
  922. // else{
  923. [self enterMainVCFromScene];
  924. //}
  925. [self showCalculatorVC];
  926. }
  927. #pragma mark 网络异常弹框
  928. -(void)showNetErrorAlertFun
  929. {
  930. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  931. if(maskModel !=0 && _isDidShowPwdType){
  932. return;
  933. }
  934. NSString *linkErrTip = NSLocalizedString(@"player_link_fail_tip_type9",nil);
  935. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable){
  936. linkErrTip = NSLocalizedString(@"player_link_fail_phone_Tips",nil);
  937. _isNeedToStopWork = YES;
  938. [self showNetErrorAlertType2Fun];
  939. return;
  940. }
  941. linkErrTip = [[NSString alloc] initWithFormat:@"[9]%@",linkErrTip];
  942. ComontAlretViewController *linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:nil
  943. msg:linkErrTip
  944. imageStr:nil
  945. cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
  946. okTitle:NSLocalizedString(@"player_link_fail_tryAgain",nil) isOkBtnHighlight:YES
  947. didClickOk:^{
  948. //[self enterMainVCFromScene];
  949. } didClickCancel:^{
  950. exit(0);
  951. }];
  952. linkFailAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  953. [self.window.rootViewController presentViewController:linkFailAlretVC animated:YES completion:^{
  954. linkFailAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  955. }];
  956. }
  957. #pragma mark 网络异常弹框
  958. -(void)showNetErrorAlertType2Fun
  959. {
  960. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable){
  961. NSString * linkErrTip = NSLocalizedString(@"netWork_error_tip_content",nil);
  962. ComontAlretViewController *linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"netWork_error_tip_title",nil)
  963. msg:linkErrTip
  964. imageStr:nil
  965. cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
  966. okTitle:nil isOkBtnHighlight:NO
  967. didClickOk:^{
  968. //[self enterMainVCFromScene];
  969. } didClickCancel:^{
  970. exit(0);
  971. }];
  972. linkFailAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  973. self.window.rootViewController = [UIViewController new];
  974. [self.window.rootViewController presentViewController:linkFailAlretVC animated:YES completion:^{
  975. linkFailAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  976. }];
  977. }
  978. }
  979. - (void)gotoScanAginByThridMsgErrorFun:(NSInteger)errorCode
  980. {
  981. /*扫码界面*/
  982. TipsQRCodeViewController *qrCodeVC = [[TipsQRCodeViewController alloc] init];
  983. qrCodeVC.isNeedToShowAleatType = YES;
  984. qrCodeVC.getSNMsgcode = errorCode;
  985. BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
  986. self.window.rootViewController = qrCodeVCNav;
  987. }
  988. #pragma mark 分享页面唤醒APP
  989. - (void)shareAwakenAppBy:(NSString*)shareStr
  990. {
  991. //[[iToast makeText:shareStr] show];
  992. NSArray * paraArr = [shareStr componentsSeparatedByString:@"&"];
  993. if(!paraArr || paraArr.count==0){
  994. return;
  995. }
  996. //type=save和download
  997. NSString *type = nil;
  998. NSString *fileIds = nil;
  999. NSString *extractionCode = nil;
  1000. NSString *token = nil;
  1001. for (NSString*objectStr in paraArr) {
  1002. if([objectStr rangeOfString:@"type"].location != NSNotFound){
  1003. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1004. if(objectArr.count == 2){
  1005. type = objectArr.lastObject;
  1006. continue;
  1007. }
  1008. }
  1009. else if([objectStr rangeOfString:@"fileIds"].location != NSNotFound){
  1010. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1011. if(objectArr.count == 2){
  1012. fileIds = objectArr.lastObject;
  1013. continue;
  1014. }
  1015. }
  1016. else if([objectStr rangeOfString:@"extractionCode"].location != NSNotFound){
  1017. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1018. if(objectArr.count == 2){
  1019. extractionCode = objectArr.lastObject;
  1020. continue;
  1021. }
  1022. }
  1023. else if([objectStr rangeOfString:@"token"].location != NSNotFound){
  1024. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1025. if(objectArr.count == 2){
  1026. token = objectArr.lastObject;
  1027. continue;
  1028. }
  1029. }
  1030. }
  1031. if(!type || type.length ==0){
  1032. HLog(@"分享 type 获取错误");
  1033. return;
  1034. }
  1035. if(!fileIds || fileIds.length ==0){
  1036. HLog(@"分享 fileIds 获取错误");
  1037. return;
  1038. }
  1039. if(!token || token.length ==0){
  1040. HLog(@"分享 token 获取错误");
  1041. return;
  1042. }
  1043. [self getShareOneFileListFunByToken:token withFileIds:fileIds withExtractionCode:extractionCode withType:type];
  1044. }
  1045. #pragma mark 分享信息重新获取
  1046. - (void)getShareOneFileListFunByToken:(NSString*)token withFileIds:(NSString*)fileIds withExtractionCode:(NSString*)extractionCode withType:(NSString*)type
  1047. {
  1048. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1049. fileIds = [fileIds stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  1050. NSData *jsonData = [fileIds dataUsingEncoding:NSUTF8StringEncoding];;
  1051. NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
  1052. HLog(@"jsonArray:%@",jsonArray)
  1053. if(!jsonArray){
  1054. return;
  1055. }
  1056. [paraDict setValue:token forKey:@"token"];
  1057. [paraDict setValue:jsonArray forKey:@"fileIdList"];
  1058. [paraDict setValue:extractionCode forKey:@"extractionCode"];
  1059. KWeakSelf
  1060. [[netWorkManager shareInstance] CommonPostCallBackCode:queryOneShareInfoFun Parameters:paraDict success:^(id _Nonnull responseObject) {
  1061. queryOneShareModel*model = [[queryOneShareModel alloc] initWithDictionary:responseObject error:nil];
  1062. if(model && model.status == 0){
  1063. weakSelf.getShareStr = nil;
  1064. [weakSelf gotoVCByModel:model withType:type];
  1065. }
  1066. else{
  1067. }
  1068. } failure:^(NSError * _Nonnull error) {
  1069. }];
  1070. }
  1071. #pragma mark 跳转
  1072. - (void)gotoVCByModel:(queryOneShareModel*)model withType:(NSString*)type
  1073. {
  1074. if([type isEqualToString:@"save"]){
  1075. [self saveFileToBoxFunBy:model];
  1076. //数据埋点
  1077. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Share_save"];
  1078. }
  1079. else if([type isEqualToString:@"download"]){
  1080. [self downloadFileToAppFunBy:model];
  1081. //数据埋点
  1082. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Share_download"];
  1083. }
  1084. }
  1085. #pragma mark 保存文件到盒子
  1086. - (void)saveFileToBoxFunBy:(queryOneShareModel*)sharemodel
  1087. {
  1088. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1089. NSMutableArray *pathArr = [NSMutableArray new];
  1090. for (ShareFileDataModel*dataModel in sharemodel.data.fileListVOS){
  1091. [pathArr addObject:dataModel.fileUrl];
  1092. }
  1093. if (pathArr) {
  1094. NSString *jsonStr = [iTools toJsonStrWithArray:pathArr];
  1095. if(jsonStr){
  1096. [paraDict setValue:jsonStr forKey:@"urls"];
  1097. }
  1098. }
  1099. NSString * boxSaveDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_box_save_default_path)];
  1100. if(!boxSaveDefaultPath || boxSaveDefaultPath.length == 0){
  1101. boxSaveDefaultPath = Const_default_save_path;
  1102. [HWDataManager setStringWithKey:stringKeyAddSn(Const_box_save_default_path) value:boxSaveDefaultPath];
  1103. }
  1104. [paraDict setValue:boxSaveDefaultPath forKey:@"savePath"];
  1105. KWeakSelf
  1106. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"downFiles" Parameters:paraDict success:^(id _Nonnull responseObject) {
  1107. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1108. if(model && model.status == 0){
  1109. [weakSelf gotoUploadFileRecordVCFunByType:2 withModel:sharemodel];
  1110. }
  1111. } failure:^(NSError * _Nonnull error) {
  1112. }];
  1113. }
  1114. #pragma mark 下载文件到手机
  1115. - (void)downloadFileToAppFunBy:(queryOneShareModel*)sharemodel
  1116. {
  1117. [self gotoUploadFileRecordVCFunByType:1 withModel:sharemodel];
  1118. }
  1119. #pragma mark 跳转传输列表
  1120. - (void)gotoUploadFileRecordVCFunByType:(NSInteger)type withModel:(queryOneShareModel*)sharemodel
  1121. {
  1122. KWeakSelf
  1123. if(type == 2){
  1124. [[boxSaveFileManager shareInstance] addBoxSaveRecordFunBy:sharemodel.data.fileListVOS complete:^(BOOL isSuccess) {
  1125. if(isSuccess){
  1126. mainBlock(^{
  1127. [weakSelf gotoUploadFileRecordVCFunByType:type];
  1128. });
  1129. }
  1130. }];
  1131. }
  1132. else if (type == 1){
  1133. if(![iTools checkFreeDiskSpaceInBytesIsOK:500*1024*1024]){
  1134. mainBlock(^{
  1135. [[iToast makeText:NSLocalizedString(@"phone_space_Insufficient",nil)] show];
  1136. });
  1137. return;
  1138. }
  1139. [[boxDownloadFileManager shareInstance] addBoxDownloadRecordFunBy:sharemodel.data.fileListVOS complete:^(BOOL isSuccess) {
  1140. if(isSuccess){
  1141. mainBlock(^{
  1142. [weakSelf gotoUploadFileRecordVCFunByType:type];
  1143. });
  1144. }
  1145. }];
  1146. }
  1147. }
  1148. - (void)gotoUploadFileRecordVCFunByType:(NSInteger)type
  1149. {
  1150. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1151. vc.isReceiveType = type;
  1152. BaseNavigationController*mainNav = ksharedAppDelegate.mainTabBar.selectedViewController;
  1153. if([mainNav isKindOfClass:[BaseNavigationController class]]){
  1154. [mainNav pushViewController:vc animated:YES];
  1155. [[UIApplication sharedApplication] setStatusBarHidden:NO];
  1156. }
  1157. }
  1158. #pragma mark UITabBarControllerDelegate
  1159. - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
  1160. {
  1161. NSInteger index = tabBarController.selectedIndex;
  1162. //HLog(@"hxd %ld",index);
  1163. int eventType = 1;
  1164. NSString* eventValue = @"Nas";
  1165. if(index == 0){
  1166. eventValue = @"Nas";
  1167. }
  1168. else if(index == 1){
  1169. eventValue = @"Cloud";
  1170. }
  1171. else if(index == 2){
  1172. eventValue = @"Home";
  1173. }
  1174. //数据埋点
  1175. [[netWorkManager shareInstance] DataEmbeddingPointBy:eventType withEventValue:eventValue];
  1176. }
  1177. @end