ViewController.m
4.74 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
135
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
[button1 setTitle:@"登陆" forState:UIControlStateNormal];
button1.frame = CGRectMake(50.0f, 100.0f, 50.0f, 40.0f);
button1.tag = 1;
[button1 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button1];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
[button2 setTitle:@"数据" forState:UIControlStateNormal];
button2.frame = CGRectMake(150.0f, 100.0f, 50.0f, 40.0f);
button2.tag = 2;
[button2 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button2];
UIButton *button4 = [UIButton buttonWithType:UIButtonTypeCustom];
[button4 setTitle:@"充值" forState:UIControlStateNormal];
button4.frame = CGRectMake(150.0f, 50.0f, 50.0f, 40.0f);
button4.tag = 4;
[button4 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button4];
UIButton *button6 = [UIButton buttonWithType:UIButtonTypeCustom];
[button6 setTitle:@"获取配置参数" forState:UIControlStateNormal];
button6.frame = CGRectMake(10.0f, 50.0f, 150.0f, 40.0f);
button6.tag = 6;
[button6 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button6];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveSDKMessage:) name:HaiBaoJuheSDK_Notification object:nil];
[[HaiBaoJuheSDK shareSDK]initSDK:self];
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
//[[HaiBaoJuheSDK shareSDK] viewDidAppear];
}
- (void) toggleButton: (UIButton *) button
{
int tag = (int)button.tag;
if (tag == 1) {
[[HaiBaoJuheSDK shareSDK] loginSDK];
}
else if (tag == 2)
{
NSLog(@"数据接口");
HaiBaoJuheReportInfo *reportInfo = [[HaiBaoJuheReportInfo alloc]init];
[reportInfo setReportType:REPORT_ENTER];
//[reportInfo setReportType:REPORT_CREATEROLE];
//[reportInfo setReportType:REPORT_ROLEUPGRADE]
[reportInfo setServerId:@"9133"];
[reportInfo setPlayerName:@"roleName"];
[reportInfo setPlayerId:@"pserverName"];
[[HaiBaoJuheSDK shareSDK] reportSDK:reportInfo];
}
else if (tag == 4)
{
HaiBaoJuheCreateOrderInfo *payInfo = [[HaiBaoJuheCreateOrderInfo alloc]init];
[payInfo setServerId:@"111"];
[payInfo setPostAmount:@"6"];
[payInfo setPlayerId:@"1231241234"];
[payInfo setTimestamp:@"1232134"];
[payInfo setExchange:@"10"];
[payInfo setCustom:@"custom"];
NSLog(@"start pay");
[[HaiBaoJuheSDK shareSDK] gzyazfWithGzyazfmentInfo:payInfo];
}
else if(tag == 6){
HaiBaoJuheSDK *haiBaoJuheSDK = [HaiBaoJuheSDK shareSDK];
NSLog(@"channelId:%@parame1:%@parame2:%@custom:%@",[haiBaoJuheSDK getGameChannelId],[haiBaoJuheSDK getChannelParameter1],[haiBaoJuheSDK getChannelParameter2],[haiBaoJuheSDK getCustomValue]);
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)receiveSDKMessage:(NSNotification *)notification
{
NSLog(@"receiveSDKMessage");
[[HaiBaoJuheConfig getInstance] getValueByKey:@"gamechannelid"];
HaiBaoJuheSDKResult *result = [notification object];
if (result == nil ) {
return;
}
switch (result.notiType) {
case HaiBaoJuheSDKNotificationInitSDK:
{
NSLog(@"收到HaiBaoJuheSDKNotificationInitSDK");
}
break;
case HaiBaoJuheSDKNotificationLogin:
{
NSLog(@"result state:%d",result.statusCode);
if (result.statusCode == HaiBaoJuheSDK_NO_ERROR) {
HaiBaoJuheLoginInfo *loginInfo = (HaiBaoJuheLoginInfo*)result.extendData;
NSLog(@"收到登陆信息public openid:%@", [loginInfo openId]);
NSLog(@"收到登陆信息public token:%@", [loginInfo sign]);
NSLog(@"收到登陆信息public timestamp:%@", [loginInfo timestamp]);
NSLog(@"userType:%@",[loginInfo userType]);
}else{
NSLog(@"%@",[result description]);
}
}
break;
case HaiBaoJuheSDKNotificationGzyazf:
{
NSLog(@"收到登陆信息HaiBaoJuheSDKNotificationPay");
}
break;
default:
break;
}
}
@end