NASViewController.m 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500
  1. //
  2. // NASViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/19.
  6. //
  7. #import "NASViewController.h"
  8. #import "NASMySpaceView.h"
  9. #import "NASCommonUsedView.h"
  10. #import "shareSecretTableViewCell.h"
  11. #import "NASLastFileView.h"
  12. #import "previewImageOrVideoViewController.h"
  13. #import "previewAudioOrDocumentViewController.h"
  14. #import "previewFileAndFolderViewController.h"
  15. #import "shareRecordViewController.h"
  16. #import "backupsOptionViewController.h"
  17. #import "fileTransfeSetViewController.h"
  18. #import "uploadFileRecordViewController.h"
  19. #import "previewToUploadFileView.h"
  20. #import "NASMySpaceViewController.h"
  21. #import "NasPreviewVideoViewController.h"
  22. #import "lastFileManager.h"
  23. #import "lastFileTableViewCell.h"
  24. #import "nasLastFileViewController.h"
  25. #import "audioPlayerViewController.h"
  26. #import "videoPlayByAVPlayerViewController.h"
  27. #import "imageDetailsScrollViewController.h"
  28. #import "queryShareModel.h"
  29. #import "imageVersionRenewTipView.h"
  30. #import "HWVersionModel.h"
  31. #import "HaveNewVersionView.h"
  32. #import "newerGuideView.h"
  33. #import "CustomerWebViewController.h"
  34. #import "noticeModel.h"
  35. #import "HaveNoticeView.h"
  36. #import "audioPlayingView.h"
  37. #import "DFPlayer.h"
  38. #import "queryShareReportMarkModel.h"
  39. #import "UpgradeInfoModel.h"
  40. #import "imageVersionUpdateDoneView.h"
  41. #import "imageVersionUpdateFailView.h"
  42. @interface NASViewController ()<UITableViewDelegate,UITableViewDataSource>
  43. {
  44. BOOL canShareType;
  45. UIImageView *welcomeImageV;//弃用
  46. UIView* rightRedView;//
  47. BOOL hadUploadTaskType;
  48. BOOL hadDownloadTaskType;
  49. NSInteger tryLinkNum;
  50. imageVersionRenewTipView * RenewTipView;
  51. imageVersionUpdateDoneView* imageVersionUpdateDoneV;
  52. imageVersionUpdateFailView* imageVersionUpdateFailV;
  53. }
  54. @property (nonatomic,strong)UITableView*tableView;
  55. @property (nonatomic, strong) UIView*tableHeadView;
  56. @property (nonatomic, strong) NASMySpaceView* NASMySpaceV;
  57. @property (nonatomic, strong) NASCommonUsedView* NASCommonUsedV;
  58. @property (nonatomic,strong)NASLastFileView*NASLastFileV;
  59. @property (nonatomic,strong) NSMutableArray *lastFileDataArr;
  60. @property (nonatomic,strong)UpgradeInfoModel*otaUpgradeInfoModel;
  61. @end
  62. @implementation NASViewController
  63. - (void)viewDidLoad {
  64. [super viewDidLoad];
  65. // Do any additional setup after loading the view.
  66. [self.view setBackgroundColor:HWF5F7FAColor];
  67. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getExtraFilesDoneFun:) name:getExtraFilesDoneNotification object:nil];
  68. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
  69. [self.toolBar setHidden:YES];
  70. [self.navigationBar setHidden:YES];
  71. [self.navBarBGView setHidden:YES];
  72. [self drawAnyView];
  73. CGFloat second = 0.1;
  74. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
  75. if(haveOpenMask){
  76. second = 5;
  77. }
  78. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(second * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  79. [self beginShowAlertFun];
  80. });
  81. }
  82. - (void)drawAnyView{
  83. //顶底底部图片
  84. UIImageView *topImageV = [UIImageView new];
  85. topImageV.image = [UIImage imageNamed:@"Nas_top_img"];
  86. [self.view addSubview:topImageV];
  87. [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.top.mas_equalTo(0);
  89. make.left.mas_equalTo(0);
  90. make.right.mas_equalTo(0);
  91. make.height.mas_equalTo(280.0*AUTOSCALE);
  92. }];
  93. // NSString *welcomeImageStr = @"nas_welcome_cs";
  94. // //欢迎
  95. // //en-US 英文 ja-JP 日文
  96. // NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
  97. // NSLog(@"arLanguages:%@",arLanguages);
  98. // ///获取设备当前地区的代码和APP语言环境
  99. // NSString *languageCode = [NSLocale preferredLanguages][0];
  100. //
  101. // //目前支持 中文(简体 繁体) 英文 日语
  102. // if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
  103. // {
  104. // welcomeImageStr = @"nas_welcome_cs";
  105. // }
  106. // else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
  107. // {
  108. // welcomeImageStr = @"nas_welcome_ct";
  109. // }
  110. // else{
  111. // welcomeImageStr = @"nas_welcome_en";
  112. // }
  113. CGFloat imageTopY = 54.0;
  114. welcomeImageV = [UIImageView new];
  115. welcomeImageV.hidden = YES;
  116. //welcomeImageV.image = [UIImage imageNamed:welcomeImageStr];
  117. [self.view addSubview:welcomeImageV];
  118. [welcomeImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.top.mas_equalTo(imageTopY);
  120. make.left.mas_equalTo(16);
  121. make.width.mas_equalTo(210);
  122. make.height.mas_equalTo(24);
  123. }];
  124. UILabel *welcomelabel = [[UILabel alloc] init];
  125. welcomelabel.text = NSLocalizedString(@"NAS_top_welcome_title",nil);
  126. welcomelabel.textColor = [UIColor hwColor:@"#0A132B"];
  127. welcomelabel.font = [UIFont boldSystemFontOfSize:18.0];
  128. [self.view addSubview:welcomelabel];
  129. [welcomelabel mas_makeConstraints:^(MASConstraintMaker *make) {
  130. make.top.mas_equalTo(imageTopY);
  131. make.left.mas_equalTo(16);
  132. make.width.mas_equalTo(240);
  133. make.height.mas_equalTo(24);
  134. }];
  135. //添加按钮
  136. UIButton *addButton = [[UIButton alloc] init];
  137. [addButton setImage:[UIImage imageNamed:@"nas_add_icon"] forState:UIControlStateNormal];
  138. addButton.tag = 1;
  139. [addButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  140. [self.view addSubview:addButton];
  141. [addButton mas_makeConstraints:^(MASConstraintMaker *make) {
  142. make.centerY.equalTo(welcomeImageV.mas_centerY).offset(0);
  143. make.right.mas_equalTo(-10);
  144. make.width.mas_equalTo(40);
  145. make.height.mas_equalTo(40);
  146. }];
  147. UIButton *rightTransferListButton = [[UIButton alloc] init];
  148. //[rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  149. [rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  150. rightTransferListButton.tag = 2;
  151. [rightTransferListButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  152. [self.view addSubview:rightTransferListButton];
  153. [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) {
  154. //make.top.mas_equalTo(imageTopY);
  155. make.centerY.equalTo(welcomeImageV.mas_centerY).offset(0);
  156. make.right.equalTo(addButton.mas_left).offset(0);
  157. make.width.mas_equalTo(40);
  158. make.height.mas_equalTo(40);
  159. }];
  160. rightRedView = [[UIView alloc] init];
  161. rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
  162. [rightTransferListButton addSubview:rightRedView];
  163. rightRedView.layer.cornerRadius = 7;
  164. rightRedView.hidden = YES;
  165. [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
  166. make.width.mas_equalTo(14);
  167. make.height.mas_equalTo(14);
  168. make.right.mas_equalTo(0);
  169. make.top.mas_equalTo(6);
  170. }];
  171. [self.view addSubview:self.tableView];
  172. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  173. make.left.mas_equalTo(0);
  174. make.right.mas_equalTo(0);
  175. make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
  176. make.bottom.mas_equalTo(-TABBARHEIGHT);
  177. }];
  178. _tableHeadView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +54 + 15)];
  179. //_tableHeadView.backgroundColor = [UIColor hwColor:@"#F6F8FA"];
  180. _tableHeadView.backgroundColor = [UIColor clearColor];
  181. self.tableView.tableHeaderView = _tableHeadView;
  182. //我的空间
  183. _NASMySpaceV = [[NASMySpaceView alloc] init];
  184. [_tableHeadView addSubview:_NASMySpaceV];
  185. [_NASMySpaceV mas_makeConstraints:^(MASConstraintMaker *make) {
  186. //make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
  187. make.top.mas_equalTo(0);
  188. make.left.mas_equalTo(0);
  189. make.right.mas_equalTo(0);
  190. make.height.mas_equalTo(165);
  191. }];
  192. //常用功能
  193. _NASCommonUsedV = [[NASCommonUsedView alloc] init];
  194. [_tableHeadView addSubview:_NASCommonUsedV];
  195. [_NASCommonUsedV mas_makeConstraints:^(MASConstraintMaker *make) {
  196. make.top.equalTo(_NASMySpaceV.mas_bottom).offset(15);
  197. make.left.mas_equalTo(0);
  198. make.right.mas_equalTo(0);
  199. make.height.mas_equalTo(120);
  200. }];
  201. //最近文件
  202. [_tableHeadView addSubview:self.NASLastFileV];
  203. [self.NASLastFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  204. make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
  205. make.left.mas_equalTo(0);
  206. make.right.mas_equalTo(0);
  207. make.height.mas_equalTo(54);
  208. }];
  209. BOOL isShowLastFileType = [HWDataManager getBoolWithKey:Const_last_file_show];
  210. self.NASLastFileV.eyeButton.selected = !isShowLastFileType;
  211. //tableFooterView
  212. NSString *text = NSLocalizedString(@"NAS_bottom_tip",nil);
  213. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 50)];
  214. label.text = [[NSString alloc] initWithFormat:@"- %@ -",text];
  215. label.textColor = [UIColor hwColor:@"#959799"];
  216. label.font = [UIFont systemFontOfSize:12];
  217. label.textAlignment = NSTextAlignmentCenter;
  218. self.tableView.tableFooterView = label;
  219. KWeakSelf
  220. _NASMySpaceV.didClickButtonFun = ^(NSInteger tag) {
  221. [weakSelf didClickMySpaceFunBy:tag];
  222. };
  223. _NASCommonUsedV.didClickButtonFun = ^(NSInteger tag) {
  224. [weakSelf didClickCommonUsedFunBy:tag];
  225. };
  226. self.NASLastFileV.didClickButtonFun = ^(NSInteger tag) {
  227. [weakSelf didClickLastFileFunBy:tag];
  228. };
  229. [self setMySpaceDataFun];
  230. }
  231. #pragma mark - 懒加载
  232. - (UITableView *)tableView{
  233. if (!_tableView) {
  234. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
  235. _tableView.delegate = self;
  236. _tableView.dataSource = self;
  237. _tableView.showsVerticalScrollIndicator = NO;
  238. _tableView.showsHorizontalScrollIndicator = NO;
  239. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  240. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  241. [_tableView setSeparatorColor:[UIColor clearColor]];
  242. //[_tableView setBackgroundColor:[UIColor hwColor:@"#FFFFFF"]];
  243. [_tableView setBackgroundColor:[UIColor clearColor]];
  244. //[_tableView setTableFooterView:[UIView new]];
  245. [_tableView setBounces:YES];
  246. if (@available(iOS 15.0, *)) {
  247. _tableView.sectionHeaderTopPadding = 0;
  248. }
  249. _tableView.layer.cornerRadius = 8;
  250. _tableView.layer.masksToBounds = YES;
  251. }
  252. return _tableView;
  253. }
  254. - (NASLastFileView*)NASLastFileV
  255. {
  256. if(!_NASLastFileV){
  257. _NASLastFileV = [NASLastFileView new];
  258. }
  259. return _NASLastFileV;
  260. }
  261. #pragma mark - 列表委托
  262. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  263. return 1;
  264. }
  265. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  266. if(!_lastFileDataArr){
  267. return 0;
  268. }
  269. return _lastFileDataArr.count;
  270. }
  271. - (lastFileTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  272. __block NSInteger row = indexPath.row;
  273. static NSString *identifier = @"lastFileTableViewCell";
  274. lastFileTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  275. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  276. if (!cell){
  277. cell = [[lastFileTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  278. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  279. [cell setBackgroundColor:[UIColor clearColor]];
  280. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  281. [cell hideCheckButtonBy:YES];
  282. }
  283. if(row < _lastFileDataArr.count){
  284. lastFileModel* dataModel = _lastFileDataArr[row];
  285. cell.curLastFileModel = dataModel;
  286. // KWeakSelf
  287. // cell.didClickSwitch = ^(BOOL SwitchOn) {
  288. // //[weakSelf userCheckFilePreviewByRow:row];
  289. // };
  290. cell.cellBgView.layer.mask = nil;
  291. if(row == _lastFileDataArr.count -1){
  292. /*下圆角*/
  293. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-32 , 84)
  294. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  295. cornerRadii:CGSizeMake(12, 12)];
  296. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  297. maskLayer.frame = cell.cellBgView.bounds;
  298. maskLayer.path = maskPath.CGPath;
  299. cell.cellBgView.layer.mask = maskLayer;
  300. }
  301. }
  302. return cell;
  303. }
  304. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  305. return 84;
  306. }
  307. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  308. {
  309. NSInteger row = indexPath.row;
  310. if(row < _lastFileDataArr.count){
  311. lastFileModel* dataModel = _lastFileDataArr[row];
  312. if([dataModel.type isEqualToString:@"video"]){
  313. videoPlayByAVPlayerViewController *vc = [videoPlayByAVPlayerViewController new];
  314. vc.VideoDataMode = (NASFileAndFolderDataModel*)dataModel;
  315. [self.navigationController pushViewController:vc animated:YES];
  316. }
  317. else if([dataModel.type isEqualToString:@"audio"]){
  318. // NSMutableArray *audioDataArr = [NSMutableArray new];
  319. // NSInteger index = 0;
  320. //
  321. // for (int i=0; i<_lastFileDataArr.count; i++) {
  322. // lastFileModel* audioDataModel = _lastFileDataArr[i];
  323. // if([audioDataModel.type isEqualToString:@"audio"]){
  324. //
  325. // if(i == row){
  326. // index = audioDataArr.count;
  327. // }
  328. //
  329. // [audioDataArr addObject:audioDataModel];
  330. // }
  331. // }
  332. audioPlayerViewController *vc = [audioPlayerViewController new];
  333. vc.isfirstEnterType = YES;
  334. vc.outSideDataModel = (NASFileAudioDataModel *)dataModel;
  335. [self.navigationController pushViewController:vc animated:YES];
  336. KWeakSelf
  337. vc.didNeedDeleteFile = ^(NSString * _Nonnull filePath) {
  338. [weakSelf getLastFileDataFun];
  339. };
  340. }
  341. else if([dataModel.type containsString:@"jpg"]){
  342. NSMutableArray *jpgDataArr = [NSMutableArray new];
  343. NSInteger index = 0;
  344. for (int i=0; i<_lastFileDataArr.count; i++) {
  345. lastFileModel* jpgDataModel = _lastFileDataArr[i];
  346. if([jpgDataModel.type containsString:@"jpg"]){
  347. if(i == row){
  348. index = jpgDataArr.count;
  349. }
  350. [jpgDataArr addObject:jpgDataModel];
  351. }
  352. }
  353. imageDetailsScrollViewController *vc = [imageDetailsScrollViewController new];
  354. vc.index = index;
  355. vc.totalDataArr = jpgDataArr;
  356. [self.navigationController pushViewController:vc animated:YES];
  357. vc.canShareType = canShareType;
  358. }
  359. }
  360. }
  361. #pragma mark 点击头部
  362. - (void)didClickHeadButtonFun:(UIButton*)but
  363. {
  364. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  365. {
  366. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  367. return;
  368. }
  369. NSInteger tag = but.tag;
  370. switch (tag) {
  371. case 1:
  372. {
  373. if(ksharedAppDelegate.DisabledFileTransferType){
  374. if(ksharedAppDelegate.isImageNewFor130){
  375. [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
  376. }
  377. else{
  378. [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
  379. }
  380. return;
  381. }
  382. [self userDidClickUploadViewFun];
  383. }
  384. break;
  385. case 2:
  386. {
  387. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  388. [self pushViewController:vc animated:YES];
  389. }
  390. break;
  391. default:
  392. break;
  393. }
  394. }
  395. #pragma mark 点击我的空间模块
  396. - (void)didClickMySpaceFunBy:(NSInteger)tag
  397. {
  398. // if(tag ==1 ){
  399. // if(!ksharedAppDelegate.cloudPhoneExtraFileListMod){
  400. // //链接了
  401. // tryLinkNum ++;
  402. // [[webSocketManager shareInstance] getExtraFilesListFun];
  403. //
  404. // if(tryLinkNum >= 3){
  405. // tryLinkNum = 0;
  406. // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
  407. // return;
  408. // }
  409. //
  410. // KWeakSelf
  411. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  412. // [weakSelf didClickMySpaceFunBy:tag];
  413. // });
  414. // return;
  415. // }
  416. // }
  417. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  418. {
  419. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  420. return;
  421. }
  422. // if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接
  423. // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
  424. // return;
  425. // }
  426. if(ksharedAppDelegate.DisabledFileTransferType){
  427. if(ksharedAppDelegate.isImageNewFor130){
  428. [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
  429. }
  430. else{
  431. [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
  432. }
  433. return;
  434. }
  435. tryLinkNum = 0;
  436. switch (tag)
  437. {
  438. case 1:
  439. {
  440. NASMySpaceViewController *vc = [NASMySpaceViewController new];
  441. [self pushViewController:vc animated:YES];
  442. }
  443. break;
  444. case 10:{
  445. previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new];
  446. vc.isPhotoType = YES;
  447. [self pushViewController:vc animated:YES];
  448. }
  449. break;
  450. case 11:{
  451. // previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new];
  452. // vc.isPhotoType = NO;
  453. // [self pushViewController:vc animated:YES];
  454. NasPreviewVideoViewController *vc = [NasPreviewVideoViewController new];
  455. [self pushViewController:vc animated:YES];
  456. }
  457. break;
  458. case 12:{
  459. previewAudioOrDocumentViewController *vc = [previewAudioOrDocumentViewController new];
  460. vc.isAudioType = YES;
  461. [self pushViewController:vc animated:YES];
  462. }
  463. break;
  464. case 13:{
  465. previewFileAndFolderViewController *vc = [previewFileAndFolderViewController new];
  466. [self pushViewController:vc animated:YES];
  467. }
  468. break;
  469. default:
  470. break;
  471. }
  472. }
  473. #pragma mark 点击常用模块模块
  474. - (void)didClickCommonUsedFunBy:(NSInteger)tag
  475. {
  476. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  477. {
  478. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  479. return;
  480. }
  481. // if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接
  482. // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
  483. // return;
  484. // }
  485. switch (tag)
  486. {
  487. case 10:{
  488. backupsOptionViewController *vc = [backupsOptionViewController new];
  489. [self pushViewController:vc animated:YES];
  490. }
  491. break;
  492. case 11:
  493. {
  494. // if(!ksharedAppDelegate.isWebSockLinkOKAginType){
  495. // [[iToast makeText:NSLocalizedString(@"check_could_phone_state",nil)] show];
  496. // return;
  497. // }
  498. fileTransfeSetViewController *nextVC = [fileTransfeSetViewController new];
  499. [self pushViewController:nextVC animated:YES];
  500. }
  501. break;
  502. case 12:{
  503. shareRecordViewController *vc = [shareRecordViewController new];
  504. [self pushViewController:vc animated:YES];
  505. [self.NASCommonUsedV setRedPointShow:NO];
  506. [self updateShareBeMarkFun];
  507. }
  508. break;
  509. default:
  510. break;
  511. }
  512. }
  513. #pragma mark 点击最近文件模块
  514. - (void)didClickLastFileFunBy:(NSInteger)tag
  515. {
  516. if(tag == 2){
  517. [self getLastFileDataFun];
  518. }
  519. else if (tag ==1){
  520. nasLastFileViewController *vc = [nasLastFileViewController new];
  521. [self pushViewController:vc animated:YES];
  522. }
  523. }
  524. #pragma mark 用户点击上传文件
  525. - (void)userDidClickUploadViewFun
  526. {
  527. [self hideTabbarFun];
  528. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  529. [self.view addSubview:previewToUploadFileV];
  530. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  531. make.left.mas_equalTo(0);
  532. make.right.mas_equalTo(0);
  533. make.bottom.mas_equalTo(10);
  534. make.top.mas_equalTo(0);
  535. }];
  536. KWeakSelf
  537. previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
  538. [weakSelf gotoUploadFileFunWith:tag];
  539. };
  540. previewToUploadFileV.didClickCloseFun = ^{
  541. [weakSelf showTabbarFun];
  542. };
  543. }
  544. #pragma mark 调整文件上传
  545. - (void)gotoUploadFileFunWith:(NSInteger)tag
  546. {
  547. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  548. if(tag ==10){
  549. vc.isPhotoType = YES;
  550. }
  551. else{
  552. vc.isPhotoType = NO;
  553. }
  554. [self pushViewController:vc animated:YES];
  555. }
  556. #pragma mark 获取到云机磁盘相关信息
  557. - (void)getExtraFilesDoneFun:(NSNotification*)not
  558. {
  559. // mainBlock(^{
  560. // [self setMySpaceDataFun];
  561. // });
  562. [self getExtraFilesByFrpHttpFun];
  563. }
  564. #pragma mark 走frp方案 获取云机磁盘信息
  565. - (void)getExtraFilesByFrpHttpFun
  566. {
  567. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  568. KWeakSelf
  569. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getExtra" Parameters:paraDict success:^(id _Nonnull responseObject) {
  570. cloudPhoneExtraFileListModel *model = [[cloudPhoneExtraFileListModel alloc] initWithDictionary:responseObject error:nil];
  571. if(model && model.status == 0){
  572. ksharedAppDelegate.cloudPhoneExtraFileListMod = model;
  573. [weakSelf setMySpaceDataFun];
  574. }
  575. } failure:^(NSError * _Nonnull error) {
  576. [weakSelf setMySpaceDataFun];
  577. }];
  578. }
  579. #pragma mark 设置我的空间信息
  580. - (void)setMySpaceDataFun
  581. {
  582. if(ksharedAppDelegate.cloudPhoneExtraFileListMod){
  583. [_NASMySpaceV setProgressFun];
  584. }
  585. else{
  586. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  587. //[self setMySpaceDataFun];
  588. [self getExtraFilesByFrpHttpFun];
  589. });
  590. }
  591. }
  592. - (void)viewWillAppear:(BOOL)animated{
  593. [super viewWillAppear:animated];
  594. [self getLastFileDataFun];
  595. [self queryShareSwitchFunFun];
  596. [self queryShareBeMarkFun];
  597. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  598. [self checkFileTransferTask];
  599. });
  600. //[self beginShowAlertFun];
  601. [self handelAudioPlayingViewFun];
  602. [self showTabbarFun];
  603. //尝试修复偶现获取不到磁盘空间问题
  604. [self getExtraFilesByFrpHttpFun];
  605. }
  606. - (void)viewWillDisappear:(BOOL)animated{
  607. [super viewWillDisappear:animated];
  608. }
  609. - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated
  610. {
  611. [self.navigationController pushViewController:vc animated:animated];
  612. //[self hideTabbarFun];
  613. }
  614. - (void)showTabbarFun
  615. {
  616. // 显示 tab bar
  617. self.tabBarController.tabBar.hidden = NO;
  618. }
  619. - (void)hideTabbarFun
  620. {
  621. // 隐藏 tab bar
  622. self.tabBarController.tabBar.hidden = YES;
  623. }
  624. #pragma mark 获取最近文件数据
  625. - (void)getLastFileDataFun
  626. {
  627. _lastFileDataArr = [lastFileManager shareManager].lastFileListArr;
  628. //HLog(@"%@",_lastFileDataArr);
  629. BOOL isShowLastFileType = [HWDataManager getBoolWithKey:Const_last_file_show];
  630. if(!isShowLastFileType){
  631. _tableHeadView.frame = CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +54 + 15);
  632. [self.NASLastFileV mas_remakeConstraints:^(MASConstraintMaker *make) {
  633. make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
  634. make.left.mas_equalTo(0);
  635. make.right.mas_equalTo(0);
  636. make.height.mas_equalTo(54);
  637. }];
  638. self.NASLastFileV.notDataImageV.hidden = YES;
  639. self.NASLastFileV.notDataLabel.hidden = YES;
  640. //全圆角
  641. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-32 , 54)
  642. byRoundingCorners:UIRectCornerAllCorners
  643. cornerRadii:CGSizeMake(12, 12)];
  644. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  645. maskLayer.frame = self.NASLastFileV.bounds;
  646. maskLayer.path = maskPath.CGPath;
  647. self.NASLastFileV.whiteBgView.layer.mask = nil;
  648. self.NASLastFileV.whiteBgView.layer.mask = maskLayer;
  649. _lastFileDataArr = [NSMutableArray new];
  650. }
  651. else if(_lastFileDataArr.count > 0){
  652. _tableHeadView.frame = CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +54 + 15);
  653. [self.NASLastFileV mas_remakeConstraints:^(MASConstraintMaker *make) {
  654. make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
  655. make.left.mas_equalTo(0);
  656. make.right.mas_equalTo(0);
  657. make.height.mas_equalTo(54);
  658. }];
  659. self.NASLastFileV.notDataImageV.hidden = YES;
  660. self.NASLastFileV.notDataLabel.hidden = YES;
  661. /*上圆角*/
  662. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W- 32 , 54)
  663. byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight
  664. cornerRadii:CGSizeMake(12, 12)];
  665. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  666. maskLayer.frame = CGRectMake(0, 0, SCREEN_W -32, 54);
  667. maskLayer.path = maskPath.CGPath;
  668. self.NASLastFileV.whiteBgView.layer.mask = nil;
  669. self.NASLastFileV.whiteBgView.layer.mask = maskLayer;
  670. }
  671. else{
  672. _tableHeadView.frame = CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +254 + 15);
  673. [self.NASLastFileV mas_remakeConstraints:^(MASConstraintMaker *make) {
  674. make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
  675. make.left.mas_equalTo(0);
  676. make.right.mas_equalTo(0);
  677. make.height.mas_equalTo(254);
  678. }];
  679. self.NASLastFileV.notDataImageV.hidden = NO;
  680. self.NASLastFileV.notDataLabel.hidden = NO;
  681. //全圆角
  682. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-32 , 254)
  683. byRoundingCorners:UIRectCornerAllCorners
  684. cornerRadii:CGSizeMake(12, 12)];
  685. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  686. maskLayer.frame = self.NASLastFileV.bounds;
  687. maskLayer.path = maskPath.CGPath;
  688. self.NASLastFileV.whiteBgView.layer.mask = nil;
  689. self.NASLastFileV.whiteBgView.layer.mask = maskLayer;
  690. }
  691. KWeakSelf
  692. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  693. [weakSelf.tableView reloadData];
  694. });
  695. }
  696. #pragma mark 获取分享开关
  697. -(void)queryShareSwitchFunFun
  698. {
  699. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  700. [paraDict setValue:@7 forKey:@"type"];
  701. //KWeakSelf
  702. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
  703. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  704. if(queryShareMod){
  705. self->canShareType = queryShareMod.data.configValue;
  706. //[weakSelf.curEditTypeBottomView setCanShaewFunBy:queryShareMod.data.configValue];
  707. }
  708. } failure:^(NSError * _Nonnull error) {
  709. }];
  710. }
  711. - (void)checkFileTransferTask
  712. {//有个偶现的闪退在BGFMDB
  713. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  714. self->hadUploadTaskType = isSuccess;
  715. [self setRightButtonRedTypeFun];
  716. }];
  717. KWeakSelf
  718. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  719. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  720. self->hadDownloadTaskType = isSuccess;
  721. [weakSelf setRightButtonRedTypeFun];
  722. }];
  723. });
  724. }
  725. - (void)setRightButtonRedTypeFun
  726. {
  727. mainBlock(^{
  728. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  729. self->rightRedView.hidden = NO;
  730. }
  731. else{
  732. self->rightRedView.hidden = YES;
  733. }
  734. });
  735. }
  736. #pragma mark 是否有新的分享被封禁
  737. -(void)queryShareBeMarkFun
  738. {
  739. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  740. KWeakSelf
  741. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareReportMarkFun Parameters:paraDict success:^(id _Nonnull responseObject){
  742. queryShareReportMarkModel *ShareMarkMod = [[queryShareReportMarkModel alloc] initWithDictionary:responseObject error:nil];
  743. if(ShareMarkMod){
  744. [weakSelf.NASCommonUsedV setRedPointShow:ShareMarkMod.data.reportMark];
  745. }
  746. } failure:^(NSError * _Nonnull error) {
  747. }];
  748. }
  749. #pragma mark 修改分享被封禁的mark状态()
  750. -(void)updateShareBeMarkFun
  751. {
  752. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  753. //KWeakSelf
  754. [[netWorkManager shareInstance] CommonPostCallBackCode:updateShareReportMarkFun Parameters:paraDict success:^(id _Nonnull responseObject){
  755. // SuperModel *ShareMarkMod = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  756. // if(ShareMarkMod){
  757. //
  758. // }
  759. } failure:^(NSError * _Nonnull error) {
  760. }];
  761. }
  762. #pragma mark 弹框流程
  763. //优先级:1.强制盒子更新弹窗
  764. // 2.APP版本更新弹窗 > 新手引导弹窗 > 通知公告弹窗
  765. - (void)beginShowAlertFun
  766. {
  767. //1.隐私模式密码界面 3秒检测一次是否输入完成密码了
  768. if(!ksharedAppDelegate.isFirstInputPwdDone){
  769. KWeakSelf
  770. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  771. [weakSelf beginShowAlertFun];
  772. });
  773. return;
  774. }
  775. // 强制盒子更新弹窗
  776. [self checkUpgradeInfoFun];
  777. }
  778. #pragma mark 弹框流程 1 检测盒子镜像更新弹窗->1.4.4改为从服务器请求
  779. - (void)checkUpgradeInfoFun
  780. {
  781. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  782. [paraDict setValue:@"ota" forKey:@"type"];
  783. KWeakSelf
  784. [[netWorkManager shareInstance] CommonPostCallBackCode:queryUpgradeInfo Parameters:paraDict success:^(id _Nonnull responseObject) {
  785. UpgradeInfoModel *model = [[UpgradeInfoModel alloc] initWithDictionary:responseObject error:nil];
  786. if (model && model.status == 0) {
  787. weakSelf.otaUpgradeInfoModel = model;
  788. [weakSelf handelUpgradeInfoFun];
  789. }
  790. else
  791. {
  792. //2. APP版本更新弹窗
  793. [weakSelf checkVersionFun];
  794. }
  795. } failure:^(NSError * _Nonnull error) {
  796. KWeakSelf
  797. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  798. [weakSelf checkUpgradeInfoFun];
  799. });
  800. }];
  801. }
  802. #pragma mark 弹框流程 1 强制盒子更新弹窗
  803. - (void)handelUpgradeInfoFun
  804. {
  805. //self.otaUpgradeInfoModel.data.status = 201;
  806. if(self.otaUpgradeInfoModel.data.status < 1){ //-1=没有更新 0=下载中
  807. //2. APP版本更新弹窗
  808. [self checkVersionFun];
  809. }
  810. else{
  811. KWeakSelf
  812. if(self.otaUpgradeInfoModel.data.status < 6){
  813. [self showImageViewRenewTipViewFun];
  814. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  815. [weakSelf checkUpgradeInfoFun];
  816. });
  817. }
  818. else if(self.otaUpgradeInfoModel.data.status == 6){//升级完成
  819. if(RenewTipView){
  820. [self showImageViewRenewTipViewFun];
  821. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  822. [weakSelf OTAUpdateDoneFun];
  823. });
  824. }
  825. else{
  826. [self OTAUpdateDoneFun];
  827. }
  828. }
  829. else if(self.otaUpgradeInfoModel.data.status == 201){//升级失败
  830. //显示升级失败
  831. [self OTAUpdateFailFun];
  832. }
  833. else{
  834. //2. APP版本更新弹窗
  835. [self checkVersionFun];
  836. }
  837. }
  838. }
  839. #pragma mark 弹框流程 1 强制盒子更新弹窗
  840. - (void)showImageViewRenewTipViewFun
  841. {
  842. //密码框界面 拦着 不给弹出
  843. if(ksharedAppDelegate.isDidShowPwdType){
  844. //didGetSysInfoType = NO;
  845. KWeakSelf
  846. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  847. [weakSelf showImageViewRenewTipViewFun];
  848. });
  849. return;
  850. }
  851. if(RenewTipView){
  852. RenewTipView.status = _otaUpgradeInfoModel.data.status;
  853. return;
  854. }
  855. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
  856. CGFloat second = 0.1;
  857. if(haveOpenMask){
  858. second = 1.5;
  859. [[NSNotificationCenter defaultCenter] postNotificationName:needToPoPCloudPhoneVCNotification object:nil];
  860. }
  861. KWeakSelf
  862. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(second * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  863. self->RenewTipView = [[imageVersionRenewTipView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  864. [ksharedAppDelegate.window addSubview:self->RenewTipView];
  865. self->RenewTipView.status = self->_otaUpgradeInfoModel.data.status;
  866. //[self.view bringSubviewToFront:RenewTipView];
  867. self->RenewTipView.didClickUpdateNowFun = ^{
  868. [weakSelf otaUpdateNowFun];
  869. };
  870. self->RenewTipView.didClickCloseFun = ^{
  871. [weakSelf didClickRenewTipViewCloseFun];
  872. };
  873. });
  874. }
  875. - (void)didClickRenewTipViewCloseFun{
  876. RenewTipView = nil;
  877. }
  878. #pragma mark 弹框流程 1 盒子更新弹窗 点击立即更新
  879. - (void)otaUpdateNowFun
  880. {
  881. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  882. [paraDict setValue:@"ota" forKey:@"type"];
  883. [paraDict setValue:@2 forKey:@"status"];
  884. KWeakSelf
  885. [[netWorkManager shareInstance] CommonPostCallBackCode:upgradeDetailAdd Parameters:paraDict success:^(id _Nonnull responseObject) {
  886. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  887. if (model && model.status == 0) {
  888. [weakSelf checkUpgradeInfoFun];
  889. }
  890. else
  891. {
  892. [weakSelf checkVersionFun];
  893. }
  894. } failure:^(NSError * _Nonnull error) {
  895. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  896. [weakSelf otaUpdateNowFun];
  897. });
  898. }];
  899. }
  900. #pragma mark 弹框流程 1 OTA升级完成
  901. - (void)OTAUpdateDoneFun
  902. {
  903. //密码框界面 拦着 不给弹出
  904. if(ksharedAppDelegate.isDidShowPwdType){
  905. KWeakSelf
  906. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  907. [weakSelf OTAUpdateDoneFun];
  908. });
  909. return;
  910. }
  911. if(RenewTipView){
  912. [RenewTipView removeFromSuperview];
  913. RenewTipView = nil;
  914. }
  915. if (imageVersionUpdateDoneV) {
  916. [imageVersionUpdateDoneV removeFromSuperview];
  917. imageVersionUpdateDoneV = nil;
  918. }
  919. //显示OTA完成页面
  920. imageVersionUpdateDoneV = [[imageVersionUpdateDoneView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  921. [ksharedAppDelegate.window addSubview:imageVersionUpdateDoneV];
  922. //[self.view bringSubviewToFront:curView];
  923. KWeakSelf
  924. imageVersionUpdateDoneV.didClickUpdateDoneFun = ^{
  925. [weakSelf closeOTAUpdateDoneFun];
  926. };
  927. }
  928. #pragma mark 弹框流程 1 OTA升级失败
  929. - (void)OTAUpdateFailFun
  930. {
  931. //密码框界面 拦着 不给弹出
  932. if(ksharedAppDelegate.isDidShowPwdType){
  933. KWeakSelf
  934. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  935. [weakSelf OTAUpdateFailFun];
  936. });
  937. return;
  938. }
  939. if(RenewTipView){
  940. [RenewTipView removeFromSuperview];
  941. RenewTipView = nil;
  942. }
  943. if (imageVersionUpdateFailV) {
  944. [imageVersionUpdateFailV removeFromSuperview];
  945. imageVersionUpdateFailV = nil;
  946. }
  947. //显示OTA完成页面
  948. imageVersionUpdateFailV = [[imageVersionUpdateFailView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  949. [ksharedAppDelegate.window addSubview:imageVersionUpdateFailV];
  950. //[self.view bringSubviewToFront:curView];
  951. KWeakSelf
  952. imageVersionUpdateFailV.didClickUpdateDoneFun = ^{
  953. [weakSelf closeOTAUpdateDoneFun];
  954. };
  955. }
  956. #pragma mark 弹框流程 1 盒子更新弹窗 关闭弹窗
  957. - (void)closeOTAUpdateDoneFun
  958. {
  959. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  960. [paraDict setValue:@"ota" forKey:@"type"];
  961. [paraDict setValue:@1 forKey:@"popButton"];
  962. KWeakSelf
  963. [[netWorkManager shareInstance] CommonPostCallBackCode:updateOTAPopButton Parameters:paraDict success:^(id _Nonnull responseObject) {
  964. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  965. if (model && model.status == 0) {
  966. }
  967. else
  968. {
  969. }
  970. [weakSelf checkVersionFun];
  971. } failure:^(NSError * _Nonnull error) {
  972. [weakSelf checkVersionFun];
  973. }];
  974. }
  975. #pragma mark 弹框流程 2 APP版本更新弹窗
  976. - (void)checkVersionFun
  977. {
  978. [self getVersion];
  979. }
  980. #pragma mark- 网络请求
  981. - (void)getVersion {
  982. //密码框界面 拦着 不给弹出
  983. if(!ksharedAppDelegate.isFirstInputPwdDone){
  984. return;
  985. }
  986. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  987. [paraDict setValue:@"ios" forKey:@"type"];
  988. [paraDict setValue:@"skyworth" forKey:@"source"];
  989. [[netWorkManager shareInstance] CommonGetWithCallBackCode:upgradeNewVersion Parameters:paraDict success:^(id _Nonnull responseObject) {
  990. //HLog(@"%@", responseObject);
  991. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  992. if (model && model.status == 0) {
  993. HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
  994. [self checkVersion:model];
  995. }
  996. else
  997. {
  998. [self checkVersion:nil];
  999. }
  1000. } failure:^(NSError * _Nonnull error) {
  1001. HLog(@"%@", error);
  1002. [self checkVersion:nil];
  1003. }];
  1004. }
  1005. - (void)checkVersion:(HWVersionModel*)versionModel {
  1006. if(!versionModel){//版本信息错误 检测新手弹框流程
  1007. [self showNewerGuideFun];
  1008. return;
  1009. }
  1010. // NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
  1011. NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
  1012. NSString *newVersion = [versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
  1013. newVersion = [newVersion stringByReplacingOccurrencesOfString:@"V" withString:@""]; //去掉v
  1014. //HLog(@"%@---%@", newVersion, currentVersion);
  1015. if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
  1016. [self showNewerGuideFun];
  1017. }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
  1018. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  1019. [self showNewerGuideFun];
  1020. }else { // 本地版本号 < 服务器版本号 (有新版本)
  1021. [self showNewVersion:versionModel];
  1022. [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
  1023. };
  1024. }
  1025. - (void)showNewVersion:(HWVersionModel*)versionModel {
  1026. HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
  1027. if (haveNewVersionView.isShow) {
  1028. return;
  1029. }
  1030. //此版本点击过稍后再试
  1031. NSString *preVersionstr = [HWDataManager getStringWithKey:Const_did_show_version_and_click_wait];
  1032. if(preVersionstr && [versionModel.versionNumber isEqualToString:preVersionstr]){
  1033. [self showNewerGuideFun];
  1034. return;
  1035. }
  1036. haveNewVersionView.versionModel = versionModel;
  1037. haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
  1038. [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
  1039. [ksharedAppDelegate.window addSubview:haveNewVersionView];
  1040. haveNewVersionView.isShow = YES;
  1041. if(!versionModel.necessary){
  1042. haveNewVersionView.deleteBtn.hidden = NO;
  1043. }
  1044. [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
  1045. make.top.mas_equalTo(0);
  1046. make.left.mas_equalTo(0);
  1047. make.right.mas_equalTo(0);
  1048. make.bottom.mas_equalTo(0);
  1049. }];
  1050. haveNewVersionView.alpha = 0.0;
  1051. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  1052. haveNewVersionView.alpha = 1.0;
  1053. KyoLog(@"in animate start");
  1054. } completion:^(BOOL finished) {
  1055. KyoLog(@"in animate completion");
  1056. }];
  1057. KWeakSelf
  1058. haveNewVersionView.closeViewFun = ^{
  1059. [weakSelf showNewerGuideFun];
  1060. };
  1061. }
  1062. #pragma mark 弹框流程 3 新手引导弹窗
  1063. - (void)showNewerGuideFun
  1064. {
  1065. BOOL didShow = [HWDataManager getBoolWithKey:@"Const_did_show_newer_Guide"];
  1066. if(didShow){
  1067. [self getLastNoticeFun];
  1068. return;
  1069. }
  1070. //密码框界面 拦着 不给弹出
  1071. if(ksharedAppDelegate.isDidShowPwdType){
  1072. KWeakSelf
  1073. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1074. [weakSelf showNewerGuideFun];
  1075. });
  1076. return;
  1077. }
  1078. newerGuideView *guideView = [[newerGuideView alloc] init];
  1079. [ksharedAppDelegate.window addSubview:guideView];
  1080. [guideView mas_makeConstraints:^(MASConstraintMaker *make) {
  1081. make.top.mas_equalTo(0);
  1082. make.left.mas_equalTo(0);
  1083. make.right.mas_equalTo(0);
  1084. make.bottom.mas_equalTo(0);
  1085. }];
  1086. KWeakSelf
  1087. guideView.didClickButtonFun = ^(NSInteger tag) {
  1088. [weakSelf didiClickNewerButtonFunBy:tag];
  1089. };
  1090. }
  1091. #pragma mark 新手引导点击事件
  1092. - (void)didiClickNewerButtonFunBy:(NSInteger)tag
  1093. {
  1094. [HWDataManager setBoolWithKey:@"Const_did_show_newer_Guide" value:YES];
  1095. if(tag ==1){
  1096. [self getLastNoticeFun];
  1097. }
  1098. else if(tag ==2 || tag == 10){
  1099. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  1100. vc.titleStr = NSLocalizedString(@"mine_newuser_title",nil);
  1101. NSString *url = [[NSString alloc] initWithFormat:@"%@/warrantyService/index.html#/novice?isNovice=true",CloudService];
  1102. if(tag == 10){
  1103. url = [url stringByReplacingOccurrencesOfString:@"?isNovice=true" withString:@""];
  1104. }
  1105. vc.webUrl = url;
  1106. [self pushViewController:vc animated:YES];
  1107. KWeakSelf
  1108. vc.didClickBackFun = ^{
  1109. [weakSelf getLastNoticeFun];
  1110. };
  1111. }
  1112. }
  1113. #pragma mark 弹框流程 4 通知公告弹窗
  1114. - (void)getLastNoticeFun
  1115. {
  1116. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  1117. [paraDict setValue:@"Private-X" forKey:@"productType"];
  1118. [paraDict setValue:@"ios" forKey:@"type"];
  1119. [[netWorkManager shareInstance] CommonPostCallBackCode:queryOneNotice Parameters:paraDict success:^(id _Nonnull responseObject) {
  1120. noticeModel *model = [[noticeModel alloc] initWithDictionary:responseObject error:nil];
  1121. //test code
  1122. // model.status = 0;
  1123. // model.data = [noticeDataModel new];
  1124. // model.data.curNoticeId = @"1111";
  1125. // model.data.title = @"版本升级通知公告";
  1126. // model.data.content = @"1.偶现挤下线问题";
  1127. // 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.进入设置页面读取数据偶现闪退!!!!";
  1128. if (model && model.data && model.status == 0) {
  1129. [self showHaveNoticeViewBy:model];
  1130. }
  1131. else
  1132. {
  1133. }
  1134. } failure:^(NSError * _Nonnull error) {
  1135. HLog(@"%@", error);
  1136. }];
  1137. }
  1138. - (void)showHaveNoticeViewBy:(noticeModel*)model
  1139. {
  1140. //密码框界面 拦着 不给弹出
  1141. if(ksharedAppDelegate.isDidShowPwdType){
  1142. KWeakSelf
  1143. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1144. [weakSelf showHaveNoticeViewBy:model];
  1145. });
  1146. return;
  1147. }
  1148. HaveNoticeView * noticeView = [HaveNoticeView shardInstance];
  1149. NSString * preShowID = [HWDataManager getStringWithKey:Const_did_show_Notice_ID];
  1150. if(noticeView.isShow
  1151. || !model
  1152. || [preShowID isEqualToString:model.data.curNoticeId]){
  1153. return;
  1154. }
  1155. noticeView.curNoticeModel = model;
  1156. //异常处理
  1157. if(![iTools getKeyWindow]){
  1158. return;
  1159. }
  1160. [[iTools getKeyWindow] addSubview:noticeView];
  1161. [noticeView mas_makeConstraints:^(MASConstraintMaker *make) {
  1162. make.top.mas_equalTo(0);
  1163. make.left.mas_equalTo(0);
  1164. make.right.mas_equalTo(0);
  1165. make.bottom.mas_equalTo(0);
  1166. }];
  1167. noticeView.alpha = 0.0;
  1168. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  1169. noticeView.alpha = 1.0;
  1170. } completion:^(BOOL finished) {
  1171. }];
  1172. }
  1173. #pragma mark 处理音频播放中的视图状态
  1174. - (void)handelAudioPlayingViewFun
  1175. {
  1176. audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  1177. if([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
  1178. ||[DFPlayer sharedPlayer].state == DFPlayerStatePlaying
  1179. ||[DFPlayer sharedPlayer].state == DFPlayerStatePause){//播放中
  1180. [self showAudioPlayingViewFun];
  1181. }
  1182. else{
  1183. [self hideAudioPlayingViewFun];
  1184. }
  1185. KWeakSelf
  1186. audioPlayingV.didClickButtonFun = ^(NSInteger tag) {
  1187. if(tag == 1){
  1188. [weakSelf hideAudioPlayingViewFun];
  1189. }
  1190. else if(tag == 5){
  1191. [weakSelf AudioPlayingGotoAudioPlayerVCFun];
  1192. }
  1193. };
  1194. }
  1195. - (void)AudioPlayingGotoAudioPlayerVCFun{
  1196. audioPlayerViewController *vc = [audioPlayerViewController new];
  1197. vc.isfirstEnterType = NO;
  1198. [self.navigationController pushViewController:vc animated:YES];
  1199. }
  1200. #pragma mark 显示音频播放中的视图
  1201. - (void)showAudioPlayingViewFun
  1202. {
  1203. audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  1204. [self.view addSubview:audioPlayingV];
  1205. if([DFPlayer sharedPlayer].state == DFPlayerStatePlaying){
  1206. [audioPlayingV startRotatingImage];
  1207. }
  1208. else if ([DFPlayer sharedPlayer].state == DFPlayerStatePause){
  1209. [audioPlayingV stopRotatingImage];
  1210. }
  1211. [audioPlayingV mas_makeConstraints:^(MASConstraintMaker *make) {
  1212. make.height.mas_equalTo(49);
  1213. make.left.mas_equalTo(0);
  1214. make.right.mas_equalTo(0);
  1215. make.bottom.mas_equalTo(-TABBARHEIGHT);
  1216. }];
  1217. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  1218. make.left.mas_equalTo(0);
  1219. make.right.mas_equalTo(0);
  1220. make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
  1221. make.bottom.mas_equalTo(-TABBARHEIGHT -49);
  1222. }];
  1223. }
  1224. #pragma mark 隐藏音频播放中的视图
  1225. - (void)hideAudioPlayingViewFun
  1226. {
  1227. // audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  1228. // [audioPlayingV removeFromSuperview];
  1229. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  1230. make.left.mas_equalTo(0);
  1231. make.right.mas_equalTo(0);
  1232. make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
  1233. make.bottom.mas_equalTo(-TABBARHEIGHT);
  1234. }];
  1235. }
  1236. - (void)applicationDidBecomeActive:(NSNotification *)notification
  1237. {
  1238. [self beginShowAlertFun];
  1239. }
  1240. @end