Browse Source

【轻会员】权益付费弹窗,订阅已过期用户,不需要显示50% OFF标签

lizhe 1 year ago
parent
commit
b00295c146

+ 27 - 15
PDF Office/PDF Master/Class/KMLightMember/Controller/AccountInfo/View/KMAccountInfoView.swift

@@ -103,7 +103,7 @@ class KMAccountInfoView: KMBaseXibView {
         self.statusLabel.font = NSFont.SFProTextSemibold(16.0)
         
         self.statusTimeLabel.textColor = NSColor(hex: "#616469")
-        self.statusTimeLabel.font = NSFont.SFProTextRegular(12.0)
+        self.statusTimeLabel.font = NSFont.SFProTextRegular(10.0)
         
         self.subscribeButton.contentTintColor = NSColor(hex: "#FFFFFF")
         self.subscribeButton.backgroundColor(NSColor(hex: "#FF852E"))
@@ -152,19 +152,8 @@ class KMAccountInfoView: KMBaseXibView {
                 self.statusLabel.stringValue = NSLocalizedString("On Trial", comment: "")
             }
             
-            
             let dateString = userInfo?.subscriptionInfoList[0].endDate ?? ""
-
-            let dateFormatter = DateFormatter()
-            dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
-
-            let date = dateFormatter.date(from: dateString)
-            let targetDateFormatter = DateFormatter()
-            targetDateFormatter.dateFormat = "yyyy-MM-dd"
-            let formattedDate = targetDateFormatter.string(from: date ?? NSDate() as Date)
-            print(formattedDate) // 输出:2024-06-28
-            
-            self.statusTimeLabel.stringValue = "\(formattedDate) \nTrial expires"
+            self.statusTimeLabel.stringValue = "\(self.fetchDate(dateString: dateString)) \n\(NSLocalizedString("Trial expires", comment: ""))"
         } else if purchaseState == .subscriptionExpired ||
                     purchaseState == .trialExpired {
             self.statusContentView.isHidden = false
@@ -174,12 +163,21 @@ class KMAccountInfoView: KMBaseXibView {
             self.statusLabel.stringValue = NSLocalizedString("Expired", comment: "")
             self.statusLabel.textColor = NSColor(hex: "#F3465B")
             
+            let dateString = userInfo?.subscriptionInfoList[0].endDate ?? ""
+            self.statusTimeLabel.stringValue = "\(self.fetchDate(dateString: dateString)) \n\(NSLocalizedString("Trial expires", comment: ""))"
         } else {
             self.statusContentView.isHidden = true
 //            self.purchaseInfoContentView.isHidden = true
             self.subscribeButtonContentView.isHidden = true
         }
         
+        if self.userInfo != nil {
+            if userInfo?.subscriptionInfoList[0].payType == 1 {
+                let dateString = userInfo?.subscriptionInfoList[0].endDate ?? ""
+                self.statusTimeLabel.stringValue = "\(self.fetchDate(dateString: dateString))\n\(NSLocalizedString("Next subscription", comment: ""))"
+            }
+        }
+        
         self.updateLanguage()
     }
     
@@ -198,8 +196,22 @@ class KMAccountInfoView: KMBaseXibView {
         paragraphStyle.alignment = .right
         self.statusTimeLabel.attributedStringValue = NSMutableAttributedString(string: NSLocalizedString(timeString, comment: ""), attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
         
-        paragraphStyle.alignment = .left
-        self.statusLabel.attributedStringValue = NSMutableAttributedString(string: NSLocalizedString(self.statusLabel.stringValue, comment: ""), attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
+        let paragraphStyle2 = NSMutableParagraphStyle()
+        paragraphStyle2.lineHeightMultiple = 1.32
+        paragraphStyle2.alignment = .left
+        self.statusLabel.attributedStringValue = NSMutableAttributedString(string: NSLocalizedString(self.statusLabel.stringValue, comment: ""), attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle2])
+    }
+    
+    func fetchDate(dateString: String) -> String {
+        let dateFormatter = DateFormatter()
+        dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
+
+        let date = dateFormatter.date(from: dateString)
+        let targetDateFormatter = DateFormatter()
+        targetDateFormatter.dateFormat = "yyyy-MM-dd"
+        let formattedDate = targetDateFormatter.string(from: date ?? NSDate() as Date)
+        print(formattedDate) // 输出:2024-06-28
+        return formattedDate
     }
 }
 

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

@@ -24,6 +24,7 @@ class KMSubscribeWaterMarkView: KMBaseXibView {
     @IBOutlet weak var lineView: NSView!
     @IBOutlet var textView: NSTextView!
     @IBOutlet weak var restoreButton: NSButton!
+    @IBOutlet weak var discountImageView: NSImageView!
     
     var closeAction: KMSubscribeWaterMarkViewCancelAction?
     var subscribeAction: KMSubscribeWaterMarkViewSubscribeAction?
@@ -116,6 +117,13 @@ class KMSubscribeWaterMarkView: KMBaseXibView {
         self.restoreButton.isHidden = true
         self.textView.isHidden = true
 #endif
+        if KMLightMemberManager.manager.purchaseState == .trialExpired ||
+            KMLightMemberManager.manager.purchaseState == .subscriptionExpired {
+            self.discountImageView.isHidden = true
+        } else {
+            self.discountImageView.isHidden = false
+        }
+            
     }
 }
 

+ 1 - 0
PDF Office/PDF Master/Class/KMLightMember/Controller/SubscriptionView/WaterMark/View/KMSubscribeWaterMarkView.xib

@@ -11,6 +11,7 @@
                 <outlet property="closeBox" destination="msn-nQ-xqN" id="QFo-LV-8P3"/>
                 <outlet property="closeButton" destination="bTN-v2-Eaj" id="h2L-kr-Gi9"/>
                 <outlet property="collectionView" destination="G8e-lU-M2R" id="Unt-cd-UZq"/>
+                <outlet property="discountImageView" destination="XJT-Av-tgl" id="sML-AH-cZs"/>
                 <outlet property="lineView" destination="gPv-qb-Uay" id="6ri-1C-OKN"/>
                 <outlet property="restoreButton" destination="2p2-EB-ZME" id="4dk-gE-x5C"/>
                 <outlet property="scrollView" destination="iQs-EU-LBJ" id="bId-Pc-Y9u"/>

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

@@ -29,7 +29,7 @@ class KMPurchaseManager: NSObject {
         get {
             let info = KMLightMemberManager.manager.info.subscriptionInfoList
             var tempState: KMPurchaseManagerState = .unknow
-            
+            return .trialExpired
             if info.count > 0 {
                 let isSubscription = false
                 for item in info {