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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//
// 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 = @"";
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];
//回调遍历所有参数,添加入字典
if (@available(iOS 11.0, *)) {
//传入url创建url组件类
NSURLComponents *urlComponents = [[NSURLComponents alloc] initWithString:urlStr.absoluteString];
[urlComponents.percentEncodedQueryItems enumerateObjectsUsingBlock:^(NSURLQueryItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (!CNLiveStringIsEmpty(obj.name) && !CNLiveStringIsEmpty(obj.value)) {
if ([obj.name isEqualToString:@"//type"]) {
[parm setObject:obj.value forKey:@"type"];
}else{
[parm setObject:obj.value forKey:obj.name];
}
}
}];
} else {
// 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