AboutViewController.m 12 KB

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