previewImageOrVideoViewController.m 46 KB

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