cloudPhoneViewController.m 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. //
  2. // cloudPhoneViewController.m
  3. //
  4. //
  5. // Created David on 2024/6/20.
  6. //
  7. #import "cloudPhoneViewController.h"
  8. #import "cloudPhoneSetView.h"
  9. #import "webRtcMsgModel.h"
  10. #import "webRtcPlayerViewController.h"
  11. #import "HaveNewVersionView.h"
  12. #import "noticeModel.h"
  13. #import "HaveNoticeView.h"
  14. //#import "boxCheckStatusModel.h"
  15. #import "imageVersionRenewTipView.h"
  16. #import "playerShowSecretkeyView.h"
  17. @interface cloudPhoneViewController ()
  18. {
  19. BOOL didGetSysInfoType;//是否收到过系统信息用在---用来判断是否要走弹框流程
  20. }
  21. @property (nonatomic,strong) cloudPhoneSetView *cloudPhoneSetV;
  22. @property (nonatomic,strong) webRtcMsgModel *webRtcMsgMod;
  23. @end
  24. @implementation cloudPhoneViewController
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. // Do any additional setup after loading the view.
  28. //输入密码完成
  29. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didInpuPwdOkFun) name:didInputPWDNotification object:nil];
  30. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneSysInfoFun:) name:getCouldPhoneSysInfoNotification object:nil];
  31. [self.view setBackgroundColor:HWF5F7FAColor];
  32. [self.toolBar setHidden:YES];
  33. [self.navigationBar setHidden:YES];
  34. [self.navBarBGView setHidden:YES];
  35. [self drawAnyView];
  36. }
  37. - (void)drawAnyView{
  38. //顶底底部图片
  39. UIImageView *topImageV = [UIImageView new];
  40. topImageV.userInteractionEnabled = YES;
  41. topImageV.image = [UIImage imageNamed:@"cloudPhone_bg"];
  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.bottom.mas_equalTo(0);
  48. }];
  49. CGFloat width = SCREEN_W;
  50. CGFloat height = SCREEN_H;
  51. BOOL isSmallPhoneType = NO;
  52. if(width == 375 && height == 667){
  53. isSmallPhoneType = YES;
  54. }
  55. CGFloat adjustSmallScale = 0.9;
  56. // if(isSmallPhoneType){
  57. // adjustSmallScale = 0.85;
  58. // }
  59. CGFloat imageTopY = 40.0;
  60. // if(isSmallPhoneType){
  61. // imageTopY = 20.0;
  62. // }
  63. //设置按钮
  64. UIButton *setButton = [[UIButton alloc] init];
  65. //[setButton setBackgroundImage:[UIImage imageNamed:@"cloudPhone_set"] forState:UIControlStateNormal];
  66. [setButton setImage:[UIImage imageNamed:@"cloudPhone_set"] forState:UIControlStateNormal];
  67. setButton.tag = 1;
  68. [setButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  69. [self.view addSubview:setButton];
  70. //setButton.backgroundColor = [UIColor greenColor];
  71. [setButton mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.top.mas_equalTo(imageTopY);
  73. if(isSmallPhoneType){
  74. make.right.mas_equalTo(-5);
  75. }
  76. else{
  77. make.right.mas_equalTo(-16);
  78. }
  79. make.width.mas_equalTo(50);
  80. make.height.mas_equalTo(50);
  81. // make.top.mas_equalTo(imageTopY);
  82. // make.right.mas_equalTo(-16);
  83. // make.width.mas_equalTo(24);
  84. // make.height.mas_equalTo(24);
  85. }];
  86. //中间图片
  87. UIImageView *midImageV = [UIImageView new];
  88. midImageV.userInteractionEnabled = YES;
  89. midImageV.image = [UIImage imageNamed:@"cloudPhone_mid_img"];
  90. [self.view addSubview:midImageV];
  91. [midImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.width.mas_equalTo(326*WAUTOSCALE*adjustSmallScale);
  93. make.height.mas_equalTo(608*WAUTOSCALE*adjustSmallScale);
  94. make.centerX.mas_equalTo(0);
  95. make.centerY.mas_equalTo(-10);
  96. }];
  97. NSString *midTopTip1Str = NSLocalizedString(@"cloudPhone_top_tip1",nil);
  98. NSString *midTopTip2Str = NSLocalizedString(@"cloudPhone_top_tip2",nil);
  99. //提示文字
  100. UILabel *midTopTipLab1 = [[UILabel alloc] init];
  101. midTopTipLab1.text = midTopTip1Str;
  102. midTopTipLab1.font = [UIFont systemFontOfSize:20.0];
  103. midTopTipLab1.textColor = [UIColor hwColor:@"#0A132B"];
  104. midTopTipLab1.textAlignment = NSTextAlignmentCenter;
  105. [midImageV addSubview:midTopTipLab1];
  106. [midTopTipLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.top.equalTo(midImageV.mas_top).offset(64);
  108. make.right.equalTo(midImageV.mas_right).offset(0);
  109. make.left.equalTo(midImageV.mas_left).offset(0);
  110. make.height.mas_equalTo(24);
  111. }];
  112. UILabel *midTopTipLab2 = [[UILabel alloc] init];
  113. midTopTipLab2.text = midTopTip2Str;
  114. midTopTipLab2.font = [UIFont systemFontOfSize:16.0];
  115. midTopTipLab2.textColor = [UIColor hwColor:@"#535657"];
  116. midTopTipLab2.textAlignment = NSTextAlignmentCenter;
  117. [midImageV addSubview:midTopTipLab2];
  118. [midTopTipLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.top.equalTo(midTopTipLab1.mas_bottom).offset(15);
  120. make.right.equalTo(midImageV.mas_right).offset(0);
  121. make.left.equalTo(midImageV.mas_left).offset(0);
  122. make.height.mas_equalTo(20);
  123. }];
  124. //进入云机
  125. UIButton*enterCloudPhoneButton = [[UIButton alloc] init];
  126. CGFloat w_btn = SCREEN_W - 15*2 - 50*2;
  127. // gradient
  128. CAGradientLayer *gl = [CAGradientLayer layer];
  129. gl.frame = CGRectMake(0,0,w_btn,44.f);
  130. gl.startPoint = CGPointMake(0, 0.5);
  131. gl.endPoint = CGPointMake(0.97, 0.5);
  132. gl.colors = @[(__bridge id)HWFFE10FColor.CGColor, (__bridge id)HWFFE411Color.CGColor];
  133. gl.locations = @[@(0), @(1.0f)];
  134. [enterCloudPhoneButton.layer addSublayer:gl];
  135. [enterCloudPhoneButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
  136. //[enterCloudPhoneButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)];
  137. [enterCloudPhoneButton setTitle:NSLocalizedString(@"cloudPhone_enter_tip",nil) forState:(UIControlStateNormal)];
  138. [enterCloudPhoneButton.titleLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
  139. [enterCloudPhoneButton.layer setCornerRadius:21.f];
  140. enterCloudPhoneButton.layer.borderWidth = 0.5;
  141. enterCloudPhoneButton.layer.borderColor = [UIColor clearColor].CGColor;
  142. enterCloudPhoneButton.clipsToBounds = YES;
  143. //enterCloudPhoneButton.tag = 2;
  144. [midImageV addSubview:enterCloudPhoneButton];
  145. [enterCloudPhoneButton mas_makeConstraints:^(MASConstraintMaker *make) {
  146. make.width.mas_equalTo(w_btn);
  147. make.height.mas_equalTo(42);
  148. make.centerX.mas_equalTo(0);
  149. make.bottom.equalTo(midImageV.mas_bottom).offset(-30);
  150. }];
  151. //扩大金融云机范围按钮
  152. UIButton *bigButton = [[UIButton alloc] init];
  153. bigButton.tag = 2;
  154. [bigButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  155. [self.view addSubview:bigButton];
  156. //bigButton.backgroundColor = [UIColor greenColor];
  157. [bigButton mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.top.equalTo(midImageV.mas_top).offset(0);
  159. make.right.equalTo(midImageV.mas_right).offset(0);
  160. make.left.equalTo(midImageV.mas_left).offset(0);
  161. make.bottom.equalTo(midImageV.mas_bottom).offset(0);
  162. }];
  163. }
  164. #pragma mark 点击按钮
  165. - (void)didClickButtonFun:(UIButton*)but
  166. {
  167. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  168. {
  169. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  170. return;
  171. }
  172. // if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接
  173. // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
  174. // return;
  175. // }
  176. NSInteger tag = but.tag;
  177. HLog(@"%ld",tag);
  178. switch (tag) {
  179. case 1:
  180. {
  181. //数据埋点
  182. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Cloud_settings"];
  183. _cloudPhoneSetV = [cloudPhoneSetView new];
  184. [ksharedAppDelegate.window addSubview:_cloudPhoneSetV];
  185. [_cloudPhoneSetV mas_makeConstraints:^(MASConstraintMaker *make) {
  186. make.left.mas_equalTo(0);
  187. make.right.mas_equalTo(0);
  188. make.top.mas_equalTo(0);
  189. make.bottom.mas_equalTo(0);
  190. }];
  191. KWeakSelf
  192. _cloudPhoneSetV.didClickButtonFun = ^(NSInteger tag) {
  193. if (tag == 10) {//重启
  194. [weakSelf didClickRestartFun];
  195. }
  196. else if (tag == 11){//恢复出厂
  197. [weakSelf RestoreFactoryAleartFun];
  198. }
  199. };
  200. }
  201. break;
  202. case 2:
  203. {
  204. //[self checkFullScreenWithTVShowStateFun];
  205. // PlayerViewController *vc = [PlayerViewController new];
  206. // [self pushViewController:vc animated:YES];
  207. //
  208. // if(ksharedAppDelegate.TvStatusMod.isTVShowType){
  209. // [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show];
  210. // }
  211. [self queryWebRtcMsgFun:YES];
  212. //数据埋点
  213. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Cloud_enter"];
  214. //[self checkBoxStatusFun];
  215. }
  216. break;
  217. default:
  218. break;
  219. }
  220. }
  221. #pragma mark 点击了重启空间
  222. - (void)didClickRestartFun
  223. {
  224. KWeakSelf
  225. /*弹窗提示重启*/
  226. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil)
  227. msg:@""
  228. imageStr:@""
  229. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  230. okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil) isOkBtnHighlight:NO
  231. didClickOk:^{
  232. [weakSelf sureToRestartCloudPhoneFun];
  233. } didClickCancel:^{
  234. }];
  235. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  236. [self presentViewController:nextVC animated:YES completion:^{
  237. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  238. }];
  239. }
  240. #pragma mark 确认重启云机
  241. - (void)sureToRestartCloudPhoneFun{
  242. // /*重启云手机*/
  243. // 通过指令通道发送 {"type":"reboot"}
  244. [[webRtcManager shareManager] needToRebootFun];
  245. //提示语
  246. [[iToast makeText:NSLocalizedString(@"player_link_rebooting_Tips",nil)] show];
  247. }
  248. #pragma mark 点击恢复出厂
  249. - (void)RestoreFactoryAleartFun
  250. {
  251. KWeakSelf
  252. /*弹窗提示恢复出厂*/
  253. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_tips",nil)
  254. msg:NSLocalizedString(@"my_set_no_Restore_Factory_msg",nil)
  255. imageStr:@"icon_Restore_Factory_big"
  256. cancelTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil)
  257. okTitle:NSLocalizedString(@"other_cancel",nil) isOkBtnHighlight:YES
  258. didClickOk:^{
  259. } didClickCancel:^{
  260. //点击确定
  261. [weakSelf gotoResetFun];
  262. }];
  263. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  264. [self presentViewController:nextVC animated:YES completion:^{
  265. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  266. }];
  267. }
  268. #pragma mark 点击了恢复出厂
  269. - (void)gotoResetFun
  270. {
  271. [[webRtcManager shareManager] needToResetFun];
  272. [self RestoreFactoryingFun];
  273. }
  274. #pragma mark 恢复出厂中
  275. - (void)RestoreFactoryingFun
  276. {
  277. KWeakSelf
  278. /*弹窗提示恢复出厂*/
  279. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factorying_tips",nil)
  280. msg:NSLocalizedString(@"my_set_no_Restore_Factorying_msg",nil)
  281. imageStr:@""
  282. cancelTitle:NSLocalizedString(@"my_set_no_Restore_Factorying",nil)
  283. okTitle:@""
  284. isOkBtnHighlight:NO
  285. didClickOk:^{
  286. [weakSelf RestoreFactoryCompleteFun];
  287. } didClickCancel:^{
  288. }];
  289. [nextVC setButtonCountdownFun:180];//90
  290. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  291. [self presentViewController:nextVC animated:YES completion:^{
  292. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  293. }];
  294. }
  295. #pragma mark 恢复出厂倒计时结束
  296. - (void)RestoreFactoryCompleteFun
  297. {
  298. //KWeakSelf
  299. /*弹窗提示恢复出厂*/
  300. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_ok_tips",nil)
  301. msg:@""
  302. imageStr:@""
  303. cancelTitle:NSLocalizedString(@"my_set_no_Restore_FactoryOK",nil)
  304. okTitle:@""
  305. isOkBtnHighlight:NO
  306. didClickOk:^{
  307. } didClickCancel:^{
  308. }];
  309. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  310. [self presentViewController:nextVC animated:YES completion:^{
  311. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  312. }];
  313. }
  314. - (void)viewWillAppear:(BOOL)animated{
  315. [super viewWillAppear:animated];
  316. // [self beginShowAlertFun];
  317. //
  318. // BOOL isNeedShowSecret = [HWDataManager getBoolWithKey:Const_need_show_Secret_key];
  319. // if(isNeedShowSecret){
  320. // [self showSecretkeyFun];
  321. // }
  322. }
  323. - (void)viewWillDisappear:(BOOL)animated{
  324. [super viewWillDisappear:animated];
  325. }
  326. - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated
  327. {
  328. [self.navigationController pushViewController:vc animated:animated];
  329. }
  330. #pragma mark 获取webrct 的链接信息
  331. -(void)queryWebRtcMsgFun:(BOOL)isPlayerType
  332. {
  333. if(isPlayerType){
  334. if(ksharedAppDelegate.DeviceWebRtcMsgMod && ksharedAppDelegate.DeviceWebRtcMsgMod.data.sn){
  335. [self gotoWebRtcVcBy:ksharedAppDelegate.DeviceWebRtcMsgMod];
  336. return;
  337. }
  338. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  339. }
  340. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  341. KWeakSelf
  342. [[netWorkManager shareInstance] CommonPostCallBackCode:webrctQueryByClient Parameters:paraDict success:^(id _Nonnull responseObject){
  343. if(isPlayerType){
  344. [weakSelf removeNewIndicator];
  345. }
  346. webRtcMsgModel *curModel = [[webRtcMsgModel alloc] initWithDictionary:responseObject error:nil];
  347. if(curModel && curModel.status == 0){
  348. ksharedAppDelegate.DeviceWebRtcMsgMod = curModel;
  349. if(isPlayerType){
  350. [weakSelf gotoWebRtcVcBy:curModel];
  351. }
  352. }
  353. else
  354. {
  355. if(isPlayerType && curModel.msg){
  356. [[iToast makeText:curModel.msg] show];
  357. }
  358. }
  359. } failure:^(NSError * _Nonnull error) {
  360. if(isPlayerType){
  361. [weakSelf removeNewIndicator];
  362. [[iToast makeText:NSLocalizedString(@"get_webrtcMsg_fail_tip",nil)] show];
  363. }
  364. }];
  365. }
  366. #pragma mark 跳转webrtc 页面
  367. - (void)gotoWebRtcVcBy:(webRtcMsgModel*)webRtcMsgMod
  368. {
  369. NSArray * vcArrs = self.navigationController.viewControllers;
  370. if(vcArrs.count != 1){
  371. return;
  372. }
  373. webRtcPlayerViewController *vc = [webRtcPlayerViewController new];
  374. vc.webRtcMsgMod = webRtcMsgMod;
  375. [self.navigationController pushViewController:vc animated:YES];
  376. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  377. ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType = NO;
  378. ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType = NO;
  379. });
  380. }
  381. #pragma mark 输入密码完成
  382. - (void)didInpuPwdOkFun
  383. {
  384. KWeakSelf
  385. mainBlock(^{
  386. [weakSelf beginShowAlertFun];
  387. BOOL isNeedShowSecret = [HWDataManager getBoolWithKey:Const_need_show_Secret_key];
  388. if(isNeedShowSecret){
  389. [self showSecretkeyFun];
  390. }
  391. if(ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType){
  392. [weakSelf queryWebRtcMsgFun:YES];
  393. }
  394. //查询掌机是否在线
  395. //[weakSelf checkBoxStatusFun];
  396. });
  397. }
  398. #pragma mark 获取到云机系统相关基本信息
  399. - (void)getCouldPhoneSysInfoFun:(NSNotification*)not
  400. {//弹框流程 优先级:强制盒子更新弹窗 > APP版本更新弹窗 > 通知公告弹窗
  401. if(didGetSysInfoType){//弹框流程已经走过
  402. return;
  403. }
  404. didGetSysInfoType = YES;
  405. if(ksharedAppDelegate.isNeedShowImageNewType){//强制盒子更新弹窗
  406. mainBlock(^{
  407. [self showImageViewRenewTipViewFun];
  408. });
  409. }
  410. }
  411. #pragma mark 弹框流程
  412. //优先级:1.强制盒子更新弹窗
  413. // 2.APP版本更新弹窗 > 通知公告弹窗
  414. - (void)beginShowAlertFun
  415. {
  416. //1.隐私模式密码界面 3秒检测一次是否输入完成密码了
  417. if(!ksharedAppDelegate.isFirstInputPwdDone){
  418. KWeakSelf
  419. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  420. [weakSelf beginShowAlertFun];
  421. });
  422. return;
  423. }
  424. //2. 强制盒子更新弹窗
  425. if(!didGetSysInfoType){
  426. [[webRtcManager shareManager] getSysInfoFun];
  427. }
  428. //3. APP版本更新弹窗
  429. [self checkVersionFun];
  430. }
  431. #pragma mark 弹框流程 1 强制盒子更新弹窗
  432. - (void)showImageViewRenewTipViewFun
  433. {
  434. //密码框界面 拦着 不给弹出
  435. if(ksharedAppDelegate.isDidShowPwdType){
  436. //didGetSysInfoType = NO;
  437. KWeakSelf
  438. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  439. [weakSelf showImageViewRenewTipViewFun];
  440. });
  441. return;
  442. }
  443. imageVersionRenewTipView * RenewTipView = [[imageVersionRenewTipView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  444. [ksharedAppDelegate.window addSubview:RenewTipView];
  445. //[self.view bringSubviewToFront:RenewTipView];
  446. }
  447. #pragma mark 弹框流程 2 APP版本更新弹窗
  448. - (void)checkVersionFun
  449. {
  450. [self getVersion];
  451. }
  452. #pragma mark- 网络请求
  453. - (void)getVersion {
  454. //密码框界面 拦着 不给弹出
  455. if(!ksharedAppDelegate.isFirstInputPwdDone){
  456. return;
  457. }
  458. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  459. [paraDict setValue:@"ios" forKey:@"type"];
  460. [paraDict setValue:@"GBox" forKey:@"source"];
  461. [[netWorkManager shareInstance] CommonGetWithCallBackCode:upgradeNewVersion Parameters:paraDict success:^(id _Nonnull responseObject) {
  462. //HLog(@"%@", responseObject);
  463. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  464. if (model && model.status == 0) {
  465. HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
  466. [self checkVersion:model];
  467. }
  468. else
  469. {
  470. [self checkVersion:nil];
  471. }
  472. } failure:^(NSError * _Nonnull error) {
  473. HLog(@"%@", error);
  474. [self checkVersion:nil];
  475. }];
  476. }
  477. - (void)checkVersion:(HWVersionModel*)versionModel {
  478. if(!versionModel){//版本信息错误 检测新手弹框流程
  479. [self getLastNoticeFun];
  480. return;
  481. }
  482. // NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
  483. NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
  484. NSString *newVersion = [versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
  485. newVersion = [newVersion stringByReplacingOccurrencesOfString:@"V" withString:@""]; //去掉v
  486. //HLog(@"%@---%@", newVersion, currentVersion);
  487. if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
  488. [self getLastNoticeFun];
  489. }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
  490. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  491. [self getLastNoticeFun];
  492. }else { // 本地版本号 < 服务器版本号 (有新版本)
  493. [self showNewVersion:versionModel];
  494. [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
  495. };
  496. }
  497. - (void)showNewVersion:(HWVersionModel*)versionModel {
  498. HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
  499. if (haveNewVersionView.isShow) {
  500. return;
  501. }
  502. //此版本点击过稍后再试
  503. NSString *preVersionstr = [HWDataManager getStringWithKey:Const_did_show_version_and_click_wait];
  504. if(preVersionstr && [versionModel.versionNumber isEqualToString:preVersionstr]){
  505. [self getLastNoticeFun];
  506. return;
  507. }
  508. haveNewVersionView.versionModel = versionModel;
  509. haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
  510. [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
  511. [ksharedAppDelegate.window addSubview:haveNewVersionView];
  512. haveNewVersionView.isShow = YES;
  513. if(!versionModel.necessary){
  514. haveNewVersionView.deleteBtn.hidden = NO;
  515. }
  516. [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
  517. make.top.mas_equalTo(0);
  518. make.left.mas_equalTo(0);
  519. make.right.mas_equalTo(0);
  520. make.bottom.mas_equalTo(0);
  521. }];
  522. haveNewVersionView.alpha = 0.0;
  523. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  524. haveNewVersionView.alpha = 1.0;
  525. KyoLog(@"in animate start");
  526. } completion:^(BOOL finished) {
  527. KyoLog(@"in animate completion");
  528. }];
  529. KWeakSelf
  530. haveNewVersionView.closeViewFun = ^{
  531. [weakSelf getLastNoticeFun];
  532. };
  533. }
  534. #pragma mark 弹框流程 4 通知公告弹窗
  535. - (void)getLastNoticeFun
  536. {
  537. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  538. [paraDict setValue:@"GBox" forKey:@"productType"];
  539. [paraDict setValue:@"ios" forKey:@"type"];
  540. [[netWorkManager shareInstance] CommonPostCallBackCode:queryOneNotice Parameters:paraDict success:^(id _Nonnull responseObject) {
  541. noticeModel *model = [[noticeModel alloc] initWithDictionary:responseObject error:nil];
  542. //test code
  543. // model.status = 0;
  544. // model.data = [noticeDataModel new];
  545. // model.data.curNoticeId = @"1111";
  546. // model.data.title = @"版本升级通知公告";
  547. // model.data.content = @"1.偶现挤下线问题";
  548. // model.data.content = @"1.偶现挤下线问题\n2.本地网络弹框\n3.访问相册权限之类的系统弹框会触发进入后台流程---显示输入密码框\n4.上传偶现UI刷新异常(数据库是正常的)\n5.偶现上传文件损坏\n6.链接不稳定问题(websock偶尔会不断重连\n7.进入设置页面读取数据偶现闪退!!!!\n8.本地网络弹框\n9.访问相册权限之类的系统弹框会触发进入后台流程---显示输入密码框\n10.上传偶现UI刷新异常(数据库是正常的)\n11.偶现上传文件损坏\n12.链接不稳定问题(websock偶尔会不断重连)\n13.进入设置页面读取数据偶现闪退!!!!\n14.本地网络弹框\n15.访问相册权限之类的系统弹框会触发进入后台流程\n16.上传偶现UI刷新异常(数据库是正常的)";//\n17.偶现上传文件损坏\n18.链接不稳定问题(websock偶尔会不断重连\n19.进入设置页面读取数据偶现闪退!!!!\n20.本地网络弹框\n21.访问相册权限之类的系统弹框会触发进入后台流程\n22.上传偶现UI刷新异常(数据库是正常的)\n23.偶现上传文件损坏\n24.链接不稳定问题(websock偶尔会不断重连)\n25.进入设置页面读取数据偶现闪退!!!!\n26.本地网络弹框\n27.访问相册权限之类的系统弹框会触发进入后台流程\n28.上传偶现UI刷新异常(数据库是正常的)\n29.偶现上传文件损坏\n30.链接不稳定问题(websock偶尔会不断重连)\n31.进入设置页面读取数据偶现闪退!!!!";
  549. if (model && model.data && model.status == 0) {
  550. [self showHaveNoticeViewBy:model];
  551. }
  552. else
  553. {
  554. }
  555. } failure:^(NSError * _Nonnull error) {
  556. HLog(@"%@", error);
  557. }];
  558. }
  559. - (void)showHaveNoticeViewBy:(noticeModel*)model
  560. {
  561. HaveNoticeView * noticeView = [HaveNoticeView shardInstance];
  562. NSString * preShowID = [HWDataManager getStringWithKey:Const_did_show_Notice_ID];
  563. if(noticeView.isShow
  564. || !model
  565. || [preShowID isEqualToString:model.data.curNoticeId]){
  566. return;
  567. }
  568. noticeView.curNoticeModel = model;
  569. //异常处理
  570. if(![iTools getKeyWindow]){
  571. return;
  572. }
  573. [[iTools getKeyWindow] addSubview:noticeView];
  574. [noticeView mas_makeConstraints:^(MASConstraintMaker *make) {
  575. make.top.mas_equalTo(0);
  576. make.left.mas_equalTo(0);
  577. make.right.mas_equalTo(0);
  578. make.bottom.mas_equalTo(0);
  579. }];
  580. noticeView.alpha = 0.0;
  581. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  582. noticeView.alpha = 1.0;
  583. } completion:^(BOOL finished) {
  584. }];
  585. }
  586. #pragma mark - 显示秘钥 后续忘记密码要
  587. -(void)showSecretkeyFun
  588. {
  589. if(!ksharedAppDelegate.isFirstInputPwdDone){
  590. KWeakSelf
  591. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  592. [weakSelf showSecretkeyFun];
  593. });
  594. return;
  595. }
  596. playerShowSecretkeyView *view = [[playerShowSecretkeyView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  597. //[ksharedAppDelegate.window addSubview:view];
  598. [self.view addSubview:view];
  599. //KWeakSelf
  600. view.didCloseSecretKeyViewTip = ^{
  601. [HWDataManager setBoolWithKey:Const_need_show_Secret_key value:NO];
  602. };
  603. view.didCopySecretKeyViewTip = ^{
  604. [[webRtcManager shareManager] updateCopydata];;
  605. };
  606. }
  607. #pragma mark - 查询掌机情况
  608. //1、掌机Gbox助手干掉 - 客户端去掉容器开关机检测功能 20231119
  609. //- (void)checkBoxStatusFun
  610. //{
  611. // NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  612. // [paraDict setValue:@2 forKey:@"type"];
  613. //
  614. // KWeakSelf
  615. // [[netWorkManager shareInstance] CommonPostCallBackCode:queryBoxStatus Parameters:paraDict success:^(id _Nonnull responseObject) {
  616. //
  617. // boxCheckStatusModel *model = [[boxCheckStatusModel alloc] initWithDictionary:responseObject error:nil];
  618. //
  619. // if (model && model.data && model.status == 0) {
  620. // if(model.data.containerAgentStatus == 0){
  621. // [weakSelf showAlertByBoxCloseStateFun];
  622. // }
  623. // }
  624. // else
  625. // {
  626. //
  627. // }
  628. //
  629. // } failure:^(NSError * _Nonnull error) {
  630. // HLog(@"%@", error);
  631. // }];
  632. //}
  633. #pragma mark 显示云机系统已经关闭
  634. - (void)showAlertByBoxCloseStateFun
  635. {
  636. KWeakSelf
  637. /*弹窗提示*/
  638. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"cloudPhone_system_state_close_title",nil)
  639. msg:NSLocalizedString(@"cloudPhone_system_state_close_tip",nil)
  640. imageStr:@""
  641. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  642. okTitle:@"" isOkBtnHighlight:NO
  643. didClickOk:^{
  644. } didClickCancel:^{
  645. }];
  646. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  647. [self presentViewController:nextVC animated:YES completion:^{
  648. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  649. }];
  650. }
  651. @end