杨锴
2025-04-16 09a372bc45fde16fd42257ab6f78b8deeecf720b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//
//  Def.swift
//  WanPai
//
//  Created by 杨锴 on 2023/6/7.
//
 
import Foundation
import UIKit
import JQTools
import SVProgressHUD
import QMUIKit
import OSLog
 
let WeChatAPPID = "wx4b9c1d814c2902a3"
let WeChatSecrect = "60fed4b6f52603ba6769e1118b4a57ae"
 
let AppleID = "6737112249"
 
let app = UIApplication.shared.delegate as! AppDelegate
 
let locationTool = JQ_LocationTool.instance()
let ShareAppleKey = ""
let DocumentPath =  NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory,FileManager.SearchPathDomainMask.userDomainMask,true).last
 
var sceneDelegate:SceneDelegate? = {
    var uiScreen:UIScene?
    UIApplication.shared.connectedScenes.forEach { scenes in
        uiScreen = scenes
    }
    return (uiScreen?.delegate as? SceneDelegate)
}()
 
func LogSuccess(_ items:Any...,separator:String=" ",file:String=#file,function:String=#function,line:Int=#line){
#if DEBUG
    if #available(iOS 14.0, *) {
        let logger = Logger(subsystem: "WanPai", category: function)
        logger.error("\(items)")
    }else{
        let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
        print("✅✅✅ SUCCESS: \(file)  \(function) [Line: \(line)]: \(items)",separator);
    }
 
#endif
}
 
func LogError(_ items:Any...,separator:String=" ",file:String=#file,function:String=#function,line:Int=#line){
#if DEBUG
    if #available(iOS 14.0, *) {
        let logger = Logger(subsystem: "WanPai", category: function)
        logger.error("\(items)")
    }else{
        let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
        print("❌❌❌ ERROR: \(file)  \(function) [Line: \(line)]: \(items)",separator);
    }
#endif
}
 
func LogInfo(_ items:Any...,separator:String=" ",file:String=#file,function:String=#function,line:Int=#line){
#if DEBUG
    if #available(iOS 14.0, *) {
        let logger = Logger(subsystem: "WanPai", category: function)
        logger.error("\(items)")
    }else{
        let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
        print("⚠️⚠️⚠️INFO: \(file)  \(function) [Line: \(line)]: \(items)",separator);
    }
#endif
}
 
func LogResponse(_ items:Any...,separator:String=" ",file:String=#file,function:String=#function,line:Int=#line){
#if DEBUG
    print("返回数据")
    print(items);
#endif
}
 
//提示框
func alert(msg: String) {
    SVProgressHUD.showInfo(withStatus: msg)
}
 
func alertError(msg:String){
    SVProgressHUD.showError(withStatus: msg)
}
 
func alertSuccess(msg:String){
    SVProgressHUD.showSuccess(withStatus: msg)
}
 
func showHUD(_ text:String? = nil){
    SVProgressHUD.show(withStatus: text)
}
 
func hiddenHUD(_ delay:TimeInterval? = nil){
    if delay != nil{
        SVProgressHUD.dismiss(withDelay: delay!)
    }else{
        SVProgressHUD.dismiss()
    }
}
 
extension UIButton {
    func localGradientColor(cornerRadius:Double,bounds:CGRect? = nil,clear:Bool = false){
        self.layer.sublayers?.removeAll(where: {$0 is CAGradientLayer})
        self.jq_gradientColor(colorArr: [UIColor(hexStr: "#8EA47A").cgColor,UIColor(hexStr: "#AFCA98").cgColor], cornerRadius: cornerRadius, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 1, y: 0), bounds: bounds,clear: clear)
    }
 
    public func openCountDown(_ t:Int = 59,defultTitle:String = "获取验证码"){
        var time = t //倒计时时间
        let queue = DispatchQueue.global()
        let timer = DispatchSource.makeTimerSource(flags: [], queue: queue)
        timer.schedule(wallDeadline: DispatchWallTime.now(), repeating: .seconds(1));
        timer.setEventHandler(handler: {
            if time <= 0 {
                timer.cancel()
                DispatchQueue.main.async(execute: {
                    self.setTitle(defultTitle, for: .normal)
                    self.setTitleColor(UIColor(hexStr: "#63BDDB"), for: .normal)
                    self.isUserInteractionEnabled = true
                });
            }else {
                DispatchQueue.main.async(execute: {
                    self.setTitle("\(time)s", for: .normal)
                    self.setTitleColor(UIColor.gray, for: .normal)
                    self.isUserInteractionEnabled = false
                });
            }
            time -= 1
        });
        timer.resume()
    }
}
 
extension Double{
    var radioW:Double{
        return 390.0 * sceneDelegate!.window!.height / 844.0
    }
 
    var radioH:Double{
        return sceneDelegate!.window!.height / 844.0 * self
    }
}
 
extension CGFloat{
    var radioW:CGFloat{
        return 390.0 * sceneDelegate!.window!.height / 844.0
    }
 
    var radioH:CGFloat{
        return 844.0 * sceneDelegate!.window!.width / 390.0
    }
}
 
let isSimulator: Bool = {
#if targetEnvironment(simulator)
    return true
#else
    return false
#endif
}()