Browse Source

【订阅】DMG购买流程调整

lizhe 1 year ago
parent
commit
6a79d0a351

+ 0 - 8
PDF Office/PDF Master/Class/ChromiumTabs/KMBrowserWindowController.swift

@@ -371,15 +371,7 @@ import Cocoa
 extension KMBrowserWindowController: KMToolbarRightViewDelegate {
     func pdfRightSegmentedControlAction(_ sender: KMSegmentedBox?) {
         self.trackEvent_upgrade()
-#if VERSION_DMG
-        KMPurchaseManager.manager.purchaseProduct(productIdentifier: "") { isSuccess, error in
-            
-        }
-#endif
-        
-#if VERSION_FREE
         KMComparativeTableViewController.show(window: self.window!, .upgrade)
-#endif
     }
     
     func userInfoButtonAction(_ sender: NSButton) {

+ 1 - 3
PDF Office/PDF Master/Class/Home/WindowController/KMAITranslationWindowController.swift

@@ -94,10 +94,8 @@ class KMAITranslationWindowController: NSWindowController {
 
         self.toContentBox.borderColor = NSColor(hex: "#DFE1E5")
         self.toContentBox.fillColor = NSColor(hex: "#FFFFFF")
-        self.toContentTextView.textColor = NSColor(hex: "#252629")
+        self.toContentTextView.textColor = .black
         self.toContentTextView.font = NSFont.SFProTextRegular(12.0)
-        self.toContentTextView.frame = (self.toContentTextView.enclosingScrollView?.contentView.bounds)!
-        self.toContentTextView.autoresizingMask = [.width, .height]
         
         self.translateBox.fillColor = NSColor(hex: "#BDDFFD")
         self.translateBox.cornerRadius = 4.0

+ 28 - 10
PDF Office/PDF Master/Class/KMLightMember/Config/KMLightMemberConfig.swift

@@ -11,18 +11,36 @@ class KMLightMemberConfig: NSObject {
     var isDebug: Bool = true
     var kServerURL: String {
         get {
-            #if DEBUG
-            if self.isDebug {
+//            #if DEBUG
+//            if self.isDebug {
 //                测试服务器
                 return "http://139.196.160.101:8081"
-            } else {
-                //正式服务器
-                return "https://pdfmaster.pdfreaderpro.com"
-            }
-            #else
-            //正式服务器
-            return "https://pdfmaster.pdfreaderpro.com"
-            #endif
+//            } else {
+//                //正式服务器
+//                return "https://pdfmaster.pdfreaderpro.com"
+//            }
+//            #else
+//            //正式服务器
+//            return "https://pdfmaster.pdfreaderpro.com"
+//            #endif
+            
+        }
+    }
+    
+    var kStoreServerURL: String {
+        get {
+//            #if DEBUG
+//            if self.isDebug {
+//                测试服务器
+                return "http://test-pdf-pro.kdan.cn:3021"
+//            } else {
+//                //正式服务器
+//                return "https://pdfmaster.pdfreaderpro.com"
+//            }
+//            #else
+//            //正式服务器
+//            return "https://pdfmaster.pdfreaderpro.com"
+//            #endif
             
         }
     }

+ 8 - 4
PDF Office/PDF Master/Class/KMLightMember/Controller/AccountInfo/KMAccountInfoWindowController.swift

@@ -141,7 +141,7 @@ class KMAccountInfoWindowController: NSWindowController {
         }
         
         self.accountInfoView.purchaseInfoAction = { view in
-            NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/store")!)
+            KMPurchaseManager.manager.showPurchasesInfo()
         }
         
         self.accountInfoView.subcriptionAction = { view in
@@ -158,9 +158,8 @@ class KMAccountInfoWindowController: NSWindowController {
             accountInfoMainWindow = nil
             
             //跳转订阅比较表
-            let _ = KMComparativeTableViewController.show(window: NSApp.mainWindow ?? NSWindow())
+            let _ = KMComparativeTableViewController.show(window: NSApp.mainWindow ?? NSWindow(), .accountInfo)
 #endif
-            
         }
     }
     
@@ -173,12 +172,17 @@ class KMAccountInfoWindowController: NSWindowController {
             self.accountViewHeightConstraint.constant = 411 - 60
 #if VERSION_DMG
             if KMLightMemberManager.manager.info.subscriptionInfoList[0].payType == 0 {
-                self.accountViewHeightConstraint.constant = 483 - 52
+                self.accountViewHeightConstraint.constant = 483 - 52 - 20
+            }  else if KMLightMemberManager.manager.info.subscriptionInfoList[0].payType == 1 {
+                self.accountViewHeightConstraint.constant = 483 - 52 - 20
             }
 #endif
         } else if state == .subscriptionExpired ||
                     state == .trialExpired {
             self.accountViewHeightConstraint.constant = 483 - 52
+#if VERSION_DMG
+            self.accountViewHeightConstraint.constant = 483
+#endif
         }
         self.accountInfoView.purchaseState = state
         

+ 7 - 4
PDF Office/PDF Master/Class/KMLightMember/Controller/AccountInfo/View/KMAccountInfoView.swift

@@ -139,13 +139,13 @@ class KMAccountInfoView: KMBaseXibView {
         
         if purchaseState == .unknow {
             self.statusContentView.isHidden = true
-//            self.purchaseInfoContentView.isHidden = true
+            self.purchaseInfoContentView.isHidden = true
             self.subscribeButtonContentView.isHidden = true
         } else if purchaseState == .subscription ||
                     purchaseState == .trial {
             self.statusContentView.isHidden = false
-//            self.purchaseInfoContentView.isHidden = false
 #if VERSION_DMG
+            self.purchaseInfoContentView.isHidden = false
             if userInfo?.subscriptionInfoList[0].payType == 1 {
                 self.subscribeButtonContentView.isHidden = true
             } else {
@@ -163,9 +163,12 @@ class KMAccountInfoView: KMBaseXibView {
         } else if purchaseState == .subscriptionExpired ||
                     purchaseState == .trialExpired {
             self.statusContentView.isHidden = false
-//            self.purchaseInfoContentView.isHidden = false
             self.subscribeButtonContentView.isHidden = false
             
+#if VERSION_DMG
+            self.purchaseInfoContentView.isHidden = false
+#endif
+            
             self.statusLabel.stringValue = NSLocalizedString("Expired", comment: "")
             self.statusLabel.textColor = NSColor(hex: "#F3465B")
             
@@ -173,7 +176,7 @@ class KMAccountInfoView: KMBaseXibView {
             self.statusTimeLabel.stringValue = "\(self.fetchDate(dateString: dateString)) \n\(NSLocalizedString("Subscription expire on", comment: ""))"
         } else {
             self.statusContentView.isHidden = true
-//            self.purchaseInfoContentView.isHidden = true
+            self.purchaseInfoContentView.isHidden = true
             self.subscribeButtonContentView.isHidden = true
         }
         

+ 32 - 32
PDF Office/PDF Master/Class/KMLightMember/Controller/AccountInfo/View/KMAccountInfoView.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22146" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21701"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22146"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -48,20 +48,20 @@
                 </box>
                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Amy-OB-Mza">
                     <rect key="frame" x="8" y="461" width="12" height="12"/>
-                    <constraints>
-                        <constraint firstAttribute="width" constant="12" id="JMt-xb-LqK"/>
-                        <constraint firstAttribute="height" constant="12" id="c7Q-qR-TGj"/>
-                    </constraints>
                     <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="control_btn_icon_close" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="c3n-rh-CpG">
                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
                     </buttonCell>
+                    <constraints>
+                        <constraint firstAttribute="width" constant="12" id="JMt-xb-LqK"/>
+                        <constraint firstAttribute="height" constant="12" id="c7Q-qR-TGj"/>
+                    </constraints>
                     <connections>
                         <action selector="closeButtonAction:" target="-2" id="U1Z-rX-5eH"/>
                     </connections>
                 </button>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wzN-5h-FkM">
-                    <rect key="frame" x="108" y="415" width="182" height="28"/>
+                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wzN-5h-FkM">
+                    <rect key="frame" x="108" y="415" width="183" height="28"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="28" id="hwe-Db-IjI"/>
                     </constraints>
@@ -76,30 +76,30 @@
                     <subviews>
                         <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="t75-lC-90r">
                             <rect key="frame" x="318" y="126" width="24" height="24"/>
-                            <constraints>
-                                <constraint firstAttribute="width" constant="24" id="fan-42-fAl"/>
-                                <constraint firstAttribute="height" constant="24" id="hFQ-nv-2SB"/>
-                            </constraints>
                             <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="icon_btn_more" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="9Nf-kJ-lvd">
                                 <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                 <font key="font" metaFont="system"/>
                             </buttonCell>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="24" id="fan-42-fAl"/>
+                                <constraint firstAttribute="height" constant="24" id="hFQ-nv-2SB"/>
+                            </constraints>
                             <connections>
                                 <action selector="moreButtonAction:" target="-2" id="bTi-kP-MP3"/>
                             </connections>
                         </button>
                         <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8gX-ju-NH5">
                             <rect key="frame" x="151" y="86" width="48" height="48"/>
-                            <constraints>
-                                <constraint firstAttribute="height" constant="48" id="4Re-q3-7cZ"/>
-                                <constraint firstAttribute="width" constant="48" id="Ssr-id-8TX"/>
-                            </constraints>
                             <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" alignment="center" imageScaling="proportionallyDown" inset="2" id="wRw-DB-pSM">
                                 <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                 <font key="font" metaFont="system"/>
                             </buttonCell>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="48" id="4Re-q3-7cZ"/>
+                                <constraint firstAttribute="width" constant="48" id="Ssr-id-8TX"/>
+                            </constraints>
                         </button>
-                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xZx-LL-ESd">
+                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xZx-LL-ESd">
                             <rect key="frame" x="127" y="53" width="96" height="17"/>
                             <textFieldCell key="cell" lineBreakMode="clipping" title="Email Address" id="XBY-1W-x0h">
                                 <font key="font" metaFont="system" size="14"/>
@@ -107,8 +107,8 @@
                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                             </textFieldCell>
                         </textField>
-                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RBL-0P-CFH">
-                            <rect key="frame" x="85" y="20" width="181" height="17"/>
+                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RBL-0P-CFH">
+                            <rect key="frame" x="84" y="20" width="182" height="17"/>
                             <textFieldCell key="cell" lineBreakMode="clipping" title="pdfoffice@kdanmobile.com" id="jfQ-Wh-ayi">
                                 <font key="font" metaFont="system" size="14"/>
                                 <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -150,18 +150,18 @@
                     </constraints>
                 </customView>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="l6v-gx-NaZ">
-                    <rect key="frame" x="24" y="30" width="350" height="40"/>
+                    <rect key="frame" x="24" y="32" width="350" height="40"/>
                     <subviews>
                         <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6uz-0m-698">
                             <rect key="frame" x="75" y="0.0" width="200" height="40"/>
-                            <constraints>
-                                <constraint firstAttribute="height" constant="40" id="Mpa-mF-kKW"/>
-                                <constraint firstAttribute="width" constant="200" id="aft-Eg-IK7"/>
-                            </constraints>
                             <buttonCell key="cell" type="square" title="Subscribe" bezelStyle="shadowlessSquare" alignment="center" imageScaling="proportionallyDown" inset="2" id="iF3-pV-hyc">
                                 <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                 <font key="font" metaFont="system"/>
                             </buttonCell>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="40" id="Mpa-mF-kKW"/>
+                                <constraint firstAttribute="width" constant="200" id="aft-Eg-IK7"/>
+                            </constraints>
                             <connections>
                                 <action selector="subcriptionButtonAction:" target="-2" id="OIO-bS-649"/>
                             </connections>
@@ -182,7 +182,7 @@
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="9AV-k7-nob">
                     <rect key="frame" x="24" y="147" width="350" height="74"/>
                     <subviews>
-                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QSv-Q9-wi2">
+                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QSv-Q9-wi2">
                             <rect key="frame" x="-2" y="58" width="43" height="16"/>
                             <textFieldCell key="cell" lineBreakMode="clipping" title="Status" id="SA6-LW-oSg">
                                 <font key="font" usesAppearanceFont="YES"/>
@@ -193,7 +193,7 @@
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="1pg-8T-wNz">
                             <rect key="frame" x="0.0" y="0.0" width="350" height="50"/>
                             <subviews>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xqM-Bi-zV4">
+                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xqM-Bi-zV4">
                                     <rect key="frame" x="-2" y="17" width="102" height="16"/>
                                     <constraints>
                                         <constraint firstAttribute="width" relation="lessThanOrEqual" constant="100" id="wYM-9K-QDj"/>
@@ -204,8 +204,8 @@
                                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                     </textFieldCell>
                                 </textField>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hNa-H6-poH">
-                                    <rect key="frame" x="275" y="9" width="77" height="32"/>
+                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hNa-H6-poH">
+                                    <rect key="frame" x="273" y="9" width="79" height="32"/>
                                     <textFieldCell key="cell" lineBreakMode="clipping" alignment="right" id="bqx-Sm-ykO">
                                         <font key="font" usesAppearanceFont="YES"/>
                                         <string key="title">2023/01/25
@@ -215,10 +215,10 @@ Trial expires</string>
                                     </textFieldCell>
                                 </textField>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="ABe-Ge-8Kf">
-                                    <rect key="frame" x="106" y="15" width="106" height="20"/>
+                                    <rect key="frame" x="106" y="15" width="107" height="20"/>
                                     <subviews>
-                                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dUy-Xz-Fsv">
-                                            <rect key="frame" x="3" y="2" width="100" height="16"/>
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dUy-Xz-Fsv">
+                                            <rect key="frame" x="3" y="2" width="101" height="16"/>
                                             <textFieldCell key="cell" lineBreakMode="clipping" title="  Auto-renewal  " id="NKq-uS-TUg">
                                                 <font key="font" metaFont="system"/>
                                                 <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -257,7 +257,7 @@ Trial expires</string>
             </subviews>
             <constraints>
                 <constraint firstAttribute="trailing" secondItem="l6v-gx-NaZ" secondAttribute="trailing" constant="24" id="67o-Fl-jBi"/>
-                <constraint firstAttribute="bottom" secondItem="l6v-gx-NaZ" secondAttribute="bottom" constant="30" id="GDb-5f-iw6"/>
+                <constraint firstAttribute="bottom" secondItem="l6v-gx-NaZ" secondAttribute="bottom" constant="32" id="GDb-5f-iw6"/>
                 <constraint firstItem="wzN-5h-FkM" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" constant="40" id="P6g-Wv-Jeq"/>
                 <constraint firstItem="WMg-Cr-JJr" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="24" id="QcH-kl-ozy"/>
                 <constraint firstItem="Amy-OB-Mza" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" constant="10" id="Sws-1x-SeB"/>

+ 2 - 4
PDF Office/PDF Master/Class/KMLightMember/Controller/ComparativeTable/KMComparativeTableViewController.swift

@@ -66,16 +66,14 @@ class KMComparativeTableViewController: NSWindowController {
     static func show(window: NSWindow, _ type: KMComparativeInputType = .unknown) -> KMComparativeTableViewController? {
 #if VERSION_DMG
         if KMLightMemberManager.manager.isLogin() {
-            KMPurchaseManager.manager.purchaseProduct(productIdentifier: "") { isSuccess, error in
-                
-            }
+            KMPurchaseManager.manager.showStore()
         } else {
             KMLoginWindowController.show(window: NSApp.mainWindow!)
         }
 #endif
         
 #if VERSION_FREE
-        if KMLightMemberManager.manager.isLogin() && (type == .upgrade || type == .equity) {
+        if KMLightMemberManager.manager.isLogin() && (type == .upgrade || type == .equity || type == .accountInfo) {
             let controller: KMComparativeTableViewController = KMComparativeTableViewController.init(windowNibName: "KMComparativeTableViewController")
             controller.inputType = type
 

+ 0 - 8
PDF Office/PDF Master/Class/KMLightMember/Controller/SubscriptionView/WaterMark/View/KMSubscribeWaterMarkView.swift

@@ -170,14 +170,6 @@ class KMSubscribeWaterMarkView: KMBaseXibView {
             self.dataArray = beforeLoginDataArray
         }
         self.collectionView.reloadData()
-        
-#if VERSION_FREE
-        
-#endif
-
-//#if VERSION_DMG
-//        self.restoreButton.isHidden = true
-//#endif
     }
 }
 

+ 6 - 1
PDF Office/PDF Master/Class/KMLightMember/InAppPurchase/DMG/KMDMGPurchaseManager.swift

@@ -14,7 +14,12 @@ class KMDMGPurchaseManager: NSObject {
     var availableProducts: [KMProduct] = []
     
     func purchaseProduct(productIdentifier: String, email: String, completion: KMPurchaseCompletion) {
-        NSWorkspace.shared.open(URL(string: "http://test-pdf-pro.kdan.cn:3021/master/checkout?email=\(email)")!)
+//        NSWorkspace.shared.open(URL(string: "http://test-pdf-pro.kdan.cn:3021/master/checkout?email=\(email)")!)
+#if DEBUG
+        NSWorkspace.shared.open(URL(string: "\(KMLightMemberManager.manager.config.kStoreServerURL)/store/master-subscription?email=\(email)")!)
+#else
+        NSWorkspace.shared.open(URL(string: "\(KMLightMemberManager.manager.config.kStoreServerURL)/store/master-subscription?email=\(email)")!)
+#endif
         completion(false, .success)
     }
     

+ 16 - 1
PDF Office/PDF Master/Class/KMLightMember/InAppPurchase/KMPurchaseManager.swift

@@ -30,7 +30,7 @@ class KMPurchaseManager: NSObject {
         get {
 #if DEBUG
             //方便调整订阅状态
-//            return .subscription
+//            return .subscriptionExpired
 #endif
             let info = KMLightMemberManager.manager.info.subscriptionInfoList
             var tempState: KMPurchaseManagerState = .unknow
@@ -105,6 +105,21 @@ class KMPurchaseManager: NSObject {
 #endif
     }
     
+    func showStore() {
+#if VERSION_DMG
+        NSWorkspace.shared.open(URL(string: "\(KMLightMemberManager.manager.config.kStoreServerURL)/store/master")!)
+#endif
+    }
+    
+    func showPurchasesInfo() {
+#if VERSION_DMG
+        if KMLightMemberManager.manager.isLogin() {
+            let token: String = KMLightMemberManager.manager.token.access_token
+            NSWorkspace.shared.open(URL(string: "\(KMLightMemberManager.manager.config.kStoreServerURL)/account/master-subscription?appid=16&token=\(token)")!)
+        }
+#endif
+    }
+    
     func restorePurchases(_ completion: @escaping KMPurchaseRestoreCompletion) {
         KMPrint("准备restore")
 #if VERSION_FREE