12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // shareView.m
- // KXYiMa
- //
- // Created by jcymac on 2018/1/24.
- // Copyright © 2018年 jcymac. All rights reserved.
- //
- #import "shareView.h"
- #import "HYUMShareManager.h"
- #import "WXApi.h"
- @interface shareView()
- @property(nonatomic,strong)NSString *title;
- @property(nonatomic,strong)NSString *desc;
- @property(nonatomic,strong)NSString *imageUrl;
- @property(nonatomic,strong)NSString *webUrl;
- @property(nonatomic,strong)UIImage *img;
- @end
- @implementation shareView
- -(void)awakeFromNib{
- [super awakeFromNib];
- [self.shareButtonOne addTarget:self action:@selector(shareOneAction) forControlEvents:UIControlEventTouchUpInside];
- [self.shareButtonTwo addTarget:self action:@selector(shareTwoAction) forControlEvents:UIControlEventTouchUpInside];
- }
- //分享到微信
- -(void)shareOneAction{
- NSLog(@"shareOneAction");
- if (![WXApi isWXAppInstalled]) {
- [MBProgressHUD showMessage:@"没有安装微信客户端"];
- if (self.shareButtonOneBlock) {
- self.shareButtonOneBlock();
- }
- return;
- }
- if (self.shareType==ShareTypeUrl) {
- [[HYUMShareManager shareInstance] shareWebPagewithplatformType:UMSocialPlatformType_WechatSession title:self.title desc:self.desc thumImageUrl:self.imageUrl webpageUrl:self.webUrl];
- }else if(self.shareType==ShareTypeImage){
- if (self.imgUrl.length > 0) {
- [MobClick event:InvateImageWeiXin label:self.imgUrl];
- }
- [[HYUMShareManager shareInstance] shareImageWithplatformType:UMSocialPlatformType_WechatSession withImg:self.img];
- }
-
- if (self.shareButtonOneBlock) {
- self.shareButtonOneBlock();
- }
-
-
-
- }
- //分享到朋友圈
- -(void)shareTwoAction{
- NSLog(@"shareTwoAction");
- if (![WXApi isWXAppInstalled]) {
- [MBProgressHUD showMessage:@"没有安装微信客户端"];
- if (self.shareButtonTwoBlock) {
- self.shareButtonTwoBlock();
- }
- return;
- }
- if (self.shareType==ShareTypeUrl) {
- [[HYUMShareManager shareInstance] shareWebPagewithplatformType:UMSocialPlatformType_WechatTimeLine title:self.title desc:self.desc thumImageUrl:self.imageUrl webpageUrl:self.webUrl];
- }else if(self.shareType==ShareTypeImage){
- if (self.imgUrl.length > 0) {
- [MobClick event:InvateImageWeiXinCircle label:self.imgUrl];
- }
- [[HYUMShareManager shareInstance] shareImageWithplatformType:UMSocialPlatformType_WechatTimeLine withImg:self.img];
- }
- if (self.shareButtonTwoBlock) {
- self.shareButtonTwoBlock();
- }
- }
- -(void)shareWeChatTitle:(NSString *)title desc:(NSString *)desc imageUrl:(NSString *)imageUrl webUrl:(NSString *)webUrl{
- self.shareType=ShareTypeUrl;
- _title=title;
- _desc=desc;
- _imageUrl=imageUrl;
- _webUrl=webUrl;
- }
- -(void)shareImage:(UIImage *)img{
- self.shareType=ShareTypeImage;
- _img=img;
-
- }
- @end
|