重庆迈尖科技有限公司
2019-01-30 94217b294ccd75a34787eb04d6e273e99536e45b
BuWanVideo2.0/LeftViewController.m
@@ -20,7 +20,9 @@
#import "UIButton+YYWebImage.h"
#import "LoggingViewController.h"
#import "Personal_informationViewController.h"
@interface LeftViewController ()<UITableViewDelegate,UITableViewDataSource>{
#import <SafariServices/SafariServices.h>
@interface LeftViewController ()<UITableViewDelegate,UITableViewDataSource,HXEasyCustomShareViewDelegate>{
    NSArray *_iconArr;
    NSArray *_dataArr;
    
@@ -30,6 +32,7 @@
@property (weak, nonatomic) IBOutlet UIButton *LeftImageIcon;//侧滑栏的头像
@property (weak, nonatomic) IBOutlet UIButton *LeftLoginBtn;//立即登录
@property (weak, nonatomic) IBOutlet UIImageView *headerImageview;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *MarkToMain;//这个的值为宽度的四分之一
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *LeftbackgroundH;//根据图片比例设置高
@@ -59,8 +62,8 @@
    self.MarkToMain.constant=0;
    self.LeftbackgroundH.constant=141;
    //头像绘圆
    self.LeftImageIcon.layer.cornerRadius=self.LeftImageIcon.frame.size.height/2;
    self.LeftImageIcon.layer.masksToBounds= YES;
    self.headerImageview.layer.cornerRadius=self.headerImageview.frame.size.height/2;
    self.headerImageview.layer.masksToBounds= YES;
    //tabelView的配置
    _LeftTableView.delegate=self;
    _LeftTableView.dataSource=self;
@@ -127,10 +130,10 @@
 */
-(void)creatData{
    if (!_iconArr) {
        _iconArr=[NSArray arrayWithObjects:@"我的收藏",@"观看记录",@"我的关注",@"我的消息",@"分享出去",@"帮助和反馈",@"设置", nil];
        _iconArr=[NSArray arrayWithObjects:@"我的收藏",@"观看记录",@"我的关注",@"我的消息",@"分享出去",@"帮助和反馈",@"隐私政策",@"设置", nil];
    }
    if (!_dataArr) {
        _dataArr=[NSArray arrayWithObjects:@"我的收藏",@"观看记录",@"我的关注",@"我的消息",@"分享软件",@"帮助与反馈",@"设置", nil];
        _dataArr=[NSArray arrayWithObjects:@"我的收藏",@"观看记录",@"我的关注",@"我的消息",@"分享软件",@"帮助与反馈",@"隐私政策",@"设置", nil];
    }
}
/**
@@ -146,6 +149,7 @@
        [self.navigationController pushViewController:Personal_informationVC animated:YES];
    }else{//跳入登录界面
        LoggingViewController *loginVC=[[LoggingViewController alloc] init];
        loginVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:loginVC animated:YES];
    }
    [self.slideMenuController closeLeft];
@@ -161,9 +165,21 @@
    
    switch (indexPath.row) {
        case 0:{
            CollectionController * cc = [CollectionController new];
            [cc setHidesBottomBarWhenPushed:YES];
            [self.navigationController pushViewController:cc animated:YES];
//            if([[NSUserDefaults standardUserDefaults] boolForKey:@"userOnLine"]){
//
                CollectionController * cc = [CollectionController new];
                [cc setHidesBottomBarWhenPushed:YES];
                [self.navigationController pushViewController:cc animated:YES];
//
//            }else{
                //未登录,引导用户登录
//                LoggingViewController *loginVC=[[LoggingViewController alloc] init];
//                loginVC.ispresent=YES;
//                [self presentViewController:loginVC animated:YES completion:^{
//
//                }];
//            }
        }
            break;
        case 1:{
@@ -198,7 +214,7 @@
        }
            break;
        case 4:{//分享
            [Share shareAPP:self.navigationController];
            [self shareAPP];
        }
            break;
//        case 5:{//发布东西
@@ -213,7 +229,25 @@
            [self.navigationController pushViewController:Help animated:YES];
        }
            break;
        case 6:{
            NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/api_control_ios.jsp",iconImageUrl]];
            SFSafariViewController *safariVC = [[SFSafariViewController alloc] initWithURL:url];
//            safariVC.delegate = self;
            //    self.navigationController.navigationBarHidden = YES;
            //    [self.navigationController pushViewController:safariVC animated:YES];
//            safariVC.title= @"隐私政策";
//            safariVC.hidesBottomBarWhenPushed = YES;
            // 建议
//            [self.navigationController pushViewController:safariVC animated:YES];
            [self presentViewController:safariVC animated:YES completion:nil];
        }
        break;
        case 7:{
            //设置
            SettingController * setting = [SettingController new];
            [setting setHidesBottomBarWhenPushed:YES];
@@ -244,14 +278,13 @@
    _userOnLine= [[NSUserDefaults standardUserDefaults] boolForKey:@"userOnLine"];
    
    if(_userOnLine){//如果当前状态是登录状态
        [self.LeftImageIcon setContentMode:UIViewContentModeScaleAspectFill];
        [self.LeftImageIcon yy_setImageWithURL:[[NSUserDefaults standardUserDefaults] objectForKey:@"iconURL"]
                                      forState:UIControlStateNormal
                                   placeholder:[UIImage imageNamed:@"用户默认"]];
        [self.headerImageview setYthImageWithURL:[[NSUserDefaults standardUserDefaults] objectForKey:@"iconURL"] placeholderImage:[UIImage imageNamed:@"用户默认"]];
        [self.LeftLoginBtn setTitle:[[NSUserDefaults standardUserDefaults] objectForKey:@"QQUserName"] forState:UIControlStateNormal];
        
    }else{//当前状态为未登录状态
        [self.LeftImageIcon setImage:[UIImage imageNamed:@"用户默认"] forState:UIControlStateNormal];
        self.headerImageview.image = [UIImage imageNamed:@"用户默认"] ;
        [self.LeftLoginBtn setTitle:@"立即登录" forState:UIControlStateNormal];
    }
}
@@ -279,6 +312,99 @@
    return cell;
}
- (void)shareAPP{//分享响应 标题  内容  分享链接
    NSMutableArray *shareAry=[NSMutableArray array];
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"mqq://"]]) {
        NSArray *QQArr=@[@{@"image":@"newqq",@"title":@"QQ"},@{@"image":@"newqq空间",@"title":@"QQ空间"}];
        [shareAry addObjectsFromArray:QQArr];
    }
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"weixin://"]]){
        NSArray *WXArr=@[@{@"image":@"new微信",@"title":@"微信"},@{@"image":@"new朋友圈",@"title":@"朋友圈"}];
        [shareAry addObjectsFromArray:WXArr];
    }
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"sinaweibo://"]]){
        NSArray *XLArr=@[@{@"image":@"new微博",@"title":@"新浪微博"}];
        [shareAry addObjectsFromArray:XLArr];
    }
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenW, 54)];
    headerView.backgroundColor = [UIColor clearColor];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, headerView.frame.size.width, 15)];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor blackColor];
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont systemFontOfSize:15];
    label.text = @"分享到";
    [headerView addSubview:label];
    UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, headerView.frame.size.height-0.5, headerView.frame.size.width, 0.5)];
    lineLabel.backgroundColor = [UIColor colorWithRed:208/255.0 green:208/255.0 blue:208/255.0 alpha:1.0];
    [headerView addSubview:lineLabel];
    UILabel *lineLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, headerView.frame.size.width, 0.5)];
    lineLabel1.backgroundColor = [UIColor colorWithRed:208/255.0 green:208/255.0 blue:208/255.0 alpha:1.0];
    HXEasyCustomShareView *shareView = [[HXEasyCustomShareView alloc] initWithFrame:CGRectMake(0, 0, KScreenW, KScreenH)];
    shareView.backView.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    shareView.headerView = headerView;
    float height = [shareView getBoderViewHeight:shareAry firstCount:0];
    shareView.boderView.frame = CGRectMake(0, 0, shareView.frame.size.width, height);
    shareView.middleLineLabel.hidden = YES;
    [shareView.cancleButton addSubview:lineLabel1];
    shareView.cancleButton.frame = CGRectMake(shareView.cancleButton.frame.origin.x, shareView.cancleButton.frame.origin.y, shareView.cancleButton.frame.size.width, 54);
    shareView.cancleButton.titleLabel.font = [UIFont systemFontOfSize:16];
    [shareView.cancleButton setTitleColor:[UIColor colorWithRed:184/255.0 green:184/255.0 blue:184/255.0 alpha:1.0] forState:UIControlStateNormal];
    [shareView setShareAry:shareAry delegate:self];
    [self.view addSubview:shareView];
}
#pragma mark -HXEasyCustomShareViewDelegate
- (void)easyCustomShareViewButtonAction:(HXEasyCustomShareView *)shareView title:(NSString *)title {
    if ([title isEqualToString:@"微信"]) {
        [self shareWebPageToPlatformType:UMSocialPlatformType_WechatSession];
    }else if ([title isEqualToString:@"朋友圈"]) {
        [self shareWebPageToPlatformType:UMSocialPlatformType_WechatTimeLine];
    }else if ([title isEqualToString:@"QQ"]) {
        [self shareWebPageToPlatformType:UMSocialPlatformType_QQ];
    }else if ([title isEqualToString:@"新浪微博"]) {
        [self shareWebPageToPlatformType:UMSocialPlatformType_Sina];
    }else if ([title isEqualToString:@"QQ空间"]) {
        [self shareWebPageToPlatformType:UMSocialPlatformType_Qzone];
    }else{
        //到这里就错了
    }
    [shareView tappedCancel];
}
/**
 分享
 */
- (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType{
    //创建分享消息对象
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    //创建网页内容对象
    UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@"布丸影视大全" descr:[NSString stringWithFormat:@"%@!%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"ShareContent"],[[NSUserDefaults standardUserDefaults] objectForKey:@"ShareUrl"]] thumImage:[UIImage imageNamed:@"分享图标"]];
    NSLog(@"%@---%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"ShareContent"],[[NSUserDefaults standardUserDefaults] objectForKey:@"ShareUrl"]);
    //设置网页地址
    shareObject.webpageUrl =[[NSUserDefaults standardUserDefaults] objectForKey:@"ShareUrl"];
    NSLog(@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"ShareUrl"]);
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;
    NSLog(@"%@",shareObject);
    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
        if (error) {
            [SVProgressHUD showErrorWithStatus:@"分享失败!"];
            NSLog(@"************Share fail with error %@*********",error);
        }else{
            NSLog(@"response data is %@",data);
        }
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.