YOUPAILCWeixinVC.m 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. //
  2. // YOUPAILCWeixinVC.m
  3. // XiaYue
  4. //
  5. // Created by leo on 2019/11/13.
  6. // Copyright © 2019 XiaYue. All rights reserved.
  7. //
  8. #import "YOUPAILCWeixinVC.h"
  9. @interface YOUPAILCWeixinVC ()
  10. @property(nonatomic,strong)UIImageView* youpaipqrImgV;
  11. @end
  12. @implementation YOUPAILCWeixinVC
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.title = @"微信公众号";
  16. self.view.backgroundColor = HexColorFromRGB(0xF6F6F6);
  17. [self youpaifsetupView];
  18. [self youpaifinitConfig];
  19. }
  20. - (void)youpaifinitConfig{ //系统配置信息
  21. [LCHttpHelper requestWithURLString:AppConfig parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  22. NSDictionary* dict = (NSDictionary*)responseObject;
  23. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  24. if (code==0) {//成功
  25. NSString* qr_image = [[[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"wx_info"] objectForKey:@"qr_image"];
  26. // NSString* gz_image = [[[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"wx_info"] objectForKey:@"gz_image"];
  27. [self.youpaipqrImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:qr_image]];
  28. // [self.bImageView sd_setImageWithURL:[LCTools getImageUrlWithAddress:gz_image]];
  29. }
  30. } failure:^(NSError *error) {
  31. }];
  32. }
  33. - (void)youpaifsetupView{
  34. UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(16,NavBarHeight+45,KScreenWidth-32, KScreenWidth-102+104+69)];
  35. [self.view addSubview:whiteView];
  36. whiteView.backgroundColor = UIColor.whiteColor;
  37. whiteView.layer.cornerRadius = 10;
  38. whiteView.layer.masksToBounds = NO;
  39. UIBezierPath *shadowPath = [UIBezierPath
  40. bezierPathWithRect:whiteView.bounds];
  41. whiteView.layer.shadowColor = HexColorFromRGB(0xA7A9FD).CGColor;
  42. whiteView.layer.shadowOffset = CGSizeMake(0.0f, 5.0f);
  43. whiteView.layer.shadowOpacity = 0.22f;
  44. whiteView.layer.shadowPath = shadowPath.CGPath;
  45. UIImageView *headerImgView = [[UIImageView alloc] initWithFrame:CGRectMake(20,20,49,49)];
  46. headerImgView.layer.cornerRadius = 24.5;
  47. headerImgView.layer.masksToBounds = YES;
  48. headerImgView.image = [UIImage imageNamed:@"weixin_applogo"];
  49. [whiteView addSubview:headerImgView];
  50. UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(79,35.5,200, 18)];
  51. nameLabel.text = @"相语欢颜";
  52. nameLabel.textColor = HexColorFromRGB(0x666666);
  53. nameLabel.font = LCFont(15);
  54. [whiteView addSubview:nameLabel];
  55. UIImageView* qrImgV = [[UIImageView alloc]initWithFrame:CGRectMake(51, 104,KScreenWidth-102,KScreenWidth-102)];
  56. qrImgV.contentMode = UIViewContentModeScaleAspectFill;
  57. qrImgV.layer.cornerRadius = 8;
  58. qrImgV.layer.masksToBounds = YES;
  59. self.youpaipqrImgV = qrImgV;
  60. [whiteView addSubview:qrImgV];
  61. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(qrImgV.frame)+35,KScreenWidth-102,14)];
  62. label.text = @"关注【相语欢颜】官方公众号 随时掌握最新下载链接";
  63. label.textAlignment = NSTextAlignmentCenter;
  64. label.textColor = HexColorFromRGB(0x999999);
  65. label.font = LCFont(10);
  66. [whiteView addSubview:label];
  67. UIButton* saveBtn = [[UIButton alloc]initWithFrame:CGRectMake(60,CGRectGetMaxY(whiteView.frame)+45, KScreenWidth-120,48)];
  68. saveBtn.titleLabel.font = LCFont(17);
  69. saveBtn.layer.cornerRadius = 24;
  70. saveBtn.layer.masksToBounds = YES;
  71. [saveBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth-120,48) FromColors:@[LCGradientOneColor,LCGradientTwoColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)];
  72. [saveBtn setTitle:@"保存二维码到相册" forState:(UIControlStateNormal)];
  73. [saveBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  74. [saveBtn addTarget:self action:@selector(youpaifsaveBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
  75. [self.view addSubview:saveBtn];
  76. //
  77. // UIImageView* topImageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenWidth)];
  78. // topImageV.contentMode = UIViewContentModeScaleAspectFill;
  79. // topImageV.image = [UIImage imageNamed:@"weixin_gzh"];
  80. // [self.view addSubview:topImageV];
  81. //
  82. //
  83. // UIButton* inviteBtn = [[UIButton alloc]initWithFrame:CGRectMake(30, KScreenHeight-110, KScreenWidth-60, 50)];
  84. // inviteBtn.titleLabel.font = LCBoldFont(18);
  85. // inviteBtn.layer.cornerRadius = 8.0;
  86. // inviteBtn.layer.masksToBounds = YES;
  87. // [inviteBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth-60, 50) FromColors:@[LCGradientOneColor,LCGradientTwoColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)];
  88. // [inviteBtn setTitle:@"保存二维码到相册" forState:(UIControlStateNormal)];
  89. // [inviteBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  90. // [inviteBtn addTarget:self action:@selector(youpaifsaveBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
  91. // [self.view addSubview:inviteBtn];
  92. //
  93. //
  94. // UILabel* labelT = [[UILabel alloc]initWithFrame:CGRectMake(10, KScreenHeight-240-182-80, KScreenWidth-20, 30)];
  95. // NSShadow *shadow=[[NSShadow alloc]init];
  96. // shadow.shadowBlurRadius=6.0;
  97. // shadow.shadowOffset=CGSizeMake(0, 0);
  98. // shadow.shadowColor=[UIColor blackColor];
  99. // NSAttributedString *attString=[[NSAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",@"关注流光花舞官方公众号"] attributes:@{NSShadowAttributeName:shadow}];
  100. // labelT.attributedText=attString;
  101. // labelT.textAlignment = NSTextAlignmentCenter;
  102. // labelT.textColor = [UIColor whiteColor];
  103. // labelT.font = LCBoldFont(20);
  104. // // labelT.text = @"关注虾约官方公众号";
  105. // [self.view addSubview:labelT];
  106. //
  107. // UILabel* labelF = [[UILabel alloc]initWithFrame:CGRectMake(10, KScreenHeight-240-182-50, KScreenWidth-20, 30)];
  108. // NSShadow *shadow2=[[NSShadow alloc]init];
  109. // shadow2.shadowBlurRadius=6.0;
  110. // shadow2.shadowOffset=CGSizeMake(0, 0);
  111. // shadow2.shadowColor=[UIColor blackColor];
  112. // NSAttributedString *attString2=[[NSAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",@"下载最新版本APP体验 随时掌握最新活动资讯"] attributes:@{NSShadowAttributeName:shadow2}];
  113. // labelF.attributedText=attString2;
  114. // labelF.textAlignment = NSTextAlignmentCenter;
  115. // labelF.textColor = [UIColor whiteColor];
  116. // labelF.font = LCBoldFont(14);
  117. // // labelF.text = @"下载最新版本APP体验 随时掌握最新活动资讯";
  118. // [self.view addSubview:labelF];
  119. //
  120. // UIView* boderImgV = [[UIView alloc]initWithFrame:CGRectMake(10,KScreenHeight-240-182 , KScreenWidth-20, 182)];
  121. // boderImgV.backgroundColor = HexColorFromRGBA(0xffffff, 0.4);
  122. // boderImgV.layer.cornerRadius = 8.0;
  123. // boderImgV.userInteractionEnabled = YES;
  124. //
  125. // UIImageView *bImageView = [[UIImageView alloc]initWithFrame:boderImgV.bounds];
  126. //// [bImageView setImage:[UIImage imageNamed:@"WechatShot.jpg"]];
  127. // self.bImageView = bImageView;
  128. //
  129. // UIBezierPath *bPath = [UIBezierPath bezierPathWithRoundedRect:bImageView.bounds cornerRadius:8];
  130. // CAShapeLayer *shapeLayer = [CAShapeLayer layer];
  131. // shapeLayer.path = bPath.CGPath;
  132. // bImageView.layer.mask = shapeLayer;
  133. // [boderImgV addSubview:bImageView];
  134. // [self.view addSubview:boderImgV];
  135. //
  136. // UIImageView* qrImgV = [[UIImageView alloc]initWithFrame:CGRectMake(KScreenWidth/2-40, KScreenHeight-200, 80, 80)];
  137. // qrImgV.contentMode = UIViewContentModeScaleAspectFill;
  138. // qrImgV.layer.cornerRadius = 10;
  139. // qrImgV.layer.masksToBounds = YES;
  140. // self.qrImgV = qrImgV;
  141. // [self.view addSubview:qrImgV];
  142. }
  143. - (void)youpaifsaveBtnClick{
  144. [self youpaifjudgeAlbumAuthorizationStatusSuccess:^{
  145. // UIImageWriteToSavedPhotosAlbum([ZCUtils getImage:self.qrImgV], self, @selector(youpaifimageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil);
  146. UIImageWriteToSavedPhotosAlbum(self.youpaipqrImgV.image, self, @selector(youpaifimageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil);
  147. }];
  148. }
  149. - (void)youpaifimageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
  150. {
  151. if (error) {
  152. [ZCHUDHelper showTitle:@"保存失败"];
  153. }else
  154. {
  155. [ZCHUDHelper showTitle:@"已保存到手机相册"];
  156. }
  157. }
  158. //- (void)youpaifinitData{
  159. // [self youpaifsetupView];
  160. // /*
  161. // [LCHttpHelper requestWithURLString:InviteInit parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  162. // NSDictionary* dict = (NSDictionary*)responseObject;
  163. // NSInteger code = [[dict objectForKey:@"code"] integerValue];
  164. // if (code==0) {//成功
  165. // self.qrcode = [[dict objectForKey:@"data"]objectForKey:@"qrcode"];
  166. // [self youpaifsetupView];
  167. // }
  168. // } failure:^(NSError *error) {
  169. //
  170. // }];
  171. // */
  172. //}
  173. - (void)youpaifjudgeAlbumAuthorizationStatusSuccess:(void(^)(void))success {
  174. PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
  175. if (status == PHAuthorizationStatusDenied) {
  176. [ZCHUDHelper showTitle:@"请为本APP开启相册权限"];
  177. } else if(status == PHAuthorizationStatusNotDetermined){
  178. [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status){
  179. if (status == PHAuthorizationStatusAuthorized) {
  180. if (success) success();
  181. } else {
  182. NSLog(@"user is not Authorized");
  183. }
  184. }];
  185. } else if (status == PHAuthorizationStatusAuthorized){
  186. if (success) success();
  187. }
  188. }
  189. /*
  190. #pragma mark - Navigation
  191. // In a storyboard-based application, you will often want to do a little preparation before navigation
  192. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  193. // Get the new view controller using [segue destinationViewController].
  194. // Pass the selected object to the new view controller.
  195. }
  196. */
  197. @end