mineViewController.m 26 KB

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