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

userinfo

parent 680731c3
......@@ -10,6 +10,9 @@
79DC3D2A364BA7FB577BAFB2 /* Pods_ShorthandMaster.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAE7010C13FC81DF2891ABE /* Pods_ShorthandMaster.framework */; };
A94D935224F7502700A886C0 /* SHRecordExportAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A94D935124F7502700A886C0 /* SHRecordExportAlertView.swift */; };
A94D935424F7503E00A886C0 /* SHRecordExportAlertView.xib in Resources */ = {isa = PBXBuildFile; fileRef = A94D935324F7503E00A886C0 /* SHRecordExportAlertView.xib */; };
A94D935724F7958500A886C0 /* SHStoreManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A94D935624F7958500A886C0 /* SHStoreManager.swift */; };
A94D935924F7969600A886C0 /* CMNetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A94D935824F7969600A886C0 /* CMNetworkManager.swift */; };
A94D935B24F7977400A886C0 /* PhoneSystemKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = A94D935A24F7977400A886C0 /* PhoneSystemKit.swift */; };
A950F5A824F36F55007AB63E /* SHRecordListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A950F5A724F36F55007AB63E /* SHRecordListViewController.swift */; };
A950F5AA24F3727A007AB63E /* SHRecordListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A950F5A924F3727A007AB63E /* SHRecordListCell.swift */; };
A950F5AC24F39EC1007AB63E /* SHRecordShowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A950F5AB24F39EC1007AB63E /* SHRecordShowViewController.swift */; };
......@@ -63,12 +66,9 @@
A95CDFE324E0EE1A0066DAE6 /* SHBaseTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFE224E0EE1A0066DAE6 /* SHBaseTabBarController.swift */; };
A95CDFE524E0EE4B0066DAE6 /* SHBaseNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFE424E0EE4B0066DAE6 /* SHBaseNavigationController.swift */; };
A95CDFE724E0EE7A0066DAE6 /* SHGuideViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFE624E0EE7A0066DAE6 /* SHGuideViewController.swift */; };
A95CE00724E0F42F0066DAE6 /* CRAccountManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFEE24E0F42E0066DAE6 /* CRAccountManager.swift */; };
A95CE00824E0F42F0066DAE6 /* CRPurchaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFEF24E0F42F0066DAE6 /* CRPurchaseManager.swift */; };
A95CE00724E0F42F0066DAE6 /* SHUserAccountManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFEE24E0F42E0066DAE6 /* SHUserAccountManager.swift */; };
A95CE00924E0F42F0066DAE6 /* CRContactTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFF024E0F42F0066DAE6 /* CRContactTools.swift */; };
A95CE00A24E0F42F0066DAE6 /* CRDateFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFF124E0F42F0066DAE6 /* CRDateFormatter.swift */; };
A95CE00B24E0F42F0066DAE6 /* CRAPIManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFF324E0F42F0066DAE6 /* CRAPIManager.swift */; };
A95CE00C24E0F42F0066DAE6 /* CRNetworkingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFF424E0F42F0066DAE6 /* CRNetworkingManager.swift */; };
A95CE00D24E0F42F0066DAE6 /* CRIAPProductModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFF624E0F42F0066DAE6 /* CRIAPProductModel.swift */; };
A95CE00E24E0F42F0066DAE6 /* CRUserInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFF724E0F42F0066DAE6 /* CRUserInfoModel.swift */; };
A95CE00F24E0F42F0066DAE6 /* AESCipher.m in Sources */ = {isa = PBXBuildFile; fileRef = A95CDFFA24E0F42F0066DAE6 /* AESCipher.m */; };
......@@ -104,6 +104,9 @@
64E548B725F65DFC619F8D08 /* Pods-ShorthandMaster.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ShorthandMaster.debug.xcconfig"; path = "Target Support Files/Pods-ShorthandMaster/Pods-ShorthandMaster.debug.xcconfig"; sourceTree = "<group>"; };
A94D935124F7502700A886C0 /* SHRecordExportAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHRecordExportAlertView.swift; sourceTree = "<group>"; };
A94D935324F7503E00A886C0 /* SHRecordExportAlertView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SHRecordExportAlertView.xib; sourceTree = "<group>"; };
A94D935624F7958500A886C0 /* SHStoreManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SHStoreManager.swift; sourceTree = "<group>"; };
A94D935824F7969600A886C0 /* CMNetworkManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CMNetworkManager.swift; sourceTree = "<group>"; };
A94D935A24F7977400A886C0 /* PhoneSystemKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhoneSystemKit.swift; sourceTree = "<group>"; };
A950F5A724F36F55007AB63E /* SHRecordListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHRecordListViewController.swift; sourceTree = "<group>"; };
A950F5A924F3727A007AB63E /* SHRecordListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHRecordListCell.swift; sourceTree = "<group>"; };
A950F5AB24F39EC1007AB63E /* SHRecordShowViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHRecordShowViewController.swift; sourceTree = "<group>"; };
......@@ -121,7 +124,7 @@
A95B3FCC24F50B2F00FABDD1 /* SHRecentDeleteCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHRecentDeleteCell.swift; sourceTree = "<group>"; };
A95B3FCF24F525AD00FABDD1 /* SwiftHoledView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftHoledView.swift; sourceTree = "<group>"; };
A95B3FD124F5261100FABDD1 /* SHRecordGuideView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SHRecordGuideView.swift; sourceTree = "<group>"; };
A95CDF6424E0E8B50066DAE6 /* ShorthandMaster.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShorthandMaster.app; sourceTree = BUILT_PRODUCTS_DIR; };
A95CDF6424E0E8B50066DAE6 /* 速记大师.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "速记大师.app"; sourceTree = BUILT_PRODUCTS_DIR; };
A95CDF6724E0E8B50066DAE6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
A95CDF6E24E0E8B50066DAE6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
A95CDF7024E0E8B80066DAE6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
......@@ -164,12 +167,9 @@
A95CDFE224E0EE1A0066DAE6 /* SHBaseTabBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SHBaseTabBarController.swift; sourceTree = "<group>"; };
A95CDFE424E0EE4B0066DAE6 /* SHBaseNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SHBaseNavigationController.swift; sourceTree = "<group>"; };
A95CDFE624E0EE7A0066DAE6 /* SHGuideViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SHGuideViewController.swift; sourceTree = "<group>"; };
A95CDFEE24E0F42E0066DAE6 /* CRAccountManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CRAccountManager.swift; sourceTree = "<group>"; };
A95CDFEF24E0F42F0066DAE6 /* CRPurchaseManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CRPurchaseManager.swift; sourceTree = "<group>"; };
A95CDFEE24E0F42E0066DAE6 /* SHUserAccountManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SHUserAccountManager.swift; sourceTree = "<group>"; };
A95CDFF024E0F42F0066DAE6 /* CRContactTools.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CRContactTools.swift; sourceTree = "<group>"; };
A95CDFF124E0F42F0066DAE6 /* CRDateFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CRDateFormatter.swift; sourceTree = "<group>"; };
A95CDFF324E0F42F0066DAE6 /* CRAPIManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CRAPIManager.swift; sourceTree = "<group>"; };
A95CDFF424E0F42F0066DAE6 /* CRNetworkingManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CRNetworkingManager.swift; sourceTree = "<group>"; };
A95CDFF624E0F42F0066DAE6 /* CRIAPProductModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CRIAPProductModel.swift; sourceTree = "<group>"; };
A95CDFF724E0F42F0066DAE6 /* CRUserInfoModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CRUserInfoModel.swift; sourceTree = "<group>"; };
A95CDFFA24E0F42F0066DAE6 /* AESCipher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AESCipher.m; sourceTree = "<group>"; };
......@@ -295,7 +295,7 @@
A95CDF6524E0E8B50066DAE6 /* Products */ = {
isa = PBXGroup;
children = (
A95CDF6424E0E8B50066DAE6 /* ShorthandMaster.app */,
A95CDF6424E0E8B50066DAE6 /* 速记大师.app */,
A95CDF7A24E0E8B80066DAE6 /* ShorthandMasterTests.xctest */,
A95CDF8524E0E8B80066DAE6 /* ShorthandMasterUITests.xctest */,
);
......@@ -417,8 +417,8 @@
A95CDFED24E0F42E0066DAE6 /* Managers */ = {
isa = PBXGroup;
children = (
A95CDFEE24E0F42E0066DAE6 /* CRAccountManager.swift */,
A95CDFEF24E0F42F0066DAE6 /* CRPurchaseManager.swift */,
A94D935624F7958500A886C0 /* SHStoreManager.swift */,
A95CDFEE24E0F42E0066DAE6 /* SHUserAccountManager.swift */,
A95CDFF024E0F42F0066DAE6 /* CRContactTools.swift */,
A95CDFF124E0F42F0066DAE6 /* CRDateFormatter.swift */,
);
......@@ -428,8 +428,8 @@
A95CDFF224E0F42F0066DAE6 /* Network */ = {
isa = PBXGroup;
children = (
A95CDFF324E0F42F0066DAE6 /* CRAPIManager.swift */,
A95CDFF424E0F42F0066DAE6 /* CRNetworkingManager.swift */,
A94D935A24F7977400A886C0 /* PhoneSystemKit.swift */,
A94D935824F7969600A886C0 /* CMNetworkManager.swift */,
);
path = Network;
sourceTree = "<group>";
......@@ -519,7 +519,7 @@
);
name = ShorthandMaster;
productName = ShorthandMaster;
productReference = A95CDF6424E0E8B50066DAE6 /* ShorthandMaster.app */;
productReference = A95CDF6424E0E8B50066DAE6 /* 速记大师.app */;
productType = "com.apple.product-type.application";
};
A95CDF7924E0E8B80066DAE6 /* ShorthandMasterTests */ = {
......@@ -690,12 +690,12 @@
A94D935224F7502700A886C0 /* SHRecordExportAlertView.swift in Sources */,
A95CE03824E17BAF0066DAE6 /* SHTimer.swift in Sources */,
A95CDFBF24E0EBF10066DAE6 /* UIWindow+Extension.swift in Sources */,
A95CE00B24E0F42F0066DAE6 /* CRAPIManager.swift in Sources */,
A95CDFE524E0EE4B0066DAE6 /* SHBaseNavigationController.swift in Sources */,
A95CDFDD24E0EBF10066DAE6 /* SwiftKeyChain.swift in Sources */,
A95CDFC224E0EBF10066DAE6 /* UIView+Extension.swift in Sources */,
A95CDFCD24E0EBF10066DAE6 /* UIView+Nib.swift in Sources */,
A95CE03A24E2AE6A0066DAE6 /* SHRecordModel.swift in Sources */,
A94D935724F7958500A886C0 /* SHStoreManager.swift in Sources */,
A95CE00E24E0F42F0066DAE6 /* CRUserInfoModel.swift in Sources */,
A95CDFD824E0EBF10066DAE6 /* CRLaunchGuideCell_1.swift in Sources */,
A95CDFC324E0EBF10066DAE6 /* UIImage+Extension.swift in Sources */,
......@@ -715,29 +715,29 @@
A95CDFD924E0EBF10066DAE6 /* iPhoneSystemKit.swift in Sources */,
A95CDF6824E0E8B50066DAE6 /* AppDelegate.swift in Sources */,
A95CDFC924E0EBF10066DAE6 /* UINavigationBar+Extension.swift in Sources */,
A95CE00724E0F42F0066DAE6 /* CRAccountManager.swift in Sources */,
A95CE00724E0F42F0066DAE6 /* SHUserAccountManager.swift in Sources */,
A95CDFBE24E0EBF10066DAE6 /* UIColor+Extension.swift in Sources */,
A95CE00A24E0F42F0066DAE6 /* CRDateFormatter.swift in Sources */,
A95CDFC024E0EBF10066DAE6 /* Date+Extension.swift in Sources */,
A95CDFC424E0EBF10066DAE6 /* Double+Extension.swift in Sources */,
A95CDFD424E0EBF10066DAE6 /* CRMemberIAPViewController.swift in Sources */,
A95CE00824E0F42F0066DAE6 /* CRPurchaseManager.swift in Sources */,
A95B3FCD24F50B2F00FABDD1 /* SHRecentDeleteCell.swift in Sources */,
A95CDFE724E0EE7A0066DAE6 /* SHGuideViewController.swift in Sources */,
A950F5AC24F39EC1007AB63E /* SHRecordShowViewController.swift in Sources */,
A950F5BC24F4E66B007AB63E /* PopBaseView.swift in Sources */,
A95CDFC824E0EBF10066DAE6 /* UITabBar+Extension.swift in Sources */,
A95CDFC124E0EBF10066DAE6 /* UIButton+Extension.swift in Sources */,
A94D935B24F7977400A886C0 /* PhoneSystemKit.swift in Sources */,
A95CDFDC24E0EBF10066DAE6 /* CRConstants.swift in Sources */,
A95CE00F24E0F42F0066DAE6 /* AESCipher.m in Sources */,
A950F5AF24F4E06E007AB63E /* SHMineViewController.swift in Sources */,
A95CE02F24E151340066DAE6 /* UIButton+Category.m in Sources */,
A94D935924F7969600A886C0 /* CMNetworkManager.swift in Sources */,
A95CE03624E1729B0066DAE6 /* SHRecordWaveView.swift in Sources */,
A950F5AA24F3727A007AB63E /* SHRecordListCell.swift in Sources */,
A95CDFC524E0EBF10066DAE6 /* UIView+Frame.swift in Sources */,
A95CDFDB24E0EBF10066DAE6 /* CRUserDefaults.swift in Sources */,
A95CDFD724E0EBF10066DAE6 /* CRGuideCollectionViewCell.swift in Sources */,
A95CE00C24E0F42F0066DAE6 /* CRNetworkingManager.swift in Sources */,
A95B3FCB24F507A900FABDD1 /* SHDeleteDetailsViewController.swift in Sources */,
A95B3FD024F525AD00FABDD1 /* SwiftHoledView.swift in Sources */,
A95B3FC924F502DD00FABDD1 /* SHSettingViewController.swift in Sources */,
......@@ -925,8 +925,9 @@
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = SH.ShorthandMaster;
PRODUCT_NAME = "$(TARGET_NAME)";
PRODUCT_NAME = "速记大师";
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/ShorthandMaster/ShorthandMaster-Bridging-Header.h";
SWIFT_OBJC_INTERFACE_HEADER_NAME = "ShorthandMaster-Swift.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
......@@ -947,8 +948,9 @@
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = SH.ShorthandMaster;
PRODUCT_NAME = "$(TARGET_NAME)";
PRODUCT_NAME = "速记大师";
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/ShorthandMaster/ShorthandMaster-Bridging-Header.h";
SWIFT_OBJC_INTERFACE_HEADER_NAME = "ShorthandMaster-Swift.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
......
......@@ -16,6 +16,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// 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?.rootViewController = SHBaseTabBarController()
......
......@@ -58,7 +58,7 @@ class CRMemberIAPViewController: UIViewController {
}
private func getGoodsList() {
// CRNetworkingManager.shared.getRequest(withPath: .getIPAPayConfig) { (json, error) in
// CMNetworkManager.shared.getRequest(withPath: .getIPAPayConfig) { (json, error) in
// guard error == nil else { return }
// let goodsList = json["result"]["data"]["goodsList"].arrayValue.map({ CRIAPProductModel(json: $0) })
//
......@@ -152,14 +152,14 @@ class CRMemberIAPViewController: UIViewController {
@IBAction func userTermsAction() {
let webVc = SHWebViewController()
webVc.title = "使用条款"
// webVc.url = CRAccountManager.shared.h5_url["user"].stringValue
// webVc.url = SHUserAccountManager.shared.h5_url["user"].stringValue
self.navigationController?.pushViewController(webVc, animated: true)
}
@IBAction func privacyPolicyAction() {
let webVc = SHWebViewController()
webVc.title = "隐私政策"
// webVc.url = CRAccountManager.shared.h5_url["privacy"].stringValue
// webVc.url = SHUserAccountManager.shared.h5_url["privacy"].stringValue
self.navigationController?.pushViewController(webVc, animated: true)
}
......@@ -180,7 +180,7 @@ class CRMemberIAPViewController: UIViewController {
// }
// CRPurchaseManager.purchaseWithProductId(productId: productId, inView: self.view, success: {
// CRAccountManager.shared.getUserInfo({ (model) in
// SHUserAccountManager.shared.getUserInfo({ (model) in
// self.dismiss(animated: true, completion: nil)
// }, failure: {
// self.dismiss(animated: true, completion: nil)
......@@ -193,7 +193,7 @@ class CRMemberIAPViewController: UIViewController {
// 恢复购买
@IBAction func restoreAction(_ sender: UIButton) {
// CRPurchaseManager.restorePurchases(success: {
// CRAccountManager.shared.getUserInfo({ (model) in
// SHUserAccountManager.shared.getUserInfo({ (model) in
// self.navigationController?.dismiss(animated: true, completion: nil)
// }, failure: {
// self.navigationController?.dismiss(animated: true, completion: nil)
......
......@@ -40,7 +40,7 @@ class SHGuideViewController: UIViewController {
@objc private func maskBtnClick(_ sender:UIButton){
let webView = SHWebViewController()
webView.title = "隐私政策"
webView.url = CRAccountManager.shared.h5_url["privacy"].stringValue
webView.url = SHUserAccountManager.shared.h5_url["privacy"].stringValue
let nav = SHBaseNavigationController.init(rootViewController: webView)
self.present(nav, animated: true, completion: nil)
......
......@@ -21,10 +21,10 @@ class SHWebViewController: SHBaseViewController {
setupViews()
// guard let urlString = url, let URL = URL(string: urlString) else { return }
// let request = URLRequest(url: URL)
guard let urlString = url, let URL = URL(string: urlString) else { return }
let request = URLRequest(url: URL)
let request = URLRequest(url: URL(fileURLWithPath: url!))
// let request = URLRequest(url: URL(fileURLWithPath: url!))
self.webView.load(request)
}
......
......@@ -24,6 +24,10 @@
<string>App需要访问麦克风,进行录音</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>XXXXXXX</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
......
......@@ -48,7 +48,17 @@ class SHMineViewController: SHBaseViewController {
}
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(){
......
......@@ -57,12 +57,28 @@ extension SHSettingViewController:UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch indexPath.row {
case 0:
let webView = SHWebViewController()
webView.url = SHUserAccountManager.shared.h5_urlDic["user"] as? String
webView.title = "用户协议"
self.navigationController?.pushViewController(webView, animated: true)
break
case 1:
let webView = SHWebViewController()
webView.url = SHUserAccountManager.shared.h5_urlDic["privacy"] as? String
webView.title = "隐私政策"
self.navigationController?.pushViewController(webView, animated: true)
break
case 2:
// let webView = SHWebViewController()
// webView.url = SHUserAccountManager.shared.h5_urlDic["user"] as? String
// webView.title = "付费用户协议"
// self.navigationController?.pushViewController(webView, animated: true)
break
case 3:
let webView = SHWebViewController()
webView.url = SHUserAccountManager.shared.h5_urlDic["FeedBackuUrl"] as? String
webView.title = "联系客服"
self.navigationController?.pushViewController(webView, animated: true)
break
default:
break
......
......@@ -176,7 +176,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="r5a-Mv-IXk" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="978" y="123"/>
<point key="canvasLocation" x="968" y="144"/>
</scene>
<!--Record Show View Controller-->
<scene sceneID="sKQ-sR-22k">
......@@ -186,12 +186,6 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<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">
<rect key="frame" x="0.0" y="702" width="414" height="160"/>
<subviews>
......@@ -278,15 +272,22 @@
<constraint firstAttribute="trailing" secondItem="mFR-Oo-fNZ" secondAttribute="trailing" id="z14-j6-l2G"/>
</constraints>
</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>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<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="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="Q9t-zd-f7P" firstAttribute="top" secondItem="epv-5f-X7c" secondAttribute="top" id="Zzf-HX-zBO"/>
<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="pPa-OG-ooa" firstAttribute="leading" secondItem="epv-5f-X7c" secondAttribute="leading" id="w7n-On-DOA"/>
<constraint firstItem="GiR-He-K55" firstAttribute="leading" secondItem="epv-5f-X7c" secondAttribute="leading" id="za2-5x-x1h"/>
</constraints>
<viewLayoutGuide key="safeArea" id="epv-5f-X7c"/>
......@@ -296,7 +297,7 @@
<outlet property="copyBtn" destination="USQ-ud-9iV" id="BBB-GX-Kav"/>
<outlet property="playingTimeLab" destination="IzE-RZ-GuS" id="2cb-6o-2hc"/>
<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="totalTimeLab" destination="ngv-W0-Sw4" id="Vax-Ac-WYI"/>
<outlet property="transmitBtn" destination="L1c-iK-0ij" id="9Ap-tU-Wqr"/>
......
......@@ -92,7 +92,7 @@ class SHRecordShowViewController: SHBaseViewController {
// 如果没有错误发生,或者 result 已经结束,停止audioEngine 录音,终止 recognitionRequest 和 recognitionTask
if error != nil || isFinal {
MBProgressHUD.showMessage("实时翻译终止,请查看原文记录", to: self.view)
}
})
}
......@@ -167,7 +167,10 @@ class SHRecordShowViewController: SHBaseViewController {
}
@objc func confirmCilck(){
recognitionTask?.cancel()
// if player?.isPlaying == false{
recordTextView?.attributedText = self.textView_text(model!.txt)
// }
}
@IBAction func playBtn(_ sender:UIButton){
......@@ -189,7 +192,7 @@ class SHRecordShowViewController: SHBaseViewController {
let location: Int = model!.pathFile.distance(from: model!.pathFile.startIndex, to: range.lowerBound)
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)
//此三方会把传入控件约束移除 需重新添加
......@@ -272,6 +275,7 @@ class SHRecordShowViewController: SHBaseViewController {
if self.model?.txt.length == 0 {
return
}
MBProgressHUD.showMessage("文本已复制到剪切板", to: self.view)
let board = UIPasteboard.general
board.string = self.recordTextView?.text
}
......
......@@ -199,19 +199,9 @@ class SHRecordViewController: SHBaseViewController {
recorder?.pause()
start = false
if self.recognitionTaskText.count == 0 {
self.recognitionTaskText.append((self.currentTxt ?? "") + "\n")
}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 = ""
recognitionTask?.cancel()
speechStop()
timerInvalidate()
}
......@@ -529,6 +519,7 @@ extension SHRecordViewController{
if self.recordTextView?.text.length == 0 {
return
}
MBProgressHUD.showMessage("文本已复制到剪切板", to: self.view)
let board = UIPasteboard.general
board.string = self.recordTextView?.text
}
......@@ -539,7 +530,7 @@ extension SHRecordViewController{
let location: Int = currentModel!.pathFile.distance(from: currentModel!.pathFile.startIndex, to: range.lowerBound)
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)
//此三方会把传入控件约束移除 需重新添加
......
//
// CRPurchaseManager
// SHStoreManager.swift
// CleanMaster
//
// Created by Mazy on 2020/6/10.
// Copyright © 2020 Mazy. All rights reserved.
// Created by Mazy on 2020/8/20.
// Copyright © 2020 CleanMaster. All rights reserved.
//
import UIKit
import SwiftyStoreKit
class CRPurchaseManager: NSObject {
class SHStoreManager: NSObject {
@objc class func purchaseWithProductId(productId: String, inView: UIView, success: @escaping(()->Void) ,faliure: @escaping(()->Void)) {
......@@ -21,9 +22,9 @@ class CRPurchaseManager: NSObject {
hud.hide(animated: true)
switch result {
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)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in
hud.hide(animated: true)
......@@ -43,7 +44,9 @@ class CRPurchaseManager: NSObject {
if product.needsFinishTransaction {
SwiftyStoreKit.finishTransaction(product.transaction)
}
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
success()
}
case .expired(let expiryDate, _):
MBProgressHUD.showError("订阅已过期,请重新获取", to: inView)
print("Product is expired since \(expiryDate)")
......@@ -70,7 +73,7 @@ class CRPurchaseManager: NSObject {
print("productId transactionId receiptData: \(dict)")
// TODO: 服务器验证
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)
print("success----iosIPAVerifyReceipt-----------------\(json)------")
......@@ -80,13 +83,14 @@ class CRPurchaseManager: NSObject {
SwiftyStoreKit.finishTransaction(product.transaction)
}
print("Purchase Success: \(product.productId)")
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
success()
}
} else {
MBProgressHUD.showError("未知错误,请联系客服")
}
}
case .error(let error):
faliure();
hud.hide(animated: true);
......@@ -107,16 +111,18 @@ class CRPurchaseManager: NSObject {
MBProgressHUD.showError("无法连接到网络")
print("Could not connect to the network")
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
if let date1 = purchase1.transaction.transactionDate, let data2 = purchase2.transaction.transactionDate {
......@@ -141,7 +147,7 @@ class CRPurchaseManager: NSObject {
let dict = ["productId": purchase.productId, "transactionId" : (purchase.transaction.transactionIdentifier ?? ""), "receiptData" : receiptString]
print("productId transactionId receiptData: \(dict)")
// 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)------")
let result: Bool = json["result"]["data"]["status"].boolValue
......@@ -150,9 +156,8 @@ class CRPurchaseManager: NSObject {
SwiftyStoreKit.finishTransaction(purchase.transaction)
}
print("Purchase Success: \(purchase.productId)")
success()
} else {
MBProgressHUD.showError("未知错误,请联系客服")
// MBProgressHUD.showError("未知错误,请联系客服")
}
}
// }
......@@ -198,7 +203,7 @@ class CRPurchaseManager: NSObject {
}
print("Restore sortedResults: \(sortedResults)")
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)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in
hud.hide(animated: true)
......
//
// CRAccountManager.swift
// SHUserAccountManager.swift
// CallRecording
//
// Created by Mazy on 2020/7/13.
......@@ -9,10 +9,10 @@
import Foundation
import SwiftyJSON
@objc class CRAccountManager: NSObject {
@objc class SHUserAccountManager: NSObject {
/// singleton
@objc static let shared = CRAccountManager()
@objc static let shared = SHUserAccountManager()
/// private init for singleton
private override init() {}
......@@ -21,6 +21,10 @@ import SwiftyJSON
@objc var userInfo: CRUserInfoModel?
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>{
return h5_url.dictionary!
......@@ -28,8 +32,6 @@ import SwiftyJSON
var servicePhone: String?
var isPayfront: Bool = false
@objc var isMember: Bool {
let dateFormatter = DateFormatter()
......@@ -58,9 +60,9 @@ import SwiftyJSON
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
CRNetworkingManager.shared.getRequest(withPath: .getUserInfo) { (json, error) in
CMNetworkManager.shared.getRequest(withPath: .getUserInfo) { (json, error) in
if error == nil {
let infoModel = CRUserInfoModel(json: json["result"]["data"])
self.userInfo = infoModel
......@@ -74,9 +76,21 @@ import SwiftyJSON
}
}
func logCollectionWithAction(_ action: String) {
let params = ["event": "guazinovel", "action": action, "value": ""]
CRNetworkingManager.shared.postLogRequest(withPath: .logCollection, parameters: params) { (json, error) in
func logCollection(with action: CMLogCollecAction, value: String = "") {
let params = ["event": "guazinovel", "action": action.rawValue, "value": value]
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"])
}
}
}
}
//
// CRNetworkingManager.swift
// CallRecording
// CMNetworkManager.swift
//
// Created by Mazy on 2020/7/13.
// Copyright © 2020 Mazy. All rights reserved.
//
// Created by apple on 2020/7/22.
// Copyright © 2020 Safety. All rights reserved.
//
import Alamofire
......@@ -11,10 +11,72 @@ import Foundation
import SwiftyJSON
import AdSupport
enum CMLogCollecAction: String {
case appStart = "app_start"
case tabImp = "tab_imp"
}
struct CMAPIManager {
#if DEBUG
static let baseUrl = "https://feedapitest.zhangxinhulian.com"
static let reportUrl = "http://reporttest.zhangxinhulian.com"
#else
static let baseUrl = "https://feedapi.seedsnovel.com"
static let reportUrl = "http://report.seedsnovel.com"
#endif
}
enum CMURLPath {
case touristLogin
case logout(String)
case getUserInfo
case userConifg
case novelInfo
case iosIPAVerifyReceipt
case getIPAPayConfig
case logCollection
case other
var urlString: String {
switch self {
// /api/v1/autoLogin/{userTel}/{uuid}自动登陆
case .touristLogin:
return "/app/v1/auth/tourist-login"
///api/v1/logout/{userTel} 用户登出
case .logout:
return "/api/v1/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 .logCollection:
return "/logCollection/log/v1/userLogCollection"
default:
return ""
}
}
}
private let TIMEOUT_INTERVAL_FOR_REQUEST: TimeInterval = 10
private let TIMEOUT_INTERVAL_FOR_RESOURCE: TimeInterval = 15
struct CRNetworkingError: Error {
struct CMNetworkingError: Error {
let code: Int
let msg: String?
......@@ -30,13 +92,13 @@ struct CRNetworkingError: Error {
}
}
typealias CRJSONCompletionHandler = (_ json: JSON, _ error: CRNetworkingError?) -> ()
typealias CRJSONPageCompletionHandler = (_ json: JSON,_ cursor: String?, _ error: CRNetworkingError?) -> ()
typealias CRNetworkingErrorHandler = (CRNetworkingError?) -> ()
typealias CMJSONCompletionHandler = (_ json: JSON, _ error: CMNetworkingError?) -> ()
typealias CMJSONPageCompletionHandler = (_ json: JSON,_ cursor: String?, _ error: CMNetworkingError?) -> ()
typealias CMNetworkingErrorHandler = (CMNetworkingError?) -> ()
class CRNetworkingManager {
class CMNetworkManager {
static let shared = CRNetworkingManager()
static let shared = CMNetworkManager()
private let sessionManager: SessionManager
......@@ -49,23 +111,16 @@ class CRNetworkingManager {
sessionManager = Alamofire.SessionManager(configuration: configuration)
}
func getRequest(withPath: CRURLPath, parameters: [String: Any]? = nil, headers: [String: String]? = nil, responseQueue: DispatchQueue? = nil, completionHandler: @escaping CRJSONCompletionHandler) {
func getRequest(withPath: CMURLPath, parameters: [String: Any]? = nil, headers: [String: String]? = nil, responseQueue: DispatchQueue? = nil, completionHandler: @escaping CMJSONCompletionHandler) {
var params = parameters ?? [:]
setHTTPParams(with: &params)
log(params)
// var pathWithParams: String = withPath.urlString
// let paramsString = (params.compactMap { (key, value) -> String in
// return "\(key)=\(value)"
// } as Array).joined(separator: "&")
// pathWithParams += ("?" + paramsString)
self.request(withPath: withPath.urlString, method: .get, parameters: params, encoding: URLEncoding.default, headers: headers, responseQueue: responseQueue, completionHandler: completionHandler)
}
func postRequest(withPath: CRURLPath, parameters: [String: Any]? = nil, headers: [String: String]? = nil, responseQueue: DispatchQueue? = nil, completionHandler: @escaping CRJSONCompletionHandler) {
func postRequest(withPath: CMURLPath, parameters: [String: Any]? = nil, headers: [String: String]? = nil, responseQueue: DispatchQueue? = nil, completionHandler: @escaping CMJSONCompletionHandler) {
var pathWithParams: String = withPath.urlString
......@@ -80,11 +135,11 @@ class CRNetworkingManager {
self.request(withPath: pathWithParams, method: .post, parameters: nil, headers: headers, responseQueue: responseQueue, completionHandler: completionHandler)
}
// 内购校验
func postRequestWithBody(withPath: CRURLPath, body: [String: String], parameters: [String: Any]? = nil, headers: [String: String]? = nil, responseQueue: DispatchQueue? = nil, completionHandler: @escaping CRJSONCompletionHandler) {
func postLogRequest(withPath: CMURLPath, parameters: [String: Any]?, headers: [String: String]? = nil, responseQueue: DispatchQueue? = nil, completionHandler: @escaping CMJSONCompletionHandler) {
var pathWithParams: String = CRAPIManager.baseUrl + withPath.urlString
var params = parameters ?? [:]
var pathWithParams: String = CMAPIManager.reportUrl + withPath.urlString
var params: [String: Any] = [:]
setHTTPParams(with: &params)
log(params)
let paramsString = (params.compactMap { (key, value) -> String in
......@@ -97,16 +152,18 @@ class CRNetworkingManager {
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.httpMethod = "POST"
request.timeoutInterval = 10
do {
// convert the JSON to raw NSData
let jsonString = JSON(body)
let rawData = try jsonString.rawData()
request.httpBody = rawData
} catch {
print("Error --- \(error)")
let json = JSON(parameters ?? [:])
let jsonString = json.rawString(.utf8, options: JSONSerialization.WritingOptions.fragmentsAllowed) ?? ""
let encryptStr = aesEncryptString(jsonString, aesKey) ?? ""
if let bb = try? JSONSerialization.data(withJSONObject: encryptStr, options: JSONSerialization.WritingOptions.fragmentsAllowed) {
request.httpBody = bb
}
log("ZJAESCommonDecrypt--\(encryptStr)-成功了 \(String(describing: aesDecryptString(encryptStr, aesKey)))");
sessionManager.request(request).responseJSON { (response) in
log(response)
switch response.result {
......@@ -118,67 +175,53 @@ class CRNetworkingManager {
}
case .failure(let error):
logError(error)
let err = CRNetworkingError(code: error._code, msg: error.localizedDescription)
let err = CMNetworkingError(code: error._code, msg: error.localizedDescription)
completionHandler(JSON.null, err)
}
}
}
func uploadRequest(withPath: CRURLPath, type: Int, parameters: [String: UIImage], headers: [String: String]? = nil, completionHandler: @escaping CRJSONCompletionHandler) {
self.upload(withPath: CRAPIManager.baseUrl + withPath.urlString, type: type, method: .post, parameters: parameters, completionHandler: completionHandler)
}
func postRequestWithBody(withPath: CMURLPath, body: [String: String], parameters: [String: Any]? = nil, headers: [String: String]? = nil, responseQueue: DispatchQueue? = nil, completionHandler: @escaping CMJSONCompletionHandler) {
/// upload
///
/// - Parameters:
/// - withPath: withPath description
/// - method: method description
/// - parameters: parameters description
/// - encoding: encoding description
/// - headers: headers description
/// - responseQueue: responseQueue description
/// - completionHandler: completionHandler description
private func upload(withPath: String, type: Int, method: HTTPMethod, parameters: [String : UIImage], headers: [String: String]? = nil, completionHandler: @escaping CRJSONCompletionHandler) {
// set header
var headers = headers ?? [:]
headers["Content-type"] = "multipart/form-data"
var pathWithParams: String = CMAPIManager.baseUrl + withPath.urlString
var params = parameters ?? [:]
setHTTPParams(with: &params)
log(params)
let paramsString = (params.compactMap { (key, value) -> String in
return "\(key)=\(value)"
} as Array).joined(separator: "&")
pathWithParams += ("?" + paramsString)
// header里要加一个language 语言类型 0中文,1英文,2日语,3韩语
var request = URLRequest(url: URL(string: pathWithParams)!)
sessionManager.upload(multipartFormData: { (multipartFormData) in
multipartFormData.append("\(type)".toData()!, withName: "type")
for (key, value) in parameters {
if let imageData = value.pngData() {
multipartFormData.append(imageData, withName: "file", fileName: key + ".png", mimeType: "image/png")
}
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.httpMethod = "POST"
do {
// convert the JSON to raw NSData
let jsonString = JSON(body)
let rawData = try jsonString.rawData()
request.httpBody = rawData
} catch {
print("Error --- \(error)")
}
}, to: withPath, method: method, headers: headers) { (result) in
switch result {
case .success(let upload, _, _):
upload.responseJSON(completionHandler: { (response) in
print("Succesfully uploaded")
print(response)
sessionManager.request(request).responseJSON { (response) in
log(response)
switch response.result {
case .success(let value):
logWarning(value)
let jsonValue = JSON(value)
if jsonValue["status"].intValue != 0 {
let msg = jsonValue["msg"].stringValue
if msg.count > 0 {
// App.mainWindow.makeToast(msg)
}
}
if jsonValue["status"].intValue == 200 {
completionHandler(jsonValue, nil)
}
case .failure(let error):
logError(error)
let err = CRNetworkingError(code: error._code, msg: error.localizedDescription)
let err = CMNetworkingError(code: error._code, msg: error.localizedDescription)
completionHandler(JSON.null, err)
}
})
case .failure(let error):
print("Error in upload: \(error.localizedDescription)")
}
}
}
/// get post delete
......@@ -191,16 +234,11 @@ class CRNetworkingManager {
/// - headers: headers description
/// - responseQueue: responseQueue description
/// - completionHandler: completionHandler description
private func request(withPath: String, method: HTTPMethod, parameters: [String: Any]?, encoding: ParameterEncoding = JSONEncoding.default, headers: [String: String]? = nil, responseQueue: DispatchQueue? = nil, completionHandler: @escaping CRJSONCompletionHandler) {
private func request(withPath: String, method: HTTPMethod, parameters: [String: Any]?, encoding: ParameterEncoding = JSONEncoding.default, headers: [String: String]? = nil, responseQueue: DispatchQueue? = nil, completionHandler: @escaping CMJSONCompletionHandler) {
// set header
let headers = headers ?? [:]
// if let sessionKey = CRAccountManager.shared.userInfo?.token {
// headers["Authorization"] = sessionKey
// headers["Content-Type"] = "application/json"
// }
let pathWithParams: String = CRAPIManager.baseUrl + withPath
let pathWithParams: String = CMAPIManager.baseUrl + withPath
logWarning(pathWithParams)
sessionManager.request(pathWithParams, method: method, parameters: parameters, encoding: encoding, headers: headers).responseJSON { (response) in
switch response.result {
......@@ -209,89 +247,39 @@ class CRNetworkingManager {
let jsonValue = JSON(value)
if jsonValue["status"].intValue == 200 { //token过期 自动登录
completionHandler(jsonValue, nil)
} else {
completionHandler(jsonValue, nil)
}
case .failure(let error):
logError(error)
let err = CRNetworkingError(code: error._code, msg: error.localizedDescription)
let err = CMNetworkingError(code: error._code, msg: error.localizedDescription)
completionHandler(JSON.null, err)
}
}
}
func postLogRequest(withPath: CRURLPath, parameters: [String: Any]?, headers: [String: String]? = nil, responseQueue: DispatchQueue? = nil, completionHandler: @escaping CRJSONCompletionHandler) {
var pathWithParams: String = CRAPIManager.reportUrl + withPath.urlString
var params: [String: Any] = [:]
setHTTPParams(with: &params)
log(params)
let paramsString = (params.compactMap { (key, value) -> String in
return "\(key)=\(value)"
} as Array).joined(separator: "&")
pathWithParams += ("?" + paramsString)
var request = URLRequest(url: URL(string: pathWithParams)!)
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.httpMethod = "POST"
request.timeoutInterval = 10
// convert the JSON to raw NSData
let json = JSON(parameters ?? [:])
let jsonString = json.rawString(.utf8, options: JSONSerialization.WritingOptions.fragmentsAllowed) ?? ""
let encryptStr = aesEncryptString(jsonString, aesKey) ?? ""
if let aaa = try? JSONSerialization.data(withJSONObject: encryptStr, options: JSONSerialization.WritingOptions.fragmentsAllowed) {
request.httpBody = aaa
// print(try? JSONSerialization.jsonObject(with: aaa, options: JSONSerialization.ReadingOptions.fragmentsAllowed))
}
log("ZJAESCommonDecrypt--\(encryptStr)-成功了 \(String(describing: aesDecryptString(encryptStr, aesKey)))");
sessionManager.request(request).responseJSON { (response) in
log(response)
switch response.result {
case .success(let value):
logWarning(value)
let jsonValue = JSON(value)
if jsonValue["status"].intValue == 200 {
completionHandler(jsonValue, nil)
}
case .failure(let error):
logError(error)
let err = CRNetworkingError(code: error._code, msg: error.localizedDescription)
completionHandler(JSON.null, err)
}
}
}
}
private extension CRNetworkingManager {
private extension CMNetworkManager {
/// set params
func setHTTPParams(with params: inout [String: Any]) {
params["w"] = "\(UIScreen.main.bounds.width)"
params["h"] = "\(UIScreen.main.bounds.height)"
params["model"] = iPhoneSystemKit.deviceName().replacingOccurrences(of: " ", with: "-")
params["w"] = String(format: "%.0f", UIScreen.main.bounds.width)
params["h"] = String(format: "%.0f", UIScreen.main.bounds.height)
params["model"] = UIDevice.current.model
params["vc"] = UIDevice.appVersion
params["platform"] = "ios"
params["pkg"] = "com.iosapp.callrecorder"
params["device"] = SwiftKeyChain.getKeyChainUUID()
params["ts"] = Date().milliStamp
params["appLs"] = "7ccb3b974f02787b"
params["pkg"] = "com.cleanerteam.cleanmaster"
params["appLs"] = "8428c6c2ce7b8b68"
params["source"] = "AppStore"
params["module"] = "behavior"
params["ua"] = "Safari"
params["svn"] = UIDevice.current.systemVersion
params["ntt"] = iPhoneSystemKit.getNetWorkTypee()
params["device"] = SwiftKeyChain.getKeyChainUUID()
params["ntt"] = PhoneSystemKit.getNetWorkTypeString()
params["ts"] = Date().milliStamp
if let idfa = ASIdentifierManager().advertisingIdentifierIfPresent {
params["idfa"] = idfa
}
if let token = CRUserDefaults.accessToken {
params["token"] = token
}
......@@ -330,6 +318,6 @@ private extension ASIdentifierManager {
if ASIdentifierManager.shared().isAdvertisingTrackingEnabled {
return ASIdentifierManager.shared().advertisingIdentifier.uuidString
}
return SwiftKeyChain.getKeyChainUUID()
return UIDevice.current.identifierForVendor?.uuidString ?? ""
}
}
//
// 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 ""
}
}
}
//
// PhoneSystemKit.swift
// CleanMaster
//
// Created by Master on 2020/8/15.
// Copyright © 2020 CleanMaster. All rights reserved.
//
import UIKit
import Foundation
import CoreTelephony
import SystemConfiguration
fileprivate let IOS_CELLULAR = "pdp_ip0"
fileprivate let IOS_WIFI = "en0"
fileprivate let IOS_VPN = "utun0"
fileprivate let IP_ADDR_IPv4 = "ipv4"
fileprivate let IP_ADDR_IPv6 = "ipv6"
fileprivate var loadPrevious = host_cpu_load_info()
/// Defines the various states of network reachability.
///
/// - unknown: It is unknown whether the network is reachable.
/// - notReachable: The network is not reachable.
/// - reachable: The network is reachable.
public enum CMNetworkReachabilityStatus {
case unknown
case notReachable
case reachable(CMConnectionType)
}
/// Defines the various connection types detected by reachability flags.
///
/// - ethernetOrWiFi: The connection type is either over Ethernet or WiFi.
/// - wwan: The connection type is a WWAN connection.
public enum CMConnectionType {
case ethernetOrWiFi
case wwan
}
@available (iOS 9.0 ,*)
open class PhoneSystemKit : NSObject {
/// app版本号
///
/// - Returns: app版本号
public static func appVerion() -> String {
return Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
}
/// 系统名称,如iPhone OS
///
/// - Returns: 当前系统名称
public static func systemName() -> String {
return UIDevice.current.systemName
}
/// 当前系统版本号
///
/// - Returns: 当前系统版本号
public static func systemVersion() -> String {
return UIDevice.current.systemVersion
}
/// 设备的唯一标识号,deviceID
///
/// - Returns: 唯一识别码uuid
public static func uuid() -> String {
return UIDevice.current.identifierForVendor!.uuidString
}
/// The model of the device,如iPhone或者iPod touch
///
/// - Returns: 设备
public static func model() -> String {
return UIDevice.current.model
}
/// The model of the device as a localized string,类似model
///
/// - Returns: localizedModel
public static func localizedModel() -> String {
return UIDevice.current.localizedModel
}
/// 设备型号(iPod、iPhone、iPad)
/// 详细参考地址:https://www.theiphonewiki.com/wiki/Models
/// - Returns: 设备型号
public static func deviceName() -> String {
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
let identifier = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8, value != 0 else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
}
switch identifier {
case "iPod4,1": return "iPod Touch 4"
case "iPod5,1": return "iPod Touch 5"
case "iPod7,1": return "iPod Touch 6"
case "iPhone3,1", "iPhone3,2", "iPhone3,3": return "iPhone 4"
case "iPhone4,1": return "iPhone 4s"
case "iPhone5,1", "iPhone5,2": return "iPhone 5"
case "iPhone5,3", "iPhone5,4": return "iPhone 5c"
case "iPhone6,1", "iPhone6,2": return "iPhone 5s"
case "iPhone7,2": return "iPhone 6"
case "iPhone7,1": return "iPhone 6 Plus"
case "iPhone8,1": return "iPhone 6s"
case "iPhone8,2": return "iPhone 6s Plus"
case "iPhone8,4": return "iPhone SE"
case "iPhone9,1", "iPhone9,3": return "iPhone 7"
case "iPhone9,2", "iPhone9,4": return "iPhone 7 Plus"
case "iPhone10,1", "iPhone10,4": return "iPhone 8"
case "iPhone10,2", "iPhone10,5": return "iPhone 8 Plus"
case "iPhone10,3", "iPhone10,6": return "iPhone X"
case "iPhone11,2": return "iPhone XS"
case "iPhone11,4", "iPhone11,6": return "iPhone XS Max"
case "iPhone11,8": return "iPhone XR"
case "iPhone12,1": return "iPhone 11"
case "iPhone12,3": return "iPhone 11 Pro"
case "iPhone12,5": return "iPhone 11 Pro Max"
case "iPad2,1", "iPad2,2", "iPad2,3", "iPad2,4":return "iPad 2"
case "iPad3,1", "iPad3,2", "iPad3,3": return "iPad 3"
case "iPad3,4", "iPad3,5", "iPad3,6": return "iPad 4"
case "iPad4,1", "iPad4,2", "iPad4,3": return "iPad Air"
case "iPad5,3", "iPad5,4": return "iPad Air 2"
case "iPad6,11", "iPad6,12": return "iPad 5"
case "iPad2,5", "iPad2,6", "iPad2,7": return "iPad Mini"
case "iPad4,4", "iPad4,5", "iPad4,6": return "iPad Mini 2"
case "iPad4,7", "iPad4,8", "iPad4,9": return "iPad Mini 3"
case "iPad5,1", "iPad5,2": return "iPad Mini 4"
case "iPad6,3", "iPad6,4": return "iPad Pro 9.7 Inch"
case "iPad6,7", "iPad6,8": return "iPad Pro 12.9 Inch"
case "iPad7,1", "iPad7,2": return "iPad Pro 12.9 Inch 2. Generation"
case "iPad7,3", "iPad7,4": return "iPad Pro 10.5 Inch"
case "i386", "x86_64": return "Simulator"
default: return identifier
}
}
// MARK: - Network
/// 检查网络连接,判断网络类型(ethernetOrWiFi / wwan)
/// 参考: https://github.com/Alamofire/Alamofire
/// - Returns: (check connected, Network Reachability Status)
public static func connectedToNetwork() -> (connected:Bool,connectionType: CMNetworkReachabilityStatus) {
var zeroAddress = sockaddr_in()
zeroAddress.sin_len = UInt8(MemoryLayout<sockaddr_in>.size)
zeroAddress.sin_family = sa_family_t(AF_INET)
guard let defaultRouteReachability = withUnsafePointer(to: &zeroAddress, {
$0.withMemoryRebound(to: sockaddr.self, capacity: 1) {
SCNetworkReachabilityCreateWithAddress(nil, $0)
}
}) else {
return (false,.unknown)
}
var flags: SCNetworkReachabilityFlags = []
if !SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags) {
return (false,.unknown)
}
let conType = flags.contains(.isWWAN) ? CMConnectionType.wwan : CMConnectionType.ethernetOrWiFi
let isReachable = flags.contains(.reachable)
let needsConnection = flags.contains(.connectionRequired)
let canConnectAutomatically = flags.contains(.connectionOnDemand) || flags.contains(.connectionOnTraffic)
let canConnectWithoutUserInteraction = canConnectAutomatically && !flags.contains(.interventionRequired)
guard isReachable && (!needsConnection || canConnectWithoutUserInteraction) else {
return (false,.notReachable)
}
return (true,.reachable(conType))
}
/// 网络状态(2G、3G、4G、WIFI)
///
/// - Returns: String
public static func getNetWorkTypee() -> String {
let result = "未知网络"
let info = CTTelephonyNetworkInfo()
let netWork = connectedToNetwork()
guard netWork.connected else {
return "未连接网络"
}
switch netWork.connectionType {
case .reachable(.ethernetOrWiFi):
return "WIFI"
case .reachable(.wwan):
let currentRadioAccessTechnology = info.currentRadioAccessTechnology
guard currentRadioAccessTechnology != nil else {
return result
}
if currentRadioAccessTechnology! == CTRadioAccessTechnologyLTE {
return "4G"
}else if (currentRadioAccessTechnology! == CTRadioAccessTechnologyEdge) || (currentRadioAccessTechnology! == CTRadioAccessTechnologyGPRS) {
return "2G"
}else {
return "3G"
}
default:
return result
}
}
/// 网络状态(2G、3G、4G、WIFI)
///
/// - Returns: String
public static func getNetWorkTypeString() -> String {
let result = "unknown"
let info = CTTelephonyNetworkInfo()
let netWork = connectedToNetwork()
guard netWork.connected else {
return "unconnected"
}
switch netWork.connectionType {
case .reachable(.ethernetOrWiFi):
return "Wi-Fi"
case .reachable(.wwan):
let currentRadioAccessTechnology = info.currentRadioAccessTechnology
guard currentRadioAccessTechnology != nil else {
return result
}
if currentRadioAccessTechnology! == CTRadioAccessTechnologyLTE {
return "4G"
}else if (currentRadioAccessTechnology! == CTRadioAccessTechnologyEdge) || (currentRadioAccessTechnology! == CTRadioAccessTechnologyGPRS) {
return "2G"
}else {
return "3G"
}
default:
return result
}
}
}
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