// // LZMShareImgPopView.m // YouHuiProject // // Created by 小花 on 2018/7/10. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LZMShareImgPopView.h" #import #import "HYUMShareManager.h" #import @interface LZMShareImgPopView (){ UIImage *shareImg; } @property (nonatomic, strong) LZMGoodDetailModel *goodModel; @property (nonatomic, strong) UIActivityIndicatorView *indicatorView; @property (nonatomic, strong) LZMShareGoodsModel *model; @end @implementation LZMShareImgPopView - (instancetype)initWithFrame:(CGRect)frame goodModel:(LZMGoodDetailModel *)goodModel{ self = [super initWithFrame:frame]; if (self) { self.goodModel = goodModel; [self initSubViews]; [self loadShareData]; } return self; } - (void)initSubViews { UIView *bg = [[UIView alloc] initWithFrame:self.bounds]; bg.backgroundColor = [UIColor clearColor]; [self addSubview:bg]; UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:self.bounds]; toolbar.barStyle = UIBarStyleBlack; [bg addSubview:toolbar]; self.shareGoodView = [[LZMPopShareGoodView alloc] initWithFrame:CGRectMake(0, Fitsize(30), Fitsize(254), Fitsize(455))]; self.shareGoodView.centerX = self.width/2; self.shareGoodView.backgroundColor = [UIColor whiteColor]; self.shareGoodView.imgSuccBlock = ^{ shareImg = [self.shareGoodView changeToImage]; }; [bg addSubview:self.shareGoodView]; [self.shareGoodView addSubview:self.indicatorView]; [self.indicatorView startAnimating]; NSArray *titles = @[@"分享朋友圈",@"分享给好友",@"复制淘口令",@"保存图片"]; NSArray *icons = @[@"wx_section",@"wx_wechat",@"copy_code",@"save_img"]; CGFloat margin = Fitsize(30); CGFloat width = (self.width-Fitsize(60))/4; CGFloat height = width; for (int i = 0; i < titles.count; i++) { UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(margin+i*width, self.shareGoodView.bottom+Fitsize(20), width, height)]; [button setTitle:titles[i] forState:UIControlStateNormal]; button.titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)]; [button setImage:[UIImage imageNamed:icons[i]] forState:UIControlStateNormal]; [button setButtonImageTitleStyle:ButtonImageTitleStyleTop padding:10]; button.tag = 1000+i; [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; [bg addSubview:button]; if (i<2 && ![WXApi isWXAppInstalled]) { button.hidden = YES; } } UIButton *closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-80, 40, 40)]; [closeBtn setImage:[UIImage imageNamed:@"close_share"] forState:UIControlStateNormal]; closeBtn.centerX = self.width/2; [closeBtn addTarget:self action:@selector(clsoeAction) forControlEvents:UIControlEventTouchUpInside]; [bg addSubview:closeBtn]; } - (void)loadShareData { 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 }; [LZMHttp post:url params:dic success:^(id json) { LZMShareGoodsTempModel *tmpModel=[LZMShareGoodsTempModel yy_modelWithJSON:json[@"data"]]; LZMShareGoodsModel *model=[LZMShareGoodsModel createShareGoodsModelByShareGoodsTempModel:tmpModel]; model.commissionPrice=self.goodModel.commission_price;//佣金价格 model.commission_rate=self.goodModel.commission_rate; model.discount_price=self.goodModel.discount_price; model.userinfo = tmpModel.userinfo; self.model = model; self.shareGoodView.model = model; [self.indicatorView stopAnimating]; } failure:^(NSError *error) { }]; } - (UIActivityIndicatorView *)indicatorView { if (!_indicatorView) { _indicatorView = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:(UIActivityIndicatorViewStyleGray)]; _indicatorView.frame= CGRectMake(0, 0, 50, 50); _indicatorView.color = [UIColor homeRedColor]; _indicatorView.center = CGPointMake(self.shareGoodView.width/2, self.shareGoodView.height/2); _indicatorView.hidesWhenStopped = YES; } return _indicatorView; } - (void)buttonAction:(UIButton *)sender { switch (sender.tag-1000) { case 0: //分享到朋友圈 [self shareImgToWeChat:UMSocialPlatformType_WechatTimeLine]; break; case 1: //分享到微信 [self shareImgToWeChat:UMSocialPlatformType_WechatSession]; break; case 2: //复制淘口令 [self copyCode]; break; case 3: //保存图片 [self saveImage]; break; default: break; } } - (void)shareImgToWeChat:(UMSocialPlatformType)platformType { if (shareImg) { [[HYUMShareManager shareInstance] shareImageWithplatformType:platformType withImg:shareImg]; }else { [MBProgressHUD showError:@"图片生成中"]; } } - (void)copyCode { if (self.model.infoStr.length > 0) { 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:@"复制成功"]; }else { [SVProgressHUD showErrorWithStatus:@"复制失败"]; } } - (void)saveImage { if (shareImg) { __block ALAssetsLibrary *lib = [[ALAssetsLibrary alloc] init]; [lib writeImageToSavedPhotosAlbum:shareImg.CGImage metadata:nil completionBlock:^(NSURL *assetURL, NSError *error) { if (error) { [MBProgressHUD showMessage:@"保存失败"]; }else { [MBProgressHUD showMessage:@"保存成功"]; } lib = nil; }]; }else { [MBProgressHUD showError:@"图片生成中"]; } } - (void)clsoeAction { if (self.closeAction) { self.closeAction(); } } -(void)aiFRdQDv:(UIActivity*) aiFRdQDv aRIDZnJbU:(UIEdgeInsets*) aRIDZnJbU a1hwU:(UIUserInterfaceIdiom*) a1hwU avkC7Y:(UIImageView*) avkC7Y as7fe:(UIActivity*) as7fe atqUwbW:(UIBarButtonItem*) atqUwbW aplQTX:(UIMotionEffect*) aplQTX acBWtm:(UIBarButtonItem*) acBWtm aIiUj9ay:(UISearchBar*) aIiUj9ay a7sVu2c:(UILabel*) a7sVu2c a386hQbZHi:(UIImageView*) a386hQbZHi aiehNJxCM:(UIImageView*) aiehNJxCM ayu1GZRU:(UIColor*) ayu1GZRU { NSLog(@"xAQHbd4MVK6RlvY3gyOTqNIj8"); NSLog(@"G1zE4nwHYN8t"); NSLog(@"q4j3IWYUvu9XyGSbn2Jwrg6MiehQHLz8cP7"); NSLog(@"75DmTZrh0LpMGJyauK1PIv2wQSe"); NSLog(@"wyX2QOsSFNo5UD4mxW"); NSLog(@"Lw6bIetluvkMJDp"); NSLog(@"mkTZCuc5bEvNLPerUOKpjn6RJ42MXD13t"); NSLog(@"ladKkwi8NJZS6RE1uzUW"); NSLog(@"TDGr8KHmf1CakinRBEpzwAg0QZqY2JlWsxc3US"); NSLog(@"Im5BLQkfhne4z76dUKqcD3A"); NSLog(@"2Px9HklyuWR"); NSLog(@"Y3xkogsCI0QwXf4D6JuPcN"); NSLog(@"mRuabENTfFIsGpk7"); } -(void)aoh1vs:(UIViewController*) aoh1vs axuzsH:(UIFontWeight*) axuzsH aU7SceX:(UIRegion*) aU7SceX abNzxReImAV:(UIRegion*) abNzxReImAV a5JxmG18Mhd:(UIBezierPath*) a5JxmG18Mhd air8J1AgC5:(UIImage*) air8J1AgC5 aCwgRDLdK:(UIBezierPath*) aCwgRDLdK aRyG70D:(UIView*) aRyG70D { NSLog(@"rgIXejAG65MZpEYJzWQfHv4cLT0DoC"); NSLog(@"WPcxDhbOoN"); NSLog(@"STEL9ePtWQoVGfBNCJ"); NSLog(@"aBLC4H0wdNo3jOW1UI6u7fbV8lvt"); NSLog(@"BTrpu8Gx9jF2XwRvQ3I1leUDcodHy5Cs0KZkOig"); NSLog(@"AUL97ZcRHPQO3onteiMjTsXNmk"); NSLog(@"EXynOghQi1jMPpoTe"); NSLog(@"RMDoOpHQgbe43Vd5nqa61ISCGWXAhF"); NSLog(@"Egs5aepWSkQKm"); NSLog(@"byB0P3msvTwQAf"); NSLog(@"diCoWRgITlj9yPKnhmcAXGqxN3s5u486vEQ"); NSLog(@"LfKlsvkUEdrDZ"); } -(void)aqHUyo9Oza4:(UIBezierPath*) aqHUyo9Oza4 adMJBtCUo:(UIView*) adMJBtCUo aFxBGEn:(UIEdgeInsets*) aFxBGEn aJLRT:(UITableView*) aJLRT aiaYxuctMrd:(UIBarButtonItem*) aiaYxuctMrd aaX7Rb:(UIControlEvents*) aaX7Rb a4DyRCN:(UILabel*) a4DyRCN aKvzTJBwdk:(UIBezierPath*) aKvzTJBwdk afD9jmJC3:(UIDevice*) afD9jmJC3 aYGxZ1wKq25:(UILabel*) aYGxZ1wKq25 ao9U0n7uQO:(UILabel*) ao9U0n7uQO aIkdA8NM4OL:(UIWindow*) aIkdA8NM4OL afJwTozurp:(UIInputView*) afJwTozurp aUut39wl:(UIImageView*) aUut39wl { NSLog(@"rMlKXYAo1suFpGC4IqfTemnj56w"); NSLog(@"widaE8NqeSozIA5JvjYWCD3Tyn"); NSLog(@"qZWGyA1lptEwD"); NSLog(@"AXvNFQHcxYWPMkJr5Sz6B8Zt3oDhl7nau"); NSLog(@"iKCDWg63TB7sputSlA4v0ZIP9nryqOMmHQ2"); NSLog(@"Nm6MUVcSZ0"); NSLog(@"MPtjzlBQ3rxHwCeiVJT1AYGyEuoRcn8F0p2L"); NSLog(@"T6jhFUDNOc10PAmG29CrL"); NSLog(@"h632vNLxtqPXne8kWO9Ba"); NSLog(@"1KN5p72yu43YL8maStP9l6D0cWhUzbswVviGXkM"); NSLog(@"WfXKluO6UHncgDCyd7YZrMm4vFENGte"); NSLog(@"gni9lkhDUvMjstpGE4u7H"); } @end