Преглед изворни кода

【会员系统】DMG版结算界面初始化部分调整

zenghong пре 6 дана
родитељ
комит
43b8a58c5b

+ 6 - 2
PDF Office/PDF Master/AppDelegate.swift

@@ -129,14 +129,18 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
                     }
 #if VERSION_DMG
                     let model = KMProductModel.shared
-                    model.getDMGProductDatas()
+                    model.getDMGProductDatas() { [weak self] success, result in
+                        
+                    }
 #endif
                 }
             }
         } else {
 #if VERSION_DMG
             let model = KMProductModel.shared
-            model.getDMGProductDatas()
+            model.getDMGProductDatas() { [weak self] success, result in
+                
+            }
 #endif
         }
 

+ 39 - 0
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseEmbeddedWindowController.swift

@@ -150,6 +150,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     @IBOutlet weak var imageBottomLayout: NSLayoutConstraint!
     @IBOutlet weak var image2BottomLayout: NSLayoutConstraint!
     
+    private var _product_code : String = ""
     private var _dmgProductType: KMDMGProductType = .advanced_annual_subscription_trail
     private var _product_Info: KMListingProductsModel = KMListingProductsModel(id: "23", productName: "PDF Reader Pro Advanced - Annual Plan", price: NSNumber(value: 99.99), maxDeviceNum: 4, displayPrice: NSNumber(value: 0.0), levels: "3", platforms: "Windows,Android,Mac,iOS", productLineId: 1, paymentModel: 1, cycle: 4, cnyPrice: NSNumber(value: 0), displayCnyPrice: NSNumber(value: 0.0), upgradePrice: NSNumber(value: 0.0), code: "advanced-annual-subscription-trail")
 
@@ -1767,6 +1768,44 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     
     // MARK: get & set
     
+    var product_code : String {
+        get {
+            return _product_code
+        }
+        
+        set {
+            _product_code = newValue
+            
+            let model = KMProductModel.shared
+            let products : [KMListingProductsModel] = model.dmgProductDatas?.listingProducts ?? []
+            if products.count > 0 {
+                for product in products {
+                    if product.code == _product_code {
+                        self.product_Info = product;
+                        //更新价格
+                        self.updateProduct_Info()
+                        break
+                    }
+                }
+            } else {
+                model.getDMGProductDatas() { [weak self] success, result in
+                    let products : [KMListingProductsModel] = model.dmgProductDatas?.listingProducts ?? []
+                    if products.count > 0 {
+                        for product in products {
+                            if product.code == self?.product_code {
+                                self?.product_Info = product;
+                                //更新价格
+                                self.updateProduct_Info()
+                                break
+                            }
+                        }
+                    }
+                }
+            }
+            
+        }
+    }
+    
     var product_Info: KMListingProductsModel {
         get {
             return _product_Info

+ 2 - 1
PDF Office/PDF Master/MemberCenter/ViewModel/KMProductModel.swift

@@ -123,11 +123,12 @@ class KMProductModel: ObservableObject {
      @abstract 获取DMG服务器架上所有商品 (得到的价格是原始价格)
      @param
      */
-    func getDMGProductDatas() -> Void {
+    func getDMGProductDatas( _ complete: @escaping KMMemberProductComplete) -> Void {
         checkConnectionAvailable()
         KMMemberCenterManager.manager.getListingProducts(isEducation: 0) { [weak self] success, result in
             guard let productsArrays : KMMemberProductResult = result else { return }
             self?.dmgProductDatas = productsArrays
+            complete(success, result)
         }
         
         if KMMemberInfo.shared.isLogin {