123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627 |
- //
- // KBShareGoodsViewController.m
- // YouHuiProject
- //
- // Created by jcymac on 2018/5/18.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "KBShareGoodsViewController.h"
- #import "KBShareGoodsTop.h"
- #import "KBShareGoodsView.h"
- #import "shareView.h"
- #import "HYUMShareManager.h"
- #import "KBLinkFansController.h"
- #import "KBPrivilegeReferralViewController.h"
- @interface KBShareGoodsViewController ()<UITextViewDelegate>
- @property(nonatomic,strong)UIScrollView *scrollView;
- @property(nonatomic,strong)UIView *topView;
- @property(nonatomic,strong)KBShareGoodsView *shareGoodsView;
- @property(nonatomic,strong)UIImageView *imageView;
- @property(nonatomic,strong)UIView *centerGrayView;
- @property(nonatomic,strong)UITextView *textView;
- @property(nonatomic,strong)UIImageView *imaginaryLineView;
- @property(nonatomic,strong)UILabel *moneyLabel;
- @property(nonatomic,strong)UILabel *infoLabel;
- @property(nonatomic,strong)UIButton *copyButton;
- @property(nonatomic,strong)UIButton *shareUrlButton;
- @property(nonatomic,strong)UIButton *shareImageButton;
- @property(nonatomic,strong)UIView *backShareView;
- @property(nonatomic,strong)shareView *shareView;
- @property(nonatomic,copy )NSNumber *flag;
- @property(nonatomic,copy )NSNumber *isSuper;
- @property(nonatomic )BOOL canShareImg;
- @end
- @implementation KBShareGoodsViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.canShareImg=NO;
- [self configNavigationBar];
- [self initHUD];
- [self loadSubViewsConfiguration];
- [self request];
- [self adjustUI];
-
- [SVProgressHUD show];
- [SVProgressHUD dismissWithDelay:2.0f];
-
- }
- -(void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- }
- - (void)configNavigationBar {
- self.view.backgroundColor = [UIColor whiteColor];
- [self.navigationBar setNavTitle:@"分享商品"];
- self.navigationBar.showNavigationBarBottomLine = YES;
- UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
- [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
- [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- [self.navigationBar setCustomLeftButtons:@[leftBtn]];
- [self.navigationBar setShowNavigationBarBottomLine:YES];
- }
- - (void)initHUD {
- [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
- [SVProgressHUD setForegroundColor:[UIColor YHColorWithHex:0xff2420]];
- [SVProgressHUD setBackgroundColor:[UIColor YHColorWithHex:0xf5f4f4]];
- }
- -(void)request{
- self.flag=@(-1);
- self.isSuper=@(-1);
- NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/shareCommonGoodsNew",BaseURL];
- NSString *coupon_start_time = [self.goodModel.is_coupon boolValue] ? self.goodModel.start_time : @"";
- NSString *coupon_end_time = [self.goodModel.is_coupon boolValue] ? self.goodModel.end_time : @"";
- if (!coupon_start_time) coupon_start_time = @"";
- if (!coupon_end_time) coupon_end_time = @"";
- NSDictionary *dic=@{
- @"goods_id":self.goodModel.goods_id,
- @"is_coupon":self.goodModel.is_coupon,
- @"coupon_price":self.goodModel.coupon_price,
- @"price":self.goodModel.price,
- @"discount_price":self.goodModel.discount_price,
- @"commission_rate":self.goodModel.commission_rate,
- @"coupon_end_time":coupon_end_time,
- @"coupon_start_time":coupon_start_time
- };
- [KBHttp post:url params:dic success:^(id json) {
- // KBShareGoodsViewController *vc=[[KBShareGoodsViewController alloc]init];
- KBShareGoodsTempModel *tmpModel=[KBShareGoodsTempModel yy_modelWithJSON:json[@"data"]];
- KBShareGoodsModel *model=[KBShareGoodsModel createShareGoodsModelByShareGoodsTempModel:tmpModel];
- model.commissionPrice=self.goodModel.commission_price;//佣金价格
- model.commission_rate=self.goodModel.commission_rate;
- model.discount_price=self.goodModel.discount_price;
- self.model=model;
-
- //第二次加载使用
- self.imageView.image=[self.shareGoodsView changeToImage];
- kWeak(self)
- self.shareGoodsView.imgSuccBlock = ^{
- //第一次加载使用
- NSLog(@"图片加载完成");
- selfWeak.imageView.image=[selfWeak.shareGoodsView changeToImage];
- selfWeak.canShareImg=YES;
-
- NSLog(@"图片加载完成2");
-
- };
-
-
- self.textView.text=self.model.title;
- self.moneyLabel.text=[NSString stringWithFormat:@"【原价】%@元 \n【券后】%@元",self.model.originalPrice,self.model.ticketAfterPrice];
- self.infoLabel.text=[NSString stringWithFormat:@"复制这条信息%@\n打开【手机淘宝】即可查看",self.model.infoStr];
-
-
-
-
- NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/shareTheTextNew",BaseURL];
- NSDictionary *dic=@{@"commission_rate":self.model.commission_rate,
- @"discount_price":self.model.discount_price
- };
- [KBHttp post:url params:dic success:^(id json) {
- if (json[@"data"]) {
- [SVProgressHUD dismiss];
- NSString *text=json[@"data"][@"text"];
- NSNumber *flag=json[@"data"][@"flag"];
- NSNumber *isSuper=json[@"data"][@"isSuper"];
- UILabel *label=(UILabel *)[self.topView viewWithTag:10001];
- label.frame=CGRectMake(FITSIZE(15), 10, SCREEN_WIDTH-FITSIZE((70)), 0);
- label.text=text;
- [label sizeToFit];
- [UIView animateWithDuration:0.5f animations:^{
- self.scrollView.frame=CGRectMake(0,NavBarHeight+label.height, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-label.height);
- }];
-
-
- self.flag=flag;
- self.isSuper=isSuper;
- [self.topView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(0);
- make.top.mas_equalTo(NavBarHeight);
- make.height.mas_equalTo((label.height+20));
- }];
- UIView *rightBtn=[self.topView viewWithTag:10002];
- [rightBtn mas_updateConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(self.topView.mas_height);
- make.top.mas_equalTo(0);
- make.width.mas_equalTo(FITSIZE(70));
-
- }];
- self.topView.hidden=NO;
-
-
- }
- } failure:^(NSError *error) {
- self.flag=0;
- }];
-
-
-
-
- } failure:^(NSError *error) {
-
- }];
- }
- -(void)loadSubViewsConfiguration{
- [self.view addSubview:self.scrollView];
- [self.scrollView addSubview:self.imageView];
-
- [self.scrollView addSubview:self.centerGrayView];
- [self.scrollView addSubview:self.textView];
- [self.scrollView addSubview:self.imaginaryLineView];
- [self.scrollView addSubview:self.moneyLabel];
- [self.scrollView addSubview:self.infoLabel];
- [self.scrollView addSubview:self.copyButton];
- self.copyButton.hidden=YES;
- //view顶层
- [self.view addSubview:self.topView];
- [self.view addSubview:self.shareImageButton];
- [self.view addSubview:self.shareUrlButton];
- [[UIApplication sharedApplication].keyWindow addSubview:self.backShareView];
- [[UIApplication sharedApplication].keyWindow addSubview:self.shareView];
- }
- -(void)adjustUI{
- UILabel *topLabel=[self.topView viewWithTag:10001];
- [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(0);
- make.top.mas_equalTo(NavBarHeight);
- make.height.mas_equalTo((topLabel.height+20));
- }];
- [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo((topLabel.height+30+20));
- make.left.mas_equalTo(54);
- make.width.mas_equalTo(SCREEN_WIDTH-2*FITSIZE(54));
- make.height.mas_equalTo(474);
- }];
- [self.centerGrayView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.width.mas_equalTo(SCREEN_WIDTH);
- make.top.equalTo(self.imageView.mas_bottom).offset(20);
- make.height.mas_equalTo(5);
- }];
-
-
- [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(FITSIZE(17));
- make.width.mas_equalTo(SCREEN_WIDTH-FITSIZE((17*2)));
- make.top.equalTo(self.centerGrayView.mas_bottom).offset(5);
- make.height.mas_equalTo(53);
- }];
- [self.imaginaryLineView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(FITSIZE(17));
- make.width.mas_equalTo(SCREEN_WIDTH-FITSIZE(17*2));
- make.top.equalTo(self.textView.mas_bottom).offset(7);
- make.height.mas_equalTo(5);
- }];
- [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.imaginaryLineView.mas_left).offset(-FITSIZE(7));
- make.top.equalTo(self.imaginaryLineView.mas_bottom).offset(8);
- }];
- [self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.imaginaryLineView.mas_left);
- make.top.equalTo(self.moneyLabel.mas_bottom).offset(10);
- }];
- [self.copyButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.imaginaryLineView.mas_right).offset(FITSIZE(-10));
- make.top.equalTo(self.imaginaryLineView.mas_bottom).offset(28);
- make.width.mas_equalTo(FITSIZE(92));
- make.height.mas_equalTo(24);
- }];
- }
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)ShareImg{
- if (self.canShareImg) {
- self.backShareView.hidden=NO;
- [self.shareView shareImage:[self.shareGoodsView changeToImage]];
- //分享图片
- [UIView animateWithDuration:0.2f animations:^{
- self.shareView.frame=CGRectMake(0, SCREEN_HEIGHT-200-SafeBottomHeight, SCREEN_WIDTH, 200+SafeBottomHeight);
- }];
- }else{
- [MBProgressHUD showMessage:@"图片还在加载中,请稍后重试"];
- }
- }
- -(void)copyCode{
- UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
-
- pasteboard.string =[NSString stringWithFormat:@"%@\n--------\n【在售价】%@元\n【券后价】%@元\n--------\n复制这条信息¥%@¥\n打开【手机淘宝】即可查看",self.model.title,self.model.originalPrice,self.model.ticketAfterPrice,self.model.infoStr];
- [SVProgressHUD showSuccessWithStatus:@"复制成功"];
-
- }
- #pragma mark 代理 UITextViewDelegate
- - (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
- return YES;
- }
- #pragma mark -点击方法
- -(void)shareAction:(UIButton *)sender{
-
- switch (sender.tag) {
- case 50001://分享链接
- {
- // [self.shareView shareWeChatTitle:self.model.title desc:@"领完券再购物,不光省钱还能赚钱" imageUrl:self.model.mainImageUrl webUrl:self.model.QRcodeImageUrl];
- // //分享链接
- // [UIView animateWithDuration:0.2f animations:^{
- // self.shareView.frame=CGRectMake(0, SCREEN_HEIGHT-200-SafeBottomHeight, SCREEN_WIDTH, 200+SafeBottomHeight);
- // }];
-
- }
- break;
- case 50002:
- {
- if (!([self.flag integerValue]==0)) {
- if ([self.flag integerValue]==1 &&[self.isSuper integerValue]==0) {
- //会员
- UILabel *label=(UILabel *)[self.topView viewWithTag:10001];
- UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"分享赚佣金" message:[NSString stringWithFormat:@"\n%@",label.text] preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"去升级" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- KBPrivilegeReferralViewController *vc=[[KBPrivilegeReferralViewController alloc]init];
- [self.navigationController pushViewController:vc animated:YES];
- }];
- UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- [self ShareImg];
- }];
- [alert addAction:cancelAction];
- [alert addAction:defaultAction];
- [self presentViewController:alert animated:YES completion:nil];
-
-
- }else{
- [self ShareImg];
- }
-
- }else{
- UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"\n您还没有绑定邀请码哟" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"前往绑定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- KBLinkFansController *linkFans = [[KBLinkFansController alloc] init];
- linkFans.linkFansBlock = ^{
- [self request];
- };
- [self.navigationController pushViewController:linkFans animated:YES];
- }];
- UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
-
- }];
- [alert addAction:defaultAction];
- [alert addAction:cancelAction];
- [self presentViewController:alert animated:YES completion:nil];
- }
-
- }
- break;
- default:
- break;
- }
- }
- -(void)doTapChange{
- self.backShareView.hidden=YES;
- [UIView animateWithDuration:0.2f animations:^{
- self.shareView.frame=CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 200+SafeBottomHeight);
- } completion:^(BOOL finished) {
- }];
- }
- -(void)copyAction{
- if ([self.flag integerValue]==-1) {
- [MBProgressHUD showMessage:@"努力生成邀请码中,请稍后尝试"];
- return;
- }
-
- if (!([self.flag integerValue]==0)) {
- if ([self.flag integerValue]==1 &&[self.isSuper integerValue]==0) {
- //会员
- UILabel *label=(UILabel *)[self.topView viewWithTag:10001];
- UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"分享赚佣金" message:[NSString stringWithFormat:@"\n%@",label.text] preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"去升级" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- KBPrivilegeReferralViewController *vc=[[KBPrivilegeReferralViewController alloc]init];
- [self.navigationController pushViewController:vc animated:YES];
- }];
- UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- [self copyCode];
- }];
- [alert addAction:cancelAction];
- [alert addAction:defaultAction];
- [self presentViewController:alert animated:YES completion:nil];
-
-
- }else{
- [self copyCode];
- }
- }else{
- UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"温馨提示"
- message:@"\n您还没有绑定邀请码"
- preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"前往绑定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- KBLinkFansController *linkFans = [[KBLinkFansController alloc] init];
- linkFans.linkFansBlock = ^{
- [self request];
- };
- [self.navigationController pushViewController:linkFans animated:YES];
- }];
- UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
-
- }];
-
- [alert addAction:defaultAction];
- [alert addAction:cancelAction];
- [self presentViewController:alert animated:YES completion:nil];
- }
-
- }
- -(void)rightAction:(id )sender{
- KBPrivilegeReferralViewController *vc=[[KBPrivilegeReferralViewController alloc]init];
- vc.flag=self.flag;
- vc.isSuper=self.isSuper;
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark 懒加载
- -(KBShareGoodsView *)shareGoodsView{
- if (!_shareGoodsView) {
- _shareGoodsView=[[KBShareGoodsView alloc]initWithFrame:CGRectMake(0, 0, 375, 667)];
- kWeak(self)
- _shareGoodsView.imgSuccBlock = ^{
- //第一次加载使用
- NSLog(@"图片加载完成");
- selfWeak.imageView.image=[selfWeak.shareGoodsView changeToImage];
- selfWeak.canShareImg=YES;
- NSLog(@"图片加载完成2");
-
- };
- _shareGoodsView.model=self.model;
- }
- return _shareGoodsView;
- }
- -(UIImageView *)imageView{
- if (!_imageView) {
- _imageView=[[UIImageView alloc]init];
- _imageView.backgroundColor=[UIColor whiteColor];
- _imageView.layer.shadowColor = [UIColor YHColorWithHex:0xF16767].CGColor;//shadowColor阴影颜色
- _imageView.layer.shadowOpacity = 0.2;//阴影透明度,默认0
- _imageView.layer.shadowRadius = 10;//阴影半径,默认3
- }
- return _imageView;
- }
- -(UIView *)topView{
- if (!_topView) {
- _topView=[[UIView alloc]init];
- _topView.hidden=YES;
- _topView.backgroundColor=[UIColor YHColorWithHex:0xFF502E];//[UIColor YHColorWithHex:0xF2F2F2];
- UILabel *leftLabel=[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(15), 10, SCREEN_WIDTH-FITSIZE((70)), 0)];
- leftLabel.numberOfLines=0;
- leftLabel.tag=10001;
- leftLabel.font=[UIFont systemFontOfSize:14.0f];
- leftLabel.textColor=[UIColor whiteColor];
- leftLabel.text=@"";
-
- [leftLabel sizeToFit];
- UIButton *rightBtn=[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-FITSIZE(70), leftLabel.y, FITSIZE(70), leftLabel.height)];
- rightBtn.tag=10002;
- [rightBtn setTitle:@"规则 " forState:UIControlStateNormal];
- UIImage *image=[UIImage imageNamed:@"share_right_regulation"];
- [rightBtn setImage:image forState:UIControlStateNormal];
- rightBtn.titleLabel.font=[UIFont systemFontOfSize:13.0f];
- [rightBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -image.size.width, 0, image.size.width)];
- [rightBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -FITSIZE(60))];
- [rightBtn addTarget:self action:@selector(rightAction:) forControlEvents:UIControlEventTouchUpInside];
- [rightBtn setTitleColor:[UIColor whiteColor]forState:UIControlStateNormal];
- UITapGestureRecognizer *singleTapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(rightAction:)];
- singleTapGesture.numberOfTapsRequired =1;
- singleTapGesture.numberOfTouchesRequired =1;
- [_topView addGestureRecognizer:singleTapGesture];
-
-
- [_topView addSubview:leftLabel];
- [_topView addSubview:rightBtn];
- }
- return _topView;
- }
- -(UIScrollView *)scrollView{
- if (!_scrollView) {
- _scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0,NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)];
- _scrollView.showsVerticalScrollIndicator = NO;
- _scrollView.showsHorizontalScrollIndicator = NO;
- _scrollView.contentSize=CGSizeMake(SCREEN_WIDTH, 851-NavBarHeight);
- }
- return _scrollView;
- }
- -(UIView *)centerGrayView{
- if (!_centerGrayView) {
- _centerGrayView=[[UIView alloc]init];
- _centerGrayView.backgroundColor=[[UIColor YHColorWithHex:0x999999] colorWithAlphaComponent:0.2f];
- }
- return _centerGrayView;
- }
- -(UITextView *)textView{
- if (!_textView) {
- _textView=[[UITextView alloc]init];
- _textView.font=[UIFont systemFontOfSize:16.0f];
- // _textView.text=self.model.title;
- _textView.text=@"";
- _textView.textColor=[UIColor YHColorWithHex:0x444444];
- // _textView.layer.borderWidth=1;
- // _textView.layer.borderColor=[UIColor lightGrayColor].CGColor;
- // _textView.layer.cornerRadius = 3;
- // _textView.layer.masksToBounds=YES;
- _textView.delegate=self;
- }
- return _textView;
- }
- -(UIImageView *)imaginaryLineView{
- if (!_imaginaryLineView) {
- _imaginaryLineView=[[UIImageView alloc]init];
- [_imaginaryLineView setImage:[UIImage imageNamed:@"share_imaginary_line"]];
- }
- return _imaginaryLineView;
- }
- -(UILabel *)moneyLabel{
- if (!_moneyLabel) {
- _moneyLabel=[[UILabel alloc]init];
- // _moneyLabel.text=[NSString stringWithFormat:@"【原价】%@元 \n【券后】%@元",self.model.originalPrice,self.model.ticketAfterPrice];
- _moneyLabel.text=[NSString stringWithFormat:@"【原价】--元 \n【券后】--元"];
- _moneyLabel.textColor=[UIColor YHColorWithHex:0x777777];
- _moneyLabel.font=[UIFont systemFontOfSize:14.0f];
- _moneyLabel.numberOfLines=2;
- [_moneyLabel sizeToFit];
-
- }
- return _moneyLabel;
- }
- -(UILabel *)infoLabel{
- if (!_infoLabel) {
- _infoLabel=[[UILabel alloc]init];
- // _infoLabel.text=[NSString stringWithFormat:@"复制这条信息¥-------\n打开【手机淘宝】即可查看",self.model.infoStr];
- _infoLabel.text=[NSString stringWithFormat:@"复制这条信息¥-------\n打开【手机淘宝】即可查看"];
- _infoLabel.textColor=[UIColor YHColorWithHex:0x878787];
- _infoLabel.font=[UIFont systemFontOfSize:14.0f];
- _infoLabel.numberOfLines=2;
- [_infoLabel sizeToFit];
- }
- return _infoLabel;
- }
- -(UIButton *)copyButton{
- if (!_copyButton) {
- _copyButton=[[UIButton alloc]init];
- [_copyButton setTitle:@"复制淘口令" forState:UIControlStateNormal];
- _copyButton.titleLabel.font=[UIFont systemFontOfSize:14];
- _copyButton.titleLabel.textAlignment=NSTextAlignmentCenter;
- _copyButton.layer.borderWidth=1;
- _copyButton.layer.cornerRadius=12;
- _copyButton.layer.masksToBounds=YES;
- _copyButton.layer.borderColor=[UIColor YHColorWithHex:0xFFDB00].CGColor;
- [_copyButton addTarget:self action:@selector(copyAction) forControlEvents:UIControlEventTouchUpInside];
- [_copyButton setTitleColor:[UIColor YHColorWithHex:0xED5B5B] forState:UIControlStateNormal];
- }
- return _copyButton;
- }
- -(UIButton *)shareUrlButton{
- if (!_shareUrlButton) {
- _shareUrlButton=[UIButton buttonWithType:UIButtonTypeCustom];
- _shareUrlButton.tag=50001;
- _shareUrlButton.frame=CGRectMake(0, SCREEN_HEIGHT-50-SafeTopHeight, SCREEN_WIDTH/2, 50+SafeTopHeight);
- CAGradientLayer *layer = [CAGradientLayer layer];
- layer.startPoint = CGPointMake(0, 0);//(0,0)表示从左上角开始变化。默认值是(0.5,0.0)表示从x轴为中间,y为顶端的开始变化
- layer.endPoint = CGPointMake(1, 1);//(1,1)表示到右下角变化结束。默认值是(0.5,1.0) 表示从x轴为中间,y为低端的结束变化
- layer.colors = [NSArray arrayWithObjects:(id)[UIColor YHColorWithHex:0xFEC800].CGColor,(id)[UIColor YHColorWithHex:0xFD9D03].CGColor, nil];
- layer.locations = @[@0.0f,@1.0f];//渐变颜色的区间分布,locations的数组长度和color一致,这个值一般不用管它,默认是nil,会平均分布
- layer.frame = _shareUrlButton.layer.bounds;
- [_shareUrlButton setTitle:@"复制淘口令" forState:UIControlStateNormal];
- _shareUrlButton.titleLabel.font=[UIFont systemFontOfSize:14.0f];
- [_shareUrlButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [_shareUrlButton addTarget:self action:@selector(copyAction) forControlEvents:UIControlEventTouchUpInside];
- [_shareUrlButton.layer insertSublayer:layer atIndex:0];
- }
- return _shareUrlButton;
- }
- -(UIButton *)shareImageButton{
- if (!_shareImageButton) {
- _shareImageButton=[UIButton buttonWithType:UIButtonTypeCustom];
- _shareImageButton.tag=50002;
- _shareImageButton.frame=CGRectMake(SCREEN_WIDTH/2, SCREEN_HEIGHT-50-SafeTopHeight, SCREEN_WIDTH/2, 50+SafeTopHeight);
- CAGradientLayer *layer = [CAGradientLayer layer];
- layer.startPoint = CGPointMake(0, 0);//(0,0)表示从左上角开始变化。默认值是(0.5,0.0)表示从x轴为中间,y为顶端的开始变化
- layer.endPoint = CGPointMake(1, 1);//(1,1)表示到右下角变化结束。默认值是(0.5,1.0) 表示从x轴为中间,y为低端的结束变化
- layer.colors = [NSArray arrayWithObjects:(id)[UIColor YHColorWithHex:0xFE6735].CGColor,(id)[UIColor YHColorWithHex:0xFF2D23].CGColor, nil];
- layer.locations = @[@0.0f,@1.0f];//渐变颜色的区间分布,locations的数组长度和color一致,这个值一般不用管它,默认是nil,会平均分布
- layer.frame = _shareImageButton.layer.bounds;
- [_shareImageButton setTitle:@"分享图片" forState:UIControlStateNormal];
- _shareImageButton.titleLabel.font=[UIFont systemFontOfSize:14.0f];
- [_shareImageButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [_shareImageButton addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
- [_shareImageButton.layer insertSublayer:layer atIndex:0];
- }
- return _shareImageButton;
- }
- -(UIView *)shareView{
- if (!_shareView) {
- _shareView=[[[NSBundle mainBundle] loadNibNamed:@"shareView" owner:self options:nil] lastObject];
- _shareView.frame=CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH,SCREEN_HEIGHT);
- [_shareView.cancelButton addTarget:self action:@selector(doTapChange) forControlEvents:UIControlEventTouchUpInside];
- WeakSelf(weakSelf)
- _shareView.shareButtonTwoBlock=^(void){
- __strong typeof(self) strongSelf=weakSelf;
- [strongSelf doTapChange];
- };
- _shareView.shareButtonOneBlock=^(void){
- __strong typeof(self) strongSelf=weakSelf;
- [strongSelf doTapChange];
- };
- }
- return _shareView;
- }
- -(UIView *)backShareView{
- if (!_backShareView) {
- _backShareView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
- _backShareView.backgroundColor=[[UIColor blackColor] colorWithAlphaComponent:0.3f];
- _backShareView.hidden=YES;
- UITapGestureRecognizer *r5 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doTapChange)];
- r5.numberOfTapsRequired = 1;
- [_backShareView addGestureRecognizer:r5];
- }
- return _backShareView;
- }
- @end
|