SceneDelegate.m 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172
  1. //
  2. // SceneDelegate.m
  3. // Private-X
  4. //
  5. // Created by 余衡武 on 2021/12/8.
  6. //
  7. #import "SceneDelegate.h"
  8. #import "HWWebViewController.h"
  9. #import "CalculatorViewController.h"
  10. #import "SetUsePWDViewController.h"
  11. #import "GuideViewController.h"
  12. #import "BaseNavigationController.h"
  13. #import "MySetViewController.h"
  14. #import "SafeForKey.h"
  15. #import "TipsQRCodeViewController.h"
  16. #import "SetPWDFirstViewController.h"
  17. #import "connectDeviceManager.h"
  18. #import "inputPWDViewController.h"
  19. #import "customLaunchView.h"
  20. #import "RSATool.h"
  21. #import "forgetPwdViewController.h"
  22. #import "TipsQRCodeForChangeDeviceViewController.h"
  23. #import "AFNetworkReachabilityManager.h"
  24. #import "ComontAlretViewController.h"
  25. #import "uploadFileManager.h"
  26. //#import "downloadManager.h"
  27. #import "nasDownloadFileManager.h"
  28. //#import "backupsFileManager.h"
  29. #import "nasBackupsManager.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 "NASViewController.h"
  39. #import "cloudPhoneViewController.h"
  40. #import "mineViewController.h"
  41. #import "lastFileManager.h"
  42. #import "customDownloadManager.h"
  43. #import "audioPlayListManager.h"
  44. #import "QRCodeScanForChangeDeviceViewController.h"
  45. #import "customToastVew.h"
  46. #import "DFPlayer.h"
  47. #import "UIInterface+HXRotation.h"
  48. #import "imageDetailsScrollViewController.h"
  49. #import "videoPlayByAVPlayerViewController.h"
  50. #import "pingManager.h"
  51. #import "webRtcPlayerViewController.h"
  52. #import "webRtcPingManager.h"
  53. #import "imageVersionRenewTipView.h"
  54. #import "HWVersionModel.h"
  55. #import "HaveNewVersionView.h"
  56. #import "newerGuideView.h"
  57. #import "CustomerWebViewController.h"
  58. #import "noticeModel.h"
  59. #import "HaveNoticeView.h"
  60. #import "UpgradeInfoModel.h"
  61. #import "imageVersionUpdateDoneView.h"
  62. #import "imageVersionUpdateFailView.h"
  63. #import "LoginType1ViewController.h"
  64. #import "privacyModeTipViewController.h"
  65. #import "previewFileAndFolderViewController.h"
  66. @interface SceneDelegate ()<SetUsePWDViewControllerDelegate,GuideViewControllerDelegate,UITabBarControllerDelegate>
  67. {
  68. imageVersionRenewTipView * RenewTipView;
  69. imageVersionUpdateDoneView* imageVersionUpdateDoneV;
  70. imageVersionUpdateFailView* imageVersionUpdateFailV;
  71. }
  72. @property (nonatomic,strong)UpgradeInfoModel*otaUpgradeInfoModel;
  73. @property(nonatomic, strong) CalculatorViewController *calculatorVC;
  74. @property(nonatomic, strong) HWWebViewController *webVC;
  75. @property(nonatomic, strong) inputPWDViewController *inputVC;
  76. @property(nonatomic, strong) customLaunchView *customLaunchV;//
  77. @property(nonatomic, strong) BaseNavigationController *preRootPlayerNav;
  78. @property(nonatomic, assign) bool isQRCodeType;//第一次 扫码进来的
  79. //@property(nonatomic, assign) bool isNeedToShowSecretKey;//扫码进来的SN 没有密码 则需要显示秘钥
  80. @property (nonatomic, assign) BOOL isLoginAgainType;// 单点登录 点重新登录进来的
  81. @property (nonatomic, assign) BOOL isNeedToStopWork;// 无网络报错
  82. @property(nonatomic, copy) NSString *getShareStr;//拿到分享的字符串
  83. @property (nonatomic, assign) BOOL isFirstOpenInLaunch;//启动页停两秒
  84. //冷启动分享跳入用
  85. @property(nonatomic, strong) UISceneSession *session;
  86. @property(nonatomic, strong) UISceneConnectionOptions *connectionOptions;
  87. @end
  88. @implementation SceneDelegate
  89. - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions API_AVAILABLE(ios(13.0)){
  90. HLog(@"willConnectToSession")
  91. if (scene) {
  92. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(guideOk:) name:GuideOkNotification object:nil];
  93. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showLockViewFun:) name:lockBypwdNotification object:nil];
  94. //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setPwdVCFun:) name:setPwdNotification object:nil];
  95. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdFun:) name:forgetPwdNotification object:nil];
  96. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdBackFun:) name:forgetPwdBackNotification object:nil];
  97. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdDidSetPwdFun:) name:forgetPwdDidSetNotification object:nil];
  98. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scanChangeDeviceFun:) name:scanChangeDeviceNotification object:nil];
  99. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scanChangeDeviceBackFun:) name:scanChangeDeviceBackNotification object:nil];
  100. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(firstDidLinkBoxFun) name:@"firstDidLinkBox" object:nil];
  101. UIWindowScene *windowScene = (UIWindowScene *)scene;
  102. self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
  103. self.window.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
  104. _isFirstOpenInLaunch = YES;
  105. // 初始化数据库
  106. [self initBrowserWindow];
  107. //查询当前的最近webrtc机房
  108. NSDictionary *dict = [HWDataManager getObjectWithKey:@"Const_best_webRtc_IPRoom"];
  109. if(dict){
  110. webrtcServerModel *model = [[webrtcServerModel alloc] initWithDictionary:dict error:nil];
  111. if(model && model.turnIp){
  112. ksharedAppDelegate.bestWebrtcServerModel = model;
  113. }
  114. }
  115. // 加载主页面
  116. [self enterMainVCFromScene];
  117. //
  118. [self reportVersionInfoFun];
  119. [self.window makeKeyAndVisible];
  120. ksharedAppDelegate.window = self.window;
  121. //冷启动
  122. if(connectionOptions.URLContexts != nil){
  123. _session = session;
  124. _connectionOptions = connectionOptions;
  125. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  126. // mainBlock(^{
  127. // [self scene:scene openURLContexts:connectionOptions.URLContexts];
  128. // });
  129. // });
  130. }
  131. }
  132. }
  133. /** 主界面 - 内部使用 */
  134. - (void)enterMainVCFromScene {
  135. // ConnectTestViewController *qrCodeVCNav = [[ConnectTestViewController alloc] init];
  136. // self.window.rootViewController = qrCodeVCNav;
  137. // return;/*临时测试*/
  138. if(_isNeedToStopWork){
  139. return;
  140. }
  141. /*先判断本地有无设备 无设备时需要先扫码添加设备*/
  142. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  143. if (!deviceDict || ![[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
  144. //默认显示最近文件
  145. [HWDataManager setBoolWithKey:Const_last_file_show value:YES];
  146. /*扫码界面*/
  147. //TipsQRCodeViewController *qrCodeVC = [[TipsQRCodeViewController alloc] init];
  148. LoginType1ViewController *qrCodeVC = [[LoginType1ViewController alloc] init];
  149. BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
  150. self.window.rootViewController = qrCodeVCNav;
  151. _isQRCodeType = YES;
  152. return;
  153. }
  154. NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
  155. // GuideViewController
  156. BOOL haveGuide = [HWDataManager getBoolWithKey:Const_Have_Show_Guide];
  157. if (haveGuide) {
  158. ;
  159. }else {
  160. GuideViewController *guiDeVC = [[GuideViewController alloc] init];
  161. guiDeVC.delegate = self;
  162. guiDeVC.sn = SNStr;
  163. self.window.rootViewController = guiDeVC;
  164. return;
  165. }
  166. //BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
  167. #ifdef developJSQ
  168. NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  169. #else
  170. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  171. #endif
  172. //添加默认启动图片
  173. if(!_customLaunchV && maskModel == 0){
  174. _customLaunchV = [[customLaunchView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  175. [self.window addSubview:_customLaunchV];
  176. }
  177. if(maskModel == 0 && _isFirstOpenInLaunch){
  178. //20240612 产品觉得 启动页太快了 要停两秒
  179. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  180. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  181. {
  182. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  183. customToastVew *toastview = [customToastVew makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)];
  184. [toastview show];
  185. [self->_customLaunchV addSubview:toastview];
  186. return;
  187. }
  188. [self getDeviceMsgInMainVCWith:deviceDict];
  189. });
  190. _isFirstOpenInLaunch = NO;
  191. }
  192. else{
  193. //延时等网络状态
  194. if(_isFirstOpenInLaunch){
  195. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  196. [self getDeviceMsgInMainVCWith:deviceDict];
  197. });
  198. _isFirstOpenInLaunch = NO;
  199. }
  200. else{
  201. [self getDeviceMsgInMainVCWith:deviceDict];
  202. }
  203. }
  204. //[self showNetErrorAlertType2Fun];
  205. }
  206. - (void)getDeviceMsgInMainVCWith:(NSDictionary*)deviceDict
  207. {
  208. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  209. {
  210. BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
  211. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  212. if(!isPrivacyMode && maskModel == 0){
  213. return;
  214. }
  215. [self initMainTabbarFun];
  216. [self showCalculatorVC];
  217. return;
  218. }
  219. KWeakSelf
  220. //有设备了先去做链接准备 // 80bec9c5
  221. NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
  222. NSString *sdnId = ksharedAppDelegate.DeviceThirdIdMod.data.sdnId;
  223. if(SNStr && !sdnId){
  224. //瑞云方案
  225. // [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr needReconnect:YES didNetEnd:^(NSInteger didSuc) {
  226. //
  227. // if(didSuc == 0){
  228. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  229. // mainBlock(^{
  230. // [weakSelf showNetErrorAlertFun];
  231. // [weakSelf enterMainVCFromSceneSecondStepFun];
  232. // });
  233. // });
  234. // }
  235. // else if(didSuc == 2
  236. // ||didSuc == 201
  237. // ||didSuc == 202){
  238. // [weakSelf gotoScanAginByThridMsgErrorFun:didSuc];
  239. // }
  240. // else{
  241. // [weakSelf enterMainVCFromSceneSecondStepFun];
  242. // }
  243. //
  244. // }];
  245. //webrtc方案
  246. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  247. [paraDict setValue:SNStr forKey:@"sn"];
  248. KWeakSelf
  249. [[netWorkManager shareInstance] CommonGetWithCallBackCode:getThirdIdBySn Parameters:paraDict success:^(id _Nonnull responseObject) {
  250. DeviceThirdIdModel *model = [[DeviceThirdIdModel alloc] initWithDictionary:responseObject error:nil];
  251. if(model.status == 0
  252. && model.data)
  253. {//根据SN 获取到正确的信息
  254. ksharedAppDelegate.DeviceThirdIdMod = model;
  255. NSString*desPwdstr = [RSATool AES128Decrypt:model.data.password key:AESCODEKEEYY];
  256. /*密码保持在本地*/
  257. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  258. NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:deviceDict];
  259. [dict setObject:desPwdstr forKey:Const_Have_Add_Device_PWD];
  260. NSString *sdnid = model.data.sdnId;
  261. if(sdnid){
  262. [dict setObject:sdnid forKey:Const_Have_Add_Device_sdnid];
  263. }
  264. [HWDataManager setObjectWithKey:Const_Have_Add_Device_Privacy_Mode value:[NSNumber numberWithBool:model.data.isPrivacyMode]];
  265. [HWDataManager setObjectWithKey:Const_Have_Add_Device value:dict];
  266. [weakSelf enterMainVCFromSceneSecondStepFun];;
  267. //ping看上是否为内网情况
  268. [[pingManager shareManager] startPingDeviceIpFun];
  269. //获取webrtc相关信息
  270. [weakSelf queryWebRtcMsgFun];
  271. }
  272. else{
  273. //if(model.status == 201||model.status == 202 || model.status ==2){}
  274. [weakSelf gotoScanAginByThridMsgErrorFun:model.status];
  275. }
  276. } failure:^(NSError * _Nonnull error) {
  277. HLog("网络报错");
  278. mainBlock(^{
  279. [weakSelf showNetErrorAlertFun];
  280. [weakSelf enterMainVCFromSceneSecondStepFun];
  281. });
  282. }];
  283. }
  284. else{
  285. //ping看上是否为内网情况
  286. [[pingManager shareManager] startPingDeviceIpFun];
  287. if (!ksharedAppDelegate.DeviceWebRtcMsgMod) {
  288. //获取webrtc相关信息
  289. [weakSelf queryWebRtcMsgFun];
  290. }
  291. [self enterMainVCFromSceneSecondStepFun];
  292. }
  293. }
  294. #pragma mark 获取webrct 的链接信息
  295. -(void)queryWebRtcMsgFun
  296. {
  297. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  298. KWeakSelf
  299. [[netWorkManager shareInstance] CommonPostCallBackCode:webrctQueryByClient Parameters:paraDict success:^(id _Nonnull responseObject){
  300. webRtcMsgModel *curModel = [[webRtcMsgModel alloc] initWithDictionary:responseObject error:nil];
  301. if(curModel && curModel.status == 0){
  302. ksharedAppDelegate.DeviceWebRtcMsgMod = curModel;
  303. if(!ksharedAppDelegate.bestWebrtcServerModel){
  304. webrtcServerModel *model = curModel.data.webrtcServerList.firstObject;
  305. ksharedAppDelegate.bestWebrtcServerModel = model;
  306. }
  307. [[webRtcManager shareManager] beginToLinkWebRtcFun];
  308. [[webRtcPingManager shareManager] startPingFun];
  309. }
  310. else
  311. {
  312. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  313. [weakSelf queryWebRtcMsgFun];
  314. });
  315. }
  316. } failure:^(NSError * _Nonnull error) {
  317. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  318. [weakSelf queryWebRtcMsgFun];
  319. });
  320. }];
  321. }
  322. - (void)enterMainVCFromSceneSecondStepFun
  323. {
  324. //确保通过SN号拿到密码了
  325. //非扫码进入 进入到这里很可能还没联网拿到设备最新信息
  326. if(!ksharedAppDelegate.DeviceThirdIdMod
  327. &&!ksharedAppDelegate.DeviceWebRtcMsgMod){
  328. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  329. mainBlock(^{
  330. [self enterMainVCFromScene];
  331. });
  332. });
  333. return;
  334. }
  335. //是否已经有密码了 有就是输入密码 没有就是设置密码
  336. NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
  337. NSString * sdnId = ksharedAppDelegate.DeviceThirdIdMod.data.sdnId;
  338. if(!sdnId && !ksharedAppDelegate.DeviceWebRtcMsgMod){
  339. HLog(@"没有拿到 --sdnId:%@ --- DeviceWebRtcMsgMod:%@",sdnId,ksharedAppDelegate.DeviceWebRtcMsgMod);
  340. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  341. mainBlock(^{
  342. [self enterMainVCFromScene];
  343. });
  344. });
  345. return;
  346. }
  347. if(_customLaunchV){
  348. [_customLaunchV removeFromSuperview];
  349. _customLaunchV = nil;
  350. }
  351. if(curPwd && curPwd.length > 0){
  352. /*设置密码*/
  353. // inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
  354. // BaseNavigationController *nextVCNav = [[BaseNavigationController alloc] initWithRootViewController:nextVC];
  355. // self.window.rootViewController = nextVCNav;
  356. }
  357. else{
  358. //1、重启、恢复出厂设备、首次设置密码 3个情况下8分钟之内不弹
  359. long seconds = [iTools getNowTimeStamp];
  360. NSNumber *secondsNum = [NSNumber numberWithLong:seconds];
  361. if(secondsNum){
  362. [HWDataManager setNumberWithKey:stringKeyAddSn(@"disenable_type2_BoxHeartbeat") value:secondsNum];
  363. }
  364. /*没有设置密码*/
  365. SetPWDFirstViewController *qrCodeVC = [[SetPWDFirstViewController alloc] init];
  366. BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
  367. self.window.rootViewController = qrCodeVCNav;
  368. return;
  369. }
  370. //下载配置先处理
  371. [boxDownloadFileManager shareInstance];
  372. [lastFileManager shareManager].uid = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
  373. [audioPlayListManager shareManager].uid = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
  374. //获取NAS相关信息
  375. [self getNASMsgFun];
  376. [self initMainTabbarFun];
  377. self.isLoginAgainType = NO;
  378. __block BOOL isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  379. //KWeakSelf
  380. if(!_isQRCodeType){
  381. if(isPrivacyMode)
  382. {
  383. [self showCalculatorVC];
  384. }
  385. else{
  386. [self HandleEnterNotPrivacyModeFun];
  387. ksharedAppDelegate.isFirstInputPwdDone = YES;
  388. //playerRootVC.isPwdVCShow = NO;
  389. //[playerRootVC setShowImgAndVoiceTypeFun:YES];
  390. //[weakSelf shareAwakenAppBy:weakSelf.getShareStr];
  391. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  392. [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
  393. });
  394. if(self->_session && self->_connectionOptions){
  395. [self scene:self->_session openURLContexts:self->_connectionOptions.URLContexts];
  396. }
  397. }
  398. //_isQRCodeType = NO;
  399. }
  400. else{
  401. if(isPrivacyMode)
  402. {
  403. [self showCalculatorVC];
  404. }
  405. else{
  406. [[webRtcManager shareManager] beginToLinkWebRtcFun];
  407. ksharedAppDelegate.isFirstInputPwdDone = YES;
  408. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  409. [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
  410. });
  411. }
  412. }
  413. _isQRCodeType = NO;
  414. //数据埋点
  415. [[netWorkManager shareInstance] DataEmbeddingPointBy:1 withEventValue:@"Nas"];
  416. }
  417. #pragma mark 1.4.1 新增tabbar
  418. - (void)initMainTabbarFun
  419. {
  420. UITabBarController *tabBarController = [[UITabBarController alloc] init];
  421. tabBarController.delegate = self;
  422. NASViewController *NASVC = [[NASViewController alloc] init];
  423. BaseNavigationController *NasNav = [[BaseNavigationController alloc] initWithRootViewController:NASVC];
  424. cloudPhoneViewController *cloudVC = [[cloudPhoneViewController alloc] init];
  425. BaseNavigationController *cloudPhoneNav = [[BaseNavigationController alloc] initWithRootViewController:cloudVC];
  426. previewFileAndFolderViewController *fileVC = [[previewFileAndFolderViewController alloc] init];
  427. BaseNavigationController *fileNav = [[BaseNavigationController alloc] initWithRootViewController:fileVC];
  428. mineViewController *mineVC = [[mineViewController alloc] init];
  429. BaseNavigationController *mineNav = [[BaseNavigationController alloc] initWithRootViewController:mineVC];
  430. NSString*phoneTitle = NSLocalizedString(@"tabbar_cloud_phone",nil);
  431. NSString*myTitle = NSLocalizedString(@"tabbar_my_title",nil);
  432. NSString*fileTitle = NSLocalizedString(@"my_set_no_file",nil);
  433. //NSArray *viewControllers = @[NasNav, cloudPhoneNav,mineNav]; // 添加更多视图控制器
  434. NSArray *viewControllers = @[NasNav,fileNav,mineNav]; // 添加更多视图控制器
  435. NSArray *titleArr = @[@"NAS",fileTitle,myTitle];
  436. NSArray *imageNArr = @[@"tabbar_nas_N", @"tabbar_file_N",@"tabbar_my_N"];
  437. NSArray *imageHArr = @[@"tabbar_nas_H", @"tabbar_file_H",@"tabbar_my_H"];
  438. //记录当前连接的SN
  439. NSString* preSN = [HWDataManager getStringWithKey:@"Const_pre_did_link_ok_sn"];
  440. NSString *curSN = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
  441. if(![curSN isEqualToString:@"0333933700223110016962"]
  442. && ![preSN isEqualToString:@"0333933700223110016962"]
  443. && preSN.length > 0){
  444. titleArr = @[@"NAS",phoneTitle,myTitle];
  445. imageNArr = @[@"tabbar_nas_N", @"my_device_NO",@"tabbar_my_N"];
  446. imageHArr = @[@"tabbar_nas_H", @"my_device_ok",@"tabbar_my_H"];
  447. viewControllers = @[NasNav,cloudPhoneNav,mineNav];
  448. }
  449. tabBarController.viewControllers = viewControllers;
  450. for (int i=0; i<viewControllers.count; i++) {
  451. UITabBarItem * tabBarItem = [UITabBarItem new];
  452. tabBarItem.title = titleArr[i];
  453. tabBarItem.selectedImage = [[UIImage imageNamed:imageHArr[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  454. tabBarItem.image = [[UIImage imageNamed:imageNArr[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  455. UIViewController *curVC = viewControllers[i];
  456. curVC.tabBarItem = tabBarItem;
  457. }
  458. //tabBarController.tabBar.barTintColor = [UIColor hwColor:@"#F6F8FA"]; // 设置标签栏背景色
  459. tabBarController.tabBar.tintColor = [UIColor hwColor:@"#01B7EA"]; // 设置选中标签项的颜色
  460. tabBarController.tabBar.unselectedItemTintColor = [UIColor hwColor:@"#7C8196"]; // 设置未选中标签项的颜色
  461. tabBarController.tabBar.backgroundColor = [UIColor whiteColor];
  462. // [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor hwColor:@"#01B7EA"],NSForegroundColorAttributeName, [UIFont systemFontOfSize:12.0],NSFontAttributeName,nil] forState:UIControlStateSelected];
  463. // //[UIColor hwColor:@"#7C8196"]
  464. // [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],NSForegroundColorAttributeName, [UIFont systemFontOfSize:12.0],NSFontAttributeName,nil] forState:UIControlStateNormal];
  465. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
  466. if(haveOpenMask){
  467. //非隐私模式 直接进入推拉流页
  468. if(ksharedAppDelegate.DeviceThirdIdMod && !ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode){
  469. ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType = YES;
  470. [cloudVC queryWebRtcMsgFun:YES];
  471. }
  472. else{
  473. ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType = YES;
  474. }
  475. tabBarController.selectedIndex = 1;
  476. }
  477. ksharedAppDelegate.mainTabBar = tabBarController;
  478. self.window.rootViewController = tabBarController;
  479. [self.window makeKeyAndVisible];
  480. CGFloat second = 1.0;
  481. //BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
  482. if(haveOpenMask){
  483. second = 3;
  484. }
  485. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(second * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  486. [self beginShowAlertFun];
  487. });
  488. }
  489. #pragma mark 第一次连接成功
  490. - (void)firstDidLinkBoxFun
  491. {
  492. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  493. if (ksharedAppDelegate.mainTabBar) {
  494. NSArray *curArr = ksharedAppDelegate.mainTabBar.viewControllers;
  495. if (curArr.count >= 3) {
  496. BaseNavigationController *Nav = curArr[1];
  497. UIViewController *curVC = Nav.viewControllers.firstObject;
  498. if (![curVC isKindOfClass:[previewFileAndFolderViewController class]]) {
  499. return;
  500. }
  501. }
  502. }
  503. //[self initMainTabbarFun];
  504. [self enterMainVCFromScene];
  505. });
  506. }
  507. #pragma mark 处理进来是非隐私模式的情况
  508. - (void)HandleEnterNotPrivacyModeFun
  509. {
  510. #ifdef developJSQ
  511. NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  512. #else
  513. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  514. #endif
  515. if (maskModel != 0){
  516. [HWDataManager setIntegerWithKey:Const_Mask_View_Model value:0];
  517. [iTools lc_setAlternateIconName:@"AppIcon1"];
  518. }
  519. }
  520. - (void)setPwdOk{
  521. [self enterMainVCFromScene];
  522. // NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
  523. //
  524. // if (dataArray.count == 0) { // 浏览器没有窗口
  525. // // 加载首页
  526. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  527. // vc.webUrl = Const_HomeUrl;
  528. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  529. // self.window.rootViewController = nvc;
  530. //
  531. // }else {
  532. // // 浏览器当前窗口索引ID
  533. // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  534. // NSString *where = [NSString stringWithFormat:@"where %@=%ld",bg_sqlKey(@"ID"),(long)ID];
  535. // NSArray* finfAlls = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
  536. // BaseModel *model = finfAlls.firstObject;
  537. //
  538. // // 加载网页
  539. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  540. // vc.webUrl = model.webUrl;
  541. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  542. // self.window.rootViewController = nvc;
  543. // }
  544. }
  545. /** 登录界面 - 外部使用*/
  546. + (void)enterLoginVC {
  547. // SetPWDViewController *vc = [[SetPWDViewController alloc] init];
  548. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  549. // UIWindow *keyWindow = [iTools getKeyWindow];
  550. // keyWindow.rootViewController = nvc;
  551. }
  552. /** 主界面 - 外部使用 */
  553. + (void)enterMainVC {
  554. // AlbumHomeViewController *vc = [[AlbumHomeViewController alloc] init];
  555. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  556. // UIWindow *keyWindow = [iTools getKeyWindow];
  557. // keyWindow.rootViewController = nvc;
  558. }
  559. - (void)sceneDidDisconnect:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  560. HLog(@"sceneDidDisconnect");
  561. //[[connectDeviceManager shareInstance] disconnect];
  562. }
  563. - (void)sceneDidBecomeActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  564. HLog(@"sceneDidBecomeActive")
  565. }
  566. - (void)sceneWillResignActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  567. HLog(@"sceneWillResignActive")
  568. }
  569. - (void)sceneWillEnterForeground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  570. HLog(@"sceneWillEnterForeground")
  571. [self beginShowAlertFun];
  572. }
  573. - (void)sceneDidEnterBackground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  574. HLog(@"sceneDidEnterBackground")
  575. ksharedAppDelegate.didShowBoxHeartbeatAlertType = NO;
  576. BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
  577. if(ksharedAppDelegate.DeviceThirdIdMod){
  578. isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  579. }
  580. if(isPrivacyMode){//隐私模式 需要弹密码框 转竖屏
  581. BOOL isNeeddelayedType = NO;
  582. //这里强制竖屏 处理图片详情 和视频详情的横屏情况
  583. BaseNavigationController*mainNav = ksharedAppDelegate.mainTabBar.selectedViewController;
  584. if([mainNav isKindOfClass:[BaseNavigationController class]]){
  585. NSArray* vcArr = mainNav.viewControllers;
  586. if(vcArr.count >= 2){
  587. UIViewController *curVC = vcArr.lastObject;
  588. if([curVC isKindOfClass:[webRtcPlayerViewController class]]){
  589. webRtcPlayerViewController* vc = (webRtcPlayerViewController*)curVC;
  590. if(vc.isLan){
  591. ksharedAppDelegate.needToPushWebRtcVCType = YES;
  592. [vc exitCloudPhoneFun];
  593. }
  594. }
  595. else if([curVC isKindOfClass:[imageDetailsScrollViewController class]]
  596. ||[curVC isKindOfClass:[videoPlayByAVPlayerViewController class]]){
  597. //切换到竖屏
  598. ksharedAppDelegate.supportScreenRotateType = YES;
  599. [curVC hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
  600. //ksharedAppDelegate.supportScreenRotateType = NO;
  601. isNeeddelayedType = YES;
  602. HLog(@"sceneDidEnterBackground 旋转屏幕为竖屏")
  603. }
  604. }
  605. }
  606. [self showCalculatorVC];
  607. }
  608. }
  609. - (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity {
  610. HLog(@"scene continueUserActivity")
  611. if([TencentOAuth CanHandleUniversalLink:userActivity.webpageURL]){
  612. [TencentOAuth HandleUniversalLink:userActivity.webpageURL];
  613. }
  614. else{
  615. [WXApi handleOpenUniversalLink:userActivity delegate:self];
  616. }
  617. }
  618. - (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
  619. HLog(@"scene openURLContexts")
  620. NSEnumerator *enumerator = [URLContexts objectEnumerator];
  621. UIOpenURLContext *context;
  622. while (context = [enumerator nextObject]) {
  623. NSLog(@"context.URL =====%@",context.URL);
  624. //openprivacyxapp://page?param1=value1&param2=value2
  625. NSString *curStr = context.URL.absoluteString;
  626. if([curStr rangeOfString:@"openprivacyxapp://page"].location != NSNotFound){
  627. _getShareStr = curStr;
  628. [self delayedHandlShareAwakenAppBy:curStr];
  629. break;
  630. }
  631. else{
  632. [WXApi handleOpenURL:context.URL delegate:self];
  633. }
  634. //NSLog(@"context.options.sourceApplication ===== %@",context.options.sourceApplication);
  635. }
  636. _session = nil;
  637. _connectionOptions = nil;
  638. }
  639. - (void)delayedHandlShareAwakenAppBy:(NSString*)curStr{
  640. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  641. [self shareAwakenAppBy:curStr];
  642. });
  643. }
  644. #pragma mark 初始化数据库-DB_BrowserWindows_TableName
  645. - (void)initBrowserWindow {
  646. // 浏览器当前所有窗口
  647. NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
  648. // 浏览器当前窗口索引ID
  649. NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  650. NSString *IDValue = [NSString stringWithFormat:@"%ld", ID];
  651. NSString *where = [NSString stringWithFormat:@"where %@=%@",bg_sqlKey(@"ID"),bg_sqlValue(IDValue)];
  652. NSArray *modelArr = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
  653. if (dataArray.count == 0) { // 浏览器没有窗口
  654. BaseModel *model = [[BaseModel alloc] init];
  655. model.ID = 0;
  656. model.name = @"主页";
  657. // model.iconFile = imageUrl;
  658. model.webUrl = Const_HomeUrl;
  659. // 写入数据库
  660. model.bg_tableName = DB_BrowserWindows_TableName;
  661. [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
  662. HLog(@"BaseModel写入:%@", isSuccess ? @"成功":@"失败");
  663. }];
  664. // 浏览器当前窗口索引ID
  665. [HWDataManager setIntegerWithKey:BrowserWindowsCurrentID value:0];
  666. }else if (modelArr.count == 0) { // 新建窗口
  667. BaseModel *model = [[BaseModel alloc] init];
  668. model.ID = ID;
  669. model.name = @"主页";
  670. // model.iconFile = imageUrl;
  671. model.webUrl = Const_HomeUrl;
  672. // 写入数据库
  673. model.bg_tableName = DB_BrowserWindows_TableName;
  674. [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
  675. HLog(@"BaseModel写入:%@", isSuccess ? @"成功":@"失败");
  676. }];
  677. }else { // 更新窗口数据
  678. // 浏览器当前窗口索引ID
  679. // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  680. //
  681. // BaseModel *model = [[BaseModel alloc] init];
  682. // model.ID = ID;
  683. // model.name = @"主页";
  684. //// model.iconFile = imageUrl;
  685. // model.webUrl = Const_HomeUrl;
  686. //
  687. // // 更新数据库
  688. // model.bg_tableName = DB_BrowserWindows_TableName;
  689. // [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
  690. // HLog(@"BaseModel更新: %@", isSuccess ? @"成功":@"失败");
  691. // }];
  692. }
  693. }
  694. #pragma mark 获取当前屏幕的截图
  695. //- (UIImage *)getScreenShotImage {
  696. // CGSize size = [UIScreen mainScreen].bounds.size;
  697. // CGFloat scale = [UIScreen mainScreen].scale;
  698. // UIGraphicsBeginImageContextWithOptions(size, YES, scale);
  699. // [self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
  700. // UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
  701. // UIGraphicsEndImageContext();
  702. // return image;
  703. //}
  704. #pragma mark 计算器伪装视图
  705. /*CalculatorViewController*/
  706. - (void)showCalculatorVC{
  707. HLog(@"showCalculatorVC 处理密码框弹出")
  708. // if(SCREEN_W > SCREEN_H){
  709. // HLog(@"showCalculatorVC 屏幕还是横屏状态")
  710. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  711. // [self showCalculatorVC];
  712. // });
  713. // return;
  714. // }
  715. ksharedAppDelegate.supportScreenRotateType = NO;
  716. if(ksharedAppDelegate.getSystemPermissType){
  717. HLog(@"检测到获取系统全进入后台");
  718. return;
  719. }
  720. BOOL haveGuide = [HWDataManager getBoolWithKey:Const_Have_Show_Guide];
  721. if (haveGuide) {
  722. ;
  723. }else {
  724. return;
  725. }
  726. BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
  727. if(ksharedAppDelegate.DeviceThirdIdMod){
  728. isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  729. }
  730. if(!isPrivacyMode){
  731. return;
  732. }
  733. //修复扫描已经有密码的合作 点击跳过因为网络弹框再次覆盖一次密码(需要输入两次密码)
  734. BaseNavigationController*curTopNav = (BaseNavigationController*)[iTools appRootViewController];
  735. if([curTopNav isKindOfClass:[BaseNavigationController class]]){
  736. NSArray *vcArr = [curTopNav viewControllers];
  737. if(vcArr && vcArr.count >0){
  738. UIViewController *lastVC = vcArr.lastObject;
  739. if([lastVC isKindOfClass:[inputPWDViewController class]]){
  740. return;
  741. }
  742. }
  743. }
  744. /*无有效时长直接返回不加载任何加密界面*/
  745. NSString *PwdStr = nil;
  746. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  747. //实时拿到的密码 (每次打开或者更换设备 通过SN重新拿)
  748. if(ksharedAppDelegate.DeviceThirdIdMod.data.password){
  749. NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
  750. NSString*desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
  751. if(desPwdStr){
  752. PwdStr = desPwdStr;
  753. }
  754. }
  755. else{
  756. //本地密码本地判断 密码改在服务器保持
  757. if ([[deviceDict allKeys] containsObject:Const_Have_Add_Device_PWD]){
  758. PwdStr = [deviceDict objectForKey:Const_Have_Add_Device_PWD];
  759. }
  760. }
  761. if (!PwdStr || [PwdStr isEqualToString:@""])
  762. {
  763. return;
  764. }
  765. // BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
  766. // if (!haveOpenMask){
  767. // //输入密码界面
  768. // [self closeCalculatorVC];
  769. // _inputVC = [[inputPWDViewController alloc] init];
  770. // [self.window addSubview:_inputVC.view];
  771. // return;
  772. // }
  773. BOOL haveVaildTime = [HWDataManager getBoolWithKey:Const_Have_No_VaildTime];
  774. if (haveVaildTime == YES){/*无有效时间*/
  775. return;
  776. }
  777. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus != AFNetworkReachabilityStatusNotReachable)
  778. {
  779. if(!ksharedAppDelegate.DeviceThirdIdMod){
  780. return;
  781. }
  782. BOOL isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  783. if(!isPrivacyMode)
  784. {
  785. ksharedAppDelegate.isFirstInputPwdDone = YES;
  786. [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
  787. return;
  788. }
  789. }
  790. #ifdef developJSQ
  791. NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  792. #else
  793. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  794. #endif
  795. if (maskModel == 0){
  796. //输入密码界面
  797. [self closeCalculatorVC];
  798. _inputVC = [[inputPWDViewController alloc] init];
  799. [self.window addSubview:_inputVC.view];
  800. ksharedAppDelegate.isDidShowPwdType = YES;
  801. }
  802. else if (maskModel == 2){
  803. /*浏览器*/
  804. [self closeCalculatorVC];
  805. _webVC = [[HWWebViewController alloc] init];
  806. _webVC.pwd = PwdStr;
  807. _webVC.webUrl = @"https://baidu.com";
  808. [self.window addSubview:_webVC.view];
  809. ksharedAppDelegate.isDidShowPwdType = YES;
  810. }else{
  811. /*计算器*/
  812. [self closeCalculatorVC];
  813. _calculatorVC = [[CalculatorViewController alloc] init];
  814. _calculatorVC.pwd = PwdStr;
  815. [self.window addSubview:_calculatorVC.view];
  816. ksharedAppDelegate.isDidShowPwdType = YES;
  817. }
  818. [[NSNotificationCenter defaultCenter] postNotificationName:ShowPwdVCNotification object:nil];
  819. }
  820. - (void)closeCalculatorVC{
  821. ksharedAppDelegate.getSystemPermissType = NO;
  822. if (_calculatorVC){
  823. [_calculatorVC.view removeFromSuperview];
  824. }
  825. /*浏览器*/
  826. if (_webVC){
  827. [_webVC.view removeFromSuperview];
  828. }
  829. if(_inputVC){
  830. [_inputVC.view removeFromSuperview];
  831. }
  832. ksharedAppDelegate.isDidShowPwdType = NO;
  833. if(self->_session && self->_connectionOptions){
  834. [self scene:self->_session openURLContexts:self->_connectionOptions.URLContexts];
  835. }
  836. }
  837. - (NSString *)documentPathForAccount:(NSString *)account fileFolder:(NSString *)fileFolder {
  838. NSString *path = DocumentPath;
  839. if (account.length != 0) {
  840. path = [NSString stringWithFormat:@"%@/%@/",DocumentPath,account];
  841. }
  842. if ([fileFolder containsString:@"/"]) {
  843. NSString *path1 = [path stringByAppendingPathComponent:fileFolder];
  844. path1 = [path1 stringByDeletingLastPathComponent];
  845. NSError *error;
  846. if (![[NSFileManager defaultManager] fileExistsAtPath:path1]) {
  847. [[NSFileManager defaultManager] createDirectoryAtPath:path1 withIntermediateDirectories:YES attributes:nil error:&error];
  848. }
  849. }else{
  850. NSError *error;
  851. if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
  852. [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
  853. }
  854. }
  855. return [path stringByAppendingPathComponent:fileFolder];
  856. }
  857. - (void)startUseBtnBePressed{
  858. [self enterMainVCFromScene];
  859. // NSString *launchAppPWDPath = [self documentPathForAccount:@"" fileFolder:@"LaunchPWD"];
  860. // NSString *str = [[NSString alloc] initWithContentsOfFile:launchAppPWDPath encoding:(NSUTF8StringEncoding) error:nil];
  861. // if (!str || [str isEqualToString:@"0"])
  862. // {
  863. // SetUsePWDViewController *loginVC = [[SetUsePWDViewController alloc] init];
  864. // loginVC.delegate = self;
  865. // self.window.rootViewController = loginVC;
  866. //
  867. // return;
  868. // }
  869. //
  870. // NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
  871. //
  872. // if (dataArray.count == 0) { // 浏览器没有窗口
  873. // // 加载首页
  874. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  875. // vc.webUrl = Const_HomeUrl;
  876. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  877. // self.window.rootViewController = nvc;
  878. //
  879. // }else {
  880. // // 浏览器当前窗口索引ID
  881. // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  882. // NSString *where = [NSString stringWithFormat:@"where %@=%ld",bg_sqlKey(@"ID"),(long)ID];
  883. // NSArray* finfAlls = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
  884. // BaseModel *model = finfAlls.firstObject;
  885. //
  886. // // 加载网页
  887. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  888. // vc.webUrl = model.webUrl;
  889. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  890. // self.window.rootViewController = nvc;
  891. // }
  892. }
  893. - (void)loginOk{
  894. [self enterMainVCFromScene];
  895. }
  896. - (void)guideOk:(NSNotification*)not{
  897. NSString *object = not.object;
  898. if(object && [object isEqualToString:@"isLoginAgainType"]){
  899. self.isLoginAgainType = YES;
  900. }
  901. //clear下载和上传的已经获取的数据
  902. // [[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  903. // [uploadFileManager shareInstance].databaseArr = [NSMutableArray new];
  904. // [uploadFileManager shareInstance].fileModelDataArr = [NSMutableArray new];
  905. // [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateWait;
  906. [[nasUploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  907. [nasUploadFileManager shareInstance].databaseArr = nil;
  908. // [[downloadManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  909. // [downloadManager shareInstance].databaseArr = [NSMutableArray new];
  910. // [downloadManager shareInstance].downLoadFileModelDataArr = [NSMutableArray new];
  911. [[nasDownloadFileManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  912. [nasDownloadFileManager shareInstance].databaseArr = nil;
  913. //[[backupsFileManager shareInstance] suspendBackupsFileFun];
  914. [[nasBackupsManager shareInstance] suspendBackupsFileFun];
  915. //frp的下载
  916. [[customDownloadManager shareManager] suspendAllDownloadTask];
  917. NSString *uid =ksharedAppDelegate.DeviceThirdIdMod.data.sn;
  918. if(uid){
  919. }
  920. else{
  921. uid = @"";
  922. }
  923. [customDownloadManager shareManager].uid = uid;
  924. //盒子1音频在播放音乐,切换盒子2成功,仍在播放中
  925. [[DFPlayer sharedPlayer] df_deallocPlayer];
  926. [lastFileManager shareManager].uid = uid;
  927. [audioPlayListManager shareManager].uid = uid;
  928. [self enterMainVCFromScene];
  929. }
  930. #pragma mark 上报版本号信息
  931. -(void)reportVersionInfoFun
  932. {
  933. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  934. NSString *vers = [iPhone appVersion];
  935. if(vers){
  936. [paraDict setValue:vers forKey:@"iosClientVersionNumber"];
  937. }
  938. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  939. if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
  940. NSString*snStr = deviceDict[Const_Have_Add_Device_SN];
  941. if(snStr){
  942. [paraDict setValue:snStr forKey:@"sn"];
  943. }
  944. else{
  945. return;
  946. }
  947. }
  948. else{
  949. return;;
  950. }
  951. // KWeakSelf
  952. [[netWorkManager shareInstance] CommonPostCallBackCode:reportVersionInfo Parameters:paraDict success:^(id _Nonnull responseObject) {
  953. } failure:^(NSError * _Nonnull error) {
  954. }];
  955. }
  956. #pragma mark 获取NAS相关信息
  957. -(void)getNASMsgFun
  958. {
  959. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  960. NSString *SNStr = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
  961. if(SNStr){
  962. [paraDict setValue:SNStr forKey:@"sn"];
  963. }
  964. else{
  965. return;;
  966. }
  967. KWeakSelf
  968. [[netWorkManager shareInstance] CommonGetWithCallBackCode:getIpFun Parameters:paraDict success:^(id _Nonnull responseObject){
  969. NASMsgModel *model = [[NASMsgModel alloc] initWithDictionary:responseObject error:nil];
  970. if(model){
  971. ksharedAppDelegate.NASMsgMod = model;
  972. }
  973. } failure:^(NSError * _Nonnull error) {
  974. }];
  975. }
  976. #pragma mark 主动上锁
  977. - (void)showLockViewFun:(NSNotification*)not
  978. {
  979. [self showCalculatorVC];
  980. }
  981. #pragma mark 进入设置密码
  982. //- (void)setPwdVCFun:(NSNotification*)not
  983. //{
  984. // _isNeedToShowSecretKey = YES;
  985. //}
  986. #pragma mark 忘记密码
  987. - (void)forgetPwdFun:(NSNotification*)not
  988. {
  989. /*忘记密码*/
  990. forgetPwdViewController *forgetPwdVC = [[forgetPwdViewController alloc] init];
  991. BaseNavigationController *forgetPwdVCNav = [[BaseNavigationController alloc] initWithRootViewController:forgetPwdVC];
  992. self.window.rootViewController = forgetPwdVCNav;
  993. }
  994. #pragma mark 忘记密码返回
  995. - (void)forgetPwdBackFun:(NSNotification*)not
  996. {
  997. // if(_preRootPlayerNav)
  998. // {
  999. // self.window.rootViewController = _preRootPlayerNav;
  1000. // }
  1001. // else{
  1002. [self enterMainVCFromScene];
  1003. //}
  1004. [self showCalculatorVC];
  1005. }
  1006. #pragma mark 忘记密码设置密码完成
  1007. - (void)forgetPwdDidSetPwdFun:(NSNotification*)not
  1008. {
  1009. // if(_preRootPlayerNav)
  1010. // {
  1011. // NSArray *vcArr = _preRootPlayerNav.viewControllers;
  1012. // if(vcArr.count > 2){
  1013. // [_preRootPlayerNav popToViewController:vcArr[1] animated:NO];
  1014. // }
  1015. // self.window.rootViewController = _preRootPlayerNav;
  1016. // }
  1017. // else{
  1018. [self enterMainVCFromScene];
  1019. //}
  1020. [self closeCalculatorVC];
  1021. ksharedAppDelegate.isFirstInputPwdDone = YES;
  1022. }
  1023. #pragma mark 扫码切换设备 scanChangeDeviceNotification
  1024. - (void)scanChangeDeviceFun:(NSNotification*)not
  1025. {
  1026. //TipsQRCodeForChangeDeviceViewController *nextVC = [[TipsQRCodeForChangeDeviceViewController alloc] init];
  1027. QRCodeScanForChangeDeviceViewController *nextVC = [[QRCodeScanForChangeDeviceViewController alloc] init];
  1028. nextVC.isRootVCType = YES;
  1029. BaseNavigationController *nextNav = [[BaseNavigationController alloc] initWithRootViewController:nextVC];
  1030. self.window.rootViewController = nextNav;
  1031. }
  1032. #pragma mark 扫码切换设备点击返回
  1033. - (void)scanChangeDeviceBackFun:(NSNotification*)not
  1034. {
  1035. // if(_preRootPlayerNav)
  1036. // {
  1037. // self.window.rootViewController = _preRootPlayerNav;
  1038. // }
  1039. // else{
  1040. [self enterMainVCFromScene];
  1041. //}
  1042. [self showCalculatorVC];
  1043. }
  1044. #pragma mark 网络异常弹框
  1045. -(void)showNetErrorAlertFun
  1046. {
  1047. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  1048. if(maskModel !=0 && ksharedAppDelegate.isDidShowPwdType){
  1049. return;
  1050. }
  1051. NSString *linkErrTip = NSLocalizedString(@"player_link_fail_tip_type9",nil);
  1052. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable){
  1053. //linkErrTip = NSLocalizedString(@"player_link_fail_phone_Tips",nil);
  1054. _isNeedToStopWork = YES;
  1055. [self showNetErrorAlertType2Fun];
  1056. return;
  1057. }
  1058. linkErrTip = [[NSString alloc] initWithFormat:@"[9]%@",linkErrTip];
  1059. ComontAlretViewController *linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:nil
  1060. msg:linkErrTip
  1061. imageStr:nil
  1062. cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
  1063. okTitle:NSLocalizedString(@"player_link_fail_tryAgain",nil) isOkBtnHighlight:YES
  1064. didClickOk:^{
  1065. //[self enterMainVCFromScene];
  1066. } didClickCancel:^{
  1067. exit(0);
  1068. }];
  1069. linkFailAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  1070. [self.window.rootViewController presentViewController:linkFailAlretVC animated:YES completion:^{
  1071. linkFailAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  1072. }];
  1073. }
  1074. #pragma mark 网络异常弹框
  1075. -(void)showNetErrorAlertType2Fun
  1076. {
  1077. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable){
  1078. NSString * linkErrTip = NSLocalizedString(@"netWork_error_tip_content",nil);
  1079. ComontAlretViewController *linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"netWork_error_tip_title",nil)
  1080. msg:linkErrTip
  1081. imageStr:nil
  1082. cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
  1083. okTitle:nil isOkBtnHighlight:NO
  1084. didClickOk:^{
  1085. //[self enterMainVCFromScene];
  1086. } didClickCancel:^{
  1087. exit(0);
  1088. }];
  1089. linkFailAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  1090. self.window.rootViewController = [UIViewController new];
  1091. [self.window.rootViewController presentViewController:linkFailAlretVC animated:YES completion:^{
  1092. linkFailAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  1093. }];
  1094. }
  1095. }
  1096. - (void)gotoScanAginByThridMsgErrorFun:(NSInteger)errorCode
  1097. {
  1098. /*扫码界面*/
  1099. TipsQRCodeViewController *qrCodeVC = [[TipsQRCodeViewController alloc] init];
  1100. qrCodeVC.isNeedToShowAleatType = YES;
  1101. qrCodeVC.getSNMsgcode = errorCode;
  1102. BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
  1103. self.window.rootViewController = qrCodeVCNav;
  1104. }
  1105. #pragma mark 分享页面唤醒APP
  1106. - (void)shareAwakenAppBy:(NSString*)shareStr
  1107. {
  1108. //[[iToast makeText:shareStr] show];
  1109. NSArray * paraArr = [shareStr componentsSeparatedByString:@"&"];
  1110. if(!paraArr || paraArr.count==0){
  1111. return;
  1112. }
  1113. //type=save和download
  1114. NSString *type = nil;
  1115. NSString *fileIds = nil;
  1116. NSString *extractionCode = nil;
  1117. NSString *token = nil;
  1118. for (NSString*objectStr in paraArr) {
  1119. if([objectStr rangeOfString:@"type"].location != NSNotFound){
  1120. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1121. if(objectArr.count == 2){
  1122. type = objectArr.lastObject;
  1123. continue;
  1124. }
  1125. }
  1126. else if([objectStr rangeOfString:@"fileIds"].location != NSNotFound){
  1127. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1128. if(objectArr.count == 2){
  1129. fileIds = objectArr.lastObject;
  1130. continue;
  1131. }
  1132. }
  1133. else if([objectStr rangeOfString:@"extractionCode"].location != NSNotFound){
  1134. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1135. if(objectArr.count == 2){
  1136. extractionCode = objectArr.lastObject;
  1137. continue;
  1138. }
  1139. }
  1140. else if([objectStr rangeOfString:@"token"].location != NSNotFound){
  1141. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1142. if(objectArr.count == 2){
  1143. token = objectArr.lastObject;
  1144. continue;
  1145. }
  1146. }
  1147. }
  1148. if(!type || type.length ==0){
  1149. HLog(@"分享 type 获取错误");
  1150. return;
  1151. }
  1152. if(!fileIds || fileIds.length ==0){
  1153. HLog(@"分享 fileIds 获取错误");
  1154. return;
  1155. }
  1156. if(!token || token.length ==0){
  1157. HLog(@"分享 token 获取错误");
  1158. return;
  1159. }
  1160. [self getShareOneFileListFunByToken:token withFileIds:fileIds withExtractionCode:extractionCode withType:type];
  1161. }
  1162. #pragma mark 分享信息重新获取
  1163. - (void)getShareOneFileListFunByToken:(NSString*)token withFileIds:(NSString*)fileIds withExtractionCode:(NSString*)extractionCode withType:(NSString*)type
  1164. {
  1165. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1166. fileIds = [fileIds stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  1167. NSData *jsonData = [fileIds dataUsingEncoding:NSUTF8StringEncoding];;
  1168. NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
  1169. HLog(@"jsonArray:%@",jsonArray)
  1170. if(!jsonArray){
  1171. return;
  1172. }
  1173. [paraDict setValue:token forKey:@"token"];
  1174. [paraDict setValue:jsonArray forKey:@"fileIdList"];
  1175. [paraDict setValue:extractionCode forKey:@"extractionCode"];
  1176. KWeakSelf
  1177. [[netWorkManager shareInstance] CommonPostCallBackCode:queryOneShareInfoFun Parameters:paraDict success:^(id _Nonnull responseObject) {
  1178. queryOneShareModel*model = [[queryOneShareModel alloc] initWithDictionary:responseObject error:nil];
  1179. if(model && model.status == 0){
  1180. weakSelf.getShareStr = nil;
  1181. [weakSelf gotoVCByModel:model withType:type];
  1182. }
  1183. else{
  1184. }
  1185. } failure:^(NSError * _Nonnull error) {
  1186. }];
  1187. }
  1188. #pragma mark 跳转
  1189. - (void)gotoVCByModel:(queryOneShareModel*)model withType:(NSString*)type
  1190. {
  1191. if([type isEqualToString:@"save"]){
  1192. [self saveFileToBoxFunBy:model];
  1193. //数据埋点
  1194. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Share_save"];
  1195. }
  1196. else if([type isEqualToString:@"download"]){
  1197. [self downloadFileToAppFunBy:model];
  1198. //数据埋点
  1199. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Share_download"];
  1200. }
  1201. }
  1202. #pragma mark 保存文件到盒子
  1203. - (void)saveFileToBoxFunBy:(queryOneShareModel*)sharemodel
  1204. {
  1205. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1206. NSMutableArray *pathArr = [NSMutableArray new];
  1207. for (ShareFileDataModel*dataModel in sharemodel.data.fileListVOS){
  1208. [pathArr addObject:dataModel.fileUrl];
  1209. }
  1210. if (pathArr) {
  1211. NSString *jsonStr = [iTools toJsonStrWithArray:pathArr];
  1212. if(jsonStr){
  1213. [paraDict setValue:jsonStr forKey:@"urls"];
  1214. }
  1215. }
  1216. NSString * boxSaveDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_box_save_default_path)];
  1217. if(!boxSaveDefaultPath || boxSaveDefaultPath.length == 0){
  1218. boxSaveDefaultPath = Const_default_save_path;
  1219. [HWDataManager setStringWithKey:stringKeyAddSn(Const_box_save_default_path) value:boxSaveDefaultPath];
  1220. }
  1221. [paraDict setValue:boxSaveDefaultPath forKey:@"savePath"];
  1222. KWeakSelf
  1223. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"downFiles" Parameters:paraDict success:^(id _Nonnull responseObject) {
  1224. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1225. if(model && model.status == 0){
  1226. [weakSelf gotoUploadFileRecordVCFunByType:2 withModel:sharemodel];
  1227. }
  1228. } failure:^(NSError * _Nonnull error) {
  1229. }];
  1230. }
  1231. #pragma mark 下载文件到手机
  1232. - (void)downloadFileToAppFunBy:(queryOneShareModel*)sharemodel
  1233. {
  1234. [self gotoUploadFileRecordVCFunByType:1 withModel:sharemodel];
  1235. }
  1236. #pragma mark 跳转传输列表
  1237. - (void)gotoUploadFileRecordVCFunByType:(NSInteger)type withModel:(queryOneShareModel*)sharemodel
  1238. {
  1239. KWeakSelf
  1240. if(type == 2){
  1241. [[boxSaveFileManager shareInstance] addBoxSaveRecordFunBy:sharemodel.data.fileListVOS complete:^(BOOL isSuccess) {
  1242. if(isSuccess){
  1243. mainBlock(^{
  1244. [weakSelf gotoUploadFileRecordVCFunByType:type];
  1245. });
  1246. }
  1247. }];
  1248. }
  1249. else if (type == 1){
  1250. if(![iTools checkFreeDiskSpaceInBytesIsOK:500*1024*1024]){
  1251. mainBlock(^{
  1252. [[iToast makeText:NSLocalizedString(@"phone_space_Insufficient",nil)] show];
  1253. });
  1254. return;
  1255. }
  1256. [[boxDownloadFileManager shareInstance] addBoxDownloadRecordFunBy:sharemodel.data.fileListVOS complete:^(BOOL isSuccess) {
  1257. if(isSuccess){
  1258. mainBlock(^{
  1259. [weakSelf gotoUploadFileRecordVCFunByType:type];
  1260. });
  1261. }
  1262. }];
  1263. }
  1264. }
  1265. - (void)gotoUploadFileRecordVCFunByType:(NSInteger)type
  1266. {
  1267. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1268. vc.isReceiveType = type;
  1269. BaseNavigationController*mainNav = ksharedAppDelegate.mainTabBar.selectedViewController;
  1270. if([mainNav isKindOfClass:[BaseNavigationController class]]){
  1271. [mainNav pushViewController:vc animated:YES];
  1272. [[UIApplication sharedApplication] setStatusBarHidden:NO];
  1273. }
  1274. }
  1275. #pragma mark UITabBarControllerDelegate
  1276. - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
  1277. {
  1278. NSInteger index = tabBarController.selectedIndex;
  1279. int eventType = 1;
  1280. NSString* eventValue = @"Nas";
  1281. if(index == 0){
  1282. eventValue = @"Nas";
  1283. }
  1284. else if(index == 1){
  1285. eventValue = @"Cloud";
  1286. }
  1287. else if(index == 2){
  1288. eventValue = @"Home";
  1289. }
  1290. //数据埋点
  1291. [[netWorkManager shareInstance] DataEmbeddingPointBy:eventType withEventValue:eventValue];
  1292. }
  1293. - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
  1294. {
  1295. if(ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType
  1296. || ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType
  1297. || ksharedAppDelegate.needToPushWebRtcVCType){
  1298. return NO;
  1299. }
  1300. return YES;
  1301. }
  1302. #pragma mark 弹框逻辑放到这里
  1303. //优先级:1.强制盒子更新弹窗
  1304. // 2.APP版本更新弹窗 > 新手引导弹窗 > 通知公告弹窗
  1305. - (void)beginShowAlertFun
  1306. {
  1307. //
  1308. if (!ksharedAppDelegate.mainTabBar) {
  1309. return;
  1310. }
  1311. //1.隐私模式密码界面 3秒检测一次是否输入完成密码了
  1312. if(!ksharedAppDelegate.isFirstInputPwdDone){
  1313. KWeakSelf
  1314. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1315. [weakSelf beginShowAlertFun];
  1316. });
  1317. return;
  1318. }
  1319. // 强制盒子更新弹窗
  1320. [self checkUpgradeInfoFun];
  1321. }
  1322. #pragma mark 弹框流程 1 检测盒子镜像更新弹窗->1.4.4改为从服务器请求
  1323. - (void)checkUpgradeInfoFun
  1324. {
  1325. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  1326. [paraDict setValue:@"ota" forKey:@"type"];
  1327. KWeakSelf
  1328. [[netWorkManager shareInstance] CommonPostCallBackCode:queryUpgradeInfo Parameters:paraDict success:^(id _Nonnull responseObject) {
  1329. UpgradeInfoModel *model = [[UpgradeInfoModel alloc] initWithDictionary:responseObject error:nil];
  1330. if (model && model.status == 0) {
  1331. weakSelf.otaUpgradeInfoModel = model;
  1332. [weakSelf handelUpgradeInfoFun];
  1333. }
  1334. else
  1335. {
  1336. //2. APP版本更新弹窗
  1337. [weakSelf checkVersionFun];
  1338. }
  1339. } failure:^(NSError * _Nonnull error) {
  1340. KWeakSelf
  1341. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1342. [weakSelf checkUpgradeInfoFun];
  1343. });
  1344. }];
  1345. }
  1346. #pragma mark 弹框流程 1 强制盒子更新弹窗
  1347. - (void)handelUpgradeInfoFun
  1348. {
  1349. //self.otaUpgradeInfoModel.data.status = 1;
  1350. if(self.otaUpgradeInfoModel.data.status < 1){ //-1=没有更新 0=下载中
  1351. //2. APP版本更新弹窗
  1352. [self checkVersionFun];
  1353. }
  1354. else{
  1355. KWeakSelf
  1356. if(self.otaUpgradeInfoModel.data.status < 6){
  1357. [self showImageViewRenewTipViewFun];
  1358. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1359. [weakSelf checkUpgradeInfoFun];
  1360. });
  1361. }
  1362. else if(self.otaUpgradeInfoModel.data.status == 6){//升级完成
  1363. if(RenewTipView){
  1364. [self showImageViewRenewTipViewFun];
  1365. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1366. [weakSelf OTAUpdateDoneFun];
  1367. });
  1368. }
  1369. else{
  1370. [self OTAUpdateDoneFun];
  1371. }
  1372. }
  1373. else if(self.otaUpgradeInfoModel.data.status == 201){//升级失败
  1374. //显示升级失败
  1375. [self OTAUpdateFailFun];
  1376. }
  1377. else{
  1378. //2. APP版本更新弹窗
  1379. [self checkVersionFun];
  1380. }
  1381. }
  1382. }
  1383. #pragma mark 弹框流程 1 强制盒子更新弹窗
  1384. - (void)showImageViewRenewTipViewFun
  1385. {
  1386. //密码框界面 拦着 不给弹出
  1387. if(ksharedAppDelegate.isDidShowPwdType){
  1388. //didGetSysInfoType = NO;
  1389. KWeakSelf
  1390. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1391. [weakSelf showImageViewRenewTipViewFun];
  1392. });
  1393. return;
  1394. }
  1395. if(RenewTipView){
  1396. RenewTipView.status = _otaUpgradeInfoModel.data.status;
  1397. return;
  1398. }
  1399. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
  1400. CGFloat second = 0.1;
  1401. if(haveOpenMask){
  1402. second = 1.5;
  1403. [[NSNotificationCenter defaultCenter] postNotificationName:needToPoPCloudPhoneVCNotification object:nil];
  1404. }
  1405. KWeakSelf
  1406. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(second * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1407. self->RenewTipView = [[imageVersionRenewTipView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  1408. [ksharedAppDelegate.window addSubview:self->RenewTipView];
  1409. self->RenewTipView.status = self->_otaUpgradeInfoModel.data.status;
  1410. //[self.view bringSubviewToFront:RenewTipView];
  1411. self->RenewTipView.didClickUpdateNowFun = ^{
  1412. [weakSelf otaUpdateNowFun];
  1413. };
  1414. self->RenewTipView.didClickCloseFun = ^{
  1415. [weakSelf didClickRenewTipViewCloseFun];
  1416. };
  1417. });
  1418. }
  1419. - (void)didClickRenewTipViewCloseFun{
  1420. RenewTipView = nil;
  1421. }
  1422. #pragma mark 弹框流程 1 盒子更新弹窗 点击立即更新
  1423. - (void)otaUpdateNowFun
  1424. {
  1425. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  1426. [paraDict setValue:@"ota" forKey:@"type"];
  1427. [paraDict setValue:@2 forKey:@"status"];
  1428. KWeakSelf
  1429. [[netWorkManager shareInstance] CommonPostCallBackCode:upgradeDetailAdd Parameters:paraDict success:^(id _Nonnull responseObject) {
  1430. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1431. if (model && model.status == 0) {
  1432. [weakSelf checkUpgradeInfoFun];
  1433. }
  1434. else
  1435. {
  1436. [weakSelf checkVersionFun];
  1437. }
  1438. } failure:^(NSError * _Nonnull error) {
  1439. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1440. [weakSelf otaUpdateNowFun];
  1441. });
  1442. }];
  1443. //1.点击更新 标志 30分别 不谈 心跳弹框
  1444. long seconds = [iTools getNowTimeStamp];
  1445. NSNumber *secondsNum = [NSNumber numberWithLong:seconds];
  1446. if(secondsNum){
  1447. [HWDataManager setNumberWithKey:stringKeyAddSn(@"disenable_type1_BoxHeartbeat") value:secondsNum];
  1448. }
  1449. }
  1450. #pragma mark 弹框流程 1 OTA升级完成
  1451. - (void)OTAUpdateDoneFun
  1452. {
  1453. //密码框界面 拦着 不给弹出
  1454. if(ksharedAppDelegate.isDidShowPwdType){
  1455. KWeakSelf
  1456. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1457. [weakSelf OTAUpdateDoneFun];
  1458. });
  1459. return;
  1460. }
  1461. if(RenewTipView){
  1462. [RenewTipView removeFromSuperview];
  1463. RenewTipView = nil;
  1464. }
  1465. if (imageVersionUpdateDoneV) {
  1466. [imageVersionUpdateDoneV removeFromSuperview];
  1467. imageVersionUpdateDoneV = nil;
  1468. }
  1469. //显示OTA完成页面
  1470. imageVersionUpdateDoneV = [[imageVersionUpdateDoneView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  1471. [ksharedAppDelegate.window addSubview:imageVersionUpdateDoneV];
  1472. //[self.view bringSubviewToFront:curView];
  1473. KWeakSelf
  1474. imageVersionUpdateDoneV.didClickUpdateDoneFun = ^{
  1475. [weakSelf closeOTAUpdateDoneFun];
  1476. };
  1477. }
  1478. #pragma mark 弹框流程 1 OTA升级失败
  1479. - (void)OTAUpdateFailFun
  1480. {
  1481. //密码框界面 拦着 不给弹出
  1482. if(ksharedAppDelegate.isDidShowPwdType){
  1483. KWeakSelf
  1484. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1485. [weakSelf OTAUpdateFailFun];
  1486. });
  1487. return;
  1488. }
  1489. if(RenewTipView){
  1490. [RenewTipView removeFromSuperview];
  1491. RenewTipView = nil;
  1492. }
  1493. if (imageVersionUpdateFailV) {
  1494. [imageVersionUpdateFailV removeFromSuperview];
  1495. imageVersionUpdateFailV = nil;
  1496. }
  1497. //显示OTA完成页面
  1498. imageVersionUpdateFailV = [[imageVersionUpdateFailView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  1499. [ksharedAppDelegate.window addSubview:imageVersionUpdateFailV];
  1500. //[self.view bringSubviewToFront:curView];
  1501. KWeakSelf
  1502. imageVersionUpdateFailV.didClickUpdateDoneFun = ^{
  1503. [weakSelf closeOTAUpdateDoneFun];
  1504. };
  1505. }
  1506. #pragma mark 弹框流程 1 盒子更新弹窗 关闭弹窗
  1507. - (void)closeOTAUpdateDoneFun
  1508. {
  1509. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  1510. [paraDict setValue:@"ota" forKey:@"type"];
  1511. [paraDict setValue:@1 forKey:@"popButton"];
  1512. KWeakSelf
  1513. [[netWorkManager shareInstance] CommonPostCallBackCode:updateOTAPopButton Parameters:paraDict success:^(id _Nonnull responseObject) {
  1514. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1515. if (model && model.status == 0) {
  1516. }
  1517. else
  1518. {
  1519. }
  1520. [weakSelf checkVersionFun];
  1521. } failure:^(NSError * _Nonnull error) {
  1522. [weakSelf checkVersionFun];
  1523. }];
  1524. }
  1525. #pragma mark 弹框流程 2 APP版本更新弹窗
  1526. - (void)checkVersionFun
  1527. {
  1528. //[self getVersion];
  1529. [self getLastNoticeFun];
  1530. }
  1531. #pragma mark- 网络请求
  1532. - (void)getVersion {
  1533. //密码框界面 拦着 不给弹出
  1534. if(!ksharedAppDelegate.isFirstInputPwdDone){
  1535. return;
  1536. }
  1537. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  1538. [paraDict setValue:@"ios" forKey:@"type"];
  1539. [paraDict setValue:@"skyworth" forKey:@"source"];
  1540. [paraDict setValue:@"iPhone" forKey:@"iosType"];
  1541. [[netWorkManager shareInstance] CommonGetWithCallBackCode:upgradeNewVersion Parameters:paraDict success:^(id _Nonnull responseObject) {
  1542. //HLog(@"%@", responseObject);
  1543. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1544. if (model && model.status == 0) {
  1545. HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
  1546. [self checkVersion:model];
  1547. }
  1548. else
  1549. {
  1550. [self checkVersion:nil];
  1551. }
  1552. } failure:^(NSError * _Nonnull error) {
  1553. HLog(@"%@", error);
  1554. [self checkVersion:nil];
  1555. }];
  1556. }
  1557. - (void)checkVersion:(HWVersionModel*)versionModel {
  1558. if(!versionModel){//版本信息错误 检测新手弹框流程
  1559. //[self showNewerGuideFun];
  1560. [self getLastNoticeFun];
  1561. return;
  1562. }
  1563. // NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
  1564. NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
  1565. NSString *newVersion = [versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
  1566. newVersion = [newVersion stringByReplacingOccurrencesOfString:@"V" withString:@""]; //去掉v
  1567. //HLog(@"%@---%@", newVersion, currentVersion);
  1568. if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
  1569. //[self showNewerGuideFun];
  1570. [self getLastNoticeFun];
  1571. }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
  1572. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  1573. //[self showNewerGuideFun];
  1574. [self getLastNoticeFun];
  1575. }else { // 本地版本号 < 服务器版本号 (有新版本)
  1576. [self showNewVersion:versionModel];
  1577. [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
  1578. };
  1579. }
  1580. - (void)showNewVersion:(HWVersionModel*)versionModel {
  1581. HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
  1582. if (haveNewVersionView.isShow) {
  1583. return;
  1584. }
  1585. //此版本点击过稍后再试
  1586. NSString *preVersionstr = [HWDataManager getStringWithKey:Const_did_show_version_and_click_wait];
  1587. if(preVersionstr && [versionModel.versionNumber isEqualToString:preVersionstr]){
  1588. //[self showNewerGuideFun];
  1589. [self getLastNoticeFun];
  1590. return;
  1591. }
  1592. haveNewVersionView.versionModel = versionModel;
  1593. haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
  1594. [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
  1595. [ksharedAppDelegate.window addSubview:haveNewVersionView];
  1596. haveNewVersionView.isShow = YES;
  1597. if(!versionModel.necessary){
  1598. haveNewVersionView.deleteBtn.hidden = NO;
  1599. }
  1600. [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
  1601. make.top.mas_equalTo(0);
  1602. make.left.mas_equalTo(0);
  1603. make.right.mas_equalTo(0);
  1604. make.bottom.mas_equalTo(0);
  1605. }];
  1606. haveNewVersionView.alpha = 0.0;
  1607. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  1608. haveNewVersionView.alpha = 1.0;
  1609. KyoLog(@"in animate start");
  1610. } completion:^(BOOL finished) {
  1611. KyoLog(@"in animate completion");
  1612. }];
  1613. KWeakSelf
  1614. haveNewVersionView.closeViewFun = ^{
  1615. //[weakSelf showNewerGuideFun];
  1616. [weakSelf getLastNoticeFun];
  1617. };
  1618. }
  1619. //#pragma mark 弹框流程 3 新手引导弹窗
  1620. //- (void)showNewerGuideFun
  1621. //{
  1622. // BOOL didShow = [HWDataManager getBoolWithKey:@"Const_did_show_newer_Guide"];
  1623. //
  1624. // if(didShow){
  1625. // [self getLastNoticeFun];
  1626. // return;
  1627. // }
  1628. //
  1629. // //密码框界面 拦着 不给弹出
  1630. // if(ksharedAppDelegate.isDidShowPwdType){
  1631. // KWeakSelf
  1632. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1633. // [weakSelf showNewerGuideFun];
  1634. // });
  1635. // return;
  1636. // }
  1637. //
  1638. // newerGuideView *guideView = [[newerGuideView alloc] init];
  1639. // [ksharedAppDelegate.window addSubview:guideView];
  1640. //
  1641. // [guideView mas_makeConstraints:^(MASConstraintMaker *make) {
  1642. // make.top.mas_equalTo(0);
  1643. // make.left.mas_equalTo(0);
  1644. // make.right.mas_equalTo(0);
  1645. // make.bottom.mas_equalTo(0);
  1646. // }];
  1647. //
  1648. //
  1649. // KWeakSelf
  1650. // guideView.didClickButtonFun = ^(NSInteger tag) {
  1651. // [weakSelf didiClickNewerButtonFunBy:tag];
  1652. // };
  1653. //
  1654. //}
  1655. //
  1656. //#pragma mark 新手引导点击事件
  1657. //- (void)didiClickNewerButtonFunBy:(NSInteger)tag
  1658. //{
  1659. // [HWDataManager setBoolWithKey:@"Const_did_show_newer_Guide" value:YES];
  1660. //
  1661. // if(tag ==1){
  1662. // [self getLastNoticeFun];
  1663. // }
  1664. // else if(tag ==2 || tag == 10){
  1665. // CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  1666. // vc.titleStr = NSLocalizedString(@"mine_newuser_title",nil);
  1667. //
  1668. // NSString *url = [[NSString alloc] initWithFormat:@"%@/warrantyService/index.html#/novice?isNovice=true",CloudService];
  1669. // if(tag == 10){
  1670. // url = [url stringByReplacingOccurrencesOfString:@"?isNovice=true" withString:@""];
  1671. // }
  1672. //
  1673. // vc.webUrl = url;
  1674. // //[self pushViewController:vc animated:YES];
  1675. //
  1676. // NSArray*curVCArr = ksharedAppDelegate.mainTabBar.viewControllers;
  1677. // NSInteger selectedIndex = ksharedAppDelegate.mainTabBar.selectedIndex;
  1678. //
  1679. // if(selectedIndex < curVCArr.count){
  1680. // UIViewController * curVC = curVCArr[selectedIndex];
  1681. // [curVC.navigationController pushViewController:curVC animated:YES];
  1682. //
  1683. // KWeakSelf
  1684. // vc.didClickBackFun = ^{
  1685. // [weakSelf getLastNoticeFun];
  1686. // };
  1687. // }
  1688. //
  1689. // }
  1690. //}
  1691. #pragma mark 弹框流程 4 通知公告弹窗
  1692. - (void)getLastNoticeFun
  1693. {
  1694. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  1695. [paraDict setValue:@"Private-X" forKey:@"productType"];
  1696. [paraDict setValue:@"ios" forKey:@"type"];
  1697. [[netWorkManager shareInstance] CommonPostCallBackCode:queryOneNotice Parameters:paraDict success:^(id _Nonnull responseObject) {
  1698. noticeModel *model = [[noticeModel alloc] initWithDictionary:responseObject error:nil];
  1699. //test code
  1700. // model.status = 0;
  1701. // model.data = [noticeDataModel new];
  1702. // model.data.curNoticeId = @"1111";
  1703. // model.data.title = @"版本升级通知公告";
  1704. // model.data.content = @"1.偶现挤下线问题";
  1705. // model.data.content = @"1.偶现挤下线问题\n2.本地网络弹框\n3.访问相册权限之类的系统弹框会触发进入后台流程---显示输入密码框\n4.上传偶现UI刷新异常(数据库是正常的)\n5.偶现上传文件损坏\n6.链接不稳定问题(websock偶尔会不断重连\n7.进入设置页面读取数据偶现闪退!!!!\n8.本地网络弹框\n9.访问相册权限之类的系统弹框会触发进入后台流程---显示输入密码框\n10.上传偶现UI刷新异常(数据库是正常的)\n11.偶现上传文件损坏\n12.链接不稳定问题(websock偶尔会不断重连)\n13.进入设置页面读取数据偶现闪退!!!!\n14.本地网络弹框\n15.访问相册权限之类的系统弹框会触发进入后台流程\n16.上传偶现UI刷新异常(数据库是正常的)";//\n17.偶现上传文件损坏\n18.链接不稳定问题(websock偶尔会不断重连\n19.进入设置页面读取数据偶现闪退!!!!\n20.本地网络弹框\n21.访问相册权限之类的系统弹框会触发进入后台流程\n22.上传偶现UI刷新异常(数据库是正常的)\n23.偶现上传文件损坏\n24.链接不稳定问题(websock偶尔会不断重连)\n25.进入设置页面读取数据偶现闪退!!!!\n26.本地网络弹框\n27.访问相册权限之类的系统弹框会触发进入后台流程\n28.上传偶现UI刷新异常(数据库是正常的)\n29.偶现上传文件损坏\n30.链接不稳定问题(websock偶尔会不断重连)\n31.进入设置页面读取数据偶现闪退!!!!";
  1706. if (model && model.data && model.status == 0) {
  1707. [self showHaveNoticeViewBy:model];
  1708. }
  1709. else
  1710. {
  1711. }
  1712. } failure:^(NSError * _Nonnull error) {
  1713. HLog(@"%@", error);
  1714. }];
  1715. }
  1716. - (void)showHaveNoticeViewBy:(noticeModel*)model
  1717. {
  1718. //密码框界面 拦着 不给弹出
  1719. if(ksharedAppDelegate.isDidShowPwdType){
  1720. KWeakSelf
  1721. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1722. [weakSelf showHaveNoticeViewBy:model];
  1723. });
  1724. return;
  1725. }
  1726. HaveNoticeView * noticeView = [HaveNoticeView shardInstance];
  1727. NSString * preShowID = [HWDataManager getStringWithKey:Const_did_show_Notice_ID];
  1728. if(noticeView.isShow
  1729. || !model
  1730. || [preShowID isEqualToString:model.data.curNoticeId]){
  1731. return;
  1732. }
  1733. noticeView.curNoticeModel = model;
  1734. //异常处理
  1735. if(![iTools getKeyWindow]){
  1736. return;
  1737. }
  1738. [[iTools getKeyWindow] addSubview:noticeView];
  1739. [noticeView mas_makeConstraints:^(MASConstraintMaker *make) {
  1740. make.top.mas_equalTo(0);
  1741. make.left.mas_equalTo(0);
  1742. make.right.mas_equalTo(0);
  1743. make.bottom.mas_equalTo(0);
  1744. }];
  1745. noticeView.alpha = 0.0;
  1746. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  1747. noticeView.alpha = 1.0;
  1748. } completion:^(BOOL finished) {
  1749. }];
  1750. }
  1751. @end