SceneDelegate.m 41 KB

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