SceneDelegate.m 43 KB

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