ViewController.swift
2.28 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
//
// ViewController.swift
// metaCode
//
// Created by iOS on 2023/5/30.
//
import UIKit
import CNLiveRequestBastKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.view.backgroundColor = .gray
let button = UIButton()
button.frame = CGRect(x: 100, y: 100, width: 100, height: 40)
button.setTitle("请求吧", for: .normal)
button.setTitle("请求吧", for: .highlighted)
button.backgroundColor = UIColor.red
button.setTitleColor(UIColor.gray, for: .normal)
button.addTarget(self, action: #selector(touchButton), for: .touchUpInside)
button.sizeToFit()
self.view.addSubview(button)
let button_sha = UIButton()
button_sha.frame = CGRect(x: 100, y: 200, width: 100, height: 40)
button_sha.setTitle("验证码", for: .normal)
button_sha.setTitle("验证码", for: .highlighted)
button_sha.backgroundColor = UIColor.red
button_sha.setTitleColor(UIColor.gray, for: .normal)
button_sha.addTarget(self, action: #selector(shaButton), for: .touchUpInside)
button_sha.sizeToFit()
self.view.addSubview(button_sha)
}
@objc func shaButton() -> Void {
let param = ["mobile":"18519714533","countryCode":"86"]
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(true)
CNLiveNetworking.requestNetwork(with: .POST, urlString: "https://api.cnlive.com/open/api2/user/sendVerifyCode4server", param: param, cacheType: .networkOnly) { task, result, error in
print("\(String(describing: result))")
}
}
@objc func touchButton() {
let param = ["userName":"18519714533","countryCode":"86","verificationCode":"599011","inviterId":"","ver":"1"]
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(true)
CNLiveNetworking.requestNetwork(with: .POST, urlString: "https://api.cnlive.com/open/api2/user/loginInMetaCode", param: param, cacheType: .networkOnly) { task, result, error in
print("\(String(describing: result))")
}
}
}