SceneDelegate.m 40 KB

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