previewImageOrVideoViewController.m 46 KB

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