previewImageOrVideoViewController.m 44 KB

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