AboutViewController.m 11 KB

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