previewFileAndFolderViewController.m 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327
  1. //
  2. // previewFileAndFolderViewController.m
  3. // Private-X
  4. //
  5. // Created by xd h on 2024/5/21.
  6. //
  7. #import "previewFileAndFolderViewController.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 "NASFileAndFolderModel.h"
  21. #import "queryShareModel.h"
  22. #import "videoPlayByAVPlayerViewController.h"
  23. #import "audioPlayerViewController.h"
  24. #import "imageDetailsScrollViewController.h"
  25. #import "MJRefresh.h"
  26. #import "searchBarThridTypeView.h"
  27. #import "NasSearchViewController.h"
  28. #import "DocumentPickerManager.h"
  29. @interface previewFileAndFolderViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
  30. {
  31. UIButton *tapBtn;
  32. UIButton* rightTransferListButton;//传输列表
  33. UIView* rightRedView;
  34. BOOL hadUploadTaskType;
  35. BOOL hadDownloadTaskType;
  36. BOOL canShareType;
  37. BOOL isFirstPageType;//是否为第一页
  38. }
  39. @property (nonatomic, strong) UITableView *tableView;
  40. @property (strong, nonatomic) UILabel *MytitleLabel;
  41. @property (strong, nonatomic) UIImageView *selectTip;
  42. @property (nonatomic, strong) diskListBgView *diskListBgV;
  43. @property (nonatomic, strong) diskListTableView *diskListTableV;
  44. @property (nonatomic, strong) NSMutableArray*diskListArr;
  45. @property (nonatomic, copy) NSString *defaultDiskPath;
  46. @property(nonatomic,assign) BOOL isEditType;
  47. @property(nonatomic,strong) editTypeHeadView*curEditTypeHeadView;
  48. @property(nonatomic,strong) editTypeBottomView*curEditTypeBottomView;
  49. @property(nonatomic,strong) searchBarThridTypeView* searchBarThridTypeV;//
  50. @property(nonatomic,strong) UIButton*uploadFileButton;
  51. @property (nonatomic, strong) NSMutableArray*didSelectListArr;//选中的数据
  52. @property (nonatomic, strong)NASFileAndFolderModel * curNASFileAudioMod;
  53. @end
  54. @implementation previewFileAndFolderViewController
  55. - (void)viewDidLoad {
  56. [super viewDidLoad];
  57. // Do any additional setup after loading the view.
  58. NSArray *vcArr = self.navigationController.viewControllers;
  59. if(vcArr.count == 1){
  60. isFirstPageType = YES;
  61. }
  62. else{
  63. isFirstPageType = NO;
  64. }
  65. [self.toolBar setHidden:YES];
  66. [self.navigationBar setHidden:YES];
  67. [self.navBarBGView setHidden:NO];
  68. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  69. [self.view setBackgroundColor:[UIColor whiteColor]];
  70. if(isFirstPageType){
  71. self.backBtn.hidden = YES;
  72. }
  73. [self drawAnyView];
  74. _didSelectListArr = [NSMutableArray new];
  75. //数据埋点
  76. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"File"];
  77. }
  78. - (void)drawAnyView{
  79. [self initNavHeadUIFun];
  80. _curEditTypeHeadView = [[editTypeHeadView alloc] init];
  81. _curEditTypeHeadView.hidden = YES;
  82. [self.navBarBGView addSubview:_curEditTypeHeadView];
  83. [_curEditTypeHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.left.mas_equalTo(0);
  85. make.right.mas_equalTo(0);
  86. make.bottom.mas_equalTo(0);
  87. make.height.mas_equalTo(NAVIHEIGHT - AdaptNaviHeight);
  88. }];
  89. #pragma mark 编辑状态的 取消 和全选按钮 响应事件
  90. KWeakSelf
  91. _curEditTypeHeadView.didClickButtonFun = ^(NSInteger tag) {
  92. if(tag==1){
  93. [weakSelf userCancelEditTypeFun];
  94. }
  95. };
  96. _curEditTypeHeadView.didClickSelectAllFun = ^(UIButton * _Nonnull but) {
  97. [weakSelf didClickSelectAllButton:but];
  98. };
  99. _curEditTypeBottomView = [[editTypeBottomView alloc] init];
  100. _curEditTypeBottomView.hidden = YES;
  101. if(!isFirstPageType){
  102. [self.view addSubview:_curEditTypeBottomView];
  103. }
  104. else{
  105. [ksharedAppDelegate.window addSubview:_curEditTypeBottomView];
  106. }
  107. [_curEditTypeBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.left.mas_equalTo(0);
  109. make.right.mas_equalTo(0);
  110. make.bottom.mas_equalTo(0);
  111. make.height.mas_equalTo(60 + AdaptTabHeight);
  112. }];
  113. #pragma mark 编辑状态的 下载 分享 删除 响应事件
  114. _curEditTypeBottomView.didClickButtonFun = ^(NSInteger tag) {
  115. if(tag==1){
  116. [weakSelf gotoDownLoadFileFun];
  117. }
  118. else if(tag==2){
  119. [weakSelf gotoShareViewFun];
  120. }
  121. else if(tag==3){
  122. [weakSelf showDeleteAlearViewFun];
  123. }
  124. };
  125. _searchBarThridTypeV = [[searchBarThridTypeView alloc] init];
  126. [self.view addSubview:_searchBarThridTypeV];
  127. [_searchBarThridTypeV mas_makeConstraints:^(MASConstraintMaker *make) {
  128. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  129. make.height.mas_equalTo(32.0);
  130. make.left.mas_equalTo(20.0);
  131. //make.right.mas_equalTo(-48.0);
  132. make.right.mas_equalTo(-20.0);
  133. }];
  134. #pragma mark 点击搜索
  135. _searchBarThridTypeV.didClickBgFun = ^{
  136. [weakSelf gotoSearchVCFun];
  137. };
  138. CGFloat tableViewAdjust = 0.0;
  139. CGFloat bigAddbuttonAdjust = 0.0;
  140. if(isFirstPageType){
  141. tableViewAdjust = TABBARHEIGHT;
  142. bigAddbuttonAdjust = TABBARHEIGHT;
  143. }
  144. [self.view addSubview:self.tableView];
  145. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  146. make.left.mas_equalTo(0);
  147. make.right.mas_equalTo(0);
  148. //make.bottom.mas_equalTo(-(safeArea));
  149. make.bottom.mas_equalTo(-tableViewAdjust);
  150. //make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  151. make.top.equalTo(self.searchBarThridTypeV.mas_bottom).offset(10.f);
  152. }];
  153. //大+号
  154. _uploadFileButton = [[UIButton alloc] init];
  155. [_uploadFileButton setBackgroundImage:[UIImage imageNamed:@"add_file_icon"] forState:UIControlStateNormal];
  156. [_uploadFileButton addTarget:self action:@selector(userDidClickUploadViewFun) forControlEvents:UIControlEventTouchUpInside];
  157. [self.view addSubview:_uploadFileButton];
  158. [_uploadFileButton mas_makeConstraints:^(MASConstraintMaker *make) {
  159. make.right.mas_equalTo(-15);
  160. make.width.mas_equalTo(52);
  161. make.height.mas_equalTo(52);
  162. make.bottom.mas_equalTo(-30 - AdaptTabHeight - bigAddbuttonAdjust);
  163. }];
  164. // 添加拖拽手势
  165. UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
  166. [_uploadFileButton addGestureRecognizer:panGesture];
  167. [self customDefaultDiskPathFun];
  168. }
  169. //设置默认磁盘
  170. - (void)customDefaultDiskPathFun
  171. {
  172. NSMutableArray *arr = [NSMutableArray new];
  173. NSArray *diskList = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  174. if(diskList && [diskList isKindOfClass:[NSArray class]]){
  175. for (cloudPhoneExtraFileModel *model in diskList) {
  176. model.isCheckType = NO;
  177. [arr addObject:model];
  178. }
  179. }
  180. if(arr.count >0){
  181. //上一次选中的磁盘
  182. NSString*preChekDiskStr = [HWDataManager getStringWithKey:Const_file_pre_disk_check];
  183. //1.没有选择过 默认选择第一次(云机)
  184. if(!preChekDiskStr || preChekDiskStr.length == 0){
  185. cloudPhoneExtraFileModel *model = arr.firstObject;
  186. model.isCheckType = YES;
  187. _defaultDiskPath = model.extraPath;
  188. }
  189. else{//2.选择过 查询磁盘是否还存在
  190. BOOL didCheckDisk = NO;
  191. for (cloudPhoneExtraFileModel *model in arr) {
  192. HLog(@"磁盘路径比较 pre:%@---%@",preChekDiskStr,model.extraPath)
  193. if([model.extraPath isEqualToString:preChekDiskStr]){
  194. model.isCheckType = YES;
  195. _defaultDiskPath = model.extraPath;
  196. didCheckDisk = YES;
  197. break;
  198. }
  199. }
  200. //3.选择过 查询磁盘不存在
  201. if(!didCheckDisk){
  202. cloudPhoneExtraFileModel *model = arr.firstObject;
  203. model.isCheckType = YES;
  204. _defaultDiskPath = model.extraPath;
  205. }
  206. }
  207. }
  208. _diskListArr = arr;
  209. [self setTitleAfterGetdiskFun];
  210. }
  211. - (void)initNavHeadUIFun
  212. {
  213. //title
  214. UILabel *titleLabel = [[UILabel alloc] init];
  215. titleLabel.textAlignment = NSTextAlignmentCenter;
  216. titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  217. titleLabel.textColor = [UIColor blackColor];
  218. titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
  219. [self.navBarBGView addSubview:titleLabel];
  220. self.MytitleLabel = titleLabel;
  221. //selectTipImageView
  222. UIImageView *selectTip = [[UIImageView alloc] init];
  223. selectTip.image = [UIImage imageNamed:@"upload_image_arrow"];
  224. selectTip.translatesAutoresizingMaskIntoConstraints = NO;
  225. [self.navBarBGView addSubview:selectTip];
  226. self.selectTip = selectTip;
  227. tapBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  228. tapBtn.backgroundColor = [UIColor clearColor];
  229. tapBtn.translatesAutoresizingMaskIntoConstraints = NO;
  230. [tapBtn addTarget:self action:@selector(selectDiskAction:) forControlEvents:UIControlEventTouchUpInside];
  231. [self.navBarBGView addSubview:tapBtn];
  232. [tapBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  233. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  234. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  235. make.width.mas_equalTo(100);
  236. make.height.mas_equalTo(30);
  237. }];
  238. [self setTitleLabelText:@""];
  239. rightTransferListButton = [[UIButton alloc] init];
  240. [rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  241. [rightTransferListButton addTarget:self action:@selector(didiClikRightButGotoTransferListFun:) forControlEvents:UIControlEventTouchUpInside];
  242. [self.navBarBGView addSubview:rightTransferListButton];
  243. [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) {
  244. make.width.mas_equalTo(40);
  245. make.height.mas_equalTo(40);
  246. make.right.mas_equalTo(-15);
  247. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  248. }];
  249. rightRedView = [[UIView alloc] init];
  250. rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
  251. [rightTransferListButton addSubview:rightRedView];
  252. rightRedView.layer.cornerRadius = 7;
  253. rightRedView.hidden = YES;
  254. [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
  255. make.width.mas_equalTo(14);
  256. make.height.mas_equalTo(14);
  257. make.right.mas_equalTo(0);
  258. make.top.mas_equalTo(6);
  259. }];
  260. }
  261. #pragma mark 处理拖拽手势
  262. - (void)handlePan:(UIPanGestureRecognizer *)gesture {
  263. if (gesture.state == UIGestureRecognizerStateChanged) {
  264. // 获取手指拖拽的偏移量
  265. CGPoint translation = [gesture translationInView:self.view];
  266. // 更新视图位置
  267. CGPoint newCenter = CGPointMake(
  268. _uploadFileButton.center.x + translation.x,
  269. _uploadFileButton.center.y + translation.y
  270. );
  271. _uploadFileButton.center = newCenter;
  272. // 重置偏移量,避免累加
  273. [gesture setTranslation:CGPointZero inView:self.view];
  274. }
  275. }
  276. #pragma mark - 懒加载
  277. - (UITableView *)tableView{
  278. if (!_tableView) {
  279. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  280. _tableView.delegate = self;
  281. _tableView.dataSource = self;
  282. _tableView.showsVerticalScrollIndicator = NO;
  283. _tableView.showsHorizontalScrollIndicator = NO;
  284. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  285. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  286. [_tableView setSeparatorColor:[UIColor clearColor]];
  287. [_tableView setBackgroundColor:[UIColor clearColor]];
  288. [_tableView setTableFooterView:[UIView new]];
  289. [_tableView setBounces:YES];
  290. if (@available(iOS 15.0, *)) {
  291. _tableView.sectionHeaderTopPadding = 0;
  292. }
  293. //空数据引入第三方开源处理
  294. _tableView.emptyDataSetSource = self;
  295. _tableView.emptyDataSetDelegate = self;
  296. // 下拉追加
  297. // MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  298. // [self getMoreNetWorkData];
  299. // }];
  300. //
  301. // NSString *text = NSLocalizedString(@"NAS_bottom_tip",nil);
  302. // [footer setTitle:text forState:MJRefreshStateNoMoreData];
  303. // _tableView.mj_footer = footer;
  304. }
  305. return _tableView;
  306. }
  307. - (diskListBgView*)diskListBgV
  308. {
  309. if(!_diskListBgV){
  310. _diskListBgV = [[diskListBgView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
  311. _diskListBgV.hidden = YES;
  312. [self.view addSubview:_diskListBgV];
  313. KWeakSelf
  314. _diskListBgV.didTapWhitePlace = ^{
  315. [weakSelf hideDiskListVieFun];
  316. };
  317. [_diskListBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  318. make.left.mas_equalTo(0);
  319. make.bottom.mas_equalTo(0);
  320. make.right.mas_equalTo(0);
  321. make.top.mas_equalTo(self.navBarBGView.mas_bottom);
  322. }];
  323. [self.view addSubview:self.diskListTableV];
  324. self.diskListTableV.hidden = YES;
  325. [self.diskListTableV mas_makeConstraints:^(MASConstraintMaker *make) {
  326. make.left.mas_equalTo(0);
  327. make.height.mas_equalTo(3*70);
  328. make.right.mas_equalTo(0);
  329. make.top.mas_equalTo(self.navBarBGView.mas_bottom);
  330. }];
  331. self.diskListTableV.diskListArr = _diskListArr;
  332. self.diskListTableV.didClickDiskModel = ^(NSString * _Nonnull checkPath) {
  333. [weakSelf didCheckDiskFunByPath:checkPath];
  334. };
  335. }
  336. return _diskListBgV;
  337. }
  338. - (UITableView *)diskListTableV{
  339. if (!_diskListTableV) {
  340. _diskListTableV = [[diskListTableView alloc] init];
  341. //
  342. }
  343. return _diskListTableV;
  344. }
  345. #pragma mark 选中磁盘
  346. - (void)didCheckDiskFunByPath:(NSString*)pathStr
  347. {
  348. if(self.defaultDiskPath
  349. && self.defaultDiskPath.length>0
  350. && ![self.defaultDiskPath isEqualToString:pathStr]){
  351. //切换硬盘了 取消全选
  352. [_didSelectListArr removeAllObjects];
  353. }
  354. //保存选中的磁盘
  355. if(pathStr){
  356. [HWDataManager setStringWithKey:Const_file_pre_disk_check value:pathStr];
  357. }
  358. self.defaultDiskPath = pathStr;
  359. _curNASFileAudioMod = nil;
  360. [self getFileListFun:NO];
  361. [self setTitleAfterGetdiskFun];
  362. [self hideDiskListVieFun];
  363. }
  364. #pragma mark - 列表委托
  365. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  366. return 1;
  367. }
  368. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  369. if(!_curNASFileAudioMod){
  370. return 0;
  371. }
  372. return _curNASFileAudioMod.data.list.count;
  373. }
  374. - (downLoadPreViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  375. __block NSInteger row = indexPath.row;
  376. static NSString *identifier = @"downLoadPreViewCell";
  377. downLoadPreViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  378. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  379. if (!cell){
  380. cell = [[downLoadPreViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  381. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  382. [cell setBackgroundColor:[UIColor clearColor]];
  383. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  384. [cell.bgViewLayer removeFromSuperlayer];
  385. [cell.titleLabel2 setHidden:NO];
  386. [cell.rightImage setHidden:YES];
  387. [cell.lineView setHidden:YES];
  388. [cell.checkButton setHidden:NO];
  389. }
  390. if(row < _curNASFileAudioMod.data.list.count){
  391. NASFileAndFolderDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  392. cell.curNASFileAndFolderDataModel = dataModel;
  393. KWeakSelf
  394. cell.didClickSwitch = ^(BOOL SwitchOn) {
  395. //if([weakSelf userCheckFileModel:dataModel withShowTip:YES]){
  396. [weakSelf userCheckFilePreviewByRow:row];
  397. //}
  398. };
  399. }
  400. return cell;
  401. }
  402. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  403. return 70;
  404. }
  405. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  406. {
  407. NSInteger row = indexPath.row;
  408. if(row < _curNASFileAudioMod.data.list.count){
  409. NASFileAndFolderDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  410. if([dataModel.type isEqualToString:@"dir"])
  411. {
  412. previewFileAndFolderSecondViewController *vc = [previewFileAndFolderSecondViewController new];
  413. vc.curFolderDataModel = dataModel;
  414. vc.canShareType = canShareType;
  415. [self.navigationController pushViewController:vc animated:YES];
  416. }
  417. else if([dataModel.type isEqualToString:@"video"]){
  418. videoPlayByAVPlayerViewController *vc = [videoPlayByAVPlayerViewController new];
  419. vc.VideoDataMode = dataModel;
  420. [self.navigationController pushViewController:vc animated:YES];
  421. KWeakSelf
  422. vc.didNeedDeleteFile = ^(NSString * _Nonnull filePath) {
  423. [weakSelf deleteNetDataByFilePath:filePath];
  424. };
  425. }
  426. else if([dataModel.type isEqualToString:@"audio"]){
  427. // NSMutableArray *dataArr = [NSMutableArray new];
  428. // [dataArr addObject:dataModel];
  429. audioPlayerViewController * vc = [audioPlayerViewController new];
  430. vc.isfirstEnterType = YES;
  431. vc.outSideDataModel = (NASFileAudioDataModel *)dataModel;
  432. [self.navigationController pushViewController:vc animated:YES];
  433. KWeakSelf
  434. vc.didNeedDeleteFile = ^(NSString * _Nonnull filePath) {
  435. [weakSelf deleteNetDataByFilePath:filePath];
  436. };
  437. }
  438. else if([dataModel.type containsString:@"jpg"]){
  439. NSMutableArray *jpgDataArr = [NSMutableArray new];
  440. NSInteger index = 0;
  441. [jpgDataArr addObject:dataModel];
  442. imageDetailsScrollViewController *vc = [imageDetailsScrollViewController new];
  443. vc.index = index;
  444. vc.totalDataArr = jpgDataArr;
  445. [self.navigationController pushViewController:vc animated:YES];
  446. vc.canShareType = canShareType;
  447. }
  448. }
  449. }
  450. #pragma mark 空数据
  451. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
  452. NSString *imageName = @"common_no_data_pic";
  453. return [UIImage imageNamed:imageName];
  454. }
  455. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  456. NSString *text = NSLocalizedString(@"common_no_data_tip",nil);
  457. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
  458. NSForegroundColorAttributeName: HW999999Color};
  459. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  460. }
  461. //调整图片位置
  462. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
  463. return -150;
  464. }
  465. //ios端:
  466. //1、需求说明:解决除MP4 MOV 3GP M4V 总计4种格式外,其他格式下载失败的问题;
  467. //2、交互说明:下载列表勾选文件中含有其他格式,toast提示“IOS系统仅支持MP4、MOV、3GP、M4V 的视频格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载MP4、MOV、3GP、M4V 的视频格式文件;
  468. //ios支持图片格式: (SVG 不支持)
  469. //需求说明:解决除JPG PNG GIF TIFF BMP总计5种格式外,其他格式下载失败的问题
  470. //视觉交互:选择文件中含有其他格式,toast提示“IOS系统仅支持JPG 、PNG、GIF、TIFF、BMP的图片格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载JPG 、PNG、GIF、TIFF、BMP的图片格式文件;
  471. - (BOOL)userCheckFileModel:(couldPhoneFileModel*)fileModel withShowTip:(BOOL)canShow{
  472. // NSString*name = [fileModel.name lowercaseString];
  473. // NSArray *nameArr = [name componentsSeparatedByString:@"."];
  474. // if(nameArr.count >0 && !_isAudioType){
  475. // BOOL canDownLoadType = NO;
  476. //
  477. // NSString *lastName = nameArr.lastObject;
  478. // if([lastName isEqualToString:@"mp4"]
  479. // ||[lastName isEqualToString:@"mov"]
  480. // ||[lastName isEqualToString:@"3gp"]
  481. // ||[lastName isEqualToString:@"m4v"]){
  482. // canDownLoadType = YES;
  483. // }
  484. //
  485. // if(!canDownLoadType){
  486. // if(canShow){
  487. // [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  488. // }
  489. //
  490. // return NO;
  491. // }
  492. // }
  493. //
  494. // if(nameArr.count >0 && _isAudioType){
  495. // BOOL canDownLoadType = NO;
  496. // //JPG 、PNG、GIF、TIFF、BMP
  497. // NSString *lastName = nameArr.lastObject;
  498. // if([lastName isEqualToString:@"jpg"]
  499. // ||[lastName isEqualToString:@"png"]
  500. // ||[lastName isEqualToString:@"gif"]
  501. // ||[lastName isEqualToString:@"tiff"]
  502. // ||[lastName isEqualToString:@"bmp"]
  503. // ||[lastName isEqualToString:@"heic"]
  504. // ||[lastName isEqualToString:@"jpeg"]
  505. // ||[lastName isEqualToString:@"heif"]){
  506. // canDownLoadType = YES;
  507. // }
  508. //
  509. // if(!canDownLoadType){
  510. // if(canShow){
  511. // [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  512. // }
  513. // return NO;
  514. // }
  515. // }
  516. return YES;
  517. }
  518. #pragma mark 用户长按图片进入编辑
  519. - (void)setViewEditTypeFun
  520. {
  521. _isEditType = YES;
  522. //[self.tableView reloadData];
  523. _curEditTypeHeadView.hidden = NO;
  524. _curEditTypeBottomView.hidden = NO;
  525. _uploadFileButton.hidden = YES;
  526. self.searchBarThridTypeV.hidden = YES;
  527. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  528. make.left.mas_equalTo(0);
  529. make.right.mas_equalTo(0);
  530. make.bottom.mas_equalTo(_curEditTypeBottomView.mas_top);
  531. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  532. }];
  533. }
  534. #pragma mark 用户取消编辑编辑
  535. - (void)userCancelEditTypeFun
  536. {
  537. //数据还原
  538. for (NASFileAndFolderDataModel*model in _didSelectListArr) {
  539. model.isSelectType = NO;
  540. }
  541. [_didSelectListArr removeAllObjects];
  542. _isEditType = NO;
  543. [self.tableView reloadData];
  544. _curEditTypeHeadView.hidden = YES;
  545. _curEditTypeBottomView.hidden = YES;
  546. _uploadFileButton.hidden = NO;
  547. self.searchBarThridTypeV.hidden = NO;
  548. CGFloat tableViewAdjust = 0.0;
  549. if(isFirstPageType){
  550. tableViewAdjust = TABBARHEIGHT;
  551. }
  552. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  553. make.left.mas_equalTo(0);
  554. make.right.mas_equalTo(0);
  555. make.bottom.mas_equalTo(-tableViewAdjust);
  556. //make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  557. make.top.equalTo(self.searchBarThridTypeV.mas_bottom).offset(10.f);
  558. }];
  559. }
  560. - (void)userCheckFilePreviewByRow:(NSInteger)row
  561. {
  562. if(row < _curNASFileAudioMod.data.list.count){
  563. NASFileAudioDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  564. if(dataModel.isSelectType){
  565. [_didSelectListArr removeObject:dataModel];
  566. }
  567. else{
  568. [_didSelectListArr addObject:dataModel];
  569. }
  570. dataModel.isSelectType = !dataModel.isSelectType;
  571. [self setEditTypeTitleFun];
  572. }
  573. }
  574. - (void)didClickSelectAllButton:(UIButton*)button
  575. {
  576. //button.selected = !button.selected;
  577. [_didSelectListArr removeAllObjects];
  578. for (NASFileAudioDataModel* dataModel in _curNASFileAudioMod.data.list) {
  579. if(!button.selected){
  580. dataModel.isSelectType = button.selected;
  581. }
  582. else{
  583. if(![dataModel.type isEqualToString:@"dir"]){
  584. [_didSelectListArr addObject:dataModel];
  585. dataModel.isSelectType = button.selected;
  586. }
  587. }
  588. }
  589. [self.tableView reloadData];
  590. //[self.dataCollectionView reloadData];
  591. [self setEditTypeTitleFun];
  592. }
  593. #pragma mark 设置选中标题
  594. - (void)setEditTypeTitleFun
  595. {
  596. [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
  597. if(_didSelectListArr.count > 0){
  598. [self setViewEditTypeFun];
  599. }
  600. else{
  601. [self userCancelEditTypeFun];
  602. }
  603. }
  604. #pragma mark 用户点击分享
  605. - (void)gotoShareViewFun
  606. {
  607. //
  608. NSString * firstFileType = nil;
  609. BOOL isSameFileType = YES;
  610. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  611. if(!firstFileType){
  612. firstFileType = dataModel.type;
  613. }
  614. else if(![firstFileType isEqualToString:dataModel.type]){
  615. isSameFileType = NO;
  616. break;
  617. }
  618. }
  619. NSInteger MaxShareNuber = 50;
  620. // if(isSameFileType && [firstFileType containsString:@"video"]){
  621. // MaxShareNuber = 20;
  622. // }
  623. if (_didSelectListArr.count > MaxShareNuber) {
  624. [[iToast makeText:NSLocalizedString(@"share_max_count_tip1",nil)] show];
  625. return;
  626. }
  627. editShareView *editShareV = [[editShareView alloc] init];
  628. editShareV.didSelectListArr = _didSelectListArr;
  629. editShareV.shareFileType = @"6";
  630. [self.view addSubview:editShareV];
  631. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  632. make.left.mas_equalTo(0);
  633. make.right.mas_equalTo(0);
  634. make.bottom.mas_equalTo(0);
  635. make.top.mas_equalTo(0);
  636. }];
  637. }
  638. #pragma mark 用户点击上传文件
  639. - (void)userDidClickUploadViewFun
  640. {
  641. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  642. [ksharedAppDelegate.window addSubview:previewToUploadFileV];
  643. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  644. make.left.mas_equalTo(0);
  645. make.right.mas_equalTo(0);
  646. make.bottom.mas_equalTo(0);
  647. make.top.mas_equalTo(0);
  648. }];
  649. KWeakSelf
  650. previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
  651. [weakSelf gotoUploadFileFunWith:tag];
  652. };
  653. }
  654. #pragma mark 设置标题
  655. - (void)setTitleLabelText:(NSString*)title
  656. {
  657. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  658. if(diskNameArr && diskNameArr.count >= 2){
  659. NSString *name = diskNameArr.lastObject;
  660. if(name.length == 0)
  661. {
  662. name = diskNameArr[diskNameArr.count -2];
  663. }
  664. //name = [name stringByReplacingOccurrencesOfString:@"sdcard" withString:NSLocalizedString(@"disk_phone_default_tip",nil)];
  665. name = [iTools changePathToShowPathBy:name];
  666. title = [[NSString alloc] initWithFormat:@"[%@]%@",name,title];
  667. }
  668. self.MytitleLabel.text = title;
  669. CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.f]} context:nil].size.width;
  670. curWidth += 20;
  671. //HLog(@"title w:%f",curWidth);
  672. [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  673. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10);
  674. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  675. make.width.mas_equalTo(curWidth);
  676. make.height.mas_equalTo(30);
  677. }];
  678. //self.MytitleLabel.backgroundColor = [UIColor greenColor];
  679. [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) {
  680. make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(0);
  681. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  682. make.width.mas_equalTo(15);
  683. make.height.mas_equalTo(15);
  684. }];
  685. [tapBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  686. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  687. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  688. make.width.mas_equalTo(curWidth+15);
  689. make.height.mas_equalTo(30);
  690. }];
  691. }
  692. #pragma mark 选择硬盘
  693. - (void)selectDiskAction:(UIButton*)but
  694. {
  695. if(self.diskListBgV.hidden){
  696. [self showDiskListVieFun];
  697. }
  698. else{
  699. [self hideDiskListVieFun];
  700. }
  701. }
  702. - (void)showDiskListVieFun
  703. {
  704. self.diskListBgV.hidden = NO;
  705. self.diskListTableV.hidden = NO;
  706. [UIView animateWithDuration:0.3 animations:^{
  707. CGRect rect = self.diskListTableV.frame;
  708. rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
  709. self.diskListTableV.frame = rect;
  710. self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
  711. }];
  712. }
  713. - (void)hideDiskListVieFun
  714. {
  715. self.diskListBgV.hidden = YES;
  716. [UIView animateWithDuration:0.3 animations:^{
  717. self.diskListTableV.hidden = YES;
  718. self.selectTip.transform = CGAffineTransformIdentity;
  719. }completion:^(BOOL finished) {
  720. CGRect rect = self.diskListTableV.frame;
  721. rect.origin.y = 0;
  722. self.diskListTableV.frame = rect;
  723. }];
  724. }
  725. #pragma mark 设置标题
  726. - (void)setTitleAfterGetdiskFun
  727. {
  728. [self setTitleLabelText:NSLocalizedString(@"my_set_no_file",nil)];
  729. }
  730. - (void)viewWillAppear:(BOOL)animated
  731. {
  732. [super viewWillAppear:animated];
  733. }
  734. - (void)viewDidAppear:(BOOL)animated{
  735. [super viewDidAppear:animated];
  736. [self showDownloadTipFun];
  737. [self checkFileTransferTask];
  738. if(!_curNASFileAudioMod || _curNASFileAudioMod.data.list == 0){
  739. [self customDefaultDiskPathFun];
  740. [self getFileListFun:NO];
  741. [self queryShareSwitchFunFun];
  742. }
  743. if(isFirstPageType){
  744. [self showTabbarFun];
  745. }
  746. }
  747. - (void)viewWillDisappear:(BOOL)animated{
  748. [super viewWillDisappear:animated];
  749. //[self removeNewIndicator];
  750. [self removeNewIndicatorHaveStr];
  751. }
  752. - (void)gotoDownloadloadFileRecordFun
  753. {
  754. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  755. [self.navigationController pushViewController:vc animated:YES];
  756. vc.isDownloadingType = YES;
  757. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  758. }
  759. - (void)showDownloadTipFun
  760. {
  761. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  762. if(didReadUploadTipType){
  763. return;
  764. }
  765. //KWeakSelf
  766. /*弹窗提示恢复出厂*/
  767. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
  768. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  769. imageStr:nil
  770. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  771. okTitle:nil
  772. isOkBtnHighlight:NO
  773. didClickOk:^{
  774. } didClickCancel:^{
  775. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  776. }];
  777. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  778. [self presentViewController:nextVC animated:YES completion:^{
  779. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  780. }];
  781. }
  782. - (void)checkFileTransferTask
  783. {//有个偶现的闪退在BGFMDB
  784. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  785. self->hadUploadTaskType = isSuccess;
  786. [self setRightButtonRedTypeFun];
  787. }];
  788. KWeakSelf
  789. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  790. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  791. self->hadDownloadTaskType = isSuccess;
  792. [weakSelf setRightButtonRedTypeFun];
  793. }];
  794. });
  795. }
  796. - (void)setRightButtonRedTypeFun
  797. {
  798. mainBlock(^{
  799. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  800. self->rightRedView.hidden = NO;
  801. }
  802. else{
  803. self->rightRedView.hidden = YES;
  804. }
  805. });
  806. }
  807. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  808. {
  809. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  810. [self.navigationController pushViewController:vc animated:YES];
  811. }
  812. #pragma mark 获取文件数据
  813. - (void)getFileListFun:(BOOL)isMoreDataType
  814. {
  815. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  816. // NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  817. // if(diskNameArr && diskNameArr.count >= 2){
  818. //
  819. // NSString *name = diskNameArr.lastObject;
  820. // if(name.length == 0)
  821. // {
  822. // name = diskNameArr[diskNameArr.count -2];
  823. // }
  824. //
  825. // [paraDict setValue:name forKey:@"path"];
  826. // }
  827. if(_defaultDiskPath){
  828. [paraDict setValue:_defaultDiskPath forKey:@"path"];
  829. }
  830. // if(!isMoreDataType){
  831. // self.pageIndex = 0;
  832. // }
  833. // else{
  834. // self.pageIndex ++;
  835. // }
  836. //
  837. // [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
  838. // [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
  839. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  840. KWeakSelf
  841. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileListByFolder" Parameters:paraDict success:^(id _Nonnull responseObject) {
  842. [weakSelf removeNewIndicatorHaveStr];
  843. //[weakSelf.tableView.mj_footer endRefreshing];
  844. NASFileAndFolderModel*NASFileAudioMod = [[NASFileAndFolderModel alloc] initWithDictionary:responseObject error:nil];
  845. // if(NASFileAudioMod.data.list.count < pageSizeNum){
  846. // [weakSelf.tableView.mj_footer endRefreshingWithNoMoreData];
  847. // }
  848. [weakSelf handelNetDataAfterFilterDataBy:NASFileAudioMod];
  849. if(weakSelf.curNASFileAudioMod && weakSelf.curNASFileAudioMod.status == 0){
  850. [weakSelf.tableView reloadData];
  851. }
  852. } failure:^(NSError * _Nonnull error) {
  853. [weakSelf removeNewIndicatorHaveStr];
  854. //[weakSelf.tableView.mj_footer endRefreshing];
  855. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  856. {
  857. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  858. }
  859. else{
  860. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  861. }
  862. }];
  863. }
  864. #pragma mark 上拉或者点击更多数据
  865. - (void)getMoreNetWorkData
  866. {
  867. [self getFileListFun:YES];
  868. }
  869. #pragma mark 分页数据组装
  870. - (void)handelNetDataAfterFilterDataBy:(NASFileAndFolderModel*)NASFileAudioMod
  871. {
  872. if(_curNASFileAudioMod && _curNASFileAudioMod.data && _curNASFileAudioMod.data.list){
  873. NSMutableArray *handelDataArr = [NSMutableArray arrayWithArray:_curNASFileAudioMod.data.list];//旧数据
  874. [handelDataArr addObjectsFromArray:NASFileAudioMod.data.list];//新数据
  875. _curNASFileAudioMod.data.list = (NSArray<NASFileAndFolderDataModel>*)handelDataArr;
  876. }
  877. else{
  878. _curNASFileAudioMod = NASFileAudioMod;
  879. }
  880. // if(_curNASFileAudioMod.data.list.count == 0 ){
  881. // self.tableView.mj_footer.hidden = YES;
  882. // }
  883. // else{
  884. // self.tableView.mj_footer.hidden = NO;
  885. // }
  886. }
  887. #pragma mark 调整文件上传
  888. - (void)gotoUploadFileFunWith:(NSInteger)tag
  889. {
  890. if(tag == 10 || tag == 11){
  891. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  892. if(tag ==10){
  893. vc.isPhotoType = YES;
  894. }
  895. else{
  896. vc.isPhotoType = NO;
  897. }
  898. [self.navigationController pushViewController:vc animated:YES];
  899. }
  900. else{
  901. KWeakSelf
  902. [[DocumentPickerManager shareManager] openDocumentPickerSuccess:^(NSArray * _Nonnull urls) {
  903. [weakSelf gotoUploadFileRecordByFileAppWithUrls:urls];
  904. }];
  905. }
  906. }
  907. #pragma mark 文件下载
  908. - (void)gotoDownLoadFileFun
  909. {
  910. if(_didSelectListArr.count == 0){
  911. [[iToast makeText:@""] show];
  912. return;
  913. }
  914. NSMutableArray *arr = [NSMutableArray new];
  915. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  916. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  917. fileModel.fileType = dataModel.type;
  918. fileModel.path = dataModel.path;
  919. fileModel.name = dataModel.name;
  920. fileModel.length = dataModel.size;
  921. fileModel.time = dataModel.duration;
  922. [arr addObject:fileModel];
  923. }
  924. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  925. [self.navigationController pushViewController:vc animated:YES];
  926. vc.isDownloadingType = YES;
  927. [vc gotoDownloadFile:arr];
  928. }
  929. #pragma mark 删除图片
  930. - (void)showDeleteAlearViewFun
  931. {
  932. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  933. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  934. KWeakSelf
  935. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  936. msg:tipStr
  937. imageStr:nil
  938. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  939. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  940. didClickOk:^{
  941. [weakSelf delFileListFun];
  942. } didClickCancel:^{
  943. }];
  944. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  945. [self presentViewController:curAlretVC animated:YES completion:^{
  946. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  947. }];
  948. }
  949. #pragma mark 删除文件数据
  950. - (void)delFileListFun
  951. {
  952. //处理数据埋点
  953. NSString * firstFileType = nil;
  954. BOOL isSameFileType = YES;
  955. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  956. if(!firstFileType){
  957. firstFileType = dataModel.type;
  958. }
  959. else if(![firstFileType isEqualToString:dataModel.type]){
  960. isSameFileType = NO;
  961. break;
  962. }
  963. }
  964. if(!isSameFileType){
  965. //数据埋点
  966. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_delete"];
  967. }
  968. else if([firstFileType containsString:@"jpg"]){
  969. //数据埋点
  970. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_delete"];
  971. }
  972. else if([firstFileType isEqualToString:@"video"]){
  973. //数据埋点
  974. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_delete"];
  975. }
  976. else if([firstFileType isEqualToString:@"audio"]){
  977. //数据埋点
  978. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_delete"];
  979. }
  980. else{
  981. //数据埋点
  982. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_delete"];
  983. }
  984. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  985. NSMutableArray *pathArr = [NSMutableArray new];
  986. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  987. [pathArr addObject:dataModel.path];
  988. }
  989. [paraDict setValue:pathArr forKey:@"path"];
  990. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  991. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  992. KWeakSelf //@"delFile"
  993. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  994. [weakSelf removeNewIndicator];
  995. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  996. if(model && model.status == 0){
  997. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  998. [weakSelf didDeleteSucFun];
  999. }
  1000. else{
  1001. }
  1002. } failure:^(NSError * _Nonnull error) {
  1003. [weakSelf removeNewIndicator];
  1004. }];
  1005. }
  1006. #pragma mark 删除成功
  1007. - (void)didDeleteSucFun
  1008. {
  1009. //删除最近文件
  1010. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  1011. [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
  1012. }
  1013. //2.删除已经获取到的网络数据
  1014. [self deleteNetDataByDeleteSucFun];
  1015. [_didSelectListArr removeAllObjects];
  1016. [self setEditTypeTitleFun];
  1017. }
  1018. #pragma mark 删除成功后 对应删除原来获取的网络数据
  1019. - (void)deleteNetDataByDeleteSucFun
  1020. {
  1021. NSMutableArray *afterFilterArr = [NSMutableArray new];
  1022. for (NASFileAndFolderDataModel *model in _curNASFileAudioMod.data.list) {
  1023. if (!model.isSelectType) {
  1024. [afterFilterArr addObject:model];
  1025. }
  1026. }
  1027. _curNASFileAudioMod.data.list = (NSArray<NASFileAndFolderDataModel>*)afterFilterArr;
  1028. [self.tableView reloadData];
  1029. }
  1030. #pragma mark 图片详情删除成功后 对应删除原来获取的网络数据
  1031. - (void)deleteNetDataByFilePath:(NSString*)filePath
  1032. {
  1033. if(!filePath || filePath.length == 0){
  1034. return;
  1035. }
  1036. NSMutableArray *afterFilterArr = [NSMutableArray new];
  1037. for (NASFileAndFolderDataModel *model in _curNASFileAudioMod.data.list) {
  1038. if (![model.path isEqualToString:filePath]) {
  1039. [afterFilterArr addObject:model];
  1040. }
  1041. }
  1042. _curNASFileAudioMod.data.list = (NSArray<NASFileAndFolderDataModel>*)afterFilterArr;
  1043. [self.tableView reloadData];
  1044. }
  1045. #pragma mark 获取分享开关
  1046. -(void)queryShareSwitchFunFun
  1047. {
  1048. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  1049. [paraDict setValue:@6 forKey:@"type"];
  1050. KWeakSelf
  1051. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
  1052. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  1053. if(queryShareMod){
  1054. self->canShareType = queryShareMod.data.configValue;
  1055. [weakSelf.curEditTypeBottomView setCanShaewFunBy:queryShareMod.data.configValue];
  1056. }
  1057. } failure:^(NSError * _Nonnull error) {
  1058. }];
  1059. }
  1060. #pragma mark 点击了搜索
  1061. - (void)gotoSearchVCFun
  1062. {
  1063. NasSearchViewController *vc = [NasSearchViewController new];
  1064. //vc.fileType = @"doc";
  1065. [self.navigationController pushViewController:vc animated:YES];
  1066. }
  1067. #pragma mark 文件上传跳转上传记录
  1068. - (void)gotoUploadFileRecordByFileAppWithUrls:(NSArray*)urls
  1069. {
  1070. if(!urls || urls.count ==0){
  1071. return;
  1072. }
  1073. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1074. [self.navigationController pushViewController:vc animated:YES];
  1075. vc.isUploadingType = YES;
  1076. [vc gotoUploadFileByFileApp:urls];
  1077. }
  1078. @end