241 lines
8.3 KiB
Objective-C
241 lines
8.3 KiB
Objective-C
//
|
|
// LoveFishLiveListBaseViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 17/3/29.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "LoveFishLiveListBaseViewController.h"
|
|
#import "WMPageController.h"
|
|
#import "IfishLiveNewListViewController.h"
|
|
#import "IfishLivePopularListViewController.h"
|
|
#import "IfishLiveRecommendListViewController.h"
|
|
#import "IfishP2PLivePlayViewController.h"
|
|
#import "KanHuListModel.h"
|
|
#import "PushMasssageWebViewController.h"
|
|
#import "MBProgressHUD.h"
|
|
#import "MineKankanEditViewController.h"
|
|
#import <AlibcTradeSDK/AlibcTradeSDK.h>
|
|
#import "IfishAlibcWebViewController.h"
|
|
@interface LoveFishLiveListBaseViewController ()<MBProgressHUDDelegate>
|
|
@property(nonatomic,strong) MBProgressHUD *progressHud;
|
|
@property(nonatomic,strong) WMPageController *pageController;
|
|
@property(nonatomic,strong) IfishP2PLivePlayViewController *shareVideoVC;
|
|
@end
|
|
|
|
@implementation LoveFishLiveListBaseViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
[self addTitleViewWithTitle:@"爱鱼看看"];
|
|
[self initNavItems];
|
|
[self addPageVC];
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(childlistViewslectIndex:) name:@"childlistViewDidselect" object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(adViewTap:) name:@"childlistViewDidselectadView" object:nil];
|
|
}
|
|
-(void)dealloc{
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"childlistViewDidselect" object:nil];
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"childlistViewDidselectadView" object:nil];
|
|
|
|
}
|
|
|
|
-(void)viewWillAppear:(BOOL)animated{
|
|
[super viewWillAppear:animated];
|
|
//看看在tab栏中 隐藏返回按钮
|
|
NSArray *Arr = self.navigationController.viewControllers;
|
|
if (Arr) {
|
|
if (Arr.count ==1) {
|
|
|
|
self.bakbutton.hidden = YES;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-(void)initNavItems{
|
|
|
|
self.rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
self.rightButton.frame = CGRectMake(0, 0, 60, 44);
|
|
[self.rightButton setImage:[UIImage imageNamed:@"live_navicon_look"] forState:UIControlStateNormal];
|
|
|
|
[self.rightButton setImageEdgeInsets:UIEdgeInsetsMake(0, 30, 0, 0)];
|
|
[self.rightButton addTarget:self action:@selector(rightButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
UIBarButtonItem *rightItem =[[UIBarButtonItem alloc] init];
|
|
rightItem.customView =self.rightButton;
|
|
self.navigationItem.rightBarButtonItem = rightItem;
|
|
|
|
|
|
}
|
|
|
|
-(void)addPageVC
|
|
{
|
|
WMPageController *pageController = [self p_defaultController];
|
|
pageController.menuViewStyle = WMMenuViewStyleLine;
|
|
pageController.titleSizeSelected = 15;
|
|
pageController.selectIndex = 0;
|
|
//pageController.menuViewBottomSpace = 10;
|
|
[self addChildViewController: pageController];
|
|
CGFloat height = [UIApplication sharedApplication].statusBarFrame.size.height + 44;
|
|
//看看在tab中时
|
|
pageController.viewFrame = CGRectMake(0,height,self.view.frame.size.width, self.view.frame.size.height - height) ;
|
|
self.pageController = pageController;
|
|
[self.view addSubview: pageController.view];
|
|
|
|
}
|
|
|
|
- (WMPageController *)p_defaultController {
|
|
NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
|
|
NSMutableArray *titles = [[NSMutableArray alloc] init];
|
|
for (int i = 0; i < 3; i++) {
|
|
Class vcClass;
|
|
NSString *title;
|
|
switch (i % 3) {
|
|
case 0:
|
|
vcClass = [IfishLiveNewListViewController class];
|
|
|
|
title = @"最新";
|
|
break;
|
|
case 1:
|
|
vcClass = [IfishLivePopularListViewController class];
|
|
title = @"人气";
|
|
break;
|
|
default:
|
|
vcClass = [IfishLiveRecommendListViewController class];
|
|
title = @"推荐";
|
|
break;
|
|
}
|
|
[viewControllers addObject:vcClass];
|
|
[titles addObject:title];
|
|
}
|
|
WMPageController *pageVC = [[WMPageController alloc] initWithViewControllerClasses:viewControllers andTheirTitles:titles];
|
|
pageVC.menuItemWidth = 85;
|
|
pageVC.postNotification = YES;
|
|
pageVC.bounces = YES;
|
|
|
|
return pageVC;
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
#pragma mark - adviewTap
|
|
|
|
-(void)adViewTap:(NSNotification *)noti{
|
|
|
|
NSString *pushlink = [noti object];
|
|
//字条串是否包含有某字符串
|
|
if ([pushlink rangeOfString:@"taobao"].location == NSNotFound) {
|
|
self.hidesBottomBarWhenPushed = YES;
|
|
PushMasssageWebViewController*webVC=[[PushMasssageWebViewController alloc]init];
|
|
webVC.pushlink =pushlink;
|
|
webVC.pushtitle = @"详情";
|
|
[self.navigationController pushViewController:webVC animated:YES];
|
|
//在tab栏时 返回要显示
|
|
self.hidesBottomBarWhenPushed = NO;
|
|
} else {
|
|
|
|
[self openAliBCWithLink:pushlink];
|
|
}
|
|
|
|
}
|
|
|
|
-(void)openAliBCWithLink:(NSString *)linkUrl{
|
|
|
|
//535991514644
|
|
//根据商品ID
|
|
//id<AlibcTradePage> page = [AlibcTradePageFactory itemDetailPage: @"535991514644"];
|
|
//根据链接打开页面
|
|
id<AlibcTradePage> page = [AlibcTradePageFactory page:linkUrl];
|
|
AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
|
|
//app 内闭环交易 强制H5 打开
|
|
showParam.openType = AlibcOpenTypeH5;
|
|
|
|
//AlibcWebViewController* myView = [[AlibcWebViewController alloc] init];
|
|
//自定义web
|
|
IfishAlibcWebViewController* myView = [[IfishAlibcWebViewController alloc] init];
|
|
NSInteger ret = [[AlibcTradeSDK sharedInstance].tradeService show:self.navigationController webView:myView.webView page:page showParams:showParam taoKeParams:nil trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
|
|
|
|
} tradeProcessFailedCallback:^(NSError * _Nullable error) {
|
|
|
|
}]; //返回1,说明h5打开,否则不应该展示页面
|
|
|
|
|
|
if (ret == 1) {
|
|
|
|
self.hidesBottomBarWhenPushed = YES;
|
|
[self.navigationController pushViewController:myView animated:YES];
|
|
//在tab栏时 返回要显示
|
|
self.hidesBottomBarWhenPushed = NO;
|
|
}
|
|
}
|
|
|
|
|
|
#pragma mark 导航右侧按钮
|
|
-(void)rightButtonClick:(UIButton *)btn{
|
|
|
|
[self pushMyKankan];
|
|
}
|
|
|
|
-(void)pushMyKankan{
|
|
|
|
self.hidesBottomBarWhenPushed = YES;
|
|
MineKankanEditViewController *editVC = [[MineKankanEditViewController alloc] init];
|
|
[self.navigationController pushViewController:editVC animated:YES];
|
|
//在tab栏时 返回要显示
|
|
self.hidesBottomBarWhenPushed = NO;
|
|
}
|
|
|
|
#pragma mark - 选择了item
|
|
-(void)childlistViewslectIndex:(NSNotification *)notify
|
|
{
|
|
IfishKankanListModel * model = [notify object];
|
|
|
|
self.progressHud = [[MBProgressHUD alloc] initWithView:self.view];
|
|
[self.view addSubview:self.progressHud];
|
|
self.progressHud.mode=MBProgressHUDModeCustomView;
|
|
self.progressHud.customView = [[UIView alloc] init];
|
|
self.progressHud.delegate = self;
|
|
self.progressHud.labelText = @"加载中...";
|
|
__weak typeof (self)weskSelf=self;
|
|
[self.progressHud showAnimated:YES whileExecutingBlock:^{
|
|
|
|
[weskSelf pushShareP2pView:model];
|
|
|
|
} onQueue:dispatch_get_main_queue()];
|
|
|
|
}
|
|
|
|
-(void)pushShareP2pView:(IfishKankanListModel *)listModel
|
|
{
|
|
KanHuListModel *kanHuCamera =[[KanHuListModel alloc] init];
|
|
//kanHuCamera.cameraId = @"3573889";
|
|
kanHuCamera.cameraId = listModel.cameraId;
|
|
IfishP2PLivePlayViewController *shareVideoVC=[[IfishP2PLivePlayViewController alloc] init];
|
|
shareVideoVC.kanHuCamera = kanHuCamera;
|
|
shareVideoVC.listRoomInfo = listModel;
|
|
self.hidesBottomBarWhenPushed = YES;
|
|
self.shareVideoVC = shareVideoVC;
|
|
[self.navigationController pushViewController:shareVideoVC animated:YES];
|
|
//在tab栏时 返回要显示
|
|
self.hidesBottomBarWhenPushed = NO;
|
|
}
|
|
|
|
/*
|
|
#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.
|
|
}
|
|
*/
|
|
|
|
@end
|