Quellcode durchsuchen

Merge branch 'develop_V4.0.1' into develop_PDFReaderProNew

# Conflicts:
#	PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift
niehaoyu vor 9 Monaten
Ursprung
Commit
f613ad9c75

+ 1 - 0
PDF Office/PDF Master/Class/Common/OC/OCR/KMGOCRManager.m

@@ -625,6 +625,7 @@ static inline NSFont * FontWithSize(NSString *strChar, CGSize size) {
     if ([self.delegate respondsToSelector:@selector(GOCRManager:didFailureOCRImageAtIndex:error:)]) {
         [self.delegate GOCRManager:self didFailureOCRImageAtIndex:index error:error];
     }
+    self.finishIndex++;
 }
 
 // Apple OCR 结果解析

+ 12 - 0
PDF Office/PDF Master/Class/GuideInfo/GuideInfoImages.xcassets/cnLight.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "cnLight.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
PDF Office/PDF Master/Class/GuideInfo/GuideInfoImages.xcassets/cnLight.imageset/cnLight.pdf


+ 12 - 0
PDF Office/PDF Master/Class/GuideInfo/GuideInfoImages.xcassets/detailCnDark.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "detailCnDark.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

Datei-Diff unterdrückt, da er zu groß ist
+ 811 - 0
PDF Office/PDF Master/Class/GuideInfo/GuideInfoImages.xcassets/detailCnDark.imageset/detailCnDark.pdf


+ 127 - 0
PDF Office/PDF Master/Class/GuideInfo/KMCouponDueWindowController.swift

@@ -0,0 +1,127 @@
+//
+//  KMCouponDueWindowController.swift
+//  PDF Reader Pro
+//
+//  Created by Niehaoyu on 2024/5/22.
+//
+
+import Cocoa
+
+class KMCouponDueWindowController: NSWindowController {
+
+    @IBOutlet var contendBox: NSBox!
+    
+    @IBOutlet var contendImage: NSImageView!
+    
+    @IBOutlet var titleLabel: NSTextField!
+    @IBOutlet var subTitleLabel: NSTextField!
+    
+    @IBOutlet var tipInfoView: NSView!
+    @IBOutlet var tipInfoImage: NSImageView!
+    
+    
+    @IBOutlet var buyBox: NSBox!
+    @IBOutlet var buyButton: KMButton!
+    @IBOutlet var laterInfoLabel: NSTextField!
+    
+    var disCount: Int = 20
+    var couponCode: String = ""
+    var endUpAt: String = ""
+    
+    deinit {
+        NotificationCenter.default.removeObserver(self)
+    }
+    
+    override func windowDidLoad() {
+        super.windowDidLoad()
+
+        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
+        
+        self.window?.contentView?.wantsLayer = true
+        
+        self.titleLabel.font = NSFont.SFProTextBoldFont(21)
+        self.subTitleLabel.font = NSFont.SFProTextRegularFont(14)
+        self.buyButton.font = NSFont.SFProTextSemiboldFont(16)
+        self.laterInfoLabel.font = NSFont.SFProTextRegularFont(12)
+        
+        self.buyBox.cornerRadius = CGRectGetHeight(self.buyBox.frame)/2
+        self.buyBox.fillColor = NSColor(red: 255/255, green: 158/255, blue: 42/255, alpha: 1)
+        self.buyButton.mouseMoveCallback = {[weak self] mouseEntered in
+            if mouseEntered {
+                self?.buyBox.fillColor = NSColor(red: 255/255, green: 139/255, blue: 0, alpha: 1)
+            } else {
+                self?.buyBox.fillColor = NSColor(red: 255/255, green: 158/255, blue: 42/255, alpha: 1)
+            }
+        }
+        self.buyButton.setTitleColor(NSColor.white)
+        
+        NotificationCenter.default.addObserver(self, selector: #selector(recommondInfoUpdateNoti), name: NSNotification.Name("KMRecommondInfoUpdateNoti"), object: nil)
+
+    }
+    
+    func refreshUI() {
+        if KMAppearance.isDarkMode() {
+            self.window?.contentView?.layer?.backgroundColor = NSColor(red: 24/255, green: 22/255, blue: 31/255, alpha: 1).cgColor
+            self.titleLabel.textColor = NSColor(red: 252/255, green: 253/255, blue: 255/255, alpha: 1)
+            self.subTitleLabel.textColor = NSColor(red: 252/255, green: 253/255, blue: 255/255, alpha: 1)
+            self.laterInfoLabel.textColor = NSColor(red: 252/255, green: 253/255, blue: 255/255, alpha: 1)
+            
+        } else {
+            self.window?.contentView?.layer?.backgroundColor = NSColor(red: 245/255, green: 249/255, blue: 255/255, alpha: 1).cgColor
+            self.titleLabel.textColor = NSColor(red: 0, green: 33/255, blue: 67/255, alpha: 1)
+            self.subTitleLabel.textColor = NSColor(red: 14/255, green: 17/255, blue: 20/255, alpha: 1)
+            self.laterInfoLabel.textColor = NSColor(red: 0, green: 33/255, blue: 67/255, alpha: 1)
+        }
+        self.buyButton.setTitleColor(NSColor.white)
+        
+    }
+    
+    func reloadData() {
+        self.titleLabel.stringValue = KMAdsInfoManager.shareInstance.couponInfo?.title ?? ""
+        
+        if KMAdsInfo().languageKey == "zh_CN" {
+            self.subTitleLabel.stringValue = String(format: KMAdsInfoManager.shareInstance.couponInfo?.subTitle ?? "", self.endUpAt)
+            self.buyButton.title = String(format: KMAdsInfoManager.shareInstance.couponInfo?.buyBtnTitle ?? "", String(format: "%ld", 10-self.disCount/10))
+        } else {
+            self.subTitleLabel.stringValue = String(format: KMAdsInfoManager.shareInstance.couponInfo?.subTitle ?? "", self.endUpAt, String(format: "%ld", self.disCount))
+            self.buyButton.title = String(format: KMAdsInfoManager.shareInstance.couponInfo?.buyBtnTitle ?? "", String(format: "%ld", self.disCount)+"%")
+        }
+        self.laterInfoLabel.stringValue = String(format: KMAdsInfoManager.shareInstance.couponInfo?.laterInfoString ?? "", self.couponCode)
+        
+        self.contendImage.image = KMAdsInfoManager.shareInstance.couponInfo?.adsImage
+        self.tipInfoImage.image = KMAdsInfoManager.shareInstance.couponInfo?.adsDetailImage
+        
+        self.refreshUI()
+    }
+    
+    //MARK: IBAction
+    @IBAction func buyBtnClicked(_ sender: KMButton) {
+        guard let string = KMAdsInfoManager.shareInstance.couponInfo?.adsURLLink else {
+            return
+        }
+        
+        let newURL = NSURL(string: string+"&coupon_code="+self.couponCode)
+
+        NSWorkspace.shared.open(newURL! as URL)
+        
+        FMTrackEventManager.defaultManager.trackEvent(event: "PUW", withProperties: ["PUW_Btn" : "Btn_PUW_TrialExpireOffer_Buy"])
+    }
+    
+    
+    @objc func recommondInfoUpdateNoti(_ notification: Notification) {
+        DispatchQueue.main.async {
+            guard let dict = notification.object as? NSDictionary else {
+                return
+            }
+            
+            guard let unique = dict["unique"] as? String else {
+                return
+            }
+            if unique == KMAdsInfoManager.shareInstance.couponInfo?.versionKey {
+                self.reloadData()
+            }
+            
+            
+        }
+    }
+}

+ 179 - 0
PDF Office/PDF Master/Class/GuideInfo/KMCouponDueWindowController.xib

@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
+        <capability name="Named colors" minToolsVersion="9.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="KMCouponDueWindowController" customModule="PDF_Reader_Pro" customModuleProvider="target">
+            <connections>
+                <outlet property="buyBox" destination="FYA-2d-xuI" id="u4E-0G-PJU"/>
+                <outlet property="buyButton" destination="Vji-vi-gbH" id="hbM-et-gc8"/>
+                <outlet property="contendBox" destination="bzV-Gq-pe9" id="dYI-Qe-kL5"/>
+                <outlet property="contendImage" destination="x8W-tS-Xhe" id="iJT-E2-Fxz"/>
+                <outlet property="laterInfoLabel" destination="VRY-Yk-fAD" id="V3J-01-cXd"/>
+                <outlet property="subTitleLabel" destination="jjn-yZ-D7c" id="X8B-q2-JDe"/>
+                <outlet property="tipInfoImage" destination="GkG-tR-cLY" id="Oe9-x1-7YF"/>
+                <outlet property="tipInfoView" destination="f1m-ug-ENL" id="gor-we-zNF"/>
+                <outlet property="titleLabel" destination="mL0-nw-nO3" id="uPj-4g-B9V"/>
+                <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
+            </connections>
+        </customObject>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" titlebarAppearsTransparent="YES" titleVisibility="hidden" id="F0z-JX-Cv5">
+            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" fullSizeContentView="YES"/>
+            <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+            <rect key="contentRect" x="196" y="240" width="660" height="443"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
+            <value key="minSize" type="size" width="660" height="443"/>
+            <value key="maxSize" type="size" width="660" height="443"/>
+            <view key="contentView" id="se5-gp-TjO">
+                <rect key="frame" x="0.0" y="0.0" width="660" height="443"/>
+                <autoresizingMask key="autoresizingMask"/>
+                <subviews>
+                    <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="bzV-Gq-pe9">
+                        <rect key="frame" x="29" y="27" width="602" height="380"/>
+                        <view key="contentView" id="VA0-92-LSU">
+                            <rect key="frame" x="0.0" y="0.0" width="602" height="380"/>
+                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                            <subviews>
+                                <customView translatesAutoresizingMaskIntoConstraints="NO" id="4n1-ck-aYe">
+                                    <rect key="frame" x="0.0" y="0.0" width="300" height="380"/>
+                                    <subviews>
+                                        <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="x8W-tS-Xhe">
+                                            <rect key="frame" x="0.0" y="0.0" width="300" height="380"/>
+                                            <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="UDr-qh-Sdk"/>
+                                        </imageView>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstItem="x8W-tS-Xhe" firstAttribute="leading" secondItem="4n1-ck-aYe" secondAttribute="leading" id="0pT-7K-Vcc"/>
+                                        <constraint firstItem="x8W-tS-Xhe" firstAttribute="top" secondItem="4n1-ck-aYe" secondAttribute="top" id="HXG-6I-MLq"/>
+                                        <constraint firstAttribute="height" constant="380" id="LGw-1W-FHg"/>
+                                        <constraint firstAttribute="width" constant="300" id="PaQ-iC-qHB"/>
+                                        <constraint firstAttribute="trailing" secondItem="x8W-tS-Xhe" secondAttribute="trailing" id="c37-hJ-FxL"/>
+                                        <constraint firstAttribute="bottom" secondItem="x8W-tS-Xhe" secondAttribute="bottom" id="fqG-Pr-D6G"/>
+                                    </constraints>
+                                </customView>
+                                <customView translatesAutoresizingMaskIntoConstraints="NO" id="IRn-Nx-1SH">
+                                    <rect key="frame" x="336" y="21" width="266" height="338"/>
+                                    <subviews>
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mL0-nw-nO3">
+                                            <rect key="frame" x="-2" y="313" width="172" height="25"/>
+                                            <textFieldCell key="cell" alignment="left" title="Limited-time Offer" id="Dv5-Ir-uCY">
+                                                <font key="font" metaFont="system" size="21"/>
+                                                <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                            </textFieldCell>
+                                        </textField>
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jjn-yZ-D7c">
+                                            <rect key="frame" x="-2" y="258" width="270" height="51"/>
+                                            <constraints>
+                                                <constraint firstAttribute="width" constant="266" id="6J1-BA-Y1S"/>
+                                            </constraints>
+                                            <textFieldCell key="cell" alignment="left" title="Dear, your free trial has expired on 2024-05-17. PDF Reader Pro offers 20% OFF for new users!" id="2mW-gH-wXX">
+                                                <font key="font" metaFont="system" size="14"/>
+                                                <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                            </textFieldCell>
+                                        </textField>
+                                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="f1m-ug-ENL">
+                                            <rect key="frame" x="0.0" y="126" width="266" height="100"/>
+                                            <subviews>
+                                                <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GkG-tR-cLY">
+                                                    <rect key="frame" x="0.0" y="0.0" width="266" height="100"/>
+                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+                                                    <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="erh-zg-aUs"/>
+                                                </imageView>
+                                            </subviews>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="100" id="TLT-K4-KS3"/>
+                                            </constraints>
+                                        </customView>
+                                        <box boxType="custom" borderType="none" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="FYA-2d-xuI">
+                                            <rect key="frame" x="0.0" y="46" width="266" height="48"/>
+                                            <view key="contentView" id="2Nb-6M-k48">
+                                                <rect key="frame" x="0.0" y="0.0" width="266" height="48"/>
+                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                                <subviews>
+                                                    <button focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Vji-vi-gbH" customClass="KMButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                                        <rect key="frame" x="0.0" y="0.0" width="266" height="48"/>
+                                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                                        <buttonCell key="cell" type="bevel" title="Buy with 20% OFF" bezelStyle="rounded" imagePosition="overlaps" alignment="center" focusRingType="none" imageScaling="axesIndependently" inset="2" id="GEO-t7-YwI">
+                                                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                                            <font key="font" metaFont="system" size="15"/>
+                                                        </buttonCell>
+                                                        <color key="contentTintColor" name="Color"/>
+                                                        <connections>
+                                                            <action selector="buyBtnClicked:" target="-2" id="zsV-Mv-Qqr"/>
+                                                        </connections>
+                                                    </button>
+                                                </subviews>
+                                            </view>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="48" id="Vh6-An-tIy"/>
+                                                <constraint firstAttribute="width" constant="266" id="j43-O9-4Ug"/>
+                                            </constraints>
+                                            <color key="fillColor" red="1" green="0.61799015410958902" blue="0.16566780821917809" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                        </box>
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="VRY-Yk-fAD">
+                                            <rect key="frame" x="-2" y="20" width="270" height="14"/>
+                                            <constraints>
+                                                <constraint firstAttribute="width" constant="266" id="5bJ-Fv-1Zy"/>
+                                            </constraints>
+                                            <textFieldCell key="cell" selectable="YES" alignment="center" title="--" id="Ukb-Yc-wec">
+                                                <font key="font" metaFont="smallSystem"/>
+                                                <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                            </textFieldCell>
+                                        </textField>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstItem="jjn-yZ-D7c" firstAttribute="top" secondItem="mL0-nw-nO3" secondAttribute="bottom" constant="4" id="17A-jq-I3m"/>
+                                        <constraint firstItem="f1m-ug-ENL" firstAttribute="top" secondItem="jjn-yZ-D7c" secondAttribute="bottom" constant="32" id="5be-PI-GD5"/>
+                                        <constraint firstItem="mL0-nw-nO3" firstAttribute="top" secondItem="IRn-Nx-1SH" secondAttribute="top" id="6LD-X2-01L"/>
+                                        <constraint firstAttribute="width" constant="266" id="6PQ-O8-DxR"/>
+                                        <constraint firstItem="VRY-Yk-fAD" firstAttribute="centerX" secondItem="IRn-Nx-1SH" secondAttribute="centerX" id="8W6-hg-tKI"/>
+                                        <constraint firstItem="VRY-Yk-fAD" firstAttribute="top" secondItem="FYA-2d-xuI" secondAttribute="bottom" constant="12" id="NSI-IU-0Ih"/>
+                                        <constraint firstAttribute="trailing" secondItem="f1m-ug-ENL" secondAttribute="trailing" id="Ovd-gM-4mt"/>
+                                        <constraint firstAttribute="height" constant="338" id="hbJ-aj-SrA"/>
+                                        <constraint firstItem="FYA-2d-xuI" firstAttribute="centerX" secondItem="IRn-Nx-1SH" secondAttribute="centerX" id="nPv-ou-sau"/>
+                                        <constraint firstItem="f1m-ug-ENL" firstAttribute="leading" secondItem="IRn-Nx-1SH" secondAttribute="leading" id="npJ-jY-Mhx"/>
+                                        <constraint firstItem="FYA-2d-xuI" firstAttribute="top" secondItem="f1m-ug-ENL" secondAttribute="bottom" constant="32" id="pXg-Rn-Hvk"/>
+                                        <constraint firstItem="jjn-yZ-D7c" firstAttribute="leading" secondItem="IRn-Nx-1SH" secondAttribute="leading" id="qdr-jp-cAz"/>
+                                        <constraint firstItem="mL0-nw-nO3" firstAttribute="leading" secondItem="IRn-Nx-1SH" secondAttribute="leading" id="ur5-xj-WPj"/>
+                                    </constraints>
+                                </customView>
+                            </subviews>
+                            <constraints>
+                                <constraint firstAttribute="bottom" secondItem="IRn-Nx-1SH" secondAttribute="bottom" constant="21" id="5xZ-JP-B1h"/>
+                                <constraint firstAttribute="bottom" secondItem="4n1-ck-aYe" secondAttribute="bottom" id="EjT-er-VP4"/>
+                                <constraint firstItem="4n1-ck-aYe" firstAttribute="leading" secondItem="VA0-92-LSU" secondAttribute="leading" id="VAV-Im-tPk"/>
+                                <constraint firstAttribute="trailing" secondItem="IRn-Nx-1SH" secondAttribute="trailing" id="jQF-ja-dvX"/>
+                            </constraints>
+                        </view>
+                        <constraints>
+                            <constraint firstAttribute="height" constant="380" id="VR1-cD-sgF"/>
+                            <constraint firstAttribute="width" constant="602" id="Y4g-au-WfJ"/>
+                        </constraints>
+                    </box>
+                </subviews>
+                <constraints>
+                    <constraint firstItem="bzV-Gq-pe9" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="29" id="cQ1-68-6lw"/>
+                    <constraint firstAttribute="bottom" secondItem="bzV-Gq-pe9" secondAttribute="bottom" constant="27" id="zWc-2T-LdA"/>
+                </constraints>
+            </view>
+            <connections>
+                <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
+            </connections>
+            <point key="canvasLocation" x="147" y="116"/>
+        </window>
+    </objects>
+    <resources>
+        <namedColor name="Color">
+            <color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </namedColor>
+    </resources>
+</document>

+ 59 - 5
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift

@@ -104,6 +104,8 @@ import Cocoa
     var repeatTrialAlertLoad: Bool = false
     
     var guideWindowVC: KMFunctionGuideWindowController!
+    var showCoupon: Bool = true
+    var couponDueWindowVC: KMCouponDueWindowController!
     
     @IBOutlet weak var rightBottonHeight: NSLayoutConstraint!
     
@@ -232,6 +234,20 @@ import Cocoa
                         }
                         KMAdsInfoManager.shareInstance.adsInfoArrM = arrM
                     }
+                    
+                    if let couponInfo = KMAdvertisementManager.manager.infoDict["couponContent"] {
+                        let infoDict: NSDictionary = KMAdvertisementManager.manager.infoDict["couponContent"] as! NSDictionary
+                        let array: [[String: Any]] = infoDict["content"] as! [[String : Any]]
+                        if array.isEmpty == false {
+                            let dict = array[0]
+                            let adsInfo = KMCouponInfo.init()
+                            let mutableDictionary = NSMutableDictionary(dictionary: dict)
+                            adsInfo.infoDict = mutableDictionary
+                            KMAdsInfoManager.shareInstance.couponInfo = adsInfo
+                            
+                            self.checkTrialEndCouponInfo()
+                        }
+                    }
                 }
             }
         }
@@ -978,15 +994,53 @@ extension KMHomeViewController {
         vc?.showWindow(nil)
     }
     
+    //MARK: 试用到期优惠券弹窗
+    func checkTrialEndCouponInfo() {
+        
+        KMRequestServerManager.manager.getDeviceRetensionCoupon {[weak self] success, result in
+            if success == true {
+                if result != nil {
+                    guard let dataDict = result!["data"] as? NSDictionary else {
+                        return
+                    }
+                    //                        if dataDict!["pop_up"] as? Bool == true {
+                    let discount = dataDict["discount"] as? Int
+                    let coupon_code = dataDict["coupon_code"] as? String
+                    let end_up_at = dataDict["end_up_at"] as? String
+                    
+                    self?.showCouponInfoWindow(discount: discount, couponCode: coupon_code, endUpAt: end_up_at)
+
+                }
+            } else {
+#if VERSION_DMG
+                if KMVerificationWindowController.allowsShowExpired() {
+                    self?.checkRepeatTrialExpiredController()
+                } else if KMVerificationWindowController.allowRepeatTrialAlertShow() {
+                    self?.checkRepeatTrialAlertController()
+                }
+#endif
+                
+            }
+        }
+    }
+    
+    func showCouponInfoWindow(discount: Int?, couponCode: String?, endUpAt: String?) {
+        if self.couponDueWindowVC == nil {
+            self.couponDueWindowVC = KMCouponDueWindowController(windowNibName: "KMCouponDueWindowController")
+        }
+        self.couponDueWindowVC.disCount = discount ?? 20
+        self.couponDueWindowVC.couponCode = couponCode ?? ""
+        self.couponDueWindowVC.endUpAt = endUpAt ?? ""
+        
+        self.couponDueWindowVC.showWindow(nil)
+        self.couponDueWindowVC.reloadData()
+        
+    }
     
     // MARK: - Noti Actions
     func deviceVerifyFinishNotification(_ sender: Notification) {
 #if VERSION_DMG
-        if KMVerificationWindowController.allowsShowExpired() {
-            self.checkRepeatTrialExpiredController()
-        } else if KMVerificationWindowController.allowRepeatTrialAlertShow() {
-            self.checkRepeatTrialAlertController()
-        }
+         
 #endif
     }
     

+ 25 - 0
PDF Office/PDF Master/Class/KMLightMember/Manager/KMRequestServerManager.swift

@@ -173,6 +173,7 @@ struct Result {
 }
 
 typealias KMRequestServerComplete = (_ success: Bool, _ result: Result?) -> Void
+typealias KMRequestServerDateComplete = (_ success: Bool, _ result: NSDictionary?) -> Void
 
 
 class KMRequestServerManager: NSObject {
@@ -478,6 +479,30 @@ extension KMRequestServerManager {
             }
         }
     }
+    
+    func getDeviceRetensionCoupon(complete: @escaping KMRequestServerDateComplete) {
+
+        let urlString = AIInfoConfig().aiActionURL + "api/devices/getRetensionCoupon"
+        let params: [String:Any] = ["unique_sn": self.uuid(),
+                                    "platform": "DMG"]
+
+        KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: params) { requestSerializer in
+            requestSerializer.setValue("Apifox/1.0.0 (https://www.apifox.cn)", forHTTPHeaderField: "User-Agent")
+        } completion: { [unowned self] (task, responseObject, error) in
+            let result = self.dealData(responseObject: responseObject as? NSDictionary, error: error)
+            if result.code == 200 && result.error != nil {
+                complete(true, responseObject as? NSDictionary)
+            } else {
+                complete(false, responseObject as? NSDictionary)
+            }
+        }
+    }
+    
+    
+    //MARK: Private Method
+    private func uuid() -> String {
+        return GetHardwareUUID()!
+    }
 }
 
 //MARK: - 订阅

+ 118 - 2
PDF Office/PDF Master/Class/Purchase/DMG/Verification/VerificationManager/KMAdsInfo.swift

@@ -13,6 +13,8 @@ import Cocoa
     
     public var adsInfoArrM: NSMutableArray = NSMutableArray()
     
+    var couponInfo: KMCouponInfo?
+    
     override init() {
         super.init()
         
@@ -117,9 +119,11 @@ import Cocoa
     
     var languageKey: String {
         let language = Bundle.main.preferredLocalizations[0]
-        if language == "zh_CN" {
+        if language == "zh_CN" ||
+            language == "zh-Hans" {
             return "zh_CN"
-        } else if language == "zh_TW" {
+        } else if language == "zh_TW" ||
+                    language == "zh-Hant" {
             return "zh_TW"
         }
         return "en"
@@ -131,3 +135,115 @@ import Cocoa
     
     
 }
+
+
+@objcMembers class KMCouponInfo: NSObject {
+
+    var infoDict: NSMutableDictionary!
+     
+    
+    var adsImage: NSImage {
+        get {
+            
+            let imageDict: [String: Any] = self.infoDict["image"] as! [String : Any]
+            var languageKey = KMAdsInfo().languageKey
+            if KMAppearance.isDarkMode() {
+                languageKey = "dark_" + KMAdsInfo().languageKey
+            }
+            guard let imageURLString = imageDict[languageKey] as? String else {
+                return NSImage(named: "cnLight")!
+            }
+            
+            var imageName = self.versionKey
+            imageName.append(String(format: "_%@.%@", languageKey, imageURLString.lastPathComponent))
+ 
+            let kImageCacheFilePath: String = NSTemporaryDirectory() + "Advertisement/ImageCache"
+            let imgSavePath = kImageCacheFilePath + "/" + imageName
+            if FileManager.default.fileExists(atPath: imgSavePath) {
+                return NSImage(contentsOfFile: imgSavePath)!
+            }
+             
+            DispatchQueue.global().async {
+                if let url = URL(string: imageURLString as String),
+                   let imageData = try? Data(contentsOf: url) {
+                    if imageData.isEmpty == false {
+                        DispatchQueue.main.async {
+                            try?imageData.write(to: URL(fileURLWithPath: imgSavePath))
+                            NotificationCenter.default.post(name: Notification.Name(rawValue: "KMRecommondInfoUpdateNoti"), object: ["unique":self.versionKey])
+                        }
+                    }
+                }
+            }
+             
+            return NSImage(named: "cnLight")!
+        }
+    }
+    
+    var adsDetailImage: NSImage {
+        get {
+            
+            let imageDict: [String: Any] = self.infoDict["detailImage"] as! [String : Any]
+            var languageKey = KMAdsInfo().languageKey
+            if KMAppearance.isDarkMode() {
+                languageKey = "dark_" + KMAdsInfo().languageKey
+            }
+            guard let imageURLString = imageDict[languageKey] as? NSString else {
+                return NSImage(named: "detailCnDark")!
+            }
+            
+            var imageName = self.versionKey
+            imageName.append(String(format: "_%@.%@", languageKey, imageURLString.lastPathComponent))
+ 
+            let kImageCacheFilePath: String = NSTemporaryDirectory() + "Advertisement/ImageCache"
+            let imgSavePath = kImageCacheFilePath + "/" + imageName
+            if FileManager.default.fileExists(atPath: imgSavePath) {
+                return NSImage(contentsOfFile: imgSavePath)!
+            }
+             
+            DispatchQueue.global().async {
+                if let url = URL(string: imageURLString as String),
+                   let imageData = try? Data(contentsOf: url) {
+                    if imageData.isEmpty == false {
+                        DispatchQueue.main.async {
+                            try?imageData.write(to: URL(fileURLWithPath: imgSavePath))
+                            NotificationCenter.default.post(name: Notification.Name(rawValue: "KMRecommondInfoUpdateNoti"), object: ["unique":self.versionKey])
+                        }
+                    }
+                }
+            }
+             
+            return NSImage(named: "detailCnDark")!
+        }
+    }
+    
+    var adsURLLink: String {
+        get {
+            let linkDict: [String: Any] = self.infoDict["linkURL"] as! [String : Any]
+            return linkDict[KMAdsInfo().languageKey] as! String
+        }
+    }
+    
+    var versionKey: String {
+        return self.infoDict["version"] as! String
+    }
+    
+    var title: String {
+        let titleDict: [String: Any] = self.infoDict["title"] as! [String : Any]
+        return titleDict[KMAdsInfo().languageKey] as! String
+    }
+    
+    var subTitle: String {
+        let titleDict: [String: Any] = self.infoDict["subTitle"] as! [String : Any]
+        return titleDict[KMAdsInfo().languageKey] as! String
+    }
+    
+    var buyBtnTitle: String {
+        let titleDict: [String: Any] = self.infoDict["buyBtnTitle"] as! [String : Any]
+        return titleDict[KMAdsInfo().languageKey] as! String
+    }
+    
+    var laterInfoString: String {
+        let titleDict: [String: Any] = self.infoDict["laterInfoString"] as! [String : Any]
+        return titleDict[KMAdsInfo().languageKey] as! String
+    }
+}

+ 16 - 0
PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj

@@ -5044,6 +5044,12 @@
 		BBFDFAA22AF3815C00E08AA2 /* KMTextHintWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFDFAA12AF3815B00E08AA2 /* KMTextHintWindowController.xib */; };
 		BBFDFAA32AF3815C00E08AA2 /* KMTextHintWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFDFAA12AF3815B00E08AA2 /* KMTextHintWindowController.xib */; };
 		BBFDFAA42AF3815C00E08AA2 /* KMTextHintWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFDFAA12AF3815B00E08AA2 /* KMTextHintWindowController.xib */; };
+		BBFE14CF2BFD7FC300176992 /* KMCouponDueWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFE14CD2BFD7FC300176992 /* KMCouponDueWindowController.swift */; };
+		BBFE14D02BFD7FC300176992 /* KMCouponDueWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFE14CD2BFD7FC300176992 /* KMCouponDueWindowController.swift */; };
+		BBFE14D12BFD7FC300176992 /* KMCouponDueWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFE14CD2BFD7FC300176992 /* KMCouponDueWindowController.swift */; };
+		BBFE14D22BFD7FC300176992 /* KMCouponDueWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFE14CE2BFD7FC300176992 /* KMCouponDueWindowController.xib */; };
+		BBFE14D32BFD7FC300176992 /* KMCouponDueWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFE14CE2BFD7FC300176992 /* KMCouponDueWindowController.xib */; };
+		BBFE14D42BFD7FC300176992 /* KMCouponDueWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFE14CE2BFD7FC300176992 /* KMCouponDueWindowController.xib */; };
 		BBFE6E582930724B00142C01 /* KMMergePageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFE6E572930724B00142C01 /* KMMergePageModel.swift */; };
 		BBFE6E592930724B00142C01 /* KMMergePageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFE6E572930724B00142C01 /* KMMergePageModel.swift */; };
 		BBFE6E5A2930724B00142C01 /* KMMergePageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFE6E572930724B00142C01 /* KMMergePageModel.swift */; };
@@ -7314,6 +7320,8 @@
 		BBFDFA922AF328B200E08AA2 /* KMBatchOperateManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchOperateManager.swift; sourceTree = "<group>"; };
 		BBFDFA9D2AF3814000E08AA2 /* KMTextHintWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMTextHintWindowController.swift; sourceTree = "<group>"; };
 		BBFDFAA12AF3815B00E08AA2 /* KMTextHintWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMTextHintWindowController.xib; sourceTree = "<group>"; };
+		BBFE14CD2BFD7FC300176992 /* KMCouponDueWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMCouponDueWindowController.swift; sourceTree = "<group>"; };
+		BBFE14CE2BFD7FC300176992 /* KMCouponDueWindowController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMCouponDueWindowController.xib; sourceTree = "<group>"; };
 		BBFE6E572930724B00142C01 /* KMMergePageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMMergePageModel.swift; sourceTree = "<group>"; };
 		BBFE6E5B2930809A00142C01 /* KMMergeCollectionPageViewItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMMergeCollectionPageViewItem.swift; sourceTree = "<group>"; };
 		BBFE6E5C2930809A00142C01 /* KMMergeCollectionPageViewItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMMergeCollectionPageViewItem.xib; sourceTree = "<group>"; };
@@ -11196,6 +11204,8 @@
 				BB1B0ABE2B4FC6E800889528 /* KMGuideInfoWindowController.xib */,
 				BB1B0AA52B4FC6E800889528 /* KMFunctionGuideWindowController.swift */,
 				BB1B0AA22B4FC6E800889528 /* KMFunctionGuideWindowController.xib */,
+				BBFE14CD2BFD7FC300176992 /* KMCouponDueWindowController.swift */,
+				BBFE14CE2BFD7FC300176992 /* KMCouponDueWindowController.xib */,
 				BB1B0AA62B4FC6E800889528 /* Controllers */,
 			);
 			path = GuideInfo;
@@ -14309,6 +14319,7 @@
 				BB03D6A02B024AC8008C9976 /* KMPDFEditInsertPageWindow.xib in Resources */,
 				AD1D48252AFB6BCB007AC1F0 /* KMMergeView.xib in Resources */,
 				F3B7DF9D2948565000333201 /* CPDFListHoverAnnotationViewController.xib in Resources */,
+				BBFE14D22BFD7FC300176992 /* KMCouponDueWindowController.xib in Resources */,
 				BB4F7E912B0C80000077EC8C /* KMNoteColorCollectionViewItem.xib in Resources */,
 				ADF1569C29A63CBF001D1018 /* KMLightMember.xcassets in Resources */,
 				ADAFDA792AEB5FCD00F084BC /* KMHomeHistoryCollectionItem.xib in Resources */,
@@ -14929,6 +14940,7 @@
 				BB1E7F2D2B4FE2C6002D9785 /* GuideInfoImages.xcassets in Resources */,
 				89752DEE293875FC003FF08E /* KMMainToolbarController.xib in Resources */,
 				BB49ED0A293F461500C82CA2 /* KMConvertCSVWindowController.xib in Resources */,
+				BBFE14D32BFD7FC300176992 /* KMCouponDueWindowController.xib in Resources */,
 				BBEC00B3295C2AF300A26C98 /* KMBatesPreviewController.xib in Resources */,
 				BB49ED12293F462E00C82CA2 /* KMConvertImageWindowController.xib in Resources */,
 				AD1CA4042A06040B0070541F /* KMAnnotationScreenCollectionView.xib in Resources */,
@@ -15368,6 +15380,7 @@
 				BBFE6E7A2930E53000142C01 /* KMMergePopoverViewController.xib in Resources */,
 				89D9897128FD50EF003A3E87 /* KMAnnotationCollectionViewItem.xib in Resources */,
 				9F1FE4E929406E4700E952CA /* COPYING in Resources */,
+				BBFE14D42BFD7FC300176992 /* KMCouponDueWindowController.xib in Resources */,
 				BB5F8A1B29BB15AD00365ADB /* pic_mail.pdf in Resources */,
 				AD3AAD952B1034C000DE5FE7 /* KMHeaderFooterView.xib in Resources */,
 				BBEC00B4295C2AF300A26C98 /* KMBatesPreviewController.xib in Resources */,
@@ -16146,6 +16159,7 @@
 				9FD0D2AF2AD51BCC00DA3FF8 /* CPDFListEditAnnotationViewController.swift in Sources */,
 				ADAFDA422AE8F3C400F084BC /* KMAdvertisementTimeStampConversion.swift in Sources */,
 				BB10F1E42B736F11008EAF7E /* FMTrackEventManager.swift in Sources */,
+				BBFE14CF2BFD7FC300176992 /* KMCouponDueWindowController.swift in Sources */,
 				9F0CB4E92986559400007028 /* KMDesignToken+PaddingBottom.swift in Sources */,
 				ADDDCE272B43A32A005B4AB5 /* AppSandboxFileAccessOpenSavePanelDelegate.m in Sources */,
 				BB570ADB2B512C90005E7E4A /* KMLeftSideViewController+Thumbnail.swift in Sources */,
@@ -17919,6 +17933,7 @@
 				9F0CB49829683E1000007028 /* KMPropertiesPanelTextSubVC.swift in Sources */,
 				9F1FE4AC29406E4700E952CA /* CTBrowserWindow.m in Sources */,
 				9FF816DE2AFA5B8E0087EFC5 /* KMAnnotationTableViewController.swift in Sources */,
+				BBFE14D02BFD7FC300176992 /* KMCouponDueWindowController.swift in Sources */,
 				AD0FA50329A8E36200EDEB50 /* KMLightMemberAlertView.swift in Sources */,
 				9F0CB53E2986571A00007028 /* KMDesignToken+Typography.swift in Sources */,
 				9FCFEC712AC40F9B00EAD2CB /* CStampSignatureObject.swift in Sources */,
@@ -18538,6 +18553,7 @@
 				9F0CB4DB2986553600007028 /* KMDesignToken+VerticalPadding.swift in Sources */,
 				BB1B0AF42B4FC6E900889528 /* KMFunctionGuideNameItemView.swift in Sources */,
 				BB6DD816293486FA001F0544 /* KMSecureEncryptPasswordCellView.swift in Sources */,
+				BBFE14D12BFD7FC300176992 /* KMCouponDueWindowController.swift in Sources */,
 				9F1FE4C829406E4700E952CA /* CTUtil.m in Sources */,
 				BB147010299DC0D100784A6A /* OIDScopes.m in Sources */,
 				BBA922342B4E97540061057A /* KMPurchaseLimitWindowController.swift in Sources */,