NasSearchViewController.m 26 KB

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