NASViewController.m 49 KB

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