mineViewController.m 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. //
  2. // mineViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/21.
  6. //
  7. #import "mineViewController.h"
  8. #import "MineCommonUsedView.h"
  9. #import "privacyModeViewController.h"
  10. #import "TipsQRCodeForChangeDeviceViewController.h"
  11. #import "AboutViewController.h"
  12. #import "clearCacheAlretViewController.h"
  13. #import "inputPWDViewController.h"
  14. #import "customerServiceViewController.h"
  15. #import "customDownloadCacheManager.h"
  16. #import "CustomerWebViewController.h"
  17. #import "audioPlayingView.h"
  18. #import "DFPlayer.h"
  19. #import "audioPlayerViewController.h"
  20. #import "scanToPCLoginViewController.h"
  21. #import "PCLoginViewController.h"
  22. #import "cloudPhoneModelViewController.h"
  23. #import <SDCycleScrollView/SDCycleScrollView.h>
  24. #import "ADModel.h"
  25. @interface mineViewController ()<SDCycleScrollViewDelegate>
  26. @property(nonatomic,strong)UIButton *netButton;
  27. @property(nonatomic,strong)UILabel *snLabel;
  28. @property(nonatomic,strong)UIButton *snCopyButton;
  29. @property(nonatomic,strong)MineCommonUsedView *MineCommonUsedV;
  30. @property (nonatomic,strong) SDCycleScrollView *curScrollView;
  31. @property (nonatomic,strong) ADModel *curADModel;
  32. @end
  33. @implementation mineViewController
  34. - (void)viewDidLoad {
  35. [super viewDidLoad];
  36. // Do any additional setup after loading the view.
  37. [self.view setBackgroundColor:HWF5F7FAColor];
  38. [self.toolBar setHidden:YES];
  39. [self.navigationBar setHidden:YES];
  40. [self.navBarBGView setHidden:YES];
  41. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(PCLoginDidPopFun) name:showTabbarNotification object:nil];
  42. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainSetDataFun) name:webRtcLinkStateChangeNotification object:nil];
  43. [self drawAnyView];
  44. [self queryOnTheShelfFun];
  45. }
  46. - (void)drawAnyView{
  47. //顶底底部图片
  48. UIImageView *topImageV = [UIImageView new];
  49. topImageV.image = [UIImage imageNamed:@"Nas_top_img"];
  50. [self.view addSubview:topImageV];
  51. [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.top.mas_equalTo(0);
  53. make.left.mas_equalTo(0);
  54. make.right.mas_equalTo(0);
  55. make.height.mas_equalTo(280.0*AUTOSCALE);
  56. }];
  57. UIButton *pcScanButton = [[UIButton alloc] init];
  58. [pcScanButton setImage:[UIImage imageNamed:@"pc_scan_icon"] forState:UIControlStateNormal];
  59. pcScanButton.tag = 100;
  60. [pcScanButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  61. [self.view addSubview:pcScanButton];
  62. [pcScanButton mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.top.mas_equalTo(50);
  64. make.right.mas_equalTo(-15);
  65. make.width.mas_equalTo(40);
  66. make.height.mas_equalTo(40);
  67. }];
  68. CGFloat tipImageTop = 50 + 40;
  69. //商标图片
  70. UIImageView *TipImageV = [UIImageView new];
  71. TipImageV.image = [UIImage imageNamed:@"mine_head_icon"];
  72. [self.view addSubview:TipImageV];
  73. [TipImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.top.mas_equalTo(tipImageTop);
  75. make.left.mas_equalTo(16);
  76. make.width.mas_equalTo(48);
  77. make.height.mas_equalTo(48);
  78. }];
  79. _snLabel = [[UILabel alloc] init];
  80. _snLabel.font = [UIFont boldSystemFontOfSize:14.0];
  81. _snLabel.textColor = [UIColor hwColor:@"#0A132B"];
  82. //_fileNamelabel.backgroundColor = [UIColor greenColor];
  83. [self.view addSubview:_snLabel];
  84. [_snLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.left.equalTo(TipImageV.mas_right).offset(5);
  86. make.right.mas_equalTo(-16);
  87. //make.centerY.mas_equalTo(TipImageV.mas_centerY).offset(0);
  88. make.top.mas_equalTo(TipImageV.mas_top).offset(0);
  89. make.height.mas_equalTo(20);
  90. }];
  91. // UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(copySnFun)];
  92. // [_snLabel addGestureRecognizer:tap];
  93. _snCopyButton = [[UIButton alloc] init];
  94. _snCopyButton.tag = 1;
  95. [_snCopyButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  96. [self.view addSubview:_snCopyButton];
  97. //_snCopyButton.backgroundColor = [UIColor redColor];
  98. [_snCopyButton mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.left.mas_equalTo(_snLabel.mas_left);
  100. make.top.equalTo(_snLabel.mas_top).offset(-5);
  101. make.right.mas_equalTo(_snLabel.mas_right);
  102. make.bottom.equalTo(_snLabel.mas_bottom).offset(2);
  103. }];
  104. _netButton = [[UIButton alloc] init];
  105. [_netButton setImage:[UIImage imageNamed:@"mine_net_icon"] forState:UIControlStateNormal];
  106. [_netButton setTitleColor:[UIColor hwColor:@"#058DFB"] forState:UIControlStateNormal];
  107. _netButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
  108. //[_netButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  109. _netButton.userInteractionEnabled = NO;
  110. [self.view addSubview:_netButton];
  111. _netButton.layer.cornerRadius = 12;
  112. _netButton.layer.borderWidth = 1.5;
  113. _netButton.layer.borderColor = [UIColor hwColor:@"#058DFB"].CGColor;
  114. _netButton.layer.masksToBounds = YES;
  115. [_netButton mas_makeConstraints:^(MASConstraintMaker *make) {
  116. //make.width.mas_equalTo(58);
  117. make.width.mas_equalTo(70);
  118. make.height.mas_equalTo(24);
  119. make.left.equalTo(TipImageV.mas_right).offset(5);
  120. make.bottom.mas_equalTo(TipImageV.mas_bottom).offset(0);
  121. }];
  122. //常用功能
  123. _MineCommonUsedV = [[MineCommonUsedView alloc] init];
  124. [self.view addSubview:_MineCommonUsedV];
  125. [_MineCommonUsedV mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.top.equalTo(TipImageV.mas_bottom).offset(15);
  127. make.left.mas_equalTo(0);
  128. make.right.mas_equalTo(0);
  129. make.height.mas_equalTo(210);
  130. }];
  131. KWeakSelf
  132. _MineCommonUsedV.didClickButtonFun = ^(NSInteger tag) {
  133. [weakSelf didClickCommonUsedFunBy:tag];
  134. };
  135. _curScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero imageURLStringsGroup:nil];
  136. _curScrollView.autoScroll = YES;
  137. _curScrollView.autoScrollTimeInterval = 5.0;
  138. _curScrollView.infiniteLoop = YES;
  139. //_curScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFit;
  140. //_curScrollView.placeholderImage = [UIImage imageNamed:@"uploadFile_image"];
  141. _curScrollView.layer.cornerRadius = 8;
  142. _curScrollView.layer.masksToBounds = YES;
  143. _curScrollView.delegate = self;
  144. [self.view addSubview:_curScrollView];
  145. //_curScrollView.backgroundColor = [UIColor blackColor];
  146. _curScrollView.hidesForSinglePage = YES;
  147. _curScrollView.hidden = YES;
  148. [_curScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  149. make.left.mas_equalTo(15);
  150. make.right.mas_equalTo(-15);
  151. make.top.equalTo(_MineCommonUsedV.mas_bottom).offset(18);
  152. make.height.mas_equalTo((SCREEN_W -15*2)*130/343.0);
  153. }];
  154. }
  155. #pragma mark 点击常用模块模块
  156. - (void)didClickCommonUsedFunBy:(NSInteger)tag
  157. {
  158. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  159. {
  160. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  161. return;
  162. }
  163. switch (tag)
  164. {
  165. case 10:{//隐私模式
  166. inputPWDViewController *nextVC = [inputPWDViewController new];
  167. nextVC.isCheckPwdType = YES;
  168. [self pushViewController:nextVC animated:YES];
  169. KWeakSelf
  170. nextVC.didInputRightPwdFun = ^{
  171. [weakSelf gotoPrivacyModeVCFun];
  172. };
  173. }
  174. break;
  175. case 11:{//云手机模式
  176. cloudPhoneModelViewController *nextVC = [cloudPhoneModelViewController new];
  177. [self pushViewController:nextVC animated:YES];
  178. }
  179. break;
  180. case 12:{//帮助与反馈
  181. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  182. vc.titleStr = NSLocalizedString(@"mine_help_title",nil);
  183. NSString *url = [[NSString alloc] initWithFormat:@"%@/problemFeedback/#/pages/fileSharing/problem/index?sn=",CloudService];
  184. vc.webUrl = [[NSString alloc] initWithFormat:@"%@%@",url,ksharedAppDelegate.DeviceThirdIdMod.data.changeSn];
  185. [self pushViewController:vc animated:YES];
  186. //数据埋点
  187. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Help_feedback"];
  188. }
  189. break;
  190. case 13:{//更换手机
  191. TipsQRCodeForChangeDeviceViewController *nextVC = [TipsQRCodeForChangeDeviceViewController new];
  192. [self pushViewController:nextVC animated:YES];
  193. break;
  194. }
  195. case 14:{//联系客服
  196. customerServiceViewController *vc = [customerServiceViewController new];
  197. [self pushViewController:vc animated:YES];
  198. }
  199. break;
  200. case 15:{//清理缓存
  201. [self clickClearCacheButtonFun];
  202. }
  203. case 16:{//版本信息
  204. AboutViewController *nextVC = [[AboutViewController alloc] init];
  205. nextVC.getSysInfo = ^{
  206. [[webRtcManager shareManager] getSysInfoFun];
  207. };
  208. [self pushViewController:nextVC animated:YES];
  209. }
  210. break;
  211. case 17:{//新手引导
  212. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  213. vc.titleStr = NSLocalizedString(@"mine_newuser_title",nil);
  214. NSString *url = [[NSString alloc] initWithFormat:@"%@/warrantyService/index.html#/novice",CloudService];
  215. vc.webUrl = url;
  216. [self pushViewController:vc animated:YES];
  217. }
  218. break;
  219. break;
  220. // case 17:{
  221. // [[iToast makeText:@"点击了注销"] show];
  222. // }
  223. // break;
  224. default:
  225. break;
  226. }
  227. }
  228. #pragma mark 去设置隐私
  229. - (void)gotoPrivacyModeVCFun
  230. {
  231. privacyModeViewController *nextVC = [[privacyModeViewController alloc] init];
  232. [self pushViewController:nextVC animated:YES];
  233. }
  234. #pragma mark 清理缓存相关
  235. - (void)clickClearCacheButtonFun
  236. {
  237. KWeakSelf
  238. /*弹窗提示清除缓存*/
  239. clearCacheAlretViewController *nextVC = [[clearCacheAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_clear_cache",nil)
  240. msg:NSLocalizedString(@"clear_cache_tip",nil)
  241. imageStr:nil
  242. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  243. okTitle:NSLocalizedString(@"other_clear",nil) isOkBtnHighlight:YES
  244. didClickOk:^(BOOL isSelect) {
  245. [weakSelf handleClearCacheFunWith:isSelect];
  246. } didClickCancel:^{
  247. }];
  248. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  249. [self presentViewController:nextVC animated:YES completion:^{
  250. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  251. }];
  252. }
  253. - (void)handleClearCacheFunWith:(BOOL)isSelectFileTransfer
  254. {
  255. [self ClearCommonCacheFun:isSelectFileTransfer];
  256. //数据埋点
  257. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Clear_cache"];
  258. }
  259. - (void)ClearCommonCacheFun:(BOOL)isSelectFileTransfer
  260. {
  261. NSString *ruiyunLogPath = [NSString stringWithFormat:@"%@/logs/debug_0.log",CachesPatch];
  262. long logSize1 = [iTools fileSizeAtPath:ruiyunLogPath];
  263. [[NSFileManager defaultManager] removeItemAtPath:ruiyunLogPath error:nil];
  264. NSString *appLogPath = [NSString stringWithFormat:@"%@/logs/app.log",CachesPatch];
  265. long logSize2 = [iTools fileSizeAtPath:appLogPath];
  266. [[NSFileManager defaultManager] removeItemAtPath:appLogPath error:nil];
  267. //
  268. NSString *downLoadThumbnailPath = [NSString stringWithFormat:@"%@/DownLoadThumbnail",CachesPatch];
  269. long logSize3 = [iTools folderSizeAtPath:downLoadThumbnailPath];
  270. [[NSFileManager defaultManager] removeItemAtPath:downLoadThumbnailPath error:nil];
  271. NSString *downLoadNasDowmPath = [customDownloadCacheManager getFullDirector];
  272. long logSize4 = [iTools folderSizeAtPath:downLoadNasDowmPath];
  273. [[NSFileManager defaultManager] removeItemAtPath:downLoadNasDowmPath error:nil];
  274. long clearTotal = logSize1 + logSize2 + logSize3 +logSize4 ;
  275. if(isSelectFileTransfer){
  276. //删除最近文件
  277. [[lastFileManager shareManager] deleteAllFileFun];
  278. [self clearCacheByFileTransferFun:clearTotal];
  279. }
  280. else{
  281. [self showClearAllTipBy:clearTotal];
  282. }
  283. }
  284. - (void)showClearAllTipBy:(long)clearTotal
  285. {
  286. long clearTotalK = clearTotal /1024;
  287. NSString *tipStr1 = NSLocalizedString(@"my_set_no_clear_finish",nil);
  288. NSString *tipStr2 = @"";
  289. if(clearTotalK > 1024*1024){
  290. tipStr2 = [[NSString alloc] initWithFormat:@"%.02fGB",clearTotalK/1024.0/1024.0];
  291. }
  292. else if(clearTotalK > 1024){
  293. tipStr2 = [[NSString alloc] initWithFormat:@"%.02fMB",clearTotalK/1024.0];
  294. }
  295. else //if(clearTotalK > 0)
  296. {
  297. tipStr2 = [[NSString alloc] initWithFormat:@"%ldKB",clearTotalK];
  298. }
  299. NSString *tipfullStr = [[NSString alloc] initWithFormat:@"%@%@",tipStr1,tipStr2];
  300. //提示语
  301. [[iToast makeText:tipfullStr] show];
  302. }
  303. - (void)clearCacheByFileTransferFun:(long)clearTotal
  304. {
  305. //清理图片
  306. BOOL needReUploadingType = NO;
  307. NSString *ImagePath = [NSString stringWithFormat:@"%@/Image",CachesPatch];
  308. long imageAllSize = [iTools folderSizeAtPath:ImagePath];
  309. // if([uploadFileManager shareInstance].curUploadFileDataModel
  310. // && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadFileType == uploadFileTypeImage
  311. // && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType == uploadStateUploading){
  312. //
  313. // [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateSuspend;
  314. // needReUploadingType = YES;
  315. // }
  316. [[NSFileManager defaultManager] removeItemAtPath:ImagePath error:nil];
  317. // if(needReUploadingType){
  318. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  319. // [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateUploading;
  320. // });
  321. // }
  322. //清理视频文件
  323. NSString *videoPath = [NSString stringWithFormat:@"%@/Video",CachesPatch];
  324. long vide0AllSizeBeforeClear = [iTools folderSizeAtPath:videoPath];
  325. NSString *backupsingVideoName = nil;
  326. if([nasBackupsManager shareInstance].curPhotosBackupsTaskMod
  327. && [nasBackupsManager shareInstance].curPhotosBackupsTaskMod.curUploadFileType == uploadFileTypeVideo){
  328. backupsingVideoName = [nasBackupsManager shareInstance].curPhotosBackupsTaskMod.filename;
  329. }
  330. NSString *uploadingVideoName = nil;
  331. // if([uploadFileManager shareInstance].curUploadFileDataModel
  332. // && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadFileType == uploadFileTypeVideo){
  333. // uploadingVideoName = [uploadFileManager shareInstance].curUploadFileDataModel.filename;
  334. // }
  335. if(backupsingVideoName || uploadingVideoName){
  336. NSMutableString *fileName = [NSMutableString new];
  337. if(backupsingVideoName){
  338. [fileName appendString:backupsingVideoName];
  339. }
  340. if(uploadingVideoName){
  341. if(fileName.length > 0){
  342. [fileName appendString:@"|"];
  343. }
  344. [fileName appendString:uploadingVideoName];
  345. }
  346. [self deleteFilesInDirectoryAtPath:videoPath withOutFileName:fileName];
  347. }
  348. else{
  349. [[NSFileManager defaultManager] removeItemAtPath:videoPath error:nil];
  350. }
  351. long vide0AllSizeAfterClear = [iTools folderSizeAtPath:videoPath];
  352. //清理下载中
  353. NSString *downLoadingPath = [NSString stringWithFormat:@"%@/DownLoadFlie",CachesPatch];
  354. long downLoadingSizeBeforeClear = [iTools folderSizeAtPath:downLoadingPath];
  355. // NSString *downLoadingFileName = nil;
  356. // if([downloadManager shareInstance].curDownloadFileModel
  357. // && ([downloadManager shareInstance].curDownloadFileModel.curDownloadStateType == downloadStateUploading
  358. // ||[downloadManager shareInstance].curDownloadFileModel.curDownloadStateType == downloadStateSuspend)){
  359. // downLoadingFileName = [[downloadManager shareInstance].curDownloadFileModel getFileNameFun];
  360. //
  361. // [self deleteFilesInDirectoryAtPath:downLoadingPath withOutFileName:downLoadingFileName];
  362. // }
  363. // else{
  364. // [[NSFileManager defaultManager] removeItemAtPath:downLoadingPath error:nil];
  365. // }
  366. [[NSFileManager defaultManager] removeItemAtPath:downLoadingPath error:nil];
  367. long downLoadingSizeAfterClear = [iTools folderSizeAtPath:downLoadingPath];
  368. //清理数据库表 完成的
  369. //下载完成
  370. NSMutableString* where = [[NSMutableString alloc] initWithString:@"where "];
  371. NSString *curStr = [NSString stringWithFormat:@"%@=%@ or %@=%@ ",bg_sqlKey(@"curDownloadStateType"),bg_sqlValue([NSNumber numberWithInt:downloadStateDone]),bg_sqlKey(@"curDownloadStateType"),bg_sqlValue([NSNumber numberWithInt:downloadStateFail])];
  372. [where appendString:curStr];
  373. [couldPhoneFileModel bg_deleteAsync:download_tableName where:where complete:^(BOOL isSuccess) {
  374. }];
  375. //上传完成
  376. NSMutableString* where2 = [[NSMutableString alloc] initWithString:@"where "];
  377. NSString *curStr2 = [NSString stringWithFormat:@"%@=%@ or %@=%@ ",bg_sqlKey(@"curUploadStateType"),bg_sqlValue([NSNumber numberWithInt:uploadStateDone]),
  378. bg_sqlKey(@"curUploadStateType"),bg_sqlValue([NSNumber numberWithInt:uploadStateFail])];
  379. [where2 appendString:curStr2];
  380. [uploadFileDataModel bg_deleteAsync:upLoadFile_image_tableName where:where2 complete:^(BOOL isSuccess) {
  381. }];
  382. //清理音频播放缓存
  383. NSString *audioPlayPath = [NSString stringWithFormat:@"%@/%@",DocumentPath,@"playAudioCache"];;
  384. long audioPlayAllSize = [iTools folderSizeAtPath:audioPlayPath];
  385. [[NSFileManager defaultManager] removeItemAtPath:audioPlayPath error:nil];
  386. //清理文件APP
  387. NSString *fileAPPPath = kSHPath_FileAPP;
  388. long fileAppPathClear = [iTools folderSizeAtPath:fileAPPPath];
  389. [[NSFileManager defaultManager] removeItemAtPath:fileAPPPath error:nil];
  390. long curTotolSize = (downLoadingSizeBeforeClear - downLoadingSizeAfterClear) + (vide0AllSizeBeforeClear - vide0AllSizeAfterClear) + imageAllSize + clearTotal + audioPlayAllSize + fileAppPathClear;
  391. [self showClearAllTipBy:curTotolSize];
  392. }
  393. - (BOOL)deleteFilesInDirectoryAtPath:(NSString *)path withOutFileName:(NSString*)fileNames {
  394. NSFileManager *fileManager = [NSFileManager defaultManager];
  395. NSArray *fileNameArr = [fileNames componentsSeparatedByString:@"|"];
  396. // 使用NSDirectoryEnumerator遍历目录
  397. NSDirectoryEnumerator *directoryEnumerator = [fileManager enumeratorAtPath:path];
  398. NSString *fileName;
  399. while ((fileName = [directoryEnumerator nextObject])) {
  400. BOOL canDelType = YES;
  401. for (NSString*noDelfileName in fileNameArr) {
  402. if([noDelfileName isEqualToString:fileName]){
  403. canDelType = NO;
  404. break;
  405. }
  406. }
  407. if(canDelType){
  408. NSString *filePath = [path stringByAppendingPathComponent:fileName];
  409. // 如果是文件,则删除它
  410. if ([fileManager fileExistsAtPath:filePath]) {
  411. BOOL success = [fileManager removeItemAtPath:filePath error:nil];
  412. if (!success) {
  413. // 如果删除失败,返回NO并处理错误
  414. return NO;
  415. }
  416. }
  417. }
  418. }
  419. // 所有文件都成功删除,返回YES
  420. return YES;
  421. }
  422. - (void)mainSetDataFun
  423. {
  424. KWeakSelf
  425. mainBlock(^{
  426. [weakSelf setDataFun];
  427. });
  428. }
  429. #pragma mark 数据设置
  430. - (void)setDataFun
  431. {
  432. NSString *SNLeftStr = [[NSString alloc] initWithFormat:@"SN:%@",ksharedAppDelegate.DeviceThirdIdMod.data.changeSn];
  433. NSString *SNMidStr = @" | ";
  434. NSString *SNRightStr = NSLocalizedString(@"common_copy",nil);
  435. NSString *fullTitle = [[NSString alloc] initWithFormat:@"%@%@%@",SNLeftStr,SNMidStr,SNRightStr];
  436. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:fullTitle];
  437. NSRange midRange = NSMakeRange([fullTitle rangeOfString:SNMidStr].location, [fullTitle rangeOfString:SNMidStr].length);
  438. UIColor *midColor =[UIColor hwColor:@"#828D9A" alpha:1.0];
  439. [attrStr addAttribute:NSForegroundColorAttributeName value:midColor range:midRange];
  440. NSRange rightRange = NSMakeRange([fullTitle rangeOfString:SNRightStr].location, [fullTitle rangeOfString:SNRightStr].length);
  441. UIColor *rightColor =[UIColor hwColor:@"#058DFB" alpha:1.0];
  442. [attrStr addAttribute:NSForegroundColorAttributeName value:rightColor range:rightRange];
  443. _snLabel.attributedText = attrStr;
  444. NSString *NetButText = NSLocalizedString(@"mine_net_LAN",nil);
  445. if(![pingManager shareManager].isPingOk){
  446. NetButText = NSLocalizedString(@"mine_net_WAN",nil);
  447. }
  448. RTCDataChannelState channelState = [webRtcManager shareManager].channelState;
  449. RTCIceConnectionState ConnectionState = [webRtcManager shareManager].ConnectionState;
  450. if((ConnectionState == RTCIceConnectionStateConnected
  451. && channelState == RTCDataChannelStateOpen)
  452. //&& !ksharedAppDelegate.isWebSockLinkOKAginType//断开了
  453. ){
  454. }
  455. else
  456. {
  457. NetButText = NSLocalizedString(@"mine_net_unLink",nil);
  458. }
  459. [_netButton setTitle:NetButText forState:UIControlStateNormal];
  460. }
  461. - (void)viewWillAppear:(BOOL)animated
  462. {
  463. [super viewWillAppear:animated];
  464. [self setDataFun];
  465. [self handelAudioPlayingViewFun];
  466. }
  467. - (void)viewWillDisappear:(BOOL)animated{
  468. [super viewWillDisappear:animated];
  469. }
  470. - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated
  471. {
  472. [self.navigationController pushViewController:vc animated:animated];
  473. }
  474. #pragma mark 处理音频播放中的视图状态
  475. - (void)handelAudioPlayingViewFun
  476. {
  477. audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  478. if([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
  479. ||[DFPlayer sharedPlayer].state == DFPlayerStatePlaying
  480. ||[DFPlayer sharedPlayer].state == DFPlayerStatePause){//播放中
  481. [self showAudioPlayingViewFun];
  482. }
  483. else{
  484. [self hideAudioPlayingViewFun];
  485. }
  486. KWeakSelf
  487. audioPlayingV.didClickButtonFun = ^(NSInteger tag) {
  488. if(tag == 1){
  489. [weakSelf hideAudioPlayingViewFun];
  490. }
  491. else if(tag == 5){
  492. [weakSelf AudioPlayingGotoAudioPlayerVCFun];
  493. }
  494. };
  495. }
  496. - (void)AudioPlayingGotoAudioPlayerVCFun{
  497. audioPlayerViewController *vc = [audioPlayerViewController new];
  498. vc.isfirstEnterType = NO;
  499. [self.navigationController pushViewController:vc animated:YES];
  500. }
  501. #pragma mark 显示音频播放中的视图
  502. - (void)showAudioPlayingViewFun
  503. {
  504. audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  505. [self.view addSubview:audioPlayingV];
  506. if([DFPlayer sharedPlayer].state == DFPlayerStatePlaying){
  507. [audioPlayingV startRotatingImage];
  508. }
  509. else if ([DFPlayer sharedPlayer].state == DFPlayerStatePause){
  510. [audioPlayingV stopRotatingImage];
  511. }
  512. [audioPlayingV mas_makeConstraints:^(MASConstraintMaker *make) {
  513. make.height.mas_equalTo(49);
  514. make.left.mas_equalTo(0);
  515. make.right.mas_equalTo(0);
  516. make.bottom.mas_equalTo(-TABBARHEIGHT);
  517. }];
  518. }
  519. #pragma mark 隐藏音频播放中的视图
  520. - (void)hideAudioPlayingViewFun
  521. {
  522. // audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  523. // [audioPlayingV removeFromSuperview];
  524. }
  525. #pragma mark 点击PC 扫码登录
  526. - (void)didClickButtonFun:(UIButton*)but
  527. {
  528. NSInteger tag = but.tag;
  529. if(tag == 100){
  530. //test code
  531. // [self getPCloginFun];
  532. scanToPCLoginViewController *nextVC = [scanToPCLoginViewController new];
  533. [self.navigationController pushViewController:nextVC animated:YES];
  534. }
  535. else if(tag == 1){
  536. [self copySnFun];
  537. }
  538. }
  539. #pragma mark 复制SN
  540. - (void)copySnFun
  541. {
  542. NSString *snStr = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
  543. UIPasteboard * Pasteboard = [UIPasteboard generalPasteboard];
  544. Pasteboard.string = snStr;
  545. NSString *tipStr = NSLocalizedString(@"sn_copy_suc",nil);
  546. [[iToast makeText:tipStr] show];
  547. }
  548. #pragma mark PC 获取码登录
  549. -(void)getPCloginFun
  550. {
  551. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  552. KWeakSelf
  553. [[netWorkManager shareInstance] CommonGetWithCallBackCode:@"/box/login/addAndGetOne" Parameters:paraDict success:^(id _Nonnull responseObject){
  554. SuperModel *ShareMarkMod = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  555. if(ShareMarkMod){
  556. [weakSelf scanToPCloginFunWithID:responseObject[@"data"][@"boxLoginId"]];
  557. }
  558. } failure:^(NSError * _Nonnull error) {
  559. }];
  560. }
  561. #pragma mark PC 扫码登录
  562. -(void)scanToPCloginFunWithID:(NSString*)idStr
  563. {
  564. NSString *changSN = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
  565. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  566. [paraDict setValue:@1 forKey:@"status"];
  567. [paraDict setValue:idStr forKey:@"boxLoginId"];
  568. [paraDict setValue:changSN forKey:@"sn"];
  569. KWeakSelf
  570. [[netWorkManager shareInstance] CommonPostCallBackCode:updatePCLoginStateFun Parameters:paraDict success:^(id _Nonnull responseObject){
  571. SuperModel *curModel = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  572. if(curModel && curModel.status == 0){
  573. [weakSelf gotoNextVCFunWithID:idStr];
  574. }
  575. else
  576. {
  577. if(curModel.msg){
  578. [[iToast makeText:curModel.msg] show];
  579. }
  580. else{
  581. [[iToast makeText:@"扫码信息错误"] show];
  582. }
  583. [weakSelf.navigationController popViewControllerAnimated:YES];
  584. }
  585. } failure:^(NSError * _Nonnull error) {
  586. //[[iToast makeText:@"扫码信息错误"] show];
  587. [weakSelf.navigationController popViewControllerAnimated:YES];
  588. }];
  589. }
  590. #pragma mark 跳转下个界面
  591. - (void)gotoNextVCFunWithID:(NSString*)idStr
  592. {
  593. PCLoginViewController *nextVC = [PCLoginViewController new];
  594. nextVC.loginIdString = idStr;
  595. [self.navigationController pushViewController:nextVC animated:YES];
  596. }
  597. #pragma mark Pc登录页面Pop出来
  598. - (void)PCLoginDidPopFun
  599. {
  600. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  601. [self showTabbarFun];
  602. });
  603. }
  604. #pragma mark 获取分销广告
  605. - (void)queryOnTheShelfFun{
  606. NSString* curSn = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
  607. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  608. [paraDict setValue:@"Private-X" forKey:@"productType"];
  609. [paraDict setValue:@"IOS" forKey:@"type"];
  610. KWeakSelf
  611. [[netWorkManager shareInstance] CommonPostCallBackCode:queryOnTheShelf Parameters:paraDict success:^(id _Nonnull responseObject) {
  612. weakSelf.curADModel = [[ADModel alloc] initWithDictionary:responseObject error:nil];
  613. if (weakSelf.curADModel && weakSelf.curADModel.status == 0) {
  614. [weakSelf handleAdUIFun];
  615. }
  616. else
  617. {
  618. }
  619. } failure:^(NSError * _Nonnull error) {
  620. }];
  621. }
  622. #pragma mark 处理广告UI事宜
  623. - (void)handleAdUIFun
  624. {
  625. _curScrollView.hidden = YES;
  626. if (_curADModel && _curADModel.data.count > 0) {
  627. NSMutableArray *imgaUrls = [NSMutableArray array];
  628. for (ADListModel*listModel in _curADModel.data) {
  629. ADImageListModel *imageModel = listModel.pictureVOList.firstObject;
  630. if (imageModel.url) {
  631. [imgaUrls addObject:imageModel.url];
  632. }
  633. }
  634. if (imgaUrls.count > 0) {
  635. _curScrollView.hidden = NO;
  636. [_curScrollView setImageURLStringsGroup:imgaUrls];
  637. }
  638. }
  639. }
  640. /** 点击图片回调 */
  641. - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
  642. {
  643. if(index >= _curADModel.data.count){
  644. return;
  645. }
  646. ADListModel*listModel = _curADModel.data[index];
  647. NSString *linkAddress = listModel.linkAddress;
  648. NSURL *url = [NSURL URLWithString:linkAddress];
  649. UIApplication *application = [UIApplication sharedApplication];
  650. if ([application canOpenURL:url]) {
  651. if (@available(iOS 10.0, *)) {
  652. [application openURL:url options:@{} completionHandler:^(BOOL success) {
  653. if (success) {
  654. //NSLog(@"成功打开浏览器");
  655. } else {
  656. //NSLog(@"打开浏览器失败");
  657. }
  658. }];
  659. } else {
  660. // iOS 10 之前的方法
  661. //[application openURL:url];
  662. }
  663. }
  664. }
  665. @end