previewImageOrVideoViewController.m 49 KB

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