123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486 |
- //
- // JXShareMoneyVc.m
- // shiku_im
- //
- // Created by 123 on 2020/5/20.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXShareMoneyVc.h"
- #import "JXShareMCell.h"
- #import "UMSocialSnsService.h"
- #import "UMSocialSnsPlatformManager.h"
- #import "UMSocial.h"
- #import "MyButton.h"
- //#import <TencentOpenAPI/TencentOAuth.h>
- //#import "TencentOpenAPI/QQApiInterface.h"
- @interface JXShareMoneyVc ()<UITableViewDataSource,UITableViewDelegate,UMSocialUIDelegate>
- @property (nonatomic,weak) UIButton *showBt;
- @property (nonatomic,weak) UIButton *yaoqingmaBtn;
- @property (nonatomic,weak) UITableView *tableView;
- @property (nonatomic,strong) NSMutableArray *dataArr;
- @end
- @implementation JXShareMoneyVc
-
- - (void)gobackBtn{
- //[self.navigationController popViewControllerAnimated:YES];
- [g_navigation dismissViewController:self animated:YES];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor=[UIColor whiteColor];
-
- _dataArr=[NSMutableArray arrayWithObjects:@"1、扫下放二维码下载“即信”APP",@"2、选择您喜爱的快捷方式登录。(首次登录ID号随便填写,注册平台 账号后再修改绑定)",@"3、选择“购彩”界面,选择“我的账户”——“立即注册”——输入下 方邀请码——根据提示注册您购彩账号",@"4、选择“聊天”界面选择“我”——“我的设置”——“账户与安全” ——将ID号修改为与购彩账号一致",@"5、成功开始体验即信购彩赚钱乐趣!", nil];
- UIImageView *backIMG = [[UIImageView alloc]init];
- backIMG.image=[UIImage imageNamed:@"BG111"];
- backIMG.userInteractionEnabled=YES;
- backIMG.frame=self.view.bounds;
- [self.view addSubview:backIMG];
-
- [self defineNavBar:@"分享赚钱" andRinghtBtnImg:@"1"];
- /*
- //头像icon
- UIImageView *iconIMG = [[UIImageView alloc]init];
- iconIMG.image=[UIImage imageNamed:@"ALOGO_120"];
- [backIMG addSubview:iconIMG];
- [iconIMG mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(JX_SCREEN_TOP);
- make.centerX.mas_equalTo(backIMG.mas_centerX);
- make.width.mas_equalTo(40);
- make.height.mas_equalTo(40);
- }];
-
- UILabel *centLabel=[[UILabel alloc]init];
- centLabel.font=[UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
- centLabel.text=@"即信";
- centLabel.textColor=kRGBColor(222, 29, 19);
- [backIMG addSubview:centLabel];
- [centLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(iconIMG.mas_bottom).mas_offset(15);
- make.centerX.mas_equalTo(iconIMG.mas_centerX);
- }];
-
- UIImageView *leftIMG = [[UIImageView alloc]init];
- leftIMG.image=[UIImage imageNamed:@"xiantiao2"];
- [backIMG addSubview:leftIMG];
- [leftIMG mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(centLabel.mas_left).mas_offset(-10);
- make.centerY.mas_equalTo(centLabel.mas_centerY);
- }];
-
-
- UIImageView *rightIMG = [[UIImageView alloc]init];
- rightIMG.image=[UIImage imageNamed:@"xiantiao1"];
- [backIMG addSubview:rightIMG];
- [rightIMG mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.mas_equalTo(centLabel.mas_right).mas_offset(10);
- make.centerY.mas_equalTo(centLabel.mas_centerY);
- }];
- */
- //搜索框
- UIButton *searchBtn = [[UIButton alloc]init];
- [searchBtn setBackgroundImage:[UIImage imageNamed:@"sousuo"] forState:UIControlStateNormal];
- [backIMG addSubview:searchBtn];
- [searchBtn addTarget:self action:@selector(saveBttIMG:) forControlEvents:UIControlEventTouchUpInside];
- [searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(backIMG.mas_top).mas_offset(JX_SCREEN_TOP+10);
- make.centerX.mas_equalTo(self.view.mas_centerX);
- }];
-
- UIImageView *iconIMG = [[UIImageView alloc]init];
- iconIMG.image=[UIImage imageNamed:@"ALOGO_120"];
- [backIMG addSubview:iconIMG];
- [iconIMG mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(searchBtn.mas_right).mas_offset(10);
- make.centerY.mas_equalTo(searchBtn.mas_centerY);
- make.width.mas_equalTo(20);
- make.height.mas_equalTo(20);
- }];
-
- UIButton *chaBtn = [[UIButton alloc]init];
- [chaBtn setImage:[UIImage imageNamed:@"chaz"] forState:UIControlStateNormal];
- [searchBtn addSubview:chaBtn];
- [chaBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(10);
- make.height.mas_equalTo(searchBtn.mas_height);
- }];
-
- UILabel *titleURL=[[UILabel alloc]init];
- titleURL.font=[UIFont systemFontOfSize:11 weight:UIFontWeightRegular];
- titleURL.textColor=kRGBColor(222, 29, 19);
- titleURL.numberOfLines=0;
- titleURL.text=@"www.7520vip.com";
- titleURL.textAlignment=NSTextAlignmentCenter;
- [searchBtn addSubview:titleURL];
- [titleURL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.centerX.mas_equalTo(self.view.mas_centerX);
- make.height.mas_equalTo(searchBtn.mas_height);
- }];
-
-
-
- // UILabel *titleL=[[UILabel alloc]init];
- // titleL.font=[UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
- // titleL.textColor=kRGBColor(51, 51, 51);
- // titleL.numberOfLines=0;
- // titleL.text=@"";
- // [backIMG addSubview:titleL];
- // [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.top.mas_equalTo(searchBtn.mas_bottom).mas_offset(10);
- // make.left.mas_equalTo(30);
- // make.right.mas_equalTo(-30);
- // }];
-
- UITableView *tableView=[[UITableView alloc]init];
- tableView.backgroundColor=[UIColor clearColor];
- tableView.dataSource=self;
- tableView.delegate=self;
- //tableView.estimatedRowHeight=100;
- tableView.separatorStyle=UITableViewCellSelectionStyleNone;
- [backIMG addSubview:tableView];
- tableView.tableFooterView=[UIView new];
- self.tableView=tableView;
- [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(searchBtn.mas_bottom).mas_offset(10);
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-10);
- make.height.mas_equalTo(200);
- }];
- //二维码
- /**
- UIImageView *imageV=[[UIImageView alloc]initWithFrame:CGRectMake(222, 222, 222, 222)];
- [self.view addSubview:imageV];
- */
- UIButton *showBt = [[UIButton alloc]init];
- [showBt setImage:[UIImage imageNamed:@"signBackImage"] forState:UIControlStateNormal];
- [backIMG addSubview:showBt];
- self.showBt=showBt;
- [showBt addTarget:self action:@selector(saveBttIMG:) forControlEvents:UIControlEventTouchUpInside];
- [showBt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(tableView.mas_bottom).mas_offset(10);
- make.centerX.mas_equalTo(backIMG.mas_centerX);
- make.width.mas_equalTo(150);
- make.height.mas_equalTo(150);
- }];
-
- UIButton *yaoqBtn = [[UIButton alloc]init];
- [yaoqBtn setTitle:@"邀请码:4578912" forState:UIControlStateNormal];
- yaoqBtn.layer.cornerRadius=18;
- yaoqBtn.layer.masksToBounds=YES;
- yaoqBtn.backgroundColor=[UIColor redColor];
- [backIMG addSubview:yaoqBtn];
- self.yaoqingmaBtn=yaoqBtn;
- [yaoqBtn addTarget:self action:@selector(saveBttIMG:) forControlEvents:UIControlEventTouchUpInside];
- [yaoqBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(showBt.mas_bottom).mas_offset(10);
- make.centerX.mas_equalTo(showBt.mas_centerX);
- make.width.mas_equalTo(200);
- make.height.mas_equalTo(36);
- }];
-
- UIButton *qCoerBtn = [[UIButton alloc]init];
- [qCoerBtn setImage:[UIImage imageNamed:@"mageshouji"] forState:UIControlStateNormal];
- [backIMG addSubview:qCoerBtn];
- [qCoerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(yaoqBtn.mas_bottom).mas_offset(10);
- make.centerX.mas_equalTo(showBt.mas_centerX);
- make.width.mas_equalTo(162);
- make.height.mas_equalTo(138);
- }];
-
-
- UIView *btView = [[UIView alloc]init];
- btView.backgroundColor=[UIColor whiteColor];
- btView.userInteractionEnabled=YES;
- [backIMG addSubview:btView];
- [btView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(-10);
- make.left.mas_equalTo(20);
- make.right.mas_equalTo(-20);
- make.height.mas_equalTo(JX_SCREEN_BOTTOM+15);
- }];
-
- NSArray *imageS=@[@"circle_of_friends_icon",@"weixin_logo",@"编组2",@"tabbar22"];
- NSArray *titleS=@[@"微信朋友圈",@"微信好友",@"QQ好友",@"保存图片"];
- for (int i=0; i<4; i++) {
- MyButton *bottomBtn = [[MyButton alloc]init];
- //bottomBtn.backgroundColor=kRGBColor246;
- bottomBtn.tag=i;
- [bottomBtn setTitleColor:kRGBColor(222, 29, 19) forState:UIControlStateNormal];
- [bottomBtn setImage:[UIImage imageNamed:imageS[i]] forState:UIControlStateNormal];
- [bottomBtn setTitle:titleS[i] forState:UIControlStateNormal];
- [bottomBtn addTarget:self action:@selector(saveBttIMG1:) forControlEvents:UIControlEventTouchUpInside];
- [btView addSubview:bottomBtn];
- [bottomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(i*((JX_SCREEN_WIDTH-40)/4));
- make.width.mas_equalTo((JX_SCREEN_WIDTH-40)/4);
- make.height.mas_equalTo(btView.mas_height);
- }];
-
-
- }
-
-
- [SVProgressHUD show];
- [g_server getAppResource:@"6" ToView:self];
-
- long time = (long)[[NSDate date] timeIntervalSince1970];
- time = (time *1000 + g_server.timeDifference);
- NSString *salt = [NSString stringWithFormat:@"%ld", time];
-
- [g_server getact_getinviteget:salt andUserId:g_server.myself.userId andToView:self];
- [tableView reloadData];
- }
-
- -(CGSize)titleBtnWight:(NSString *)titBtnW and:(UIFont *)titBtn {
- CGSize titleSize = [titBtnW boundingRectWithSize:CGSizeMake(JX_SCREEN_WIDTH-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:titBtn} context:nil].size;
-
- return titleSize;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- NSString *titleStr =_dataArr[indexPath.row];
- CGFloat titleH=[self titleBtnWight:titleStr and:[UIFont systemFontOfSize:14 weight:UIFontWeightRegular]].height;
-
- return titleH+6;;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return _dataArr.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- JXShareMCell *cell = [JXShareMCell cellWithTableView:tableView];
- cell.backgroundColor=[UIColor clearColor];
- NSString *titleStr =_dataArr[indexPath.row];
- cell.strURL=titleStr;
- return cell;
-
- }
- #pragma mark --- 请求成功
- -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
- [SVProgressHUD dismiss];
-
- //NSLog(@"dict: %@ --- arry: %@",dict ,array1 );
- if([aDownload.action isEqualToString:act_getAppResource]){
- NSDictionary *dict=[array1 firstObject];
- NSString *string=dict[@"link"];
- //创建过滤器
- CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
- //过滤器恢复默认
- [filter setDefaults];
- //给过滤器添加数据<字符串长度893>
- NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
- [filter setValue:data forKey:@"inputMessage"];
- //获取二维码过滤器生成二维码
- CIImage *image = [filter outputImage];
- UIImage *img = [self createNonInterpolatedUIImageFromCIImage:image WithSize:140];
- [self.showBt setImage:img forState:UIControlStateNormal];
-
- }
- else if([aDownload.action isEqualToString:act_getinviteget])
- {
- NSDictionary *dictM=dict;
- NSString *str=[NSString stringWithFormat:@"邀请码:%@",dictM[@"invite"]];
- [self.yaoqingmaBtn setTitle:str forState:UIControlStateNormal];
-
- }
-
-
-
-
- }
-
- -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
- [SVProgressHUD dismiss];
- NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]];
- if([errorCode isEqualToString:@"权限验证失败"])
- {
- if ([aDownload.action isEqualToString:act_GetBalanceRedTimes])
- {
-
- }else{
-
- }
- }
-
- return [errorCode intValue];
- }
- //分享
- - (void)saveBttIMG1:(UIButton *)sender{
- if (sender.tag==0) {
- [self shareAction:
- @[UMShareToWechatTimeline] pathUrl:@"https://apps.apple.com/cn/app/%E8%81%8A%E5%95%B5-%E4%B8%8E%E6%9C%8B%E5%8F%8B%E4%B8%80%E8%B5%B7%E7%95%85%E8%81%8A/id1463401862" ];
-
- } if (sender.tag==1) {
- [self shareAction:
- @[UMShareToWechatSession] pathUrl:@"https://apps.apple.com/cn/app/%E8%81%8A%E5%95%B5-%E4%B8%8E%E6%9C%8B%E5%8F%8B%E4%B8%80%E8%B5%B7%E7%95%85%E8%81%8A/id1463401862" ];
-
- } if (sender.tag==2) {
-
- NSString *musicPath1=@"https://apps.apple.com/cn/app/%E8%81%8A%E5%95%B5-%E4%B8%8E%E6%9C%8B%E5%8F%8B%E4%B8%80%E8%B5%B7%E7%95%85%E8%81%8A/id1463401862";
- NSString *yaoqingM =self.yaoqingmaBtn.titleLabel.text;
- NSString *dicript = [NSString stringWithFormat:@"您的邀请码是:%@%@",yaoqingM,@" 即信—安全稳定的赚钱平台 \n给你推荐一款可以赚钱的APP。我今天又收入了999元,现在还有3个名额,快进来下载一起赚钱吧!"];
- UIImage *shareImage = [UIImage imageNamed:@"ALOGO_120"];
- NSURL *url = [NSURL fileURLWithPath:musicPath1];
- NSArray * activityItems = @[dicript,shareImage,url];
-
- UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
- //去除一些不需要的图标选项
- activityVC.excludedActivityTypes = @[UIActivityTypePostToFacebook, UIActivityTypeAirDrop, UIActivityTypePostToWeibo, UIActivityTypePostToTencentWeibo];
-
- //成功失败的回调block
- UIActivityViewControllerCompletionWithItemsHandler myBlock = ^(UIActivityType __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError) {
-
- if (completed){
- }else{
- }
- };
- activityVC.completionWithItemsHandler = myBlock;
-
- [self presentViewController:activityVC animated:YES completion:nil];
- }
- if (sender.tag==3) {
- UIImage *saveIMG = [self captureImageFromView:self.view];
- UIImageWriteToSavedPhotosAlbum(saveIMG, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
-
- }
-
- }
- - (void)saveBttIMG:(UIButton *)showBt{
-
- UIImage *saveIMG = [self captureImageFromView:self.view];
- UIImageWriteToSavedPhotosAlbum(saveIMG, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
- }
- -(UIImage *)captureImageFromView:(UIView *)view{
-
- UIGraphicsBeginImageContextWithOptions(self.view.frame.size,NO, 0);
-
- [[UIColor clearColor] setFill];
-
- [[UIBezierPath bezierPathWithRect:self.view.bounds] fill];
-
- CGContextRef ctx = UIGraphicsGetCurrentContext();
-
- [self.view.layer renderInContext:ctx];
-
- UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
-
- UIGraphicsEndImageContext();
-
- return image;
-
- }
-
-
- //下面得到分享完成的回调
- -(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
- {
- NSLog(@"didFinishGetUMSocialDataInViewController with response is %@",response);
- //根据`responseCode`得到发送结果,如果分享成功
- if(response.responseCode == UMSResponseCodeSuccess)
- {
- //得到分享到的微博平台名
- NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
- }
- }
- - (void)shareAction:(NSArray *)type pathUrl:(NSString *)musicPath {
-
- //[self shareAction: @[ UMShareToQzone,UMShareToQQ,UMShareToTencent] pathUrl: ];
- musicPath=@"https://apps.apple.com/cn/app/%E8%81%8A%E5%95%B5-%E4%B8%8E%E6%9C%8B%E5%8F%8B%E4%B8%80%E8%B5%B7%E7%95%85%E8%81%8A/id1463401862";
- NSString *yaoqingM =self.yaoqingmaBtn.titleLabel.text;
- NSString *dicript = [NSString stringWithFormat:@"您的邀请码是:%@%@",yaoqingM,@" 即信—安全稳定的赚钱平台 \n给你推荐一款可以赚钱的APP。我今天又收入了999元,现在还有3个名额,快进来下载一起赚钱吧!"];
- UIImage *shareImage = [UIImage imageNamed:@"ALOGO_120"];
- NSURL *url = [NSURL fileURLWithPath:musicPath];
- NSArray * activityItems = @[dicript,musicPath];
-
- UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
- //去除一些不需要的图标选项
- activityVC.excludedActivityTypes = @[UIActivityTypePostToFacebook, UIActivityTypeAirDrop, UIActivityTypePostToWeibo, UIActivityTypePostToTencentWeibo];
-
- //成功失败的回调block
- UIActivityViewControllerCompletionWithItemsHandler myBlock = ^(UIActivityType __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError) {
-
- if (completed){
- }else{
- }
- };
- activityVC.completionWithItemsHandler = myBlock;
-
- [self presentViewController:activityVC animated:YES completion:nil];
-
- return;
- NSString *shareText = dicript; //分享内嵌文字
-
- [UMSocialSnsService presentSnsIconSheetView:self appKey:@"5edaacbe978eea085d11d331" shareText:shareText shareImage:shareImage shareToSnsNames:type delegate:self];
-
-
- return;
-
-
- }
-
- - (UIImage *)createNonInterpolatedUIImageFromCIImage:(CIImage *)image WithSize:(CGFloat)size
- {
- CGRect extent = CGRectIntegral(image.extent);
- CGFloat scale = MIN(size/CGRectGetWidth(extent), size/CGRectGetHeight(extent));
-
- //创建bitmap
- size_t width = CGRectGetWidth(extent)*scale;
- size_t height = CGRectGetHeight(extent)*scale;
- CGColorSpaceRef cs = CGColorSpaceCreateDeviceGray();
- CGContextRef bitmapRef = CGBitmapContextCreate(nil, width, height, 8, 0, cs, (CGBitmapInfo)kCGImageAlphaNone);
- CIContext *context = [CIContext contextWithOptions:nil];
- CGImageRef bitmapImage = [context createCGImage:image fromRect:extent];
- CGContextSetInterpolationQuality(bitmapRef, kCGInterpolationNone);
- CGContextScaleCTM(bitmapRef, scale, scale);
- CGContextDrawImage(bitmapRef, extent, bitmapImage);
-
- //保存图片
- CGImageRef scaledImage = CGBitmapContextCreateImage(bitmapRef);
- CGContextRelease(bitmapRef);
- CGImageRelease(bitmapImage);
- return [UIImage imageWithCGImage:scaledImage];
- }
- #pragma mark -- <保存到相册>
- -(void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
- NSString *msg = nil ;
- if(error){
- msg = @"保存图片失败" ;
- }else{
- msg = @"保存图片成功" ;
- }
- }
- /*
- #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.
- }
- */
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
- [self.view endEditing:YES];
- }
- @end
|