JLChen
2021-02-03 4715e99a9be1c50d8ec31f594af9ebde18647c94
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
136
137
138
//
//  EZSupportViewController.m
//  EZOpenSDKDemo
//
//  Created by linyong on 2018/7/5.
//  Copyright © 2018年 linyong. All rights reserved.
//
 
#import "EZSupportViewController.h"
#import "Toast+UIView.h"
#import "EZOpenSDK.h"
#import "GlobalKit.h"
 
#define test2AppKey         @"a8bc553b576c430a9c4bcf96cc7de377"
#define test2AppAPIUrl      @"https://test2.ys7.com:9000"
#define test2AppAuthUrl     @"https://test2auth.ys7.com:8643"
#define testAppKey          @"ae1b9af9dcac4caeb88da6dbbf2dd8d5"
#define testAppAPIUrl       @"https://test.ys7.com:65"
#define testAppAuthUrl      @"https://testopenauth.ys7.com:8447"
 
 
@interface EZSupportViewController ()
 
@property (weak, nonatomic) IBOutlet UITextField *appKeyInput;
@property (weak, nonatomic) IBOutlet UITextField *accessTokenInput;
@property (weak, nonatomic) IBOutlet UITextField *apiUrlInput;
@property (weak, nonatomic) IBOutlet UITextField *authUrlInput;
@property (weak, nonatomic) IBOutlet UITextField *devSerialInput;
 
@end
 
@implementation EZSupportViewController
 
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self initSubviews];
    
//    self.appKeyInput.text = @"26810f3acd794862b608b6cfbc32a6b8";
//    self.accessTokenInput.text = @"at.2nizmrxb0u30ixknd6qu3cv609qs7f50-2h6hy82vta-0gvc2c8-hrvpporto";
//    self.apiUrlInput.text = @"https://open.ys7.com";
//    self.authUrlInput.text = @"https://test12openauth.ys7.com";
//    self.devSerialInput.text = @"789393515";
}
 
- (void) initSubviews
{
    self.title = @"支持界面";
    [self createBackBtn];
    [self createDoneBtn];
}
 
- (void) showToastWithText:(NSString *) text
{
    if (!text)
    {
        return;
    }
    
    [self.view makeToast:text duration:2.0 position:@"center"];
}
 
- (void)createBackBtn
{
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"退出"
                                                                             style:UIBarButtonItemStylePlain
                                                                            target:self
                                                                            action:@selector(backClick:)];
}
 
- (void)backClick:(id) sender
{
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
 
- (void)createDoneBtn
{
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"完成"
                                                                              style:UIBarButtonItemStylePlain
                                                                             target:self
                                                                             action:@selector(doneClick:)];
}
 
- (void)doneClick:(id) sender
{
    [GlobalKit shareKit].configDevSerial = self.devSerialInput.text.length > 0 ? self.devSerialInput.text : @"";
    
    if (self.appKeyInput.text.length == 0 )
    {
        [self showToastWithText:@"appKey不正确."];
        return;
    }
    
    if (self.apiUrlInput.text.length > 0)
    {
        [EZOpenSDK initLibWithAppKey:self.appKeyInput.text
                                 url:self.apiUrlInput.text
                             authUrl:self.authUrlInput.text.length>0?self.authUrlInput.text:nil];
    }
    else
    {
        [EZOpenSDK initLibWithAppKey:self.appKeyInput.text];
    }
    
    if (self.accessTokenInput.text.length > 0)
    {
        [EZOpenSDK setAccessToken:self.accessTokenInput.text];
    }
    
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
 
- (IBAction)test2BtnClick:(id)sender
{
    [EZOpenSDK logout:^(NSError *error) {
        
    }];
    [EZOpenSDK initLibWithAppKey:test2AppKey
                          url:test2AppAPIUrl
                         authUrl:test2AppAuthUrl];
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
 
- (IBAction)testBtnClick:(id)sender
{
    [EZOpenSDK logout:^(NSError *error) {
        
    }];
    [EZOpenSDK initLibWithAppKey:testAppKey
                          url:testAppAPIUrl
                         authUrl:testAppAuthUrl];
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
 
 
 
@end