YOUPAILCAboutVC.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. //
  2. // YOUPAILCAboutVC.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/8/25.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCAboutVC.h"
  9. #import "YOUPAILCUpdateVersionVC.h"
  10. #import "UIViewController+TFPresent.h"
  11. @interface YOUPAILCAboutVC ()
  12. @property (nonatomic,assign) NSInteger youpaipnumber;
  13. @end
  14. @implementation YOUPAILCAboutVC
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. self.title = @"关于相语欢颜";
  18. self.view.backgroundColor = [UIColor whiteColor];
  19. [self youpaifsetupView];
  20. }
  21. - (void)youpaifsetupView{
  22. self.youpaipnumber = 0;
  23. UIScrollView* scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, NavBarHeight+30, KScreenWidth, KScreenHeight-NavBarHeight - 60)];
  24. scrollView.backgroundColor = [UIColor whiteColor];
  25. scrollView.contentSize = CGSizeMake(KScreenWidth, KScreenHeight-NavBarHeight-60+1);
  26. scrollView.bounces = YES;
  27. scrollView.showsHorizontalScrollIndicator = NO;
  28. scrollView.showsVerticalScrollIndicator = NO;
  29. // scrollView.layer.cornerRadius = 8;
  30. // scrollView.layer.masksToBounds = YES;
  31. [self.view addSubview:scrollView];
  32. UIImageView* iconLogoView = [[UIImageView alloc]initWithFrame:CGRectMake((KScreenWidth-63)/2, 25.0f,63,63)];
  33. iconLogoView.image = [UIImage imageNamed:@"vqu_images_appLogo"];
  34. iconLogoView.contentMode = UIViewContentModeScaleAspectFill;
  35. iconLogoView.layer.masksToBounds = YES;
  36. iconLogoView.layer.cornerRadius= 8.0;
  37. [scrollView addSubview:iconLogoView];
  38. UILabel* appNameL = [[UILabel alloc]initWithFrame:CGRectMake((KScreenWidth-200)/2,CGRectGetMaxY(iconLogoView.frame) + 8.0f, 200, 22)];
  39. appNameL.textColor = LZ273145Color;
  40. appNameL.font = LCFont(20.0f);
  41. appNameL.textAlignment = NSTextAlignmentCenter;
  42. appNameL.text = @"相语欢颜";
  43. [scrollView addSubview:appNameL];
  44. UILabel* versionLabel = [[UILabel alloc]initWithFrame:CGRectMake((KScreenWidth-200)/2,CGRectGetMaxY(appNameL.frame) + 8.0f, 200, 12)];
  45. versionLabel.textColor = LZA3AABEColor;
  46. versionLabel.font = [UIFont systemFontOfSize:10];
  47. versionLabel.textAlignment = NSTextAlignmentCenter;
  48. versionLabel.text = [NSString stringWithFormat:@"版本%@",[[UIApplication sharedApplication] appVersion]];
  49. [scrollView addSubview:versionLabel];
  50. UIButton* protocolBtn = [[UIButton alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(versionLabel.frame) + 17.0f, KScreenWidth,70.0f)];
  51. protocolBtn.backgroundColor = [UIColor whiteColor];
  52. [protocolBtn addTarget:self action:@selector(youpaifprotocolClick) forControlEvents:(UIControlEventTouchUpInside)];
  53. [scrollView addSubview:protocolBtn];
  54. UILabel* btnL1 = [[UILabel alloc]initWithFrame:CGRectMake(14, 0,150, 70.0f)];
  55. btnL1.textColor = LZ273145Color;
  56. btnL1.text = @"用户协议";
  57. btnL1.font = LCBoldFont(14.0f);
  58. [protocolBtn addSubview:btnL1];
  59. UIImageView* imgV1 = [[UIImageView alloc]initWithFrame:CGRectMake(KScreenWidth-32-14-14+16, (70.0f - 14.0f) / 2.0f, 14, 14)];
  60. imgV1.image = [UIImage imageNamed:@"vqu_images_H_cell_arrow_gray"];
  61. imgV1.contentMode = UIViewContentModeScaleAspectFill;
  62. [protocolBtn addSubview:imgV1];
  63. UIView *line1 = [[UIView alloc] initWithFrame:CGRectMake(14,69.5,KScreenWidth-28,0.5)];
  64. line1.backgroundColor = LZF5F4F7Color;
  65. [protocolBtn addSubview:line1];
  66. UIButton* privacyBtn = [[UIButton alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(protocolBtn.frame), KScreenWidth,70.0f)];
  67. privacyBtn.backgroundColor = [UIColor whiteColor];
  68. [privacyBtn addTarget:self action:@selector(youpaifprivacyClick) forControlEvents:(UIControlEventTouchUpInside)];
  69. [scrollView addSubview:privacyBtn];
  70. UILabel* btnL2 = [[UILabel alloc]initWithFrame:CGRectMake(14, 0,150, 70.0f)];
  71. btnL2.textColor = LZ273145Color;
  72. btnL2.text = @"隐私保护";
  73. btnL2.font = LCBoldFont(14.0f);
  74. [privacyBtn addSubview:btnL2];
  75. UIImageView* imgV2 = [[UIImageView alloc]initWithFrame:CGRectMake(KScreenWidth-32-14-14+16, (70.0f - 14.0f) / 2.0f, 14, 14)];
  76. imgV2.image = [UIImage imageNamed:@"vqu_images_H_cell_arrow_gray"];
  77. imgV2.contentMode = UIViewContentModeScaleAspectFill;
  78. [privacyBtn addSubview:imgV2];
  79. UIView *line2 = [[UIView alloc] initWithFrame:CGRectMake(14,69.5,KScreenWidth-28,0.5)];
  80. line2.backgroundColor = LZF5F4F7Color;
  81. [privacyBtn addSubview:line2];
  82. UIButton* updataBtn = [[UIButton alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(privacyBtn.frame), KScreenWidth,70.0f)];
  83. updataBtn.backgroundColor = [UIColor whiteColor];
  84. [updataBtn addTarget:self action:@selector(youpaifupdateBtnClick:) forControlEvents:(UIControlEventTouchUpInside)];
  85. [scrollView addSubview:updataBtn];
  86. UILabel* btnL3 = [[UILabel alloc]initWithFrame:CGRectMake(14, 0,150, 70.0f)];
  87. btnL3.textColor = LZ273145Color;
  88. btnL3.text = @"检查版本更新";
  89. btnL3.font = LCBoldFont(14.0f);
  90. [updataBtn addSubview:btnL3];
  91. UIImageView* imgV3 = [[UIImageView alloc]initWithFrame:CGRectMake(KScreenWidth-32-14-14+16, (70.0f - 14.0f) / 2.0f, 14, 14)];
  92. imgV3.image = [UIImage imageNamed:@"vqu_images_H_cell_arrow_gray"];
  93. imgV3.contentMode = UIViewContentModeScaleAspectFill;
  94. [updataBtn addSubview:imgV3];
  95. // UIView *line3 = [[UIView alloc] initWithFrame:CGRectMake(14,69.5,KScreenWidth-28,0.5)];
  96. // line3.backgroundColor = HexColorFromRGB(0x28262D);
  97. // [updataBtn addSubview:line3];
  98. // UILabel* botTipLabel = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth/2-100, KScreenHeight-NavBarHeight-40, 200, 15)];
  99. // botTipLabel.textColor = LCTextGray;
  100. // botTipLabel.font = [UIFont systemFontOfSize:11];
  101. // botTipLabel.textAlignment = NSTextAlignmentCenter;
  102. // botTipLabel.text = @"赤彩科技 版权所有";
  103. // [scrollView addSubview:botTipLabel];
  104. // UILabel* botTipL = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth/2-150, KScreenHeight-NavBarHeight-20, 300, 15)];
  105. // botTipL.textColor = LCTextGray;
  106. // botTipL.font = [UIFont systemFontOfSize:11];
  107. // botTipL.textAlignment = NSTextAlignmentCenter;
  108. // botTipL.text = @"Copyright © 2018 Red Color ALL Rights Reserved";
  109. // [scrollView addSubview:botTipL];
  110. // UIButton* protocolBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth/2-120, KScreenHeight-NavBarHeight-80, 120, 30)];
  111. // NSMutableAttributedString* attrStr = [[NSMutableAttributedString alloc]initWithString:@"《流光花舞用户协议》"];
  112. // [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, attrStr.length)];
  113. // [attrStr addAttribute:NSForegroundColorAttributeName value:LCBlueColor range:NSMakeRange(0, attrStr.length)];
  114. // [attrStr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:0] range:NSMakeRange(0, attrStr.length)];
  115. // [protocolBtn setAttributedTitle:attrStr forState:(UIControlStateNormal)];
  116. // [protocolBtn addTarget:self action:@selector(youpaifprotocolClick) forControlEvents:(UIControlEventTouchUpInside)];
  117. // [scrollView addSubview:protocolBtn];
  118. // UIButton* privacyBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth/2, KScreenHeight-NavBarHeight-80, 120, 30)];
  119. // NSMutableAttributedString* pattrStr = [[NSMutableAttributedString alloc]initWithString:@"《流光花舞隐私保护》"];
  120. // [pattrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, pattrStr.length)];
  121. // [pattrStr addAttribute:NSForegroundColorAttributeName value:LCBlueColor range:NSMakeRange(0, pattrStr.length)];
  122. // [pattrStr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:0] range:NSMakeRange(0, attrStr.length)];
  123. // [privacyBtn setAttributedTitle:pattrStr forState:(UIControlStateNormal)];
  124. // [privacyBtn addTarget:self action:@selector(youpaifprivacyClick) forControlEvents:(UIControlEventTouchUpInside)];
  125. // [scrollView addSubview:privacyBtn];
  126. }
  127. - (void)youpaifupdateBtnClick:(UIButton *)btn{
  128. [self youpaifcheckAppUpdate:YES];
  129. }
  130. - (void)youpaifprotocolClick{
  131. ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init];
  132. vc.contentUrl = [NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserProtocolH5];
  133. [self.navigationController pushViewController:vc animated:YES];
  134. }
  135. - (void)youpaifprivacyClick{
  136. ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init];
  137. vc.contentUrl = [NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserPrivacyH5];
  138. [self.navigationController pushViewController:vc animated:YES];
  139. }
  140. -(void)youpaifcheckAppUpdate:(BOOL)need
  141. {
  142. [ZCHUDHelper showWithStatus:@"请求中..."];
  143. [LCHttpHelper requestWithURLString:CheckUpdateVersion parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  144. NSDictionary *dict = (NSDictionary *)responseObject;
  145. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  146. if (code == 0)
  147. {
  148. NSString *newVersion = [[dict objectForKey:@"data"] objectForKey:@"newversion"];
  149. //NSString *myVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
  150. NSString *app_build = [[UIApplication sharedApplication] appVersion];
  151. if ([newVersion compare:app_build options:NSCaseInsensitiveSearch] > 0) {
  152. [ZCHUDHelper dismiss];
  153. YOUPAILCUpdateVersionVC *VC= [[YOUPAILCUpdateVersionVC alloc]init];
  154. VC.youpaipenforce = [[[dict objectForKey:@"data"] objectForKey:@"enforce"]integerValue];
  155. VC.youpaipdownLoadUrl = [[dict objectForKey:@"data"] objectForKey:@"downloadurl"];
  156. VC.youpaipversionStr = [NSString stringWithFormat:@"版本号:%@",newVersion];
  157. VC.youpaipupdateText = [[dict objectForKey:@"data"] objectForKey:@"upgradetext"];
  158. VC.vWidth = KScreenWidth - 70;
  159. NSDictionary *attrs = @{NSFontAttributeName : [UIFont systemFontOfSize:14]};
  160. CGSize maxSize= [VC.youpaipupdateText boundingRectWithSize:CGSizeMake(VC.vWidth-116,66) options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
  161. if(maxSize.height<28)
  162. {
  163. maxSize.height = 28;
  164. }
  165. else{
  166. maxSize.height = maxSize.height+20;
  167. }
  168. VC.vHeight = VC.vWidth*203/305.0 +86 + maxSize.height + 120;
  169. VC.isTouchDismiss = YES;
  170. [self TFPresentVC:VC completion:^{
  171. }];
  172. }else{
  173. if (need) {
  174. // [ZCHUDHelper dismiss];
  175. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)0.5*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
  176. [ZCHUDHelper showTitle:@"已经是最新版本" showtime:1];
  177. });
  178. }
  179. }
  180. }
  181. } failure:^(NSError *error) {
  182. [ZCHUDHelper dismiss];
  183. }];
  184. }
  185. -(void)youpaifcheckVersion
  186. {
  187. [LCHttpHelper requestWithURLString:VersionCheck parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  188. NSDictionary* dict = (NSDictionary*)responseObject;
  189. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  190. if (code==0) {
  191. // NSString *version = [dict[@"data"] objectForKey:@"version"];
  192. NSString *newversion = [dict[@"data"] objectForKey:@"newversion"];
  193. NSString *downLoadUrl = dict[@"data"][@"downloadurl"];
  194. NSString *upgradetext = dict[@"data"][@"upgradetext"];
  195. BOOL enforce = [dict[@"data"][@"enforce"]boolValue];
  196. if(newversion.floatValue>[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]floatValue])
  197. {
  198. YOUPAILCUpdateVersionVC *VC= [[YOUPAILCUpdateVersionVC alloc]init];
  199. VC.youpaipenforce = enforce;
  200. VC.youpaipversionStr = [NSString stringWithFormat:@"版本号:%@",newversion];
  201. VC.vWidth = KScreenWidth -60;
  202. VC.vHeight = KScreenWidth -60;
  203. VC.youpaipdownLoadUrl = downLoadUrl;
  204. VC.youpaipupdateText = upgradetext;
  205. VC.isTouchDismiss = YES;
  206. [self TFPresentVC:VC completion:^{
  207. }];
  208. }
  209. }
  210. } failure:^(NSError *error) {
  211. }];
  212. }
  213. @end