previewImageOrVideoViewController.m 45 KB

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