mineViewController.m 26 KB

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