previewFileAndFolderViewController.m 43 KB

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