SceneDelegate.m 50 KB

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