mineViewController.m 26 KB

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