Commit 07452738 authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

userinfo

parent 680731c3
This diff is collapsed.
...@@ -16,6 +16,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -16,6 +16,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch. // Override point for customization after application launch.
SHStoreManager.launchWithSwiftyStoreKit()
// UMConfigure.initWithAppkey("5f310903b4b08b653e92e421", channel: "App Store")
// MobClick.event("app_start")
SHUserAccountManager.shared.getUserInfo({ (model) in
}, failure: {
})
SHUserAccountManager.shared.logCollection(with: .appStart)
SHUserAccountManager.shared.getNovelInfo { (json) in
}
self.window = UIWindow(frame: UIScreen.main.bounds) self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = SHBaseTabBarController() self.window?.rootViewController = SHBaseTabBarController()
......
...@@ -58,7 +58,7 @@ class CRMemberIAPViewController: UIViewController { ...@@ -58,7 +58,7 @@ class CRMemberIAPViewController: UIViewController {
} }
private func getGoodsList() { private func getGoodsList() {
// CRNetworkingManager.shared.getRequest(withPath: .getIPAPayConfig) { (json, error) in // CMNetworkManager.shared.getRequest(withPath: .getIPAPayConfig) { (json, error) in
// guard error == nil else { return } // guard error == nil else { return }
// let goodsList = json["result"]["data"]["goodsList"].arrayValue.map({ CRIAPProductModel(json: $0) }) // let goodsList = json["result"]["data"]["goodsList"].arrayValue.map({ CRIAPProductModel(json: $0) })
// //
...@@ -152,14 +152,14 @@ class CRMemberIAPViewController: UIViewController { ...@@ -152,14 +152,14 @@ class CRMemberIAPViewController: UIViewController {
@IBAction func userTermsAction() { @IBAction func userTermsAction() {
let webVc = SHWebViewController() let webVc = SHWebViewController()
webVc.title = "使用条款" webVc.title = "使用条款"
// webVc.url = CRAccountManager.shared.h5_url["user"].stringValue // webVc.url = SHUserAccountManager.shared.h5_url["user"].stringValue
self.navigationController?.pushViewController(webVc, animated: true) self.navigationController?.pushViewController(webVc, animated: true)
} }
@IBAction func privacyPolicyAction() { @IBAction func privacyPolicyAction() {
let webVc = SHWebViewController() let webVc = SHWebViewController()
webVc.title = "隐私政策" webVc.title = "隐私政策"
// webVc.url = CRAccountManager.shared.h5_url["privacy"].stringValue // webVc.url = SHUserAccountManager.shared.h5_url["privacy"].stringValue
self.navigationController?.pushViewController(webVc, animated: true) self.navigationController?.pushViewController(webVc, animated: true)
} }
...@@ -180,7 +180,7 @@ class CRMemberIAPViewController: UIViewController { ...@@ -180,7 +180,7 @@ class CRMemberIAPViewController: UIViewController {
// } // }
// CRPurchaseManager.purchaseWithProductId(productId: productId, inView: self.view, success: { // CRPurchaseManager.purchaseWithProductId(productId: productId, inView: self.view, success: {
// CRAccountManager.shared.getUserInfo({ (model) in // SHUserAccountManager.shared.getUserInfo({ (model) in
// self.dismiss(animated: true, completion: nil) // self.dismiss(animated: true, completion: nil)
// }, failure: { // }, failure: {
// self.dismiss(animated: true, completion: nil) // self.dismiss(animated: true, completion: nil)
...@@ -193,7 +193,7 @@ class CRMemberIAPViewController: UIViewController { ...@@ -193,7 +193,7 @@ class CRMemberIAPViewController: UIViewController {
// 恢复购买 // 恢复购买
@IBAction func restoreAction(_ sender: UIButton) { @IBAction func restoreAction(_ sender: UIButton) {
// CRPurchaseManager.restorePurchases(success: { // CRPurchaseManager.restorePurchases(success: {
// CRAccountManager.shared.getUserInfo({ (model) in // SHUserAccountManager.shared.getUserInfo({ (model) in
// self.navigationController?.dismiss(animated: true, completion: nil) // self.navigationController?.dismiss(animated: true, completion: nil)
// }, failure: { // }, failure: {
// self.navigationController?.dismiss(animated: true, completion: nil) // self.navigationController?.dismiss(animated: true, completion: nil)
......
...@@ -40,7 +40,7 @@ class SHGuideViewController: UIViewController { ...@@ -40,7 +40,7 @@ class SHGuideViewController: UIViewController {
@objc private func maskBtnClick(_ sender:UIButton){ @objc private func maskBtnClick(_ sender:UIButton){
let webView = SHWebViewController() let webView = SHWebViewController()
webView.title = "隐私政策" webView.title = "隐私政策"
webView.url = CRAccountManager.shared.h5_url["privacy"].stringValue webView.url = SHUserAccountManager.shared.h5_url["privacy"].stringValue
let nav = SHBaseNavigationController.init(rootViewController: webView) let nav = SHBaseNavigationController.init(rootViewController: webView)
self.present(nav, animated: true, completion: nil) self.present(nav, animated: true, completion: nil)
......
...@@ -21,10 +21,10 @@ class SHWebViewController: SHBaseViewController { ...@@ -21,10 +21,10 @@ class SHWebViewController: SHBaseViewController {
setupViews() setupViews()
// guard let urlString = url, let URL = URL(string: urlString) else { return } guard let urlString = url, let URL = URL(string: urlString) else { return }
// let request = URLRequest(url: URL) let request = URLRequest(url: URL)
let request = URLRequest(url: URL(fileURLWithPath: url!)) // let request = URLRequest(url: URL(fileURLWithPath: url!))
self.webView.load(request) self.webView.load(request)
} }
......
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
<string>App需要访问麦克风,进行录音</string> <string>App需要访问麦克风,进行录音</string>
<key>NSSpeechRecognitionUsageDescription</key> <key>NSSpeechRecognitionUsageDescription</key>
<string>XXXXXXX</string> <string>XXXXXXX</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <string>LaunchScreen</string>
<key>UIMainStoryboardFile</key> <key>UIMainStoryboardFile</key>
......
...@@ -48,7 +48,17 @@ class SHMineViewController: SHBaseViewController { ...@@ -48,7 +48,17 @@ class SHMineViewController: SHBaseViewController {
} }
func getUserInfo(){ func getUserInfo(){
loginStatusLab.text = SHUserAccountManager.shared.userInfo!.phoneNo.length == 0 ? SHUserAccountManager.shared.userInfo!.phoneNo : " "
userNameLab.text = "用户ID:" + SHUserAccountManager.shared.userInfo!.uid
if SHUserAccountManager.shared.userInfo?.isMember == true{
lockBtn.isHidden = true
lockLab.text = "功能已解锁"
lockDetailsLab.text = "解锁全部功能"
}else {
lockBtn.isHidden = false
lockLab.text = "功能未解锁"
lockDetailsLab.text = "解锁使用更多服务"
}
} }
@objc func setting(){ @objc func setting(){
......
...@@ -57,12 +57,28 @@ extension SHSettingViewController:UITableViewDelegate, UITableViewDataSource{ ...@@ -57,12 +57,28 @@ extension SHSettingViewController:UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch indexPath.row { switch indexPath.row {
case 0: case 0:
let webView = SHWebViewController()
webView.url = SHUserAccountManager.shared.h5_urlDic["user"] as? String
webView.title = "用户协议"
self.navigationController?.pushViewController(webView, animated: true)
break break
case 1: case 1:
let webView = SHWebViewController()
webView.url = SHUserAccountManager.shared.h5_urlDic["privacy"] as? String
webView.title = "隐私政策"
self.navigationController?.pushViewController(webView, animated: true)
break break
case 2: case 2:
// let webView = SHWebViewController()
// webView.url = SHUserAccountManager.shared.h5_urlDic["user"] as? String
// webView.title = "付费用户协议"
// self.navigationController?.pushViewController(webView, animated: true)
break break
case 3: case 3:
let webView = SHWebViewController()
webView.url = SHUserAccountManager.shared.h5_urlDic["FeedBackuUrl"] as? String
webView.title = "联系客服"
self.navigationController?.pushViewController(webView, animated: true)
break break
default: default:
break break
......
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="r5a-Mv-IXk" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="r5a-Mv-IXk" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="978" y="123"/> <point key="canvasLocation" x="968" y="144"/>
</scene> </scene>
<!--Record Show View Controller--> <!--Record Show View Controller-->
<scene sceneID="sKQ-sR-22k"> <scene sceneID="sKQ-sR-22k">
...@@ -186,12 +186,6 @@ ...@@ -186,12 +186,6 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/> <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" usesAttributedText="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Q9t-zd-f7P">
<rect key="frame" x="0.0" y="44" width="414" height="658"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<attributedString key="attributedText"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GiR-He-K55"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GiR-He-K55">
<rect key="frame" x="0.0" y="702" width="414" height="160"/> <rect key="frame" x="0.0" y="702" width="414" height="160"/>
<subviews> <subviews>
...@@ -278,15 +272,22 @@ ...@@ -278,15 +272,22 @@
<constraint firstAttribute="trailing" secondItem="mFR-Oo-fNZ" secondAttribute="trailing" id="z14-j6-l2G"/> <constraint firstAttribute="trailing" secondItem="mFR-Oo-fNZ" secondAttribute="trailing" id="z14-j6-l2G"/>
</constraints> </constraints>
</view> </view>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="pPa-OG-ooa">
<rect key="frame" x="0.0" y="44" width="414" height="658"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="textColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews> </subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints> <constraints>
<constraint firstItem="GiR-He-K55" firstAttribute="top" secondItem="pPa-OG-ooa" secondAttribute="bottom" id="6Cn-ni-TXj"/>
<constraint firstItem="epv-5f-X7c" firstAttribute="bottom" secondItem="GiR-He-K55" secondAttribute="bottom" id="6oS-Kk-KUr"/> <constraint firstItem="epv-5f-X7c" firstAttribute="bottom" secondItem="GiR-He-K55" secondAttribute="bottom" id="6oS-Kk-KUr"/>
<constraint firstItem="epv-5f-X7c" firstAttribute="trailing" secondItem="pPa-OG-ooa" secondAttribute="trailing" id="M7h-5f-Fw0"/>
<constraint firstItem="pPa-OG-ooa" firstAttribute="top" secondItem="epv-5f-X7c" secondAttribute="top" id="Z2t-lB-LB6"/>
<constraint firstItem="epv-5f-X7c" firstAttribute="trailing" secondItem="GiR-He-K55" secondAttribute="trailing" id="ZtO-xK-Uvb"/> <constraint firstItem="epv-5f-X7c" firstAttribute="trailing" secondItem="GiR-He-K55" secondAttribute="trailing" id="ZtO-xK-Uvb"/>
<constraint firstItem="Q9t-zd-f7P" firstAttribute="top" secondItem="epv-5f-X7c" secondAttribute="top" id="Zzf-HX-zBO"/> <constraint firstItem="pPa-OG-ooa" firstAttribute="leading" secondItem="epv-5f-X7c" secondAttribute="leading" id="w7n-On-DOA"/>
<constraint firstItem="GiR-He-K55" firstAttribute="top" secondItem="Q9t-zd-f7P" secondAttribute="bottom" id="eJg-mT-xbe"/>
<constraint firstItem="epv-5f-X7c" firstAttribute="trailing" secondItem="Q9t-zd-f7P" secondAttribute="trailing" id="sbt-yW-lMW"/>
<constraint firstItem="Q9t-zd-f7P" firstAttribute="leading" secondItem="epv-5f-X7c" secondAttribute="leading" id="uFN-qn-S9g"/>
<constraint firstItem="GiR-He-K55" firstAttribute="leading" secondItem="epv-5f-X7c" secondAttribute="leading" id="za2-5x-x1h"/> <constraint firstItem="GiR-He-K55" firstAttribute="leading" secondItem="epv-5f-X7c" secondAttribute="leading" id="za2-5x-x1h"/>
</constraints> </constraints>
<viewLayoutGuide key="safeArea" id="epv-5f-X7c"/> <viewLayoutGuide key="safeArea" id="epv-5f-X7c"/>
...@@ -296,7 +297,7 @@ ...@@ -296,7 +297,7 @@
<outlet property="copyBtn" destination="USQ-ud-9iV" id="BBB-GX-Kav"/> <outlet property="copyBtn" destination="USQ-ud-9iV" id="BBB-GX-Kav"/>
<outlet property="playingTimeLab" destination="IzE-RZ-GuS" id="2cb-6o-2hc"/> <outlet property="playingTimeLab" destination="IzE-RZ-GuS" id="2cb-6o-2hc"/>
<outlet property="progress" destination="9Af-DH-jgW" id="UUC-v8-ORw"/> <outlet property="progress" destination="9Af-DH-jgW" id="UUC-v8-ORw"/>
<outlet property="recordTextView" destination="Q9t-zd-f7P" id="dgf-li-Mvu"/> <outlet property="recordTextView" destination="pPa-OG-ooa" id="O5P-zy-7nF"/>
<outlet property="recorderBtn" destination="yBJ-eO-4Dd" id="N74-6y-EgL"/> <outlet property="recorderBtn" destination="yBJ-eO-4Dd" id="N74-6y-EgL"/>
<outlet property="totalTimeLab" destination="ngv-W0-Sw4" id="Vax-Ac-WYI"/> <outlet property="totalTimeLab" destination="ngv-W0-Sw4" id="Vax-Ac-WYI"/>
<outlet property="transmitBtn" destination="L1c-iK-0ij" id="9Ap-tU-Wqr"/> <outlet property="transmitBtn" destination="L1c-iK-0ij" id="9Ap-tU-Wqr"/>
......
...@@ -92,7 +92,7 @@ class SHRecordShowViewController: SHBaseViewController { ...@@ -92,7 +92,7 @@ class SHRecordShowViewController: SHBaseViewController {
// 如果没有错误发生,或者 result 已经结束,停止audioEngine 录音,终止 recognitionRequest 和 recognitionTask // 如果没有错误发生,或者 result 已经结束,停止audioEngine 录音,终止 recognitionRequest 和 recognitionTask
if error != nil || isFinal { if error != nil || isFinal {
MBProgressHUD.showMessage("实时翻译终止,请查看原文记录", to: self.view)
} }
}) })
} }
...@@ -167,7 +167,10 @@ class SHRecordShowViewController: SHBaseViewController { ...@@ -167,7 +167,10 @@ class SHRecordShowViewController: SHBaseViewController {
} }
@objc func confirmCilck(){ @objc func confirmCilck(){
recognitionTask?.cancel()
// if player?.isPlaying == false{
recordTextView?.attributedText = self.textView_text(model!.txt)
// }
} }
@IBAction func playBtn(_ sender:UIButton){ @IBAction func playBtn(_ sender:UIButton){
...@@ -189,7 +192,7 @@ class SHRecordShowViewController: SHBaseViewController { ...@@ -189,7 +192,7 @@ class SHRecordShowViewController: SHBaseViewController {
let location: Int = model!.pathFile.distance(from: model!.pathFile.startIndex, to: range.lowerBound) let location: Int = model!.pathFile.distance(from: model!.pathFile.startIndex, to: range.lowerBound)
let subStr = model!.pathFile.prefix(location) let subStr = model!.pathFile.prefix(location)
let documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!+subStr+"/txt.pdf" let documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!+subStr+"/\(subStr).pdf"
try PDFGenerator.generate(self.recordTextView!, to: documentsFile) try PDFGenerator.generate(self.recordTextView!, to: documentsFile)
//此三方会把传入控件约束移除 需重新添加 //此三方会把传入控件约束移除 需重新添加
...@@ -272,6 +275,7 @@ class SHRecordShowViewController: SHBaseViewController { ...@@ -272,6 +275,7 @@ class SHRecordShowViewController: SHBaseViewController {
if self.model?.txt.length == 0 { if self.model?.txt.length == 0 {
return return
} }
MBProgressHUD.showMessage("文本已复制到剪切板", to: self.view)
let board = UIPasteboard.general let board = UIPasteboard.general
board.string = self.recordTextView?.text board.string = self.recordTextView?.text
} }
......
...@@ -199,19 +199,9 @@ class SHRecordViewController: SHBaseViewController { ...@@ -199,19 +199,9 @@ class SHRecordViewController: SHBaseViewController {
recorder?.pause() recorder?.pause()
start = false start = false
if self.recognitionTaskText.count == 0 {
self.recognitionTaskText.append((self.currentTxt ?? "") + "\n") recognitionTask?.cancel()
}else{
var s = ""
if let text = self.currentTxt, text.length > 0 {
s = self.recognitionTaskText.first! + text + "\n"
} else{
s = self.recognitionTaskText.first!
}
self.currentTxt = s
self.recognitionTaskText[0] = s
}
self.currentTxt = ""
speechStop() speechStop()
timerInvalidate() timerInvalidate()
} }
...@@ -529,6 +519,7 @@ extension SHRecordViewController{ ...@@ -529,6 +519,7 @@ extension SHRecordViewController{
if self.recordTextView?.text.length == 0 { if self.recordTextView?.text.length == 0 {
return return
} }
MBProgressHUD.showMessage("文本已复制到剪切板", to: self.view)
let board = UIPasteboard.general let board = UIPasteboard.general
board.string = self.recordTextView?.text board.string = self.recordTextView?.text
} }
...@@ -539,7 +530,7 @@ extension SHRecordViewController{ ...@@ -539,7 +530,7 @@ extension SHRecordViewController{
let location: Int = currentModel!.pathFile.distance(from: currentModel!.pathFile.startIndex, to: range.lowerBound) let location: Int = currentModel!.pathFile.distance(from: currentModel!.pathFile.startIndex, to: range.lowerBound)
let subStr = currentModel!.pathFile.prefix(location) let subStr = currentModel!.pathFile.prefix(location)
let documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!+subStr+"/txt.pdf" let documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!+subStr+"/\(subStr).pdf"
try PDFGenerator.generate(self.recordTextView!, to: documentsFile) try PDFGenerator.generate(self.recordTextView!, to: documentsFile)
//此三方会把传入控件约束移除 需重新添加 //此三方会把传入控件约束移除 需重新添加
......
// //
// CRPurchaseManager // SHStoreManager.swift
// CleanMaster
// //
// Created by Mazy on 2020/6/10. // Created by Mazy on 2020/8/20.
// Copyright © 2020 Mazy. All rights reserved. // Copyright © 2020 CleanMaster. All rights reserved.
// //
import UIKit import UIKit
import SwiftyStoreKit import SwiftyStoreKit
class CRPurchaseManager: NSObject { class SHStoreManager: NSObject {
@objc class func purchaseWithProductId(productId: String, inView: UIView, success: @escaping(()->Void) ,faliure: @escaping(()->Void)) { @objc class func purchaseWithProductId(productId: String, inView: UIView, success: @escaping(()->Void) ,faliure: @escaping(()->Void)) {
...@@ -21,9 +22,9 @@ class CRPurchaseManager: NSObject { ...@@ -21,9 +22,9 @@ class CRPurchaseManager: NSObject {
hud.hide(animated: true) hud.hide(animated: true)
switch result { switch result {
case .success(let product): case .success(let product):
print("Purchase Success: \(product.productId)") log("Purchase Success: \(product.productId)")
let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: "5618f2067bc64ba299fee95b3112e04b") let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: "a2495c6d266e43fea58fda6c49f12264")
let hud = MBProgressHUD.showAdded(to: inView, animated: true) let hud = MBProgressHUD.showAdded(to: inView, animated: true)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in
hud.hide(animated: true) hud.hide(animated: true)
...@@ -43,7 +44,9 @@ class CRPurchaseManager: NSObject { ...@@ -43,7 +44,9 @@ class CRPurchaseManager: NSObject {
if product.needsFinishTransaction { if product.needsFinishTransaction {
SwiftyStoreKit.finishTransaction(product.transaction) SwiftyStoreKit.finishTransaction(product.transaction)
} }
success() DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
success()
}
case .expired(let expiryDate, _): case .expired(let expiryDate, _):
MBProgressHUD.showError("订阅已过期,请重新获取", to: inView) MBProgressHUD.showError("订阅已过期,请重新获取", to: inView)
print("Product is expired since \(expiryDate)") print("Product is expired since \(expiryDate)")
...@@ -70,7 +73,7 @@ class CRPurchaseManager: NSObject { ...@@ -70,7 +73,7 @@ class CRPurchaseManager: NSObject {
print("productId transactionId receiptData: \(dict)") print("productId transactionId receiptData: \(dict)")
// TODO: 服务器验证 // TODO: 服务器验证
let innerHud = MBProgressHUD.showAdded(to: inView, animated: true) let innerHud = MBProgressHUD.showAdded(to: inView, animated: true)
CRNetworkingManager.shared.postRequestWithBody(withPath: .iosIPAVerifyReceipt, body: dict) { (json, error) in CMNetworkManager.shared.postRequestWithBody(withPath: .iosIPAVerifyReceipt, body: dict) { (json, error) in
innerHud.hide(animated: true) innerHud.hide(animated: true)
print("success----iosIPAVerifyReceipt-----------------\(json)------") print("success----iosIPAVerifyReceipt-----------------\(json)------")
...@@ -80,13 +83,14 @@ class CRPurchaseManager: NSObject { ...@@ -80,13 +83,14 @@ class CRPurchaseManager: NSObject {
SwiftyStoreKit.finishTransaction(product.transaction) SwiftyStoreKit.finishTransaction(product.transaction)
} }
print("Purchase Success: \(product.productId)") print("Purchase Success: \(product.productId)")
success() DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
success()
}
} else { } else {
MBProgressHUD.showError("未知错误,请联系客服") MBProgressHUD.showError("未知错误,请联系客服")
} }
} }
case .error(let error): case .error(let error):
faliure(); faliure();
hud.hide(animated: true); hud.hide(animated: true);
...@@ -107,16 +111,18 @@ class CRPurchaseManager: NSObject { ...@@ -107,16 +111,18 @@ class CRPurchaseManager: NSObject {
MBProgressHUD.showError("无法连接到网络") MBProgressHUD.showError("无法连接到网络")
print("Could not connect to the network") print("Could not connect to the network")
case .cloudServiceRevoked: print("User has revoked permission to use this cloud service") case .cloudServiceRevoked: print("User has revoked permission to use this cloud service")
default: print((error as NSError).localizedDescription) default:
print((error as NSError).localizedDescription)
MBProgressHUD.showError((error as NSError).localizedDescription)
} }
} }
} }
} }
/// 静态初始化 /// 静态初始化
@objc class func launchWithSwiftyStoreKit(success: @escaping(()->Void)) { @objc class func launchWithSwiftyStoreKit() {
SwiftyStoreKit.completeTransactions(atomically: false) { purchases in SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
let sortedResults = purchases.sorted { (purchase1, purchase2) -> Bool in let sortedResults = purchases.sorted { (purchase1, purchase2) -> Bool in
if let date1 = purchase1.transaction.transactionDate, let data2 = purchase2.transaction.transactionDate { if let date1 = purchase1.transaction.transactionDate, let data2 = purchase2.transaction.transactionDate {
...@@ -133,7 +139,7 @@ class CRPurchaseManager: NSObject { ...@@ -133,7 +139,7 @@ class CRPurchaseManager: NSObject {
let receiptString = receiptData?.base64EncodedString(options: []) ?? "" let receiptString = receiptData?.base64EncodedString(options: []) ?? ""
print("Purchase Success: \(purchase.productId.description) receiptString: \(receiptString)") print("Purchase Success: \(purchase.productId.description) receiptString: \(receiptString)")
// TODO: 服务器验证 // TODO: 服务器验证
// if purchase.needsFinishTransaction { // if purchase.needsFinishTransaction {
// let receiptData = SwiftyStoreKit.localReceiptData // let receiptData = SwiftyStoreKit.localReceiptData
...@@ -141,7 +147,7 @@ class CRPurchaseManager: NSObject { ...@@ -141,7 +147,7 @@ class CRPurchaseManager: NSObject {
let dict = ["productId": purchase.productId, "transactionId" : (purchase.transaction.transactionIdentifier ?? ""), "receiptData" : receiptString] let dict = ["productId": purchase.productId, "transactionId" : (purchase.transaction.transactionIdentifier ?? ""), "receiptData" : receiptString]
print("productId transactionId receiptData: \(dict)") print("productId transactionId receiptData: \(dict)")
// TODO: 服务器验证 // TODO: 服务器验证
CRNetworkingManager.shared.postRequestWithBody(withPath: .iosIPAVerifyReceipt, body: dict) { (json, error) in CMNetworkManager.shared.postRequestWithBody(withPath: .iosIPAVerifyReceipt, body: dict) { (json, error) in
print("success----iosIPAVerifyReceipt-----------------\(json)------") print("success----iosIPAVerifyReceipt-----------------\(json)------")
let result: Bool = json["result"]["data"]["status"].boolValue let result: Bool = json["result"]["data"]["status"].boolValue
...@@ -150,15 +156,14 @@ class CRPurchaseManager: NSObject { ...@@ -150,15 +156,14 @@ class CRPurchaseManager: NSObject {
SwiftyStoreKit.finishTransaction(purchase.transaction) SwiftyStoreKit.finishTransaction(purchase.transaction)
} }
print("Purchase Success: \(purchase.productId)") print("Purchase Success: \(purchase.productId)")
success()
} else { } else {
MBProgressHUD.showError("未知错误,请联系客服") // MBProgressHUD.showError("未知错误,请联系客服")
} }
} }
// } // }
// Unlock content // Unlock content
case .failed, .purchasing, .deferred: case .failed, .purchasing, .deferred:
break // do nothing break // do nothing
@unknown default: @unknown default:
break break
} }
...@@ -198,7 +203,7 @@ class CRPurchaseManager: NSObject { ...@@ -198,7 +203,7 @@ class CRPurchaseManager: NSObject {
} }
print("Restore sortedResults: \(sortedResults)") print("Restore sortedResults: \(sortedResults)")
if let purchase = sortedResults.last { if let purchase = sortedResults.last {
let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: "5618f2067bc64ba299fee95b3112e04b") let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: "a2495c6d266e43fea58fda6c49f12264")
let hud = MBProgressHUD.showAdded(to: UIApplication.shared.delegate!.window!!, animated: true) let hud = MBProgressHUD.showAdded(to: UIApplication.shared.delegate!.window!!, animated: true)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in
hud.hide(animated: true) hud.hide(animated: true)
......
// //
// CRAccountManager.swift // SHUserAccountManager.swift
// CallRecording // CallRecording
// //
// Created by Mazy on 2020/7/13. // Created by Mazy on 2020/7/13.
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
import Foundation import Foundation
import SwiftyJSON import SwiftyJSON
@objc class CRAccountManager: NSObject { @objc class SHUserAccountManager: NSObject {
/// singleton /// singleton
@objc static let shared = CRAccountManager() @objc static let shared = SHUserAccountManager()
/// private init for singleton /// private init for singleton
private override init() {} private override init() {}
...@@ -21,6 +21,10 @@ import SwiftyJSON ...@@ -21,6 +21,10 @@ import SwiftyJSON
@objc var userInfo: CRUserInfoModel? @objc var userInfo: CRUserInfoModel?
var h5_url: JSON = JSON.null var h5_url: JSON = JSON.null
var isPayfront: Bool = false
var isStartFront: Bool = false
var autoButtonText: String = ""
var threeDayText: String = ""
@objc var h5_urlDic : Dictionary<String, Any>{ @objc var h5_urlDic : Dictionary<String, Any>{
return h5_url.dictionary! return h5_url.dictionary!
...@@ -28,8 +32,6 @@ import SwiftyJSON ...@@ -28,8 +32,6 @@ import SwiftyJSON
var servicePhone: String? var servicePhone: String?
var isPayfront: Bool = false
@objc var isMember: Bool { @objc var isMember: Bool {
let dateFormatter = DateFormatter() let dateFormatter = DateFormatter()
...@@ -58,9 +60,9 @@ import SwiftyJSON ...@@ -58,9 +60,9 @@ import SwiftyJSON
func getUserInfo(_ success: @escaping((CRUserInfoModel)->Void), failure: @escaping ()->Void) { func getUserInfo(_ success: @escaping((CRUserInfoModel)->Void), failure: @escaping ()->Void) {
CRNetworkingManager.shared.postRequest(withPath: .touristLogin) { (json, error) in CMNetworkManager.shared.postRequest(withPath: .touristLogin) { (json, error) in
CRUserDefaults.accessToken = json["result"]["data"]["token"].stringValue CRUserDefaults.accessToken = json["result"]["data"]["token"].stringValue
CRNetworkingManager.shared.getRequest(withPath: .getUserInfo) { (json, error) in CMNetworkManager.shared.getRequest(withPath: .getUserInfo) { (json, error) in
if error == nil { if error == nil {
let infoModel = CRUserInfoModel(json: json["result"]["data"]) let infoModel = CRUserInfoModel(json: json["result"]["data"])
self.userInfo = infoModel self.userInfo = infoModel
...@@ -74,9 +76,21 @@ import SwiftyJSON ...@@ -74,9 +76,21 @@ import SwiftyJSON
} }
} }
func logCollectionWithAction(_ action: String) { func logCollection(with action: CMLogCollecAction, value: String = "") {
let params = ["event": "guazinovel", "action": action, "value": ""] let params = ["event": "guazinovel", "action": action.rawValue, "value": value]
CRNetworkingManager.shared.postLogRequest(withPath: .logCollection, parameters: params) { (json, error) in CMNetworkManager.shared.postLogRequest(withPath: .logCollection, parameters: params) { (json, error) in
} }
}
func getNovelInfo(_ success: @escaping((JSON)->Void)) {
CMNetworkManager.shared.getRequest(withPath: .novelInfo) { (result, error) in
if result["status"].intValue == 200 {
self.h5_url = result["result"]["data"]["h5_url"]
self.isStartFront = result["result"]["data"]["open1close0"]["isPayfront"].boolValue
self.autoButtonText = result["result"]["data"]["config"]["pay_button_text"].stringValue
self.threeDayText = result["result"]["data"]["config"]["pay_3day_txt"].stringValue
success(result["result"]["data"])
}
}
} }
} }
//
// CRAPIManager.swift
// CallRecording
//
// Created by Mazy on 2020/7/13.
// Copyright © 2020 Mazy. All rights reserved.
//
import Foundation
struct CRAPIManager {
#if DEBUG
static let baseUrl = "https://feedapitest.zhangxinhulian.com"
static let reportUrl = "http://reporttest.zhangxinhulian.com"
#else
static let baseUrl = "https://feedapi.zhangxinhulian.com"
static let reportUrl = "http://report.zhangxinhulian.com"
#endif
}
enum CRURLPath {
// 短信验证码相关接口
case sendCode
// 用户登陆
case login
case touristLogin
case logout
case getUserInfo
case userConifg
case novelInfo
case iosIPAVerifyReceipt
case callrecorder
case getIPAPayConfig
case logCollection
case resetTourist
case bindPhone
case other
var urlString: String {
switch self {
case .sendCode:
return "/app/v1/auth/sendCode"
case .login:
return "/app/v1/auth/phoneCodeLogin"
// /api/v1/autoLogin/{userTel}/{uuid}自动登陆
case .touristLogin:
return "/app/v1/auth/tourist-login"
///api/v1/logout/{userTel} 用户登出
case .logout:
return "/app/v1/auth/logout"
case .getIPAPayConfig:
return "/app/v1/location/user/pay-config"
///获取用户信息
case .getUserInfo:
return "/app/v1/location/user/info"
case .userConifg:
return "/app/v1/pa/user/config"
case .novelInfo:
return "/app/v1/novel/info"
case .iosIPAVerifyReceipt:
return "/app/v1/location/pay/ios-verify-receipt"
case .callrecorder:
return "/app/v1/callrecorder"
case .logCollection:
return "/logCollection/log/v1/userLogCollection"
case .resetTourist:
return "/app/v1/auth/resetTourist"
case .bindPhone:
return "/app/v2/user/bind-phone"
default:
return ""
}
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment