CNLIVEViewController.m
4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//
// 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 = @"http://wjjh5test.cnlive.com/smartappLandingpage.html?title=%E5%85%B3%E4%BA%8E%E5%8A%A8%E7%89%A9%E7%9A%84%E8%B6%A3%E5%91%B3%E4%BF%9A%E8%AF%AD%E8%A1%A8%E8%BE%BE%EF%BD%9E&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://b.bdstatic.com/searchbox/mappconsole/image/20181105/1541398769-33490.png&swanId=lDvbSAZzaa8xPTQ8M0EquG1xos75HGvU%2F%2Fpages%2FaudioDetail%2FaudioDetail%3Fshare%3D1%26contentId%3D1279583%26rowId%3D1%26pubDate%3D2021%2D11%2D10%26assignTag%3D%E5%B0%8F%E8%AF%8D%E5%A4%A7%E7%94%A8&type=smartapp";
NSURL *url = [NSURL URLWithString:urlStr];
NSDictionary * paramDic = [self requestURLParameters:url];
[CNLiveBBASMModuleService openBBASMModule:[NSString stringWithFormat :@"cnlive://swan/%@",[CNLiveEscpTools unesp:paramDic[@"swanId"]]]];
}
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