previewImageOrVideoViewController.m 41 KB

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