previewImageOrVideoViewController.m 47 KB

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