Parcourir la source

【会员系统】- 注销账户时间一直固定7天

dinglingui il y a 3 mois
Parent
commit
b2941bb4dd

+ 35 - 2
PDF Office/PDF Master/MemberCenter/ViewModel/KMUserInfoVCModel.swift

@@ -229,8 +229,41 @@ class KMUserInfoVCModel: ObservableObject {
             let msg = resultDict.msg
             if success {
                 let logOff: KMMemberLogOff = resultDict.logOff!
-                if let token = logOff.currentTime { KMCloseApplyWC.shared.currentTime = token }
-                if let token = logOff.logOffTime { KMCloseApplyWC.shared.logOffTime = token }
+                var currentTime = "0"
+                var logOffTime = "0"
+
+                let currentDate = Date()
+                let calendar = Calendar.current
+
+                if let token = logOff.currentTime {
+                    let dateFormatter = DateFormatter()
+                    dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
+                    // 将字符串转换为日期对象
+                    if let date = dateFormatter.date(from: token) {
+                        // 创建一个新的日期格式化器,用于只显示天
+                        let components = calendar.dateComponents([.day], from: currentDate, to: date)
+                        
+                        if let daysDifference = components.day {
+                            currentTime = String(daysDifference)
+                        }
+                    }
+                }
+                if let token = logOff.logOffTime {
+                    let dateFormatter = DateFormatter()
+                    dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
+                    
+                    // 将字符串转换为日期对象
+                    if let date = dateFormatter.date(from: token) {
+                        let components = calendar.dateComponents([.day], from: currentDate, to: date)
+                        
+                        if let daysDifference = components.day {
+                            logOffTime = String(daysDifference)
+                        }
+                    }
+                }
+//                KMCloseApplyWC.shared.logOffTime = logOffTime
+//                KMCloseApplyWC.shared.currentTime = currentTime
+
                 KMCloseApplyWC.shared.showWindow(nil)
             } else {
                 print(msg as Any)

+ 1 - 1
PDF Office/PDF Master/MemberCenter/WindowsController/KMCloseApplyWC.swift

@@ -14,7 +14,7 @@ class KMCloseApplyWC: NSWindowController {
     @IBOutlet weak var subTitleLabel: NSTextField!
     @IBOutlet weak var yesButton: NSButton!
     
-    var currentTime: String = ""
+    var currentTime: String = "7"
     var logOffTime: String = "7"
 
     private var viewModel = KMUserInfoVCModel()

+ 6 - 6
PDF Office/PDF Master/MemberCenter/WindowsController/KMCloseApplyWC.xib

@@ -1,8 +1,8 @@
 <?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">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -19,14 +19,14 @@
         <window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
             <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
             <rect key="contentRect" x="196" y="240" width="358" height="312"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
             <value key="minSize" type="size" width="358" height="312"/>
             <value key="maxSize" type="size" width="358" height="312"/>
             <view key="contentView" id="se5-gp-TjO">
                 <rect key="frame" x="0.0" y="0.0" width="358" height="312"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RB3-y4-vun">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RB3-y4-vun">
                         <rect key="frame" x="18" y="216" width="322" height="16"/>
                         <constraints>
                             <constraint firstAttribute="width" constant="318" id="gmc-If-mgM"/>
@@ -37,12 +37,12 @@
                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="EQD-z7-1z0">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="EQD-z7-1z0">
                         <rect key="frame" x="18" y="256" width="322" height="16"/>
                         <constraints>
                             <constraint firstAttribute="width" constant="318" id="jb4-a1-xPP"/>
                         </constraints>
-                        <textFieldCell key="cell" lineBreakMode="charWrapping" title="Label" id="IBg-5H-TzV">
+                        <textFieldCell key="cell" title="Label" id="IBg-5H-TzV">
                             <font key="font" usesAppearanceFont="YES"/>
                             <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>