// // YOUPAILCWeixinVC.m // XiaYue // // Created by leo on 2019/11/13. // Copyright © 2019 XiaYue. All rights reserved. // #import "YOUPAILCWeixinVC.h" @interface YOUPAILCWeixinVC () @property(nonatomic,strong)UIImageView* youpaipqrImgV; @end @implementation YOUPAILCWeixinVC - (void)viewDidLoad { [super viewDidLoad]; self.title = @"微信公众号"; self.view.backgroundColor = HexColorFromRGB(0xF6F6F6); [self youpaifsetupView]; [self youpaifinitConfig]; } - (void)youpaifinitConfig{ //系统配置信息 [LCHttpHelper requestWithURLString:AppConfig parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSString* qr_image = [[[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"wx_info"] objectForKey:@"qr_image"]; // NSString* gz_image = [[[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"wx_info"] objectForKey:@"gz_image"]; [self.youpaipqrImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:qr_image]]; // [self.bImageView sd_setImageWithURL:[LCTools getImageUrlWithAddress:gz_image]]; } } failure:^(NSError *error) { }]; } - (void)youpaifsetupView{ UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(16,NavBarHeight+45,KScreenWidth-32, KScreenWidth-102+104+69)]; [self.view addSubview:whiteView]; whiteView.backgroundColor = UIColor.whiteColor; whiteView.layer.cornerRadius = 10; whiteView.layer.masksToBounds = NO; UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:whiteView.bounds]; whiteView.layer.shadowColor = HexColorFromRGB(0xA7A9FD).CGColor; whiteView.layer.shadowOffset = CGSizeMake(0.0f, 5.0f); whiteView.layer.shadowOpacity = 0.22f; whiteView.layer.shadowPath = shadowPath.CGPath; UIImageView *headerImgView = [[UIImageView alloc] initWithFrame:CGRectMake(20,20,49,49)]; headerImgView.layer.cornerRadius = 24.5; headerImgView.layer.masksToBounds = YES; headerImgView.image = [UIImage imageNamed:@"weixin_applogo"]; [whiteView addSubview:headerImgView]; UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(79,35.5,200, 18)]; nameLabel.text = @"相语欢颜"; nameLabel.textColor = HexColorFromRGB(0x666666); nameLabel.font = LCFont(15); [whiteView addSubview:nameLabel]; UIImageView* qrImgV = [[UIImageView alloc]initWithFrame:CGRectMake(51, 104,KScreenWidth-102,KScreenWidth-102)]; qrImgV.contentMode = UIViewContentModeScaleAspectFill; qrImgV.layer.cornerRadius = 8; qrImgV.layer.masksToBounds = YES; self.youpaipqrImgV = qrImgV; [whiteView addSubview:qrImgV]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(qrImgV.frame)+35,KScreenWidth-102,14)]; label.text = @"关注【相语欢颜】官方公众号 随时掌握最新下载链接"; label.textAlignment = NSTextAlignmentCenter; label.textColor = HexColorFromRGB(0x999999); label.font = LCFont(10); [whiteView addSubview:label]; UIButton* saveBtn = [[UIButton alloc]initWithFrame:CGRectMake(60,CGRectGetMaxY(whiteView.frame)+45, KScreenWidth-120,48)]; saveBtn.titleLabel.font = LCFont(17); saveBtn.layer.cornerRadius = 24; saveBtn.layer.masksToBounds = YES; [saveBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth-120,48) FromColors:@[LCGradientOneColor,LCGradientTwoColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)]; [saveBtn setTitle:@"保存二维码到相册" forState:(UIControlStateNormal)]; [saveBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; [saveBtn addTarget:self action:@selector(youpaifsaveBtnClick) forControlEvents:(UIControlEventTouchUpInside)]; [self.view addSubview:saveBtn]; // // UIImageView* topImageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenWidth)]; // topImageV.contentMode = UIViewContentModeScaleAspectFill; // topImageV.image = [UIImage imageNamed:@"weixin_gzh"]; // [self.view addSubview:topImageV]; // // // UIButton* inviteBtn = [[UIButton alloc]initWithFrame:CGRectMake(30, KScreenHeight-110, KScreenWidth-60, 50)]; // inviteBtn.titleLabel.font = LCBoldFont(18); // inviteBtn.layer.cornerRadius = 8.0; // inviteBtn.layer.masksToBounds = YES; // [inviteBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth-60, 50) FromColors:@[LCGradientOneColor,LCGradientTwoColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)]; // [inviteBtn setTitle:@"保存二维码到相册" forState:(UIControlStateNormal)]; // [inviteBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; // [inviteBtn addTarget:self action:@selector(youpaifsaveBtnClick) forControlEvents:(UIControlEventTouchUpInside)]; // [self.view addSubview:inviteBtn]; // // // UILabel* labelT = [[UILabel alloc]initWithFrame:CGRectMake(10, KScreenHeight-240-182-80, KScreenWidth-20, 30)]; // NSShadow *shadow=[[NSShadow alloc]init]; // shadow.shadowBlurRadius=6.0; // shadow.shadowOffset=CGSizeMake(0, 0); // shadow.shadowColor=[UIColor blackColor]; // NSAttributedString *attString=[[NSAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",@"关注流光花舞官方公众号"] attributes:@{NSShadowAttributeName:shadow}]; // labelT.attributedText=attString; // labelT.textAlignment = NSTextAlignmentCenter; // labelT.textColor = [UIColor whiteColor]; // labelT.font = LCBoldFont(20); // // labelT.text = @"关注虾约官方公众号"; // [self.view addSubview:labelT]; // // UILabel* labelF = [[UILabel alloc]initWithFrame:CGRectMake(10, KScreenHeight-240-182-50, KScreenWidth-20, 30)]; // NSShadow *shadow2=[[NSShadow alloc]init]; // shadow2.shadowBlurRadius=6.0; // shadow2.shadowOffset=CGSizeMake(0, 0); // shadow2.shadowColor=[UIColor blackColor]; // NSAttributedString *attString2=[[NSAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",@"下载最新版本APP体验 随时掌握最新活动资讯"] attributes:@{NSShadowAttributeName:shadow2}]; // labelF.attributedText=attString2; // labelF.textAlignment = NSTextAlignmentCenter; // labelF.textColor = [UIColor whiteColor]; // labelF.font = LCBoldFont(14); // // labelF.text = @"下载最新版本APP体验 随时掌握最新活动资讯"; // [self.view addSubview:labelF]; // // UIView* boderImgV = [[UIView alloc]initWithFrame:CGRectMake(10,KScreenHeight-240-182 , KScreenWidth-20, 182)]; // boderImgV.backgroundColor = HexColorFromRGBA(0xffffff, 0.4); // boderImgV.layer.cornerRadius = 8.0; // boderImgV.userInteractionEnabled = YES; // // UIImageView *bImageView = [[UIImageView alloc]initWithFrame:boderImgV.bounds]; //// [bImageView setImage:[UIImage imageNamed:@"WechatShot.jpg"]]; // self.bImageView = bImageView; // // UIBezierPath *bPath = [UIBezierPath bezierPathWithRoundedRect:bImageView.bounds cornerRadius:8]; // CAShapeLayer *shapeLayer = [CAShapeLayer layer]; // shapeLayer.path = bPath.CGPath; // bImageView.layer.mask = shapeLayer; // [boderImgV addSubview:bImageView]; // [self.view addSubview:boderImgV]; // // UIImageView* qrImgV = [[UIImageView alloc]initWithFrame:CGRectMake(KScreenWidth/2-40, KScreenHeight-200, 80, 80)]; // qrImgV.contentMode = UIViewContentModeScaleAspectFill; // qrImgV.layer.cornerRadius = 10; // qrImgV.layer.masksToBounds = YES; // self.qrImgV = qrImgV; // [self.view addSubview:qrImgV]; } - (void)youpaifsaveBtnClick{ [self youpaifjudgeAlbumAuthorizationStatusSuccess:^{ // UIImageWriteToSavedPhotosAlbum([ZCUtils getImage:self.qrImgV], self, @selector(youpaifimageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil); UIImageWriteToSavedPhotosAlbum(self.youpaipqrImgV.image, self, @selector(youpaifimageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil); }]; } - (void)youpaifimageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { if (error) { [ZCHUDHelper showTitle:@"保存失败"]; }else { [ZCHUDHelper showTitle:@"已保存到手机相册"]; } } //- (void)youpaifinitData{ // [self youpaifsetupView]; // /* // [LCHttpHelper requestWithURLString:InviteInit parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { // NSDictionary* dict = (NSDictionary*)responseObject; // NSInteger code = [[dict objectForKey:@"code"] integerValue]; // if (code==0) {//成功 // self.qrcode = [[dict objectForKey:@"data"]objectForKey:@"qrcode"]; // [self youpaifsetupView]; // } // } failure:^(NSError *error) { // // }]; // */ //} - (void)youpaifjudgeAlbumAuthorizationStatusSuccess:(void(^)(void))success { PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus]; if (status == PHAuthorizationStatusDenied) { [ZCHUDHelper showTitle:@"请为本APP开启相册权限"]; } else if(status == PHAuthorizationStatusNotDetermined){ [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status){ if (status == PHAuthorizationStatusAuthorized) { if (success) success(); } else { NSLog(@"user is not Authorized"); } }]; } else if (status == PHAuthorizationStatusAuthorized){ if (success) success(); } } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end