NasSearchViewController.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  1. //
  2. // NasSearchViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2025/3/18.
  6. //
  7. #import "NasSearchViewController.h"
  8. #import "searchBarSecondTypeView.h"
  9. #import "searchListModel.h"
  10. #import "couldPhoneFileListModel.h"
  11. #import "downloadManager.h"
  12. #import "uploadFileRecordViewController.h"
  13. #import "UIScrollView+EmptyDataSet.h"
  14. #import "downLoadPreViewCell.h"
  15. #import "editTypeHeadView.h"
  16. #import "editTypeBottomView.h"
  17. #import "editShareView.h"
  18. #import "netWorkManager.h"
  19. #import "queryShareModel.h"
  20. #import "audioPlayerViewController.h"
  21. #import "videoPlayByAVPlayerViewController.h"
  22. #import "MJRefresh.h"
  23. #import "previewFileAndFolderSecondViewController.h"
  24. #import "imageDetailsScrollViewController.h"
  25. @interface NasSearchViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
  26. {
  27. BOOL canShareType;
  28. }
  29. @property (nonatomic, strong) UITableView *tableView;
  30. @property(nonatomic,assign) BOOL isEditType;
  31. @property(nonatomic,strong) editTypeHeadView*curEditTypeHeadView;
  32. @property(nonatomic,strong) editTypeBottomView*curEditTypeBottomView;
  33. @property(nonatomic,strong) searchBarSecondTypeView* searchBarSecondTypeV;//
  34. @property (nonatomic, strong) NSMutableArray*didSelectListArr;//选中的数据
  35. @property (nonatomic, strong) searchListModel *curSearchLisyMod;
  36. @property (nonatomic, copy) NSString *searchKeyWord;//搜索关键字
  37. @property (nonatomic, strong) UIView *tableViewHead;
  38. @property (nonatomic, strong) UILabel *tableViewHeadLabel;
  39. @end
  40. @implementation NasSearchViewController
  41. - (void)viewDidLoad {
  42. [super viewDidLoad];
  43. // Do any additional setup after loading the view.
  44. [self.toolBar setHidden:YES];
  45. [self.navigationBar setHidden:YES];
  46. [self.navBarBGView setHidden:NO];
  47. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  48. [self.view setBackgroundColor:[UIColor whiteColor]];
  49. [self drawAnyView];
  50. _didSelectListArr = [NSMutableArray new];
  51. //数据埋点
  52. //[[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Video"];
  53. }
  54. - (void)drawAnyView{
  55. _searchBarSecondTypeV = [[searchBarSecondTypeView alloc] init];
  56. [self.view addSubview:_searchBarSecondTypeV];
  57. [_searchBarSecondTypeV mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.centerY.equalTo(self.backBtn.mas_centerY).offset(0);
  59. make.height.mas_equalTo(32.0);
  60. make.left.mas_equalTo(52.0);
  61. //make.right.mas_equalTo(-48.0);
  62. make.right.mas_equalTo(0.0);
  63. }];
  64. KWeakSelf
  65. _searchBarSecondTypeV.didClickSearchFun = ^(NSString * _Nonnull searchText) {
  66. //HLog(@"1111:%@",searchText)
  67. weakSelf.searchKeyWord = searchText;
  68. weakSelf.curSearchLisyMod = nil;
  69. [weakSelf searchListDataFun:NO];
  70. };
  71. _curEditTypeHeadView = [[editTypeHeadView alloc] init];
  72. _curEditTypeHeadView.hidden = YES;
  73. [self.navBarBGView addSubview:_curEditTypeHeadView];
  74. [_curEditTypeHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.left.mas_equalTo(0);
  76. make.right.mas_equalTo(0);
  77. make.bottom.mas_equalTo(0);
  78. make.height.mas_equalTo(NAVIHEIGHT - AdaptNaviHeight);
  79. }];
  80. #pragma mark 编辑状态的 取消 和全选按钮 响应事件
  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. [self.view addSubview:self.tableView];
  111. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.left.mas_equalTo(0);
  113. make.right.mas_equalTo(0);
  114. //make.bottom.mas_equalTo(-(safeArea));
  115. make.bottom.mas_equalTo(0);
  116. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  117. }];
  118. self.tableView.hidden = YES;
  119. _tableViewHead = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 30)];
  120. _tableViewHead.backgroundColor = [UIColor whiteColor];
  121. //self.tableView.tableHeaderView = _tableViewHead;
  122. _tableViewHeadLabel = [[UILabel alloc] init];
  123. _tableViewHeadLabel.textColor = [UIColor hwColor:@"#0A132B"];
  124. _tableViewHeadLabel.font = [UIFont systemFontOfSize:12.0];
  125. _tableViewHeadLabel.text = NSLocalizedString(@"Search_Total_result",nil);
  126. [_tableViewHead addSubview:_tableViewHeadLabel];
  127. [_tableViewHeadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  128. make.left.mas_equalTo(15.0);
  129. make.right.mas_equalTo(0.0);
  130. make.top.mas_equalTo(0.0);
  131. make.bottom.mas_equalTo(0.0);
  132. }];
  133. }
  134. #pragma mark - 懒加载
  135. - (UITableView *)tableView{
  136. if (!_tableView) {
  137. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  138. _tableView.delegate = self;
  139. _tableView.dataSource = self;
  140. _tableView.showsVerticalScrollIndicator = NO;
  141. _tableView.showsHorizontalScrollIndicator = NO;
  142. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  143. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  144. [_tableView setSeparatorColor:[UIColor clearColor]];
  145. [_tableView setBackgroundColor:[UIColor clearColor]];
  146. [_tableView setTableFooterView:[UIView new]];
  147. [_tableView setBounces:YES];
  148. if (@available(iOS 15.0, *)) {
  149. _tableView.sectionHeaderTopPadding = 0;
  150. }
  151. //空数据引入第三方开源处理
  152. _tableView.emptyDataSetSource = self;
  153. _tableView.emptyDataSetDelegate = self;
  154. // 下拉追加
  155. MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  156. [self getMoreNetWorkData];
  157. }];
  158. NSString *text = NSLocalizedString(@"NAS_bottom_tip",nil);
  159. [footer setTitle:text forState:MJRefreshStateNoMoreData];
  160. _tableView.mj_footer = footer;
  161. _tableView.mj_footer.hidden = YES;
  162. }
  163. return _tableView;
  164. }
  165. #pragma mark - 列表委托
  166. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  167. return 1;
  168. }
  169. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  170. if(!_curSearchLisyMod){
  171. return 0;
  172. }
  173. return _curSearchLisyMod.data.list.count;
  174. }
  175. - (downLoadPreViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  176. __block NSInteger row = indexPath.row;
  177. static NSString *identifier = @"downLoadPreViewCell";
  178. downLoadPreViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  179. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  180. if (!cell){
  181. cell = [[downLoadPreViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  182. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  183. [cell setBackgroundColor:[UIColor clearColor]];
  184. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  185. [cell.bgViewLayer removeFromSuperlayer];
  186. [cell.titleLabel2 setHidden:NO];
  187. [cell.rightImage setHidden:YES];
  188. [cell.lineView setHidden:YES];
  189. [cell.checkButton setHidden:NO];
  190. }
  191. if(row < _curSearchLisyMod.data.list.count){
  192. searchDataModel* dataModel = _curSearchLisyMod.data.list[row];
  193. cell.curNASFileAudioDataModel = (NASFileAudioDataModel*)dataModel;
  194. KWeakSelf
  195. cell.didClickSwitch = ^(BOOL SwitchOn) {
  196. //if([weakSelf userCheckFileModel:dataModel withShowTip:YES]){
  197. [weakSelf userCheckFilePreviewByRow:row];
  198. //}
  199. };
  200. }
  201. return cell;
  202. }
  203. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  204. return 70;
  205. }
  206. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  207. {
  208. NSInteger row = indexPath.row;
  209. if(row < _curSearchLisyMod.data.list.count){
  210. NASFileAndFolderDataModel* dataModel = _curSearchLisyMod.data.list[row];
  211. if([dataModel.type isEqualToString:@"dir"])
  212. {
  213. previewFileAndFolderSecondViewController *vc = [previewFileAndFolderSecondViewController new];
  214. vc.curFolderDataModel = dataModel;
  215. vc.canShareType = canShareType;
  216. [self.navigationController pushViewController:vc animated:YES];
  217. }
  218. else if([dataModel.type isEqualToString:@"video"]){
  219. videoPlayByAVPlayerViewController *vc = [videoPlayByAVPlayerViewController new];
  220. vc.VideoDataMode = dataModel;
  221. [self.navigationController pushViewController:vc animated:YES];
  222. KWeakSelf
  223. vc.didNeedDeleteFile = ^(NSString * _Nonnull filePath) {
  224. [weakSelf deleteNetDataByFilePath:filePath];
  225. };
  226. }
  227. else if([dataModel.type isEqualToString:@"audio"]){
  228. // NSMutableArray *dataArr = [NSMutableArray new];
  229. // [dataArr addObject:dataModel];
  230. audioPlayerViewController * vc = [audioPlayerViewController new];
  231. vc.isfirstEnterType = YES;
  232. vc.outSideDataModel = (NASFileAudioDataModel *)dataModel;
  233. [self.navigationController pushViewController:vc animated:YES];
  234. KWeakSelf
  235. vc.didNeedDeleteFile = ^(NSString * _Nonnull filePath) {
  236. [weakSelf deleteNetDataByFilePath:filePath];
  237. };
  238. }
  239. else if([dataModel.type containsString:@"jpg"]){
  240. NSMutableArray *jpgDataArr = [NSMutableArray new];
  241. NSInteger index = 0;
  242. [jpgDataArr addObject:dataModel];
  243. imageDetailsScrollViewController *vc = [imageDetailsScrollViewController new];
  244. vc.index = index;
  245. vc.totalDataArr = jpgDataArr;
  246. [self.navigationController pushViewController:vc animated:YES];
  247. vc.canShareType = canShareType;
  248. }
  249. }
  250. }
  251. #pragma mark 空数据
  252. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
  253. NSString *imageName = @"common_no_data_pic";
  254. return [UIImage imageNamed:imageName];
  255. }
  256. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  257. NSString *text = NSLocalizedString(@"Search_nodata_tip",nil);
  258. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
  259. NSForegroundColorAttributeName: HW999999Color};
  260. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  261. }
  262. //调整图片位置
  263. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
  264. return -150;
  265. }
  266. //ios端:
  267. //1、需求说明:解决除MP4 MOV 3GP M4V 总计4种格式外,其他格式下载失败的问题;
  268. //2、交互说明:下载列表勾选文件中含有其他格式,toast提示“IOS系统仅支持MP4、MOV、3GP、M4V 的视频格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载MP4、MOV、3GP、M4V 的视频格式文件;
  269. //ios支持图片格式: (SVG 不支持)
  270. //需求说明:解决除JPG PNG GIF TIFF BMP总计5种格式外,其他格式下载失败的问题
  271. //视觉交互:选择文件中含有其他格式,toast提示“IOS系统仅支持JPG 、PNG、GIF、TIFF、BMP的图片格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载JPG 、PNG、GIF、TIFF、BMP的图片格式文件;
  272. - (BOOL)userCheckFileModel:(couldPhoneFileModel*)fileModel withShowTip:(BOOL)canShow{
  273. NSString*name = [fileModel.name lowercaseString];
  274. NSArray *nameArr = [name componentsSeparatedByString:@"."];
  275. if(nameArr.count >0){
  276. BOOL canDownLoadType = NO;
  277. NSString *lastName = nameArr.lastObject;
  278. if([lastName isEqualToString:@"mp4"]
  279. ||[lastName isEqualToString:@"mov"]
  280. ||[lastName isEqualToString:@"3gp"]
  281. ||[lastName isEqualToString:@"m4v"]){
  282. canDownLoadType = YES;
  283. }
  284. if(!canDownLoadType){
  285. if(canShow){
  286. [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  287. }
  288. return NO;
  289. }
  290. }
  291. if(nameArr.count >0){
  292. BOOL canDownLoadType = NO;
  293. //JPG 、PNG、GIF、TIFF、BMP
  294. NSString *lastName = nameArr.lastObject;
  295. if([lastName isEqualToString:@"jpg"]
  296. ||[lastName isEqualToString:@"png"]
  297. ||[lastName isEqualToString:@"gif"]
  298. ||[lastName isEqualToString:@"tiff"]
  299. ||[lastName isEqualToString:@"bmp"]
  300. ||[lastName isEqualToString:@"heic"]
  301. ||[lastName isEqualToString:@"jpeg"]
  302. ||[lastName isEqualToString:@"heif"]){
  303. canDownLoadType = YES;
  304. }
  305. if(!canDownLoadType){
  306. if(canShow){
  307. [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  308. }
  309. return NO;
  310. }
  311. }
  312. return YES;
  313. }
  314. #pragma mark 用户长按图片进入编辑
  315. - (void)setViewEditTypeFun
  316. {
  317. _isEditType = YES;
  318. _searchBarSecondTypeV.hidden = YES;
  319. //[self.tableView reloadData];
  320. _curEditTypeHeadView.hidden = NO;
  321. _curEditTypeBottomView.hidden = NO;
  322. [self RefreshAllUIFun];
  323. }
  324. #pragma mark 用户取消编辑编辑
  325. - (void)userCancelEditTypeFun
  326. {
  327. //数据还原
  328. for (NASFileAudioDataModel*model in _didSelectListArr) {
  329. model.isSelectType = NO;
  330. }
  331. [_didSelectListArr removeAllObjects];
  332. _isEditType = NO;
  333. _searchBarSecondTypeV.hidden = NO;
  334. //[self.tableView reloadData];
  335. _curEditTypeHeadView.hidden = YES;
  336. _curEditTypeBottomView.hidden = YES;
  337. [self RefreshAllUIFun];
  338. }
  339. #pragma mark 更新UI界面
  340. - (void)RefreshAllUIFun
  341. {
  342. [self.tableView reloadData];
  343. KWeakSelf
  344. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  345. make.left.mas_equalTo(0);
  346. make.right.mas_equalTo(0);
  347. if(weakSelf.isEditType){
  348. make.bottom.equalTo(weakSelf.curEditTypeBottomView.mas_top).offset(0.0);
  349. }
  350. else{
  351. make.bottom.mas_equalTo(0);
  352. }
  353. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  354. }];
  355. }
  356. - (void)userCheckFilePreviewByRow:(NSInteger)row
  357. {
  358. if(row < _curSearchLisyMod.data.list.count){
  359. NASFileAudioDataModel* dataModel = _curSearchLisyMod.data.list[row];
  360. if(dataModel.isSelectType){
  361. [_didSelectListArr removeObject:dataModel];
  362. }
  363. else{
  364. [_didSelectListArr addObject:dataModel];
  365. }
  366. dataModel.isSelectType = !dataModel.isSelectType;
  367. [self setEditTypeTitleFun];
  368. }
  369. }
  370. - (void)didClickSelectAllButton:(UIButton*)button
  371. {
  372. //button.selected = !button.selected;
  373. [_didSelectListArr removeAllObjects];
  374. for (NASFileAudioDataModel* dataModel in _curSearchLisyMod.data.list) {
  375. if(!button.selected){
  376. dataModel.isSelectType = button.selected;
  377. }
  378. else{
  379. [_didSelectListArr addObject:dataModel];
  380. dataModel.isSelectType = button.selected;
  381. }
  382. }
  383. [self.tableView reloadData];
  384. //[self.dataCollectionView reloadData];
  385. [self setEditTypeTitleFun];
  386. }
  387. #pragma mark 设置选中标题
  388. - (void)setEditTypeTitleFun
  389. {
  390. [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
  391. if(_didSelectListArr.count > 0){
  392. [self setViewEditTypeFun];
  393. }
  394. else{
  395. [self userCancelEditTypeFun];
  396. }
  397. }
  398. #pragma mark 用户点击分享
  399. - (void)gotoShareViewFun
  400. {
  401. if (_didSelectListArr.count > 5) {
  402. [[iToast makeText:NSLocalizedString(@"share_max_count_tip2",nil)] show];
  403. return;
  404. }
  405. editShareView *editShareV = [[editShareView alloc] init];
  406. editShareV.didSelectListArr = _didSelectListArr;
  407. editShareV.shareFileType = @"3";
  408. [self.view addSubview:editShareV];
  409. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  410. make.left.mas_equalTo(0);
  411. make.right.mas_equalTo(0);
  412. make.bottom.mas_equalTo(0);
  413. make.top.mas_equalTo(0);
  414. }];
  415. }
  416. - (void)viewWillAppear:(BOOL)animated
  417. {
  418. [super viewWillAppear:animated];
  419. }
  420. - (void)viewDidAppear:(BOOL)animated{
  421. [super viewDidAppear:animated];
  422. [self showDownloadTipFun];
  423. if(!_curSearchLisyMod){
  424. [self queryShareSwitchFunFun];
  425. }
  426. }
  427. - (void)viewWillDisappear:(BOOL)animated{
  428. [super viewWillDisappear:animated];
  429. //[self removeNewIndicator];
  430. [self removeNewIndicatorHaveStr];
  431. }
  432. - (void)gotoDownloadloadFileRecordFun
  433. {
  434. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  435. [self.navigationController pushViewController:vc animated:YES];
  436. vc.isDownloadingType = YES;
  437. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  438. }
  439. - (void)showDownloadTipFun
  440. {
  441. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  442. if(didReadUploadTipType){
  443. return;
  444. }
  445. //KWeakSelf
  446. /*弹窗提示恢复出厂*/
  447. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:@""
  448. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  449. imageStr:@""
  450. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  451. okTitle:@""
  452. isOkBtnHighlight:NO
  453. didClickOk:^{
  454. } didClickCancel:^{
  455. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  456. }];
  457. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  458. [self presentViewController:nextVC animated:YES completion:^{
  459. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  460. }];
  461. }
  462. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  463. {
  464. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  465. [self.navigationController pushViewController:vc animated:YES];
  466. }
  467. #pragma mark 获取文件数据
  468. - (void)searchListDataFun:(BOOL)isMoreDataType
  469. {
  470. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  471. if(self.searchKeyWord){
  472. [paraDict setValue:self.searchKeyWord forKey:@"keyword"];
  473. }
  474. if(self.fileType){
  475. [paraDict setValue:self.fileType forKey:@"fileType"];
  476. }
  477. if(!isMoreDataType){
  478. self.pageIndex = 0;
  479. }
  480. else{
  481. self.pageIndex ++;
  482. }
  483. [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
  484. [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
  485. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  486. KWeakSelf
  487. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"search1" Parameters:paraDict success:^(id _Nonnull responseObject) {
  488. weakSelf.tableView.hidden = NO;
  489. [weakSelf.tableView.mj_footer endRefreshing];
  490. [weakSelf removeNewIndicatorHaveStr];
  491. searchListModel *model = [[searchListModel alloc] initWithDictionary:responseObject error:nil];;
  492. if(model && model.status == 0){
  493. [self handelNetDataAfterFilterDataBy:model];
  494. if (model.data.list.count < pageSizeNum) {
  495. [weakSelf.tableView.mj_footer endRefreshingWithNoMoreData];
  496. }
  497. else{
  498. [weakSelf.tableView.mj_footer resetNoMoreData];
  499. }
  500. [weakSelf RefreshAllUIFun];
  501. }
  502. } failure:^(NSError * _Nonnull error) {
  503. weakSelf.tableView.hidden = NO;
  504. [weakSelf.tableView.mj_footer endRefreshing];
  505. [weakSelf removeNewIndicatorHaveStr];
  506. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  507. {
  508. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  509. }
  510. else{
  511. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  512. }
  513. }];
  514. }
  515. #pragma mark 上拉或者点击更多数据
  516. - (void)getMoreNetWorkData
  517. {
  518. [self searchListDataFun:YES];
  519. }
  520. #pragma mark 分页数据组装
  521. - (void)handelNetDataAfterFilterDataBy:(searchListModel*)model
  522. {
  523. if(_curSearchLisyMod && _curSearchLisyMod.data.list ){
  524. NSMutableArray *handelDataArr = [NSMutableArray arrayWithArray:_curSearchLisyMod.data.list];//旧数据
  525. [handelDataArr addObjectsFromArray:model.data.list];//新数据
  526. _curSearchLisyMod.data.list = (NSArray<searchDataModel>*)handelDataArr;
  527. }
  528. else{
  529. _curSearchLisyMod = model;
  530. if (_curSearchLisyMod.data.total == 0) {
  531. self.tableView.tableHeaderView = nil;
  532. }
  533. else{
  534. self.tableView.tableHeaderView = _tableViewHead;
  535. NSString *str = [[NSString alloc] initWithFormat:@"%@(%ld)",NSLocalizedString(@"Search_Total_result",nil),_curSearchLisyMod.data.total];
  536. _tableViewHeadLabel.text = str;
  537. }
  538. }
  539. if(_curSearchLisyMod.data.list.count == 0 ){
  540. self.tableView.mj_footer.hidden = YES;
  541. }
  542. else{
  543. self.tableView.mj_footer.hidden = NO;
  544. }
  545. }
  546. #pragma mark 文件下载
  547. - (void)gotoDownLoadFileFun
  548. {
  549. if(_didSelectListArr.count == 0){
  550. [[iToast makeText:@""] show];
  551. return;
  552. }
  553. NSMutableArray *arr = [NSMutableArray new];
  554. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  555. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  556. fileModel.fileType = dataModel.type;
  557. fileModel.path = dataModel.path;
  558. fileModel.name = dataModel.name;
  559. fileModel.length = dataModel.size;
  560. fileModel.time = dataModel.duration;
  561. [arr addObject:fileModel];
  562. }
  563. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  564. [self.navigationController pushViewController:vc animated:YES];
  565. vc.isDownloadingType = YES;
  566. [vc gotoDownloadFile:arr];
  567. }
  568. #pragma mark 删除图片
  569. - (void)showDeleteAlearViewFun
  570. {
  571. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  572. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  573. KWeakSelf
  574. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  575. msg:tipStr
  576. imageStr:@""
  577. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  578. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  579. didClickOk:^{
  580. [weakSelf delFileListFun];
  581. } didClickCancel:^{
  582. }];
  583. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  584. [self presentViewController:curAlretVC animated:YES completion:^{
  585. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  586. }];
  587. }
  588. #pragma mark 删除文件数据
  589. - (void)delFileListFun
  590. {
  591. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  592. NSMutableArray *pathArr = [NSMutableArray new];
  593. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  594. [pathArr addObject:dataModel.path];
  595. }
  596. [paraDict setValue:pathArr forKey:@"path"];
  597. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  598. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  599. KWeakSelf //@"delFile"
  600. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  601. [weakSelf removeNewIndicator];
  602. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  603. if(model && model.status == 0){
  604. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  605. [weakSelf didDeleteSucFun];
  606. }
  607. else{
  608. }
  609. } failure:^(NSError * _Nonnull error) {
  610. [weakSelf removeNewIndicator];
  611. }];
  612. //数据埋点
  613. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_delete"];
  614. }
  615. #pragma mark 删除成功
  616. - (void)didDeleteSucFun
  617. {
  618. //删除最近文件
  619. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  620. [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
  621. }
  622. //2.删除已经获取到的网络数据
  623. [self deleteNetDataByDeleteSucFun];
  624. [_didSelectListArr removeAllObjects];
  625. [self setEditTypeTitleFun];
  626. }
  627. #pragma mark 删除成功后 对应删除原来获取的网络数据
  628. - (void)deleteNetDataByDeleteSucFun
  629. {
  630. NSMutableArray *afterFilterArr = [NSMutableArray new];
  631. for (searchDataModel *model in _curSearchLisyMod.data.list) {
  632. if (!model.isSelectType) {
  633. [afterFilterArr addObject:model];
  634. }
  635. }
  636. _curSearchLisyMod.data.list = (NSArray<searchDataModel>*)afterFilterArr;
  637. [self.tableView reloadData];
  638. }
  639. #pragma mark 图片详情删除成功后 对应删除原来获取的网络数据
  640. - (void)deleteNetDataByFilePath:(NSString*)filePath
  641. {
  642. if(!filePath || filePath.length == 0){
  643. return;
  644. }
  645. NSMutableArray *afterFilterArr = [NSMutableArray new];
  646. for (searchDataModel *model in _curSearchLisyMod.data.list) {
  647. if (![model.path isEqualToString:filePath]) {
  648. [afterFilterArr addObject:model];
  649. }
  650. }
  651. _curSearchLisyMod.data.list = (NSArray<searchDataModel>*)afterFilterArr;
  652. [self.tableView reloadData];
  653. }
  654. #pragma mark 获取分享开关
  655. -(void)queryShareSwitchFunFun
  656. {
  657. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  658. [paraDict setValue:@3 forKey:@"type"];
  659. KWeakSelf
  660. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
  661. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  662. if(queryShareMod){
  663. self->canShareType = queryShareMod.data.configValue;
  664. //weakSelf.curEditTypeBottomView.isCanShareType = self->canShareType;
  665. [weakSelf.curEditTypeBottomView setCanShaewFunBy:queryShareMod.data.configValue];
  666. }
  667. } failure:^(NSError * _Nonnull error) {
  668. }];
  669. }
  670. @end