mineViewController.m 25 KB

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