AboutViewController.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. //
  2. // AboutViewController.m
  3. // VclustersGemini
  4. //
  5. // Created by APPLE on 2020/2/24.
  6. // Copyright © 2020 APPLE. All rights reserved.
  7. //
  8. #import "AboutViewController.h"
  9. #import "HaveNewVersionView.h"
  10. #import "HWVersionModel.h"
  11. #import "iPhone.h"
  12. #import "CloudPhoneAPI.h"
  13. #import <MJExtension.h>
  14. #import "CustomerWebViewController.h"
  15. #import "netWorkManager.h"
  16. #import "SuperModel.h"
  17. #import "allVersionView.h"
  18. @interface AboutViewController ()
  19. @property (nonatomic, strong) UIButton *checUpdatekBtn;
  20. // gradient
  21. @property (nonatomic, strong)CAGradientLayer *gl_checkVersonBut;
  22. @property (nonatomic, strong) UIButton *ruleBtn;
  23. @property (nonatomic, strong) UIButton *privateBtn;
  24. @property (nonatomic, strong) HWVersionModel *versionModel;
  25. @end
  26. @implementation AboutViewController
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. [self drawAnyView];
  30. //数据埋点
  31. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Version_information"];
  32. }
  33. - (void)viewDidAppear:(BOOL)animated {
  34. [super viewDidAppear:animated];
  35. }
  36. - (void)drawAnyView
  37. {
  38. [self.view setBackgroundColor:HWF5F7FAColor];
  39. self.navBarBGView.hidden = NO;
  40. [self.navigationBar setHidden:YES];
  41. [self.toolBar setHidden:YES];
  42. [self.titleLabel setText:NSLocalizedString(@"app_update_title",nil)];
  43. UIImageView *topImage = [[UIImageView alloc] init];
  44. [topImage setImage:[self getAppIcon]];
  45. topImage.userInteractionEnabled = YES;
  46. [self.view addSubview:topImage];
  47. [topImage mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.width.mas_equalTo(72.f);
  49. make.height.mas_equalTo(72.f);
  50. make.centerX.equalTo(self.view.mas_centerX);
  51. make.top.equalTo(self.navBarBGView.mas_bottom).offset(123.f);
  52. }];
  53. [topImage.layer setCornerRadius:15.f];
  54. topImage.clipsToBounds = YES;
  55. UITapGestureRecognizer *tap5 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap5NumFun)];
  56. tap5.numberOfTapsRequired = 5;
  57. [topImage addGestureRecognizer:tap5];
  58. /*app名*/
  59. UILabel *appName = [[UILabel alloc] init];
  60. [appName setBackgroundColor:[UIColor clearColor]];
  61. [appName setTextColor:HW333333Color];
  62. [appName setFont:[UIFont boldSystemFontOfSize:16.f]];
  63. [appName setTextAlignment:(NSTextAlignmentCenter)];
  64. [appName setText:[NSString stringWithFormat:@"%@",[iPhone appBundleName]]];
  65. //[appName setText:[NSString stringWithFormat:@"%@",@"Private- X"]];
  66. [self.view addSubview:appName];
  67. [appName mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.top.equalTo(topImage.mas_bottom).offset(20.f);
  69. make.right.mas_equalTo(-27.f);
  70. make.left.mas_equalTo(27.f);
  71. make.height.mas_equalTo(22.f);
  72. }];
  73. /*版本号*/
  74. UILabel *versionLabel = [[UILabel alloc] init];
  75. [versionLabel setBackgroundColor:[UIColor clearColor]];
  76. [versionLabel setTextColor:HW333333Color];
  77. [versionLabel setFont:[UIFont systemFontOfSize:13.f]];
  78. [versionLabel setTextAlignment:(NSTextAlignmentCenter)];
  79. NSString *vers = [iPhone appVersion];
  80. [versionLabel setText:[NSString stringWithFormat:@"V%@",vers]];
  81. [self.view addSubview:versionLabel];
  82. [versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.top.equalTo(appName.mas_bottom).offset(10.f);
  84. make.right.mas_equalTo(-27.f);
  85. make.left.mas_equalTo(27.f);
  86. make.height.mas_equalTo(20.f);
  87. }];
  88. /*开始体验*/
  89. _checUpdatekBtn = [[UIButton alloc] init];
  90. _checUpdatekBtn.frame = CGRectMake(0, 0, 160.f, 48.f);
  91. // gradient
  92. _gl_checkVersonBut = [CAGradientLayer layer];
  93. _gl_checkVersonBut.frame = CGRectMake(0,0,160.f,48.f);
  94. _gl_checkVersonBut.startPoint = CGPointMake(0, 0.5);
  95. _gl_checkVersonBut.endPoint = CGPointMake(1, 0.5);
  96. _gl_checkVersonBut.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  97. _gl_checkVersonBut.locations = @[@(0), @(1.0f)];
  98. [_checUpdatekBtn.layer addSublayer:_gl_checkVersonBut];
  99. [_checUpdatekBtn addTarget:self action:@selector(versionCheckBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
  100. [_checUpdatekBtn setTitle:NSLocalizedString(@"app_update_check",nil) forState:(UIControlStateNormal)];
  101. [_checUpdatekBtn setTitle:NSLocalizedString(@"app_update_last_version",nil) forState:(UIControlStateDisabled)];
  102. [_checUpdatekBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  103. [_checUpdatekBtn.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
  104. [_checUpdatekBtn.layer setCornerRadius:8.f];
  105. _checUpdatekBtn.clipsToBounds = YES;
  106. [self.view addSubview:_checUpdatekBtn];
  107. [_checUpdatekBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.centerX.equalTo(self.view.mas_centerX);
  109. make.width.mas_equalTo(160.f);
  110. make.top.equalTo(versionLabel.mas_bottom).offset(25.f);
  111. make.height.mas_equalTo(48.f);
  112. }];
  113. UIButton *privateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  114. self.privateBtn = privateBtn;
  115. privateBtn.titleLabel.font = [UIFont systemFontOfSize:13.f];
  116. [privateBtn setTitle:NSLocalizedString(@"app_update_private",nil) forState:UIControlStateNormal];
  117. [privateBtn setTitleColor:HW13B2EBColor forState:UIControlStateNormal];
  118. [privateBtn setBackgroundColor:[UIColor clearColor]];
  119. [privateBtn addTarget:self action:@selector(privateBtnClick) forControlEvents:UIControlEventTouchUpInside];
  120. privateBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  121. [self.view addSubview:privateBtn];
  122. [privateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  123. make.bottom.mas_equalTo(-80-AdaptTabHeight);
  124. //make.width.mas_equalTo(55);
  125. make.width.mas_equalTo(130);
  126. make.height.mas_equalTo(38);
  127. make.left.equalTo(self.view.mas_centerX).offset(6);
  128. }];
  129. UIButton *ruleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  130. self.ruleBtn = ruleBtn;
  131. ruleBtn.titleLabel.font = [UIFont systemFontOfSize:13.f];
  132. [ruleBtn setTitle:NSLocalizedString(@"app_update_use_deal",nil) forState:UIControlStateNormal];
  133. [ruleBtn setTitleColor:HW13B2EBColor forState:UIControlStateNormal];
  134. [ruleBtn setBackgroundColor:[UIColor clearColor]];
  135. [ruleBtn addTarget:self action:@selector(ruleBtnClick) forControlEvents:UIControlEventTouchUpInside];
  136. ruleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  137. [self.view addSubview:ruleBtn];
  138. [ruleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  139. make.bottom.mas_equalTo(-80-AdaptTabHeight);
  140. //make.width.mas_equalTo(55);
  141. make.width.mas_equalTo(130);
  142. make.height.mas_equalTo(38);
  143. make.right.equalTo(self.view.mas_centerX).offset(-6);
  144. }];
  145. UIView *lineView = [[UIView alloc] init];
  146. [lineView setBackgroundColor:HW999999Color];
  147. [self.view addSubview:lineView];
  148. [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  149. make.centerX.equalTo(self.view.mas_centerX);
  150. make.width.mas_equalTo(1);
  151. make.height.mas_equalTo(14);
  152. make.centerY.equalTo(ruleBtn.mas_centerY);
  153. }];
  154. }
  155. - (UIImage *)getAppIcon{
  156. NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
  157. //获取app中所有icon名字数组
  158. NSArray *iconsArr = infoDict[@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconFiles"];
  159. //取最后一个icon的名字
  160. NSString *iconLastName = [iconsArr lastObject];
  161. //打印icon名字
  162. NSLog(@"iconsArr: %@", iconsArr);
  163. NSLog(@"iconLastName: %@", iconLastName);
  164. return [UIImage imageNamed:iconLastName];
  165. }
  166. #pragma mark- 网络请求
  167. - (void)getVersion {
  168. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"app_update_checking",nil)];
  169. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  170. [paraDict setValue:@"ios" forKey:@"type"];
  171. [paraDict setValue:@"skyworth" forKey:@"source"];
  172. [[netWorkManager shareInstance] CommonGetWithCallBackCode:upgradeNewVersion Parameters:paraDict success:^(id _Nonnull responseObject) {
  173. HLog(@"%@", responseObject);
  174. [self removeNewIndicatorHaveStr];
  175. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  176. if (model.status == 0) {
  177. HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
  178. self.versionModel = model;
  179. [self checkVersion];
  180. }
  181. else
  182. {
  183. //[[iToast makeText:model.msg] show];
  184. }
  185. } failure:^(NSError * _Nonnull error) {
  186. HLog(@"%@", error);
  187. [[iToast makeText:NSLocalizedString(@"player_link_fail_tip",nil)] show];
  188. [self removeNewIndicatorHaveStr];
  189. }];
  190. }
  191. - (void)versionCheckBtnClick {
  192. [self getVersion];
  193. }
  194. - (void)checkVersion {
  195. // NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
  196. NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
  197. NSString *newVersion = [self.versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
  198. // HLog(@"%@---%@", newVersion, currentVersion);
  199. if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
  200. // [self showNoNewVersion];
  201. //[self showNewVersion];
  202. [[iToast makeText:NSLocalizedString(@"app_update_last_version",nil)] show];
  203. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  204. // _checUpdatekBtn.enabled = NO;
  205. // _checUpdatekBtn.backgroundColor = [UIColor hwColor:@"#959799" alpha:1.0];
  206. // [_gl_checkVersonBut removeFromSuperlayer];
  207. }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
  208. [self showNoNewVersion];
  209. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  210. // _checUpdatekBtn.enabled = NO;
  211. // _checUpdatekBtn.backgroundColor = [UIColor hwColor:@"#959799" alpha:1.0];
  212. // [_gl_checkVersonBut removeFromSuperlayer];
  213. }else { // 本地版本号 < 服务器版本号 (有新版本)
  214. self.versionModel.versionNumber = newVersion;
  215. [self showNewVersion];
  216. [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
  217. };
  218. }
  219. - (void)showNewVersion {
  220. HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
  221. if (haveNewVersionView.isShow) {
  222. return;
  223. }
  224. haveNewVersionView.versionModel = self.versionModel;
  225. haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
  226. [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
  227. [[[UIApplication sharedApplication] keyWindow] addSubview:haveNewVersionView];
  228. haveNewVersionView.isShow = YES;
  229. if(!self.versionModel.necessary){
  230. haveNewVersionView.deleteBtn.hidden = NO;
  231. }
  232. [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
  233. make.top.mas_equalTo(0);
  234. make.left.mas_equalTo(0);
  235. make.right.mas_equalTo(0);
  236. make.bottom.mas_equalTo(0);
  237. }];
  238. haveNewVersionView.alpha = 0.0;
  239. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  240. haveNewVersionView.alpha = 1.0;
  241. KyoLog(@"in animate start");
  242. } completion:^(BOOL finished) {
  243. KyoLog(@"in animate completion");
  244. }];
  245. }
  246. - (void)showNoNewVersion {
  247. [[iToast makeText:NSLocalizedString(@"app_update_last_version",nil)] show];
  248. }
  249. - (void)ruleBtnClick {
  250. //https://cliys.armclouding.com/h5/protocol/protocol.html?agreementCoding=YSZYHXY2002&type=1
  251. // [self gotoProtocolWKWebVCByPush:YES];
  252. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  253. vc.titleStr = NSLocalizedString(@"app_update_use_deal",nil);
  254. NSString *url = @"https://cliys.armclouding.com/h5/protocol/protocol.html?agreementCoding=YSZYHXY2003&type=1";//[NSString stringWithFormat:@"%@/h5/protocol/protocol.html?agreementCoding=YSZYHXY2002&type=1", CloudService];
  255. vc.webUrl = url;
  256. [self.navigationController pushViewController:vc animated:YES];
  257. }
  258. - (void)privateBtnClick {
  259. // [self gotoPrivateProtocolWKWebVCByPush:YES];
  260. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  261. vc.titleStr = NSLocalizedString(@"app_update_private",nil);
  262. NSString *url = @"https://cliys.armclouding.com/h5/protocol/protocol.html?agreementCoding=YSZYSXY2002&type=1";//[NSString stringWithFormat:@"%@/h5/protocol/protocol.html?agreementCoding=YSZYSXY2001&type=1", CloudService];
  263. vc.webUrl = url;
  264. [self.navigationController pushViewController:vc animated:YES];
  265. }
  266. - (void)didTap5NumFun
  267. {
  268. allVersionView *view = [[allVersionView alloc] init];
  269. UIWindow *keyWindow = [iTools getKeyWindow];
  270. [keyWindow addSubview:view];
  271. [view mas_makeConstraints:^(MASConstraintMaker *make) {
  272. make.top.mas_equalTo(0);
  273. make.left.mas_equalTo(0);
  274. make.right.mas_equalTo(0);
  275. make.bottom.mas_equalTo(0);
  276. }];
  277. if(_getSysInfo){
  278. _getSysInfo();
  279. }
  280. }
  281. @end