Commit 17256e0ff5d643dda9de2f74a49c433c14f2f5ba

Authored by liushiyu
1 parent 97eab73a

提交添加网家家请求库

1 # Uncomment the next line to define a global platform for your project 1 # Uncomment the next line to define a global platform for your project
2 # platform :ios, '9.0' 2 # platform :ios, '9.0'
  3 +source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
  4 +#source 'https://github.com/CocoaPods/Specs.git'
  5 +#source 'https://cdn.cocoapods.org'
  6 +
  7 +source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git'
  8 +source 'http://bj.gitlab.cnlive.com/DSIOSTeam/DSSpecRepos.git'
3 9
4 target 'metaCode' do 10 target 'metaCode' do
5 # Comment the next line if you don't want to use dynamic frameworks 11 # Comment the next line if you don't want to use dynamic frameworks
6 use_frameworks! 12 use_frameworks!
7 13
8 - pod 'Alamofire'  
9 - pod 'Moya'  
10 - pod 'SwiftyJSON'  
11 - pod 'YYCategories' 14 +# pod 'Alamofire'
  15 +# pod 'Moya'
  16 +# pod 'SwiftyJSON'
  17 +# pod 'YYCategories'
  18 +# pod 'CryptoSwift'
12 # Pods for metaCode 19 # Pods for metaCode
  20 +
  21 + pod 'AFNetworking'
  22 + #基础请求组件库
  23 + pod 'CNLiveRequestBastKit'
13 24
14 target 'metaCodeTests' do 25 target 'metaCodeTests' do
15 inherit! :search_paths 26 inherit! :search_paths
metaCode.xcodeproj/project.pbxproj
@@ -12,8 +12,7 @@ @@ -12,8 +12,7 @@
12 796398932A260C0100D045EB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963988C2A260C0100D045EB /* ViewController.swift */; }; 12 796398932A260C0100D045EB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963988C2A260C0100D045EB /* ViewController.swift */; };
13 796398942A260C0100D045EB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963988D2A260C0100D045EB /* AppDelegate.swift */; }; 13 796398942A260C0100D045EB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963988D2A260C0100D045EB /* AppDelegate.swift */; };
14 7963989D2A260E6200D045EB /* CNLiveBaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963989C2A260E6200D045EB /* CNLiveBaseViewController.swift */; }; 14 7963989D2A260E6200D045EB /* CNLiveBaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963989C2A260E6200D045EB /* CNLiveBaseViewController.swift */; };
15 - 79A68C4A2A26E6CE00DC3B43 /* Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A68C492A26E6CE00DC3B43 /* Network.swift */; };  
16 - 79A68C4C2A26EA6000DC3B43 /* API.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A68C4B2A26EA6000DC3B43 /* API.swift */; }; 15 + 79A68C542A27307900DC3B43 /* CNLiveConfigMacro.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A68C532A27307900DC3B43 /* CNLiveConfigMacro.swift */; };
17 818163C32A25CFCC00579C86 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 818163C12A25CFCC00579C86 /* Main.storyboard */; }; 16 818163C32A25CFCC00579C86 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 818163C12A25CFCC00579C86 /* Main.storyboard */; };
18 818163C52A25CFCF00579C86 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 818163C42A25CFCF00579C86 /* Assets.xcassets */; }; 17 818163C52A25CFCF00579C86 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 818163C42A25CFCF00579C86 /* Assets.xcassets */; };
19 818163C82A25CFCF00579C86 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 818163C62A25CFCF00579C86 /* LaunchScreen.storyboard */; }; 18 818163C82A25CFCF00579C86 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 818163C62A25CFCF00579C86 /* LaunchScreen.storyboard */; };
@@ -50,9 +49,8 @@ @@ -50,9 +49,8 @@
50 7963988C2A260C0100D045EB /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; 49 7963988C2A260C0100D045EB /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
51 7963988D2A260C0100D045EB /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 50 7963988D2A260C0100D045EB /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
52 7963989C2A260E6200D045EB /* CNLiveBaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNLiveBaseViewController.swift; sourceTree = "<group>"; }; 51 7963989C2A260E6200D045EB /* CNLiveBaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNLiveBaseViewController.swift; sourceTree = "<group>"; };
53 - 79A68C492A26E6CE00DC3B43 /* Network.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = "<group>"; };  
54 - 79A68C4B2A26EA6000DC3B43 /* API.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = API.swift; sourceTree = "<group>"; };  
55 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; }; 52 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; };
  53 + 79A68C532A27307900DC3B43 /* CNLiveConfigMacro.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveConfigMacro.swift; sourceTree = "<group>"; };
56 818163B82A25CFCC00579C86 /* metaCode.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = metaCode.app; sourceTree = BUILT_PRODUCTS_DIR; }; 54 818163B82A25CFCC00579C86 /* metaCode.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = metaCode.app; sourceTree = BUILT_PRODUCTS_DIR; };
57 818163C22A25CFCC00579C86 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; 55 818163C22A25CFCC00579C86 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
58 818163C42A25CFCF00579C86 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 56 818163C42A25CFCF00579C86 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -154,7 +152,6 @@ @@ -154,7 +152,6 @@
154 796398912A260C0100D045EB /* Common */ = { 152 796398912A260C0100D045EB /* Common */ = {
155 isa = PBXGroup; 153 isa = PBXGroup;
156 children = ( 154 children = (
157 - 7963989E2A260E7600D045EB /* Network */,  
158 7963989B2A260E6200D045EB /* Base */, 155 7963989B2A260E6200D045EB /* Base */,
159 ); 156 );
160 path = Common; 157 path = Common;
@@ -163,6 +160,7 @@ @@ -163,6 +160,7 @@
163 796398922A260C0100D045EB /* Config */ = { 160 796398922A260C0100D045EB /* Config */ = {
164 isa = PBXGroup; 161 isa = PBXGroup;
165 children = ( 162 children = (
  163 + 79A68C532A27307900DC3B43 /* CNLiveConfigMacro.swift */,
166 ); 164 );
167 path = Config; 165 path = Config;
168 sourceTree = "<group>"; 166 sourceTree = "<group>";
@@ -185,15 +183,6 @@ @@ -185,15 +183,6 @@
185 path = Base; 183 path = Base;
186 sourceTree = "<group>"; 184 sourceTree = "<group>";
187 }; 185 };
188 - 7963989E2A260E7600D045EB /* Network */ = {  
189 - isa = PBXGroup;  
190 - children = (  
191 - 79A68C492A26E6CE00DC3B43 /* Network.swift */,  
192 - 79A68C4B2A26EA6000DC3B43 /* API.swift */,  
193 - );  
194 - path = Network;  
195 - sourceTree = "<group>";  
196 - };  
197 818163AF2A25CFCC00579C86 = { 186 818163AF2A25CFCC00579C86 = {
198 isa = PBXGroup; 187 isa = PBXGroup;
199 children = ( 188 children = (
@@ -456,6 +445,7 @@ @@ -456,6 +445,7 @@
456 ); 445 );
457 name = "[CP] Embed Pods Frameworks"; 446 name = "[CP] Embed Pods Frameworks";
458 outputFileListPaths = ( 447 outputFileListPaths = (
  448 + "${PODS_ROOT}/Target Support Files/Pods-metaCode/Pods-metaCode-frameworks-${CONFIGURATION}-output-files.xcfilelist",
459 ); 449 );
460 runOnlyForDeploymentPostprocessing = 0; 450 runOnlyForDeploymentPostprocessing = 0;
461 shellPath = /bin/sh; 451 shellPath = /bin/sh;
@@ -493,9 +483,8 @@ @@ -493,9 +483,8 @@
493 files = ( 483 files = (
494 796398942A260C0100D045EB /* AppDelegate.swift in Sources */, 484 796398942A260C0100D045EB /* AppDelegate.swift in Sources */,
495 7963989D2A260E6200D045EB /* CNLiveBaseViewController.swift in Sources */, 485 7963989D2A260E6200D045EB /* CNLiveBaseViewController.swift in Sources */,
496 - 79A68C4A2A26E6CE00DC3B43 /* Network.swift in Sources */, 486 + 79A68C542A27307900DC3B43 /* CNLiveConfigMacro.swift in Sources */,
497 796398932A260C0100D045EB /* ViewController.swift in Sources */, 487 796398932A260C0100D045EB /* ViewController.swift in Sources */,
498 - 79A68C4C2A26EA6000DC3B43 /* API.swift in Sources */,  
499 ); 488 );
500 runOnlyForDeploymentPostprocessing = 0; 489 runOnlyForDeploymentPostprocessing = 0;
501 }; 490 };
@@ -672,10 +661,11 @@ @@ -672,10 +661,11 @@
672 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 661 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
673 ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 662 ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
674 CODE_SIGN_STYLE = Automatic; 663 CODE_SIGN_STYLE = Automatic;
675 - CURRENT_PROJECT_VERSION = 1; 664 + CURRENT_PROJECT_VERSION = 1.0;
676 DEVELOPMENT_TEAM = 94X49GG3ZW; 665 DEVELOPMENT_TEAM = 94X49GG3ZW;
677 GENERATE_INFOPLIST_FILE = YES; 666 GENERATE_INFOPLIST_FILE = YES;
678 INFOPLIST_FILE = metaCode/Info.plist; 667 INFOPLIST_FILE = metaCode/Info.plist;
  668 + INFOPLIST_KEY_CFBundleDisplayName = "元码";
679 INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 669 INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
680 INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen.storyboard; 670 INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen.storyboard;
681 INFOPLIST_KEY_UIMainStoryboardFile = Main; 671 INFOPLIST_KEY_UIMainStoryboardFile = Main;
@@ -687,7 +677,7 @@ @@ -687,7 +677,7 @@
687 "@executable_path/Frameworks", 677 "@executable_path/Frameworks",
688 ); 678 );
689 MARKETING_VERSION = 1.0; 679 MARKETING_VERSION = 1.0;
690 - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.metaCode; 680 + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.metaCode.debug;
691 PRODUCT_NAME = "$(TARGET_NAME)"; 681 PRODUCT_NAME = "$(TARGET_NAME)";
692 SWIFT_EMIT_LOC_STRINGS = YES; 682 SWIFT_EMIT_LOC_STRINGS = YES;
693 SWIFT_VERSION = 5.0; 683 SWIFT_VERSION = 5.0;
@@ -702,10 +692,11 @@ @@ -702,10 +692,11 @@
702 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 692 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
703 ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 693 ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
704 CODE_SIGN_STYLE = Automatic; 694 CODE_SIGN_STYLE = Automatic;
705 - CURRENT_PROJECT_VERSION = 1; 695 + CURRENT_PROJECT_VERSION = 1.0;
706 DEVELOPMENT_TEAM = 94X49GG3ZW; 696 DEVELOPMENT_TEAM = 94X49GG3ZW;
707 GENERATE_INFOPLIST_FILE = YES; 697 GENERATE_INFOPLIST_FILE = YES;
708 INFOPLIST_FILE = metaCode/Info.plist; 698 INFOPLIST_FILE = metaCode/Info.plist;
  699 + INFOPLIST_KEY_CFBundleDisplayName = "元码";
709 INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 700 INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
710 INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen.storyboard; 701 INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen.storyboard;
711 INFOPLIST_KEY_UIMainStoryboardFile = Main; 702 INFOPLIST_KEY_UIMainStoryboardFile = Main;
@@ -717,7 +708,7 @@ @@ -717,7 +708,7 @@
717 "@executable_path/Frameworks", 708 "@executable_path/Frameworks",
718 ); 709 );
719 MARKETING_VERSION = 1.0; 710 MARKETING_VERSION = 1.0;
720 - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.metaCode; 711 + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.metaCode.debug;
721 PRODUCT_NAME = "$(TARGET_NAME)"; 712 PRODUCT_NAME = "$(TARGET_NAME)";
722 SWIFT_EMIT_LOC_STRINGS = YES; 713 SWIFT_EMIT_LOC_STRINGS = YES;
723 SWIFT_VERSION = 5.0; 714 SWIFT_VERSION = 5.0;
metaCode/Classes/Common/Base/CNLiveBaseViewController.swift
@@ -8,5 +8,46 @@ @@ -8,5 +8,46 @@
8 import UIKit 8 import UIKit
9 import Foundation 9 import Foundation
10 10
11 - 11 +class CNLiveBaseViewController: UIViewController {
  12 +
  13 + deinit {
  14 + log("主界面已销毁")
  15 + }
  16 +
  17 + override func viewDidLoad() {
  18 + self.view.backgroundColor = .white
  19 +
  20 + configIOS11()
  21 + configIOS15()
  22 + }
  23 +
  24 +
  25 +
  26 + // MARK: - iOS 适配
  27 +
  28 + func configIOS11() {
  29 + /// 适配 iOS 11.0 ,iOS11以后,控制器的automaticallyAdjustsScrollViewInsets已经废弃,所以默认就会是YES
  30 + /// iOS 11新增:adjustContentInset 和 contentInsetAdjustmentBehavior 来处理滚动区域
  31 + if #available(iOS 11.0, *) {
  32 + UITableView.appearance().estimatedRowHeight = 0
  33 + UITableView.appearance().estimatedSectionHeaderHeight = 0
  34 + UITableView.appearance().estimatedSectionFooterHeight = 0
  35 + // 防止列表/页面偏移
  36 + UIScrollView.appearance().contentInsetAdjustmentBehavior = .never
  37 + UITableView.appearance().contentInsetAdjustmentBehavior = .never
  38 + UICollectionView.appearance().contentInsetAdjustmentBehavior = .never
  39 + } else {
  40 + self.automaticallyAdjustsScrollViewInsets = false
  41 + }
  42 + }
  43 +
  44 + func configIOS15() {
  45 + // 适配iOS15,tableView的section设置
  46 + // iOS15中,tableView会给每一个section的顶部(header以上)再加上一个22像素的高度,形成一个section和section之间的间距
  47 + // 新增的sectionHeaderTopPadding会使表头新增一段间隙,默认为UITableViewAutomaticDimension
  48 + if #available(iOS 15.0, *) {
  49 + UITableView.appearance().sectionHeaderTopPadding = 0
  50 + }
  51 + }
  52 +}
12 53
metaCode/Classes/Common/Network/API.swift deleted 100644 → 0
1 -//  
2 -// API.swift  
3 -// metaCode  
4 -//  
5 -// Created by open on 2023/5/31.  
6 -//  
7 -  
8 -import Foundation  
9 -import Moya  
10 -  
11 -let base_URL = "https://api.cnlive.com/open/api2/"  
12 -  
13 -enum API{  
14 - //登陆api  
15 - case requestLoginApi  
16 - //获取验证码api  
17 - case requestAuthCodeApi  
18 -}  
19 -  
20 -extension API : TargetType {  
21 -  
22 - //此处是为了区分不同根请求  
23 - var baseURL: URL {  
24 - switch self {  
25 - case .requestLoginApi:  
26 - return URL.init(string: base_URL)!  
27 - default:  
28 - return URL.init(string: base_URL)!  
29 - }  
30 - }  
31 -  
32 - var path: String {  
33 - switch self{  
34 - case .requestLoginApi:  
35 - return "user/loginInMetaCode"  
36 - case .requestAuthCodeApi:  
37 - return "user/sendVerifyCode4server"  
38 - }  
39 - }  
40 -  
41 - var method: Moya.Method {  
42 - switch self{  
43 - default:  
44 - return.post  
45 - }  
46 - }  
47 -  
48 - var task: Moya.Task {  
49 - switch self{  
50 - default:  
51 - return .requestPlain  
52 - }  
53 - }  
54 -  
55 - var headers: [String : String]? {  
56 - return ["Content-Type":"application/x-www-form-urlencoded"]  
57 - }  
58 -  
59 -  
60 -  
61 -  
62 -}  
metaCode/Classes/Common/Network/Network.swift deleted 100644 → 0
1 -//  
2 -// Network.swift  
3 -// metaCode  
4 -//  
5 -// Created by open on 2023/5/31.  
6 -//  
7 -  
8 -import Foundation  
9 -import UIKit  
10 -import Alamofire  
11 -import Moya  
12 -import SwiftyJSON  
13 -  
14 -  
15 -class Network: NSObject {  
16 - //请求成功  
17 - typealias successCallBack = ((Int,JSON) -> (Void))  
18 - //请求失败  
19 - typealias failedCallBack = ((Int,String) -> (Void))  
20 - //网络错误  
21 - typealias errorCallBack = (() -> (Void))  
22 -  
23 -  
24 -  
25 -}  
26 -  
metaCode/Classes/Config/CNLiveConfigMacro.swift 0 → 100644
  1 +//
  2 +// CNLiveConfigMacro.swift
  3 +// metaCode
  4 +//
  5 +// Created by open on 2023/5/31.
  6 +//
  7 +
  8 +import Foundation
  9 +import UIKit
  10 +
  11 +/// App 显示名称
  12 +let kAppDisplayName = Bundle.main.infoDictionary?["CFBundleDisplayName"] ?? ""
  13 +/// App BundleName
  14 +let kAppName = Bundle.main.infoDictionary![kCFBundleNameKey as String] ?? ""
  15 +/// App BundleID
  16 +let kAppBundleID = Bundle.main.bundleIdentifier ?? ""
  17 +/// App 版本号
  18 +let kAppVersion = Bundle.main.infoDictionary!["CFBundleShortVersionString"] ?? ""
  19 +/// App BuildNumber
  20 +let kAppBuildNumber = Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) ?? ""
  21 +
  22 +/// App Language en
  23 +let kAPPLanguage = NSLocale.preferredLanguages[0]
  24 +
  25 +
  26 +let kApplication = UIApplication.shared
  27 +let keyWindow = UIApplication.shared.keyWindow
  28 +let appDelegate = UIApplication.shared.delegate
  29 +let userDefaults = UserDefaults.standard
  30 +let notificationCenter = NotificationCenter.default
  31 +
  32 +
  33 +// MARK: - 打印输出
  34 +
  35 +/// 默认打印
  36 +public func log<T>(_ message: T) {
  37 +#if DEBUG
  38 + print("\(message)")
  39 +#endif
  40 +}
  41 +
  42 +/// 全部打印
  43 +public func aLog<T>(_ message: T, file: String = #file, funcName: String = #function, lineNum: Int = #line) {
  44 +#if DEBUG
  45 + let fileName = (file as NSString).lastPathComponent
  46 + print("\n********** JhAllLog-satrt ***********\n\n文件名称:\(fileName)\n方法名称:\(funcName)\n行数:\(lineNum)\n信息:\n\n\(message)\n\n********** JhAllLog-end ***********\n")
  47 +#endif
  48 +}
metaCode/Classes/Other/AppDelegate.swift
@@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
6 // 6 //
7 7
8 import UIKit 8 import UIKit
  9 +import CNLiveRequestBastKit
  10 +
9 11
10 @main 12 @main
11 class AppDelegate: UIResponder, UIApplicationDelegate { 13 class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -20,6 +22,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate { @@ -20,6 +22,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
20 window?.rootViewController = ViewController.init() 22 window?.rootViewController = ViewController.init()
21 window?.makeKeyAndVisible() 23 window?.makeKeyAndVisible()
22 24
  25 +
  26 + let kAppBundleID = Bundle.main.bundleIdentifier ?? ""
  27 + let uuid : String = UIDevice.current.identifierForVendor?.uuidString.replacingOccurrences(of: "-", with: "") ?? ""
  28 + let ver : String = Bundle.main.infoDictionary?["CFBundleVersion"] as! String
  29 + let p : Dictionary = ["platform_id":kAppBundleID,"uuid":uuid,"plat":"i","ver":ver,"appId":"802_li40qhp922","timestamp":String(NSNumber(floatLiteral: Date().timeIntervalSince1970).intValue),"clientPlat":"i","frmId":"ios"]
  30 + CNLiveNetworking.setupDefaultParam(p)
  31 + CNLiveNetworking.setupShowDataResult(false)
  32 + CNLiveNetworking.setupSignKey("ae3a7ad3e4b9beb7cfe2078db648ebb89aa249ca2e82ac")
  33 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  34 + CNLiveNetworking.setResponseSerializerType(.JSON)
  35 +
  36 +
23 return true 37 return true
24 } 38 }
25 39
metaCode/Classes/Other/ViewController.swift
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 // 6 //
7 7
8 import UIKit 8 import UIKit
  9 +import CNLiveRequestBastKit
9 10
10 class ViewController: UIViewController { 11 class ViewController: UIViewController {
11 12
@@ -13,6 +14,47 @@ class ViewController: UIViewController { @@ -13,6 +14,47 @@ class ViewController: UIViewController {
13 super.viewDidLoad() 14 super.viewDidLoad()
14 // Do any additional setup after loading the view. 15 // Do any additional setup after loading the view.
15 self.view.backgroundColor = .gray 16 self.view.backgroundColor = .gray
  17 +
  18 +
  19 + let button = UIButton()
  20 + button.frame = CGRect(x: 100, y: 100, width: 100, height: 40)
  21 + button.setTitle("请求吧", for: .normal)
  22 + button.setTitle("请求吧", for: .highlighted)
  23 + button.backgroundColor = UIColor.red
  24 + button.setTitleColor(UIColor.gray, for: .normal)
  25 + button.addTarget(self, action: #selector(touchButton), for: .touchUpInside)
  26 + button.sizeToFit()
  27 + self.view.addSubview(button)
  28 +
  29 + let button_sha = UIButton()
  30 + button_sha.frame = CGRect(x: 100, y: 200, width: 100, height: 40)
  31 + button_sha.setTitle("验证码", for: .normal)
  32 + button_sha.setTitle("验证码", for: .highlighted)
  33 + button_sha.backgroundColor = UIColor.red
  34 + button_sha.setTitleColor(UIColor.gray, for: .normal)
  35 + button_sha.addTarget(self, action: #selector(shaButton), for: .touchUpInside)
  36 + button_sha.sizeToFit()
  37 + self.view.addSubview(button_sha)
  38 + }
  39 +
  40 + @objc func shaButton() -> Void {
  41 + let param = ["mobile":"18519714533","countryCode":"86"]
  42 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  43 + CNLiveNetworking.setupShowDataResult(true)
  44 + CNLiveNetworking.requestNetwork(with: .POST, urlString: "https://api.cnlive.com/open/api2/user/sendVerifyCode4server", param: param, cacheType: .networkOnly) { task, result, error in
  45 + print("\(String(describing: result))")
  46 + }
  47 + }
  48 +
  49 + @objc func touchButton() {
  50 + let param = ["userName":"18519714533","countryCode":"86","verificationCode":"599011","inviterId":"","ver":"1"]
  51 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  52 + CNLiveNetworking.setupShowDataResult(true)
  53 + CNLiveNetworking.requestNetwork(with: .POST, urlString: "https://api.cnlive.com/open/api2/user/loginInMetaCode", param: param, cacheType: .networkOnly) { task, result, error in
  54 + print("\(String(describing: result))")
  55 + }
  56 +
  57 +
16 } 58 }
17 59
18 60