CNLIVEViewController.m 4.27 KB
//
//  CNLIVEViewController.m
//  CNLiveBBASMModule
//
//  Created by 杨苓玉 on 10/21/2021.
//  Copyright (c) 2021 杨苓玉. All rights reserved.
//

#import "CNLIVEViewController.h"
#import "CNLiveBBASMModule/CNLiveBBASMModuleService.h"
#import <CNLiveBeeHive/CNLiveBeeHive.h>
#import <CNLiveBusinessTools/CNLiveEscpTools.h>
#import <CNLiveBaseKit/CNLiveBaseKit.h>

@interface CNLIVEViewController ()<HomeServiceProtocol>

@end

@BeeHiveService(HomeServiceProtocol, CNLIVEViewController)
@implementation CNLIVEViewController
- (UIViewController *)getConnnectVC
{
    CNLIVEViewController *vc = [[CNLIVEViewController alloc] init];
    return vc;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    NSArray *titleArray = [NSArray arrayWithObjects:@"百度小程序",@"退出登录",@"分享链接打开",@"猫眼视频",@"e代驾",@"高铁",@"英语学习", nil];
    for (int i = 0;i < titleArray.count;i++){
        UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 40+100 + 54 *i, [UIScreen mainScreen].bounds.size.width, 44)];
        btn.tag = 1001 + i;
        [btn addTarget:self action:@selector(action:) forControlEvents:UIControlEventTouchUpInside];
        [btn setTitle:titleArray[i] forState:UIControlStateNormal];
        btn.backgroundColor = [UIColor grayColor];
        [self.view addSubview:btn];
    }
    
}
-(void)action:(UIButton *)sender
{
    switch (sender.tag - 1001) {
        case 0:
        {
            NSString *spURL = @"cnlive://swan/4fecoAqgCIUtzIyA4FAPgoyrc4oUc25c";
            [CNLiveBBASMModuleService openBBASMModule:spURL];
        }
            break;
        case 1:
        {
            [CNLiveBBASMModuleService accountLogout];
        }
            break;
        case 2:
        {
            NSString *urlStr = @"https://wjjh5.cnlive.com/smartappLandingpage.html?title=%E6%B2%AA%E6%B1%9F%E8%8B%B1%E8%AF%AD%E5%AD%A6%E4%B9%A0&content=%E6%B2%AA%E6%B1%9F%E8%8B%B1%E8%AF%AD%E6%8F%90%E4%BE%9B%E8%8B%B1%E8%AF%AD%E5%9B%9B%E5%85%AD%E7%BA%A7%E3%80%81%E5%90%AC%E8%AF%B4%E8%AF%BB%E5%86%99%E3%80%81%E5%BD%B1%E8%A7%86%E5%A8%B1%E4%B9%90%E3%80%81%E5%85%A5%E9%97%A8%E5%AD%A6%E4%B9%A0%E8%B5%84%E8%AE%AF&imageUrl=https%3A%2F%2Fb.bdstatic.com%2Fsearchbox%2Fmappconsole%2Fimage%2F20181105%2F1541398769-33490.png&swanId=lDvbSAZzaa8xPTQ8M0EquG1xos75HGvU%2F%2Fpages%2Fsubcate%2Fsubcate%3Fcatename%3D%E8%81%8C%E5%9C%BA%E8%8B%B1%E8%AF%AD&type=smartapp";
            [CNLiveBBASMModuleService skipOpenBBASMModule:urlStr];
        }
            break;
        case 3:
        {
            NSString *spURL = @"cnlive://swan/WtZRSkMo3I3VcIQ3unY30Ch4y9Wxr0nN";
            [CNLiveBBASMModuleService openBBASMModule:spURL];
        }
            break;
        case 4:
        {
            NSString *spURL = @"cnlive://swan/FdMouSDlO3kyhUoMz0wtlnukEkfHKxDI";
            [CNLiveBBASMModuleService openBBASMModule:spURL];
        }
            break;
        case 5:
        {
            NSString *spURL = @"cnlive://swan/fn4HbXgoHtGWc1TkREts2nDTZKE0wvIh";
            [CNLiveBBASMModuleService openBBASMModule:spURL];
        }
            break;
        case 6:
        {
            NSString *spURL = @"cnlive://swan/lDvbSAZzaa8xPTQ8M0EquG1xos75HGvU";
            [CNLiveBBASMModuleService openBBASMModule:spURL];
        }
            break;
            
        default:
            break;
    }
    
}
//参数的跳转逻辑
-(NSDictionary *)requestURLParameters:(NSURL *)urlStr
{
    NSMutableDictionary *parm = [[NSMutableDictionary alloc]init];
        // Fallback on earlier versions
        NSString * path = [urlStr.absoluteString componentsSeparatedByString:@"?"].lastObject;
        NSArray * paramArray = [path componentsSeparatedByString:@"&"];
        [paramArray enumerateObjectsUsingBlock:^(NSString *  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            NSArray * tempArray = [obj componentsSeparatedByString:@"="];
            if ([tempArray.firstObject isEqualToString:@"//type"]) {
                [parm setObject:tempArray.lastObject forKey:@"type"];
            }else{
                [parm setObject:tempArray.lastObject forKey:tempArray.firstObject];
            }
        }];
    
    return parm;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end