mineViewController.m 25 KB

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