# ZKPageSDK **Repository Path**: gzzlit-open/ZKPageSDK ## Basic Information - **Project Name**: ZKPageSDK - **Description**: 智校乐中卡设备对接sdk - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-05-29 - **Last Updated**: 2025-09-12 ## Categories & Tags **Categories**: instructional **Tags**: None ## README # ZKPageSDK ## 示例 运行示例,从终端打开示例根目录,第一次安装运行 `pod install` ,之后若有版本更新请运行`pod update --no-repo-update`。示例的包名需要改成智校乐的包名才能正常使用。 ## 要求 iOS9 Swift5 Objective-C ## 安装 ZKPageSDK 可通过 [CocoaPods](https://cocoapods.org)安装使用,终端运行添加智磊私有库: `pod repo add Spec https://gitee.com/zhi_lei/Spec.git `。 简单地添加以下代码到你的Podfile中,然后在你的Podfile目录打开终端运行 `pod install` 。 ```ruby use_frameworks! source 'https://gitee.com/zhi_lei/Spec.git' source 'https://github.com/CocoaPods/Specs.git' target 'ZKPageSDK_Example' do pod 'ZKPageSDK' end ``` ## 使用 在需要使用SDK的地方导入`ZKPageManager` swift: ```swift import ZKPageManager ``` objc: ```objc @import ZKPageManager; ``` ### 1. 初始化 在`AppDelegate`的`didFinishLaunching`方法中,使用`ZKPageManager`类来初始化SDK,并添加域名。 swift: ```swift ZKPageManager.initSDK(host: "域名") ``` objc: ```objc [ZKPageManager initSDKWithHost:@"域名"]; ``` ### 2. 实现代理 首页控制器实现`ZKPageDelegate`代理,在代理方法添加对应业务代码,包含发起支付、获取广告和点击广告。 swift: ```swift func onZKPageCallPay(_ isPayEnough: Bool, _ pageType: ZKPageType, _ completion: (String) -> Void) { log("发起支付 \(isPayEnough) \(pageType.rawValue)") completion("订单号") } func onZKPageReadAds(_ pos: ZKAdsPos, _ completion: (ZKPageAds) -> Void) { log("获取广告 \(pos.rawValue)") completion(ZKPageAds(img: "https://img/img-ad.png", dic: [:], pos: pos)) } func onZKPageClickAds(_ ads: ZKPageAds) { log("点击广告 \(ads.img)") } ``` objc: ```objc - (void)onZKPageCallPay:(BOOL)isPayEnough :(enum ZKPageType)pageType :(void (^)(NSString *))completion{ //发起支付 completion(@"订单号"); } -(void)onZKPageReadAds:(enum ZKAdsPos)pos :(void (^)(ZKPageAds *))completion{ //获取广告 completion([ZKPageAds adsWithImg:"https://img/img-ad.png" dic:@{} pos:pos];); } - (void)onZKPageClickAds:(ZKPageAds *)ads { //点击广告 NSString *adsImgUrl = ads.img; NSDictionary *adsDic = ads.dic; int position = ads.pos; } ``` ### 3. 显示页面 使用`ZKPageManager`类`showPage`方法显示洗澡、饮水、吹风和洗衣页面。 swift: ```swift @IBAction func bath(_ sender: Any) { ZKPageManager.showPage(delegate: self, phone: "手机号", type: .洗澡) } @IBAction func drink(_ sender: Any) { ZKPageManager.showPage(delegate: self, phone: "手机号", type: .饮水) } @IBAction func wind(_ sender: Any) { ZKPageManager.showPage(delegate: self, phone: "手机号", type: .吹风) } @IBAction func wash(_ sender: Any) { ZKPageManager.showPage(delegate: self, phone: "手机号", type: .洗衣) } ``` objc: ```objc [ZKPageManager showPageWithDelegate:self phone:@"手机号" type:ZKPageType吹风]; ``` ## 作者 Liang Qiubing, 465061258@qq.com ## 许可 ZKPageSDK is available under the MIT license. See the LICENSE file for more info.