previewFileAndFolderSecondViewController.m 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. //
  2. // previewFileAndFolderSecondViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/5/21.
  6. //
  7. #import "previewFileAndFolderSecondViewController.h"
  8. #import "couldPhoneFileListModel.h"
  9. #import "downloadManager.h"
  10. #import "uploadFileRecordViewController.h"
  11. #import "UIScrollView+EmptyDataSet.h"
  12. #import "diskListBgView.h"
  13. #import "diskListTableView.h"
  14. #import "downLoadPreViewCell.h"
  15. #import "editTypeHeadView.h"
  16. #import "editTypeBottomView.h"
  17. #import "editShareView.h"
  18. #import "previewToUploadFileView.h"
  19. #import "netWorkManager.h"
  20. #import "videoPlayByAVPlayerViewController.h"
  21. #import "audioPlayerViewController.h"
  22. #import "imageDetailsScrollViewController.h"
  23. #import "searchBarThridTypeView.h"
  24. #import "NasSearchViewController.h"
  25. @interface previewFileAndFolderSecondViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
  26. {
  27. UIButton* rightTransferListButton;//传输列表
  28. UIView* rightRedView;
  29. BOOL hadUploadTaskType;
  30. BOOL hadDownloadTaskType;
  31. }
  32. @property (nonatomic, strong) UITableView *tableView;
  33. @property(nonatomic,assign) BOOL isEditType;
  34. @property(nonatomic,strong) editTypeHeadView*curEditTypeHeadView;
  35. @property(nonatomic,strong) editTypeBottomView*curEditTypeBottomView;
  36. @property(nonatomic,strong) searchBarThridTypeView* searchBarThridTypeV;//
  37. @property(nonatomic,strong) UIButton*uploadFileButton;
  38. @property (nonatomic, strong) NSMutableArray*didSelectListArr;//选中的数据
  39. @property (nonatomic, strong)NASFileAndFolderModel * curNASFileAudioMod;
  40. @end
  41. @implementation previewFileAndFolderSecondViewController
  42. - (void)viewDidLoad {
  43. [super viewDidLoad];
  44. // Do any additional setup after loading the view.
  45. [self.toolBar setHidden:YES];
  46. [self.navigationBar setHidden:YES];
  47. [self.navBarBGView setHidden:NO];
  48. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  49. [self.view setBackgroundColor:[UIColor whiteColor]];
  50. [self drawAnyView];
  51. _didSelectListArr = [NSMutableArray new];
  52. }
  53. - (void)drawAnyView{
  54. [self initNavHeadUIFun];
  55. _curEditTypeHeadView = [[editTypeHeadView alloc] init];
  56. _curEditTypeHeadView.hidden = YES;
  57. [self.navBarBGView addSubview:_curEditTypeHeadView];
  58. [_curEditTypeHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.left.mas_equalTo(0);
  60. make.right.mas_equalTo(0);
  61. make.bottom.mas_equalTo(0);
  62. make.height.mas_equalTo(NAVIHEIGHT - AdaptNaviHeight);
  63. }];
  64. #pragma mark 编辑状态的 取消 和全选按钮 响应事件
  65. KWeakSelf
  66. _curEditTypeHeadView.didClickButtonFun = ^(NSInteger tag) {
  67. if(tag==1){
  68. [weakSelf userCancelEditTypeFun];
  69. }
  70. };
  71. _curEditTypeHeadView.didClickSelectAllFun = ^(UIButton * _Nonnull but) {
  72. [weakSelf didClickSelectAllButton:but];
  73. };
  74. _curEditTypeBottomView = [[editTypeBottomView alloc] init];
  75. _curEditTypeBottomView.hidden = YES;
  76. [self.view addSubview:_curEditTypeBottomView];
  77. [_curEditTypeBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.left.mas_equalTo(0);
  79. make.right.mas_equalTo(0);
  80. make.bottom.mas_equalTo(0);
  81. make.height.mas_equalTo(60 + AdaptTabHeight);
  82. }];
  83. #pragma mark 编辑状态的 下载 分享 删除 响应事件
  84. _curEditTypeBottomView.didClickButtonFun = ^(NSInteger tag) {
  85. if(tag==1){
  86. [weakSelf gotoDownLoadFileFun];
  87. }
  88. else if(tag==2){
  89. [weakSelf gotoShareViewFun];
  90. }
  91. else if(tag==3){
  92. [weakSelf showDeleteAlearViewFun];
  93. }
  94. };
  95. _searchBarThridTypeV = [[searchBarThridTypeView alloc] init];
  96. [self.view addSubview:_searchBarThridTypeV];
  97. [_searchBarThridTypeV mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  99. make.height.mas_equalTo(32.0);
  100. make.left.mas_equalTo(20.0);
  101. //make.right.mas_equalTo(-48.0);
  102. make.right.mas_equalTo(-20.0);
  103. }];
  104. #pragma mark 点击搜索
  105. _searchBarThridTypeV.didClickBgFun = ^{
  106. [weakSelf gotoSearchVCFun];
  107. };
  108. [self.view addSubview:self.tableView];
  109. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  110. make.left.mas_equalTo(0);
  111. make.right.mas_equalTo(0);
  112. //make.bottom.mas_equalTo(-(safeArea));
  113. make.bottom.mas_equalTo(0);
  114. //make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  115. make.top.equalTo(self.searchBarThridTypeV.mas_bottom).offset(10.f);
  116. }];
  117. //大+号
  118. _uploadFileButton = [[UIButton alloc] init];
  119. [_uploadFileButton setBackgroundImage:[UIImage imageNamed:@"add_file_icon"] forState:UIControlStateNormal];
  120. [_uploadFileButton addTarget:self action:@selector(userDidClickUploadViewFun) forControlEvents:UIControlEventTouchUpInside];
  121. [self.view addSubview:_uploadFileButton];
  122. [_uploadFileButton mas_makeConstraints:^(MASConstraintMaker *make) {
  123. make.right.mas_equalTo(-15);
  124. make.width.mas_equalTo(52);
  125. make.height.mas_equalTo(52);
  126. make.bottom.mas_equalTo(-30 - AdaptTabHeight);
  127. }];
  128. }
  129. - (void)initNavHeadUIFun
  130. {
  131. rightTransferListButton = [[UIButton alloc] init];
  132. [rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  133. [rightTransferListButton addTarget:self action:@selector(didiClikRightButGotoTransferListFun:) forControlEvents:UIControlEventTouchUpInside];
  134. [self.navBarBGView addSubview:rightTransferListButton];
  135. [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) {
  136. make.width.mas_equalTo(40);
  137. make.height.mas_equalTo(40);
  138. make.right.mas_equalTo(-15);
  139. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  140. }];
  141. rightRedView = [[UIView alloc] init];
  142. rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
  143. [rightTransferListButton addSubview:rightRedView];
  144. rightRedView.layer.cornerRadius = 7;
  145. rightRedView.hidden = YES;
  146. [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
  147. make.width.mas_equalTo(14);
  148. make.height.mas_equalTo(14);
  149. make.right.mas_equalTo(0);
  150. make.top.mas_equalTo(6);
  151. }];
  152. }
  153. #pragma mark - 懒加载
  154. - (UITableView *)tableView{
  155. if (!_tableView) {
  156. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  157. _tableView.delegate = self;
  158. _tableView.dataSource = self;
  159. _tableView.showsVerticalScrollIndicator = NO;
  160. _tableView.showsHorizontalScrollIndicator = NO;
  161. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  162. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  163. [_tableView setSeparatorColor:[UIColor clearColor]];
  164. [_tableView setBackgroundColor:[UIColor clearColor]];
  165. [_tableView setTableFooterView:[UIView new]];
  166. [_tableView setBounces:YES];
  167. if (@available(iOS 15.0, *)) {
  168. _tableView.sectionHeaderTopPadding = 0;
  169. }
  170. //空数据引入第三方开源处理
  171. _tableView.emptyDataSetSource = self;
  172. _tableView.emptyDataSetDelegate = self;
  173. }
  174. return _tableView;
  175. }
  176. #pragma mark - 列表委托
  177. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  178. return 1;
  179. }
  180. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  181. if(!_curNASFileAudioMod){
  182. return 0;
  183. }
  184. return _curNASFileAudioMod.data.list.count;
  185. }
  186. - (downLoadPreViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  187. __block NSInteger row = indexPath.row;
  188. static NSString *identifier = @"downLoadPreViewCell";
  189. downLoadPreViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  190. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  191. if (!cell){
  192. cell = [[downLoadPreViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  193. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  194. [cell setBackgroundColor:[UIColor clearColor]];
  195. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  196. [cell.bgViewLayer removeFromSuperlayer];
  197. [cell.titleLabel2 setHidden:NO];
  198. [cell.rightImage setHidden:YES];
  199. [cell.lineView setHidden:YES];
  200. [cell.checkButton setHidden:NO];
  201. }
  202. if(row < _curNASFileAudioMod.data.list.count){
  203. NASFileAndFolderDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  204. cell.curNASFileAndFolderDataModel = dataModel;
  205. KWeakSelf
  206. cell.didClickSwitch = ^(BOOL SwitchOn) {
  207. //if([weakSelf userCheckFileModel:dataModel withShowTip:YES]){
  208. [weakSelf userCheckFilePreviewByRow:row];
  209. //}
  210. };
  211. }
  212. return cell;
  213. }
  214. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  215. return 70;
  216. }
  217. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  218. {
  219. NSInteger row = indexPath.row;
  220. if(row < _curNASFileAudioMod.data.list.count){
  221. NASFileAndFolderDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  222. if([dataModel.type isEqualToString:@"dir"])
  223. {
  224. previewFileAndFolderSecondViewController *vc = [previewFileAndFolderSecondViewController new];
  225. vc.curFolderDataModel = dataModel;
  226. vc.canShareType = _canShareType;
  227. [self.navigationController pushViewController:vc animated:YES];
  228. }
  229. else if([dataModel.type isEqualToString:@"video"]){
  230. videoPlayByAVPlayerViewController *vc = [videoPlayByAVPlayerViewController new];
  231. vc.VideoDataMode = dataModel;
  232. [self.navigationController pushViewController:vc animated:YES];
  233. KWeakSelf
  234. // vc.didNeedToRegetDataFun = ^{
  235. // [weakSelf getFileListFun];
  236. // };
  237. }
  238. else if([dataModel.type isEqualToString:@"audio"]){
  239. // NSMutableArray *dataArr = [NSMutableArray new];
  240. // [dataArr addObject:dataModel];
  241. audioPlayerViewController *vc = [audioPlayerViewController new];
  242. vc.isfirstEnterType = YES;
  243. vc.outSideDataModel = (NASFileAudioDataModel *)dataModel;
  244. [self.navigationController pushViewController:vc animated:YES];
  245. KWeakSelf
  246. vc.didNeedDeleteFile = ^(NSString * _Nonnull filePath) {
  247. };
  248. // vc.didNeedToRegetDataFun = ^{
  249. // [weakSelf getFileListFun];
  250. // };
  251. }
  252. else if([dataModel.type containsString:@"jpg"]){
  253. NSMutableArray *jpgDataArr = [NSMutableArray new];
  254. NSInteger index = 0;
  255. [jpgDataArr addObject:dataModel];
  256. imageDetailsScrollViewController *vc = [imageDetailsScrollViewController new];
  257. vc.index = index;
  258. vc.totalDataArr = jpgDataArr;
  259. [self.navigationController pushViewController:vc animated:YES];
  260. vc.canShareType = _canShareType;
  261. }
  262. }
  263. }
  264. #pragma mark 空数据
  265. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
  266. NSString *imageName = @"common_no_data_pic";
  267. return [UIImage imageNamed:imageName];
  268. }
  269. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  270. NSString *text = NSLocalizedString(@"common_no_data_tip",nil);
  271. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
  272. NSForegroundColorAttributeName: HW999999Color};
  273. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  274. }
  275. //调整图片位置
  276. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
  277. return -150;
  278. }
  279. //ios端:
  280. //1、需求说明:解决除MP4 MOV 3GP M4V 总计4种格式外,其他格式下载失败的问题;
  281. //2、交互说明:下载列表勾选文件中含有其他格式,toast提示“IOS系统仅支持MP4、MOV、3GP、M4V 的视频格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载MP4、MOV、3GP、M4V 的视频格式文件;
  282. //ios支持图片格式: (SVG 不支持)
  283. //需求说明:解决除JPG PNG GIF TIFF BMP总计5种格式外,其他格式下载失败的问题
  284. //视觉交互:选择文件中含有其他格式,toast提示“IOS系统仅支持JPG 、PNG、GIF、TIFF、BMP的图片格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载JPG 、PNG、GIF、TIFF、BMP的图片格式文件;
  285. - (BOOL)userCheckFileModel:(couldPhoneFileModel*)fileModel withShowTip:(BOOL)canShow{
  286. // NSString*name = [fileModel.name lowercaseString];
  287. // NSArray *nameArr = [name componentsSeparatedByString:@"."];
  288. // if(nameArr.count >0 && !_isAudioType){
  289. // BOOL canDownLoadType = NO;
  290. //
  291. // NSString *lastName = nameArr.lastObject;
  292. // if([lastName isEqualToString:@"mp4"]
  293. // ||[lastName isEqualToString:@"mov"]
  294. // ||[lastName isEqualToString:@"3gp"]
  295. // ||[lastName isEqualToString:@"m4v"]){
  296. // canDownLoadType = YES;
  297. // }
  298. //
  299. // if(!canDownLoadType){
  300. // if(canShow){
  301. // [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  302. // }
  303. //
  304. // return NO;
  305. // }
  306. // }
  307. //
  308. // if(nameArr.count >0 && _isAudioType){
  309. // BOOL canDownLoadType = NO;
  310. // //JPG 、PNG、GIF、TIFF、BMP
  311. // NSString *lastName = nameArr.lastObject;
  312. // if([lastName isEqualToString:@"jpg"]
  313. // ||[lastName isEqualToString:@"png"]
  314. // ||[lastName isEqualToString:@"gif"]
  315. // ||[lastName isEqualToString:@"tiff"]
  316. // ||[lastName isEqualToString:@"bmp"]
  317. // ||[lastName isEqualToString:@"heic"]
  318. // ||[lastName isEqualToString:@"jpeg"]
  319. // ||[lastName isEqualToString:@"heif"]){
  320. // canDownLoadType = YES;
  321. // }
  322. //
  323. // if(!canDownLoadType){
  324. // if(canShow){
  325. // [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  326. // }
  327. // return NO;
  328. // }
  329. // }
  330. return YES;
  331. }
  332. #pragma mark 用户长按图片进入编辑
  333. - (void)setViewEditTypeFun
  334. {
  335. _isEditType = YES;
  336. //[self.tableView reloadData];
  337. _curEditTypeHeadView.hidden = NO;
  338. _curEditTypeBottomView.hidden = NO;
  339. _uploadFileButton.hidden = YES;
  340. self.searchBarThridTypeV.hidden = YES;
  341. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  342. make.left.mas_equalTo(0);
  343. make.right.mas_equalTo(0);
  344. make.bottom.mas_equalTo(_curEditTypeBottomView.mas_top);
  345. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  346. }];
  347. }
  348. #pragma mark 用户取消编辑编辑
  349. - (void)userCancelEditTypeFun
  350. {
  351. //数据还原
  352. for (NASFileAndFolderDataModel*model in _didSelectListArr) {
  353. model.isSelectType = NO;
  354. }
  355. [_didSelectListArr removeAllObjects];
  356. _isEditType = NO;
  357. [self.tableView reloadData];
  358. _curEditTypeHeadView.hidden = YES;
  359. _curEditTypeBottomView.hidden = YES;
  360. _uploadFileButton.hidden = NO;
  361. self.searchBarThridTypeV.hidden = NO;
  362. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  363. make.left.mas_equalTo(0);
  364. make.right.mas_equalTo(0);
  365. make.bottom.mas_equalTo(0);
  366. //make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  367. make.top.equalTo(self.searchBarThridTypeV.mas_bottom).offset(10.f);
  368. }];
  369. }
  370. - (void)userCheckFilePreviewByRow:(NSInteger)row
  371. {
  372. if(row < _curNASFileAudioMod.data.list.count){
  373. NASFileAudioDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  374. if(dataModel.isSelectType){
  375. [_didSelectListArr removeObject:dataModel];
  376. }
  377. else{
  378. [_didSelectListArr addObject:dataModel];
  379. }
  380. dataModel.isSelectType = !dataModel.isSelectType;
  381. [self setEditTypeTitleFun];
  382. }
  383. }
  384. - (void)didClickSelectAllButton:(UIButton*)button
  385. {
  386. //button.selected = !button.selected;
  387. [_didSelectListArr removeAllObjects];
  388. for (NASFileAudioDataModel* dataModel in _curNASFileAudioMod.data.list) {
  389. if(!button.selected){
  390. dataModel.isSelectType = button.selected;
  391. }
  392. else{
  393. if(![dataModel.type isEqualToString:@"dir"]){
  394. [_didSelectListArr addObject:dataModel];
  395. dataModel.isSelectType = button.selected;
  396. }
  397. }
  398. }
  399. [self.tableView reloadData];
  400. //[self.dataCollectionView reloadData];
  401. [self setEditTypeTitleFun];
  402. }
  403. #pragma mark 设置选中标题
  404. - (void)setEditTypeTitleFun
  405. {
  406. [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
  407. if(_didSelectListArr.count > 0){
  408. [self setViewEditTypeFun];
  409. }
  410. else{
  411. [self userCancelEditTypeFun];
  412. }
  413. }
  414. #pragma mark 用户点击分享
  415. - (void)gotoShareViewFun
  416. {
  417. //
  418. NSString * firstFileType = nil;
  419. BOOL isSameFileType = YES;
  420. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  421. if(!firstFileType){
  422. firstFileType = dataModel.type;
  423. }
  424. else if(![firstFileType isEqualToString:dataModel.type]){
  425. isSameFileType = NO;
  426. break;
  427. }
  428. }
  429. NSInteger MaxShareNuber = 50;
  430. // if(isSameFileType && [firstFileType containsString:@"video"]){
  431. // MaxShareNuber = 20;
  432. // }
  433. if (_didSelectListArr.count > MaxShareNuber) {
  434. [[iToast makeText:NSLocalizedString(@"share_max_count_tip1",nil)] show];
  435. return;
  436. }
  437. editShareView *editShareV = [[editShareView alloc] init];
  438. editShareV.didSelectListArr = _didSelectListArr;
  439. editShareV.shareFileType = @"6";
  440. [self.view addSubview:editShareV];
  441. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  442. make.left.mas_equalTo(0);
  443. make.right.mas_equalTo(0);
  444. make.bottom.mas_equalTo(0);
  445. make.top.mas_equalTo(0);
  446. }];
  447. }
  448. #pragma mark 用户点击上传文件
  449. - (void)userDidClickUploadViewFun
  450. {
  451. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  452. [self.view addSubview:previewToUploadFileV];
  453. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  454. make.left.mas_equalTo(0);
  455. make.right.mas_equalTo(0);
  456. make.bottom.mas_equalTo(0);
  457. make.top.mas_equalTo(0);
  458. }];
  459. KWeakSelf
  460. previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
  461. [weakSelf gotoUploadFileFunWith:tag];
  462. };
  463. }
  464. #pragma mark 设置标题
  465. - (void)viewWillAppear:(BOOL)animated
  466. {
  467. [super viewWillAppear:animated];
  468. }
  469. - (void)viewDidAppear:(BOOL)animated{
  470. [super viewDidAppear:animated];
  471. [self showDownloadTipFun];
  472. [self checkFileTransferTask];
  473. if(!_curNASFileAudioMod){
  474. self.titleLabel.text = _curFolderDataModel.name;
  475. [self getFileListFun];
  476. [self.curEditTypeBottomView setCanShaewFunBy:_canShareType];
  477. }
  478. }
  479. - (void)viewWillDisappear:(BOOL)animated{
  480. [super viewWillDisappear:animated];
  481. //[self removeNewIndicator];
  482. [self removeNewIndicatorHaveStr];
  483. }
  484. //- (void)setCurFolderDataModel:(NASFileAndFolderDataModel *)curFolderDataModel
  485. //{
  486. // _curFolderDataModel = curFolderDataModel;
  487. //}
  488. - (void)gotoDownloadloadFileRecordFun
  489. {
  490. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  491. [self.navigationController pushViewController:vc animated:YES];
  492. vc.isDownloadingType = YES;
  493. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  494. }
  495. - (void)showDownloadTipFun
  496. {
  497. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  498. if(didReadUploadTipType){
  499. return;
  500. }
  501. //KWeakSelf
  502. /*弹窗提示恢复出厂*/
  503. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:@""
  504. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  505. imageStr:@""
  506. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  507. okTitle:@""
  508. isOkBtnHighlight:NO
  509. didClickOk:^{
  510. } didClickCancel:^{
  511. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  512. }];
  513. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  514. [self presentViewController:nextVC animated:YES completion:^{
  515. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  516. }];
  517. }
  518. - (void)checkFileTransferTask
  519. {//有个偶现的闪退在BGFMDB
  520. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  521. self->hadUploadTaskType = isSuccess;
  522. [self setRightButtonRedTypeFun];
  523. }];
  524. KWeakSelf
  525. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  526. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  527. self->hadDownloadTaskType = isSuccess;
  528. [weakSelf setRightButtonRedTypeFun];
  529. }];
  530. });
  531. }
  532. - (void)setRightButtonRedTypeFun
  533. {
  534. mainBlock(^{
  535. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  536. self->rightRedView.hidden = NO;
  537. }
  538. else{
  539. self->rightRedView.hidden = YES;
  540. }
  541. });
  542. }
  543. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  544. {
  545. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  546. [self.navigationController pushViewController:vc animated:YES];
  547. }
  548. #pragma mark 获取文件数据
  549. - (void)getFileListFun
  550. {
  551. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  552. if(_curFolderDataModel.path){
  553. [paraDict setValue:_curFolderDataModel.path forKey:@"path"];
  554. }
  555. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  556. KWeakSelf
  557. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileListByFolder" Parameters:paraDict success:^(id _Nonnull responseObject) {
  558. [weakSelf removeNewIndicatorHaveStr];
  559. weakSelf.curNASFileAudioMod = [[NASFileAndFolderModel alloc] initWithDictionary:responseObject error:nil];
  560. if(weakSelf.curNASFileAudioMod && weakSelf.curNASFileAudioMod.status == 0){
  561. [weakSelf.tableView reloadData];
  562. }
  563. } failure:^(NSError * _Nonnull error) {
  564. [weakSelf removeNewIndicatorHaveStr];
  565. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  566. {
  567. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  568. }
  569. else{
  570. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  571. }
  572. }];
  573. }
  574. #pragma mark 调整文件上传
  575. - (void)gotoUploadFileFunWith:(NSInteger)tag
  576. {
  577. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  578. if(tag ==10){
  579. vc.isPhotoType = YES;
  580. }
  581. else{
  582. vc.isPhotoType = NO;
  583. }
  584. [self.navigationController pushViewController:vc animated:YES];
  585. }
  586. #pragma mark 文件下载
  587. - (void)gotoDownLoadFileFun
  588. {
  589. if(_didSelectListArr.count == 0){
  590. [[iToast makeText:@""] show];
  591. return;
  592. }
  593. NSMutableArray *arr = [NSMutableArray new];
  594. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  595. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  596. fileModel.fileType = dataModel.type;
  597. fileModel.path = dataModel.path;
  598. fileModel.name = dataModel.name;
  599. fileModel.length = dataModel.size;
  600. fileModel.time = dataModel.duration;
  601. [arr addObject:fileModel];
  602. }
  603. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  604. [self.navigationController pushViewController:vc animated:YES];
  605. vc.isDownloadingType = YES;
  606. [vc gotoDownloadFile:arr];
  607. }
  608. #pragma mark 删除图片
  609. - (void)showDeleteAlearViewFun
  610. {
  611. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  612. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  613. KWeakSelf
  614. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  615. msg:tipStr
  616. imageStr:@""
  617. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  618. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  619. didClickOk:^{
  620. [weakSelf delFileListFun];
  621. } didClickCancel:^{
  622. }];
  623. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  624. [self presentViewController:curAlretVC animated:YES completion:^{
  625. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  626. }];
  627. }
  628. #pragma mark 删除文件数据
  629. - (void)delFileListFun
  630. {
  631. //处理数据埋点
  632. NSString * firstFileType = nil;
  633. BOOL isSameFileType = YES;
  634. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  635. if(!firstFileType){
  636. firstFileType = dataModel.type;
  637. }
  638. else if(![firstFileType isEqualToString:dataModel.type]){
  639. isSameFileType = NO;
  640. break;
  641. }
  642. }
  643. if(!isSameFileType){
  644. //数据埋点
  645. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_delete"];
  646. }
  647. else if([firstFileType containsString:@"jpg"]){
  648. //数据埋点
  649. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_delete"];
  650. }
  651. else if([firstFileType isEqualToString:@"video"]){
  652. //数据埋点
  653. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_delete"];
  654. }
  655. else if([firstFileType isEqualToString:@"audio"]){
  656. //数据埋点
  657. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_delete"];
  658. }
  659. else{
  660. //数据埋点
  661. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_delete"];
  662. }
  663. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  664. NSMutableArray *pathArr = [NSMutableArray new];
  665. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  666. [pathArr addObject:dataModel.path];
  667. }
  668. [paraDict setValue:pathArr forKey:@"path"];
  669. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  670. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  671. KWeakSelf //@"delFile"
  672. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  673. [weakSelf removeNewIndicator];
  674. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  675. if(model && model.status == 0){
  676. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  677. [weakSelf didDeleteSucFun];
  678. }
  679. else{
  680. }
  681. } failure:^(NSError * _Nonnull error) {
  682. [weakSelf removeNewIndicator];
  683. }];
  684. }
  685. #pragma mark 删除成功
  686. - (void)didDeleteSucFun
  687. {
  688. //删除最近文件
  689. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  690. [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
  691. }
  692. [_didSelectListArr removeAllObjects];
  693. [self setEditTypeTitleFun];
  694. [self getFileListFun];
  695. }
  696. #pragma mark 点击了搜索
  697. - (void)gotoSearchVCFun
  698. {
  699. NasSearchViewController *vc = [NasSearchViewController new];
  700. [self.navigationController pushViewController:vc animated:YES];
  701. }
  702. @end