NASViewController.m 49 KB

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