Переглянути джерело

【会员系统】购买界面价格显示问题修改

wangshuai 3 місяців тому
батько
коміт
3acc29f42b

+ 24 - 33
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseEmbeddedWindowController.swift

@@ -429,6 +429,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         payExplainLabel.allowsEditingTextAttributes = true
         payExplainLabel.textColor = NSColor.black
         payExplainLabel.font = NSFont.SFProTextRegularFont(11.0)
+        discountPriceLabel1.isHidden = true
+
         let localizedString = NSLocalizedString("By submitting this order, I agree to the %@ and %@ for subscription products", comment: "")
         let privacyPolicy = NSLocalizedString("Privacy Policy", comment: "")
         let termsOfService = NSLocalizedString("Terms of Service", comment: "")
@@ -529,24 +531,24 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
             // Mac & Win 双平台高级永久      119.99 美金,黑五订单
             // AI 年订阅                    125.99 美金,带免费试用
             
-            var tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
+            var tipsString = NSLocalizedString("%.2f/year, auto-renewal", comment: "")
             if product_Info.cycle == 4 {
-                tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/year, auto-renewal", comment: "")
             }
             if product_Info.cycle == 3 {
-                tipsString = NSLocalizedString("%.2@/half a year, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/half a year, auto-renewal", comment: "")
             }
             if product_Info.cycle == 2 {
-                tipsString = NSLocalizedString("%.2@/quarter, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/quarter, auto-renewal", comment: "")
             }
             if product_Info.cycle == 1 {
-                tipsString = NSLocalizedString("%.2@/monthly, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/monthly, auto-renewal", comment: "")
             }
             if product_Info.cycle == 0 {
-                tipsString = NSLocalizedString("%.2@, One time purchase.", comment: "")
+                tipsString = NSLocalizedString("%.2f, One time purchase.", comment: "")
             }
             
-            let fullString = String(format: tipsString, showOrgPriceString())
+            let fullString = String(format: tipsString, insting ?? 0)
             
             prmiumLabel.stringValue = String(format: "%@ %@", abbreviation, fullString)
             original1 = Float(showOrgPriceString()) ?? 0
@@ -563,24 +565,24 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
             // Mac & Win 双平台高级永久      119.99 美金
             // AI 月订阅                    14.99 美金
             
-            var tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
+            var tipsString = NSLocalizedString("%.2f/year, auto-renewal", comment: "")
             if product_Info.cycle == 4 {
-                tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/year, auto-renewal", comment: "")
             }
             if product_Info.cycle == 3 {
-                tipsString = NSLocalizedString("%.2@/half a year, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/half a year, auto-renewal", comment: "")
             }
             if product_Info.cycle == 2 {
-                tipsString = NSLocalizedString("%.2@/quarter, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/quarter, auto-renewal", comment: "")
             }
             if product_Info.cycle == 1 {
-                tipsString = NSLocalizedString("%.2@/monthly, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/monthly, auto-renewal", comment: "")
             }
             if product_Info.cycle == 0 {
-                tipsString = NSLocalizedString("%.2@, One time purchase.", comment: "")
+                tipsString = NSLocalizedString("%.2f, One time purchase.", comment: "")
             }
         
-            let fullString = String(format: tipsString, showOrgPriceString())
+            let fullString = String(format: tipsString, insting ?? 0)
 
             prmiumLabel.stringValue = String(format: "%@ %@", abbreviation, fullString)
             original1 = Float(showOrgPriceString()) ?? 0
@@ -592,23 +594,23 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         if _product_code == "advanced-permanent" {
             // Mac & Win 双平台高级永久      119.99 美金
             
-            var tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
+            var tipsString = NSLocalizedString("%.2f/year, auto-renewal", comment: "")
             if product_Info.cycle == 4 {
-                tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/year, auto-renewal", comment: "")
             }
             if product_Info.cycle == 3 {
-                tipsString = NSLocalizedString("%.2@/half a year, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/half a year, auto-renewal", comment: "")
             }
             if product_Info.cycle == 2 {
-                tipsString = NSLocalizedString("%.2@/quarter, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/quarter, auto-renewal", comment: "")
             }
             if product_Info.cycle == 1 {
-                tipsString = NSLocalizedString("%.2@/monthly, auto-renewal", comment: "")
+                tipsString = NSLocalizedString("%.2f/monthly, auto-renewal", comment: "")
             }
             if product_Info.cycle == 0 {
-                tipsString = NSLocalizedString("%.2@, One time purchase.", comment: "")
+                tipsString = NSLocalizedString("%.2f, One time purchase.", comment: "")
             }
-            let fullString = String(format: tipsString, showOrgPriceString())
+            let fullString = String(format: tipsString, insting ?? 0)
 
             prmiumLabel.stringValue = String(format: "%@ %@", abbreviation, fullString)
             original1 = Float(showOrgPriceString()) ?? 0
@@ -617,17 +619,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
             discount = listPrice - paySum
         }
         
-        originalPriceLabel1.stringValue = String(format: "%@ %@", abbreviation, String(format: "%.2f", discount1))
-        if String(format: "%.2f", original1) == String(format: "%.2f", discount1) {
-            discountPriceLabel1.isHidden = true
-        } else {
-            discountPriceLabel1.isHidden = false
-            let attributedString = NSMutableAttributedString(string: String(format: "%@ %@", abbreviation, String(format: "%.2f", original1)))
-            attributedString.addAttribute(.strikethroughStyle, value: NSNumber(value: NSUnderlineStyle.single.rawValue), range: NSMakeRange(0, attributedString.length))
-            attributedString.addAttribute(.strikethroughColor, value: NSColor(named: "KMPurchaseDiscountColor") as Any, range: NSMakeRange(0, attributedString.length))
-            discountPriceLabel1.attributedStringValue = attributedString
-        }
-        
+        originalPriceLabel1.stringValue = String(format: "%@ %@", abbreviation, String(format: "%.2f", insting ?? 0))
      
         lastPriceLabel1.stringValue = String(format: "%@ %@", abbreviation, String(format: "%.2f", listPrice))
         discountLabel1.stringValue = String(format: "%@ %@", abbreviation, String(format: "%.2f", discount))
@@ -1277,7 +1269,6 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     }
     
     func showSinglePriceString()->String { //单价
-        let preferredLanguage = Locale.preferredLanguages.first ?? "en"
         var priceString = product_Info.individualPriceString ?? ""
         if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "CN" {
             priceString = product_Info.individualCnyPriceString ?? ""