mineViewController.m 25 KB

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