previewFileAndFolderViewController.m 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325
  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 getFileListFun:NO];
  740. [self queryShareSwitchFunFun];
  741. }
  742. if(isFirstPageType){
  743. [self showTabbarFun];
  744. }
  745. }
  746. - (void)viewWillDisappear:(BOOL)animated{
  747. [super viewWillDisappear:animated];
  748. //[self removeNewIndicator];
  749. [self removeNewIndicatorHaveStr];
  750. }
  751. - (void)gotoDownloadloadFileRecordFun
  752. {
  753. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  754. [self.navigationController pushViewController:vc animated:YES];
  755. vc.isDownloadingType = YES;
  756. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  757. }
  758. - (void)showDownloadTipFun
  759. {
  760. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  761. if(didReadUploadTipType){
  762. return;
  763. }
  764. //KWeakSelf
  765. /*弹窗提示恢复出厂*/
  766. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
  767. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  768. imageStr:nil
  769. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  770. okTitle:nil
  771. isOkBtnHighlight:NO
  772. didClickOk:^{
  773. } didClickCancel:^{
  774. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  775. }];
  776. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  777. [self presentViewController:nextVC animated:YES completion:^{
  778. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  779. }];
  780. }
  781. - (void)checkFileTransferTask
  782. {//有个偶现的闪退在BGFMDB
  783. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  784. self->hadUploadTaskType = isSuccess;
  785. [self setRightButtonRedTypeFun];
  786. }];
  787. KWeakSelf
  788. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  789. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  790. self->hadDownloadTaskType = isSuccess;
  791. [weakSelf setRightButtonRedTypeFun];
  792. }];
  793. });
  794. }
  795. - (void)setRightButtonRedTypeFun
  796. {
  797. mainBlock(^{
  798. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  799. self->rightRedView.hidden = NO;
  800. }
  801. else{
  802. self->rightRedView.hidden = YES;
  803. }
  804. });
  805. }
  806. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  807. {
  808. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  809. [self.navigationController pushViewController:vc animated:YES];
  810. }
  811. #pragma mark 获取文件数据
  812. - (void)getFileListFun:(BOOL)isMoreDataType
  813. {
  814. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  815. // NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  816. // if(diskNameArr && diskNameArr.count >= 2){
  817. //
  818. // NSString *name = diskNameArr.lastObject;
  819. // if(name.length == 0)
  820. // {
  821. // name = diskNameArr[diskNameArr.count -2];
  822. // }
  823. //
  824. // [paraDict setValue:name forKey:@"path"];
  825. // }
  826. if(_defaultDiskPath){
  827. [paraDict setValue:_defaultDiskPath forKey:@"path"];
  828. }
  829. // if(!isMoreDataType){
  830. // self.pageIndex = 0;
  831. // }
  832. // else{
  833. // self.pageIndex ++;
  834. // }
  835. //
  836. // [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
  837. // [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
  838. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  839. KWeakSelf
  840. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileListByFolder" Parameters:paraDict success:^(id _Nonnull responseObject) {
  841. [weakSelf removeNewIndicatorHaveStr];
  842. //[weakSelf.tableView.mj_footer endRefreshing];
  843. NASFileAndFolderModel*NASFileAudioMod = [[NASFileAndFolderModel alloc] initWithDictionary:responseObject error:nil];
  844. // if(NASFileAudioMod.data.list.count < pageSizeNum){
  845. // [weakSelf.tableView.mj_footer endRefreshingWithNoMoreData];
  846. // }
  847. [weakSelf handelNetDataAfterFilterDataBy:NASFileAudioMod];
  848. if(weakSelf.curNASFileAudioMod && weakSelf.curNASFileAudioMod.status == 0){
  849. [weakSelf.tableView reloadData];
  850. }
  851. } failure:^(NSError * _Nonnull error) {
  852. [weakSelf removeNewIndicatorHaveStr];
  853. //[weakSelf.tableView.mj_footer endRefreshing];
  854. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  855. {
  856. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  857. }
  858. else{
  859. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  860. }
  861. }];
  862. }
  863. #pragma mark 上拉或者点击更多数据
  864. - (void)getMoreNetWorkData
  865. {
  866. [self getFileListFun:YES];
  867. }
  868. #pragma mark 分页数据组装
  869. - (void)handelNetDataAfterFilterDataBy:(NASFileAndFolderModel*)NASFileAudioMod
  870. {
  871. if(_curNASFileAudioMod && _curNASFileAudioMod.data && _curNASFileAudioMod.data.list){
  872. NSMutableArray *handelDataArr = [NSMutableArray arrayWithArray:_curNASFileAudioMod.data.list];//旧数据
  873. [handelDataArr addObjectsFromArray:NASFileAudioMod.data.list];//新数据
  874. _curNASFileAudioMod.data.list = (NSArray<NASFileAndFolderDataModel>*)handelDataArr;
  875. }
  876. else{
  877. _curNASFileAudioMod = NASFileAudioMod;
  878. }
  879. // if(_curNASFileAudioMod.data.list.count == 0 ){
  880. // self.tableView.mj_footer.hidden = YES;
  881. // }
  882. // else{
  883. // self.tableView.mj_footer.hidden = NO;
  884. // }
  885. }
  886. #pragma mark 调整文件上传
  887. - (void)gotoUploadFileFunWith:(NSInteger)tag
  888. {
  889. if(tag == 10 || tag == 11){
  890. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  891. if(tag ==10){
  892. vc.isPhotoType = YES;
  893. }
  894. else{
  895. vc.isPhotoType = NO;
  896. }
  897. [self.navigationController pushViewController:vc animated:YES];
  898. }
  899. else{
  900. KWeakSelf
  901. [[DocumentPickerManager shareManager] openDocumentPickerSuccess:^(NSArray * _Nonnull urls) {
  902. [weakSelf gotoUploadFileRecordByFileAppWithUrls:urls];
  903. }];
  904. }
  905. }
  906. #pragma mark 文件下载
  907. - (void)gotoDownLoadFileFun
  908. {
  909. if(_didSelectListArr.count == 0){
  910. [[iToast makeText:@""] show];
  911. return;
  912. }
  913. NSMutableArray *arr = [NSMutableArray new];
  914. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  915. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  916. fileModel.fileType = dataModel.type;
  917. fileModel.path = dataModel.path;
  918. fileModel.name = dataModel.name;
  919. fileModel.length = dataModel.size;
  920. fileModel.time = dataModel.duration;
  921. [arr addObject:fileModel];
  922. }
  923. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  924. [self.navigationController pushViewController:vc animated:YES];
  925. vc.isDownloadingType = YES;
  926. [vc gotoDownloadFile:arr];
  927. }
  928. #pragma mark 删除图片
  929. - (void)showDeleteAlearViewFun
  930. {
  931. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  932. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  933. KWeakSelf
  934. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  935. msg:tipStr
  936. imageStr:nil
  937. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  938. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  939. didClickOk:^{
  940. [weakSelf delFileListFun];
  941. } didClickCancel:^{
  942. }];
  943. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  944. [self presentViewController:curAlretVC animated:YES completion:^{
  945. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  946. }];
  947. }
  948. #pragma mark 删除文件数据
  949. - (void)delFileListFun
  950. {
  951. //处理数据埋点
  952. NSString * firstFileType = nil;
  953. BOOL isSameFileType = YES;
  954. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  955. if(!firstFileType){
  956. firstFileType = dataModel.type;
  957. }
  958. else if(![firstFileType isEqualToString:dataModel.type]){
  959. isSameFileType = NO;
  960. break;
  961. }
  962. }
  963. if(!isSameFileType){
  964. //数据埋点
  965. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_delete"];
  966. }
  967. else if([firstFileType containsString:@"jpg"]){
  968. //数据埋点
  969. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_delete"];
  970. }
  971. else if([firstFileType isEqualToString:@"video"]){
  972. //数据埋点
  973. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_delete"];
  974. }
  975. else if([firstFileType isEqualToString:@"audio"]){
  976. //数据埋点
  977. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_delete"];
  978. }
  979. else{
  980. //数据埋点
  981. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_delete"];
  982. }
  983. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  984. NSMutableArray *pathArr = [NSMutableArray new];
  985. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  986. [pathArr addObject:dataModel.path];
  987. }
  988. [paraDict setValue:pathArr forKey:@"path"];
  989. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  990. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  991. KWeakSelf //@"delFile"
  992. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  993. [weakSelf removeNewIndicator];
  994. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  995. if(model && model.status == 0){
  996. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  997. [weakSelf didDeleteSucFun];
  998. }
  999. else{
  1000. }
  1001. } failure:^(NSError * _Nonnull error) {
  1002. [weakSelf removeNewIndicator];
  1003. }];
  1004. }
  1005. #pragma mark 删除成功
  1006. - (void)didDeleteSucFun
  1007. {
  1008. //删除最近文件
  1009. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  1010. [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
  1011. }
  1012. //2.删除已经获取到的网络数据
  1013. [self deleteNetDataByDeleteSucFun];
  1014. [_didSelectListArr removeAllObjects];
  1015. [self setEditTypeTitleFun];
  1016. }
  1017. #pragma mark 删除成功后 对应删除原来获取的网络数据
  1018. - (void)deleteNetDataByDeleteSucFun
  1019. {
  1020. NSMutableArray *afterFilterArr = [NSMutableArray new];
  1021. for (NASFileAndFolderDataModel *model in _curNASFileAudioMod.data.list) {
  1022. if (!model.isSelectType) {
  1023. [afterFilterArr addObject:model];
  1024. }
  1025. }
  1026. _curNASFileAudioMod.data.list = (NSArray<NASFileAndFolderDataModel>*)afterFilterArr;
  1027. [self.tableView reloadData];
  1028. }
  1029. #pragma mark 图片详情删除成功后 对应删除原来获取的网络数据
  1030. - (void)deleteNetDataByFilePath:(NSString*)filePath
  1031. {
  1032. if(!filePath || filePath.length == 0){
  1033. return;
  1034. }
  1035. NSMutableArray *afterFilterArr = [NSMutableArray new];
  1036. for (NASFileAndFolderDataModel *model in _curNASFileAudioMod.data.list) {
  1037. if (![model.path isEqualToString:filePath]) {
  1038. [afterFilterArr addObject:model];
  1039. }
  1040. }
  1041. _curNASFileAudioMod.data.list = (NSArray<NASFileAndFolderDataModel>*)afterFilterArr;
  1042. [self.tableView reloadData];
  1043. }
  1044. #pragma mark 获取分享开关
  1045. -(void)queryShareSwitchFunFun
  1046. {
  1047. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  1048. [paraDict setValue:@6 forKey:@"type"];
  1049. KWeakSelf
  1050. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
  1051. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  1052. if(queryShareMod){
  1053. self->canShareType = queryShareMod.data.configValue;
  1054. [weakSelf.curEditTypeBottomView setCanShaewFunBy:queryShareMod.data.configValue];
  1055. }
  1056. } failure:^(NSError * _Nonnull error) {
  1057. }];
  1058. }
  1059. #pragma mark 点击了搜索
  1060. - (void)gotoSearchVCFun
  1061. {
  1062. NasSearchViewController *vc = [NasSearchViewController new];
  1063. //vc.fileType = @"doc";
  1064. [self.navigationController pushViewController:vc animated:YES];
  1065. }
  1066. #pragma mark 文件上传跳转上传记录
  1067. - (void)gotoUploadFileRecordByFileAppWithUrls:(NSArray*)urls
  1068. {
  1069. if(!urls || urls.count){
  1070. return;
  1071. }
  1072. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1073. [self.navigationController pushViewController:vc animated:YES];
  1074. vc.isUploadingType = YES;
  1075. [vc gotoUploadFileByFileApp:urls];
  1076. }
  1077. @end