杨锴
2025-05-11 7453d2d0cef415b34323d1b91e6cfa4a6ba31178
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
//
//  Def.swift
//  WanPai
//
//  Created by 杨锴 on 2023/6/7.
//
 
import Foundation
import UIKit
import JQTools
import SVProgressHUD
import QMUIKit
import OSLog
 
let SHAKEY = "BT7NPhA0f775uzcUuftWjCE1TYZlWmHZ"
let WechatUniversalLinks = "https://www.weparklife.com/"
let WeChatAPPID = "wx41d32f362ba0f911"
let WeChatSecrect = "cf0ebf950f5926a69041a0e2bbe20f3e"
let APPScheme = "weparklife"
let AMapKey = "a2aff8a000be5543e410555c548793b8"
let WeChatMinProgram = "gh_fea25aea0fc8" //
let WeChatMinProgramPath = "pages-sub/web/index"
 
let app = UIApplication.shared.delegate as! AppDelegate
 
let locationTool = JQ_LocationTool.instance()
 
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){
                                self.layer.sublayers?.removeAll(where: {$0 is CAGradientLayer})
                                self.jq_gradientColor(colorArr: [UIColor(hexStr: "#FD8802").cgColor,UIColor(hexStr: "#FE7703").cgColor], cornerRadius: cornerRadius, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 1), bounds: bounds)
                }
 
                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()
                }
}
 
func jumpPage(model:String,page:String = "",type:String = "",id:Int? = nil){
 
                var storeModel:NormalSimpleModel?
                if let storeStr = UserDefaults.standard.object(forKey: "CurrentStore") as? String{
                                if let deserModel = HomeStoreModel.deserialize(from: storeStr){
                                                storeModel = NormalSimpleModel(id: deserModel.storeId, name: deserModel.name)
                                }
                }
 
 
                switch model {
                                case "加入会员":
                                                if page == "成为会员"{
                                                                let vc = JoinMemberIntroduceVC()
                                                                JQ_currentViewController().jq_push(vc:vc)
                                                }
 
                                case "首页banner":
                                                if page == "成为会员"{
                                                                let vc = JoinMemberIntroduceVC()
                                                                JQ_currentViewController().jq_push(vc:vc)
                                                }
                                case "首页":
                                                if page == "常见问题"{
                                                                JQ_currentViewController().jq_push(vc: CustomerListVC(page: 1))
                                                }
                                                ///===============
 
 
                                case "加入玩湃":
                                                if page == "主页"{
                                                                JQ_currentViewController().navigationController?.popToRootViewController(animated: true)
                                                                DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
                                                                                JQ_currentViewController().tabBarController?.selectedIndex = 0
                                                                }
                                                }
 
                                                if page == "课程列表"{
                                                                if type == "详情"{
                                                                                JQ_currentViewController().jq_push(vc: CourseDetailVC(id:id ?? 0))
                                                                }else{
                                                                                JQ_currentViewController().jq_push(vc: CourseListVC(selectStore: storeModel))
                                                                }
                                                }
 
                                                if page == "赛事活动列表"{
                                                                if type == "详情"{
                                                                                JQ_currentViewController().jq_push(vc: ActivityDetailVC(id: id ?? 0))
                                                                }else{
                                                                                JQ_currentViewController().jq_push(vc: ActivityListVC())
                                                                }
                                                }
 
                                                if page == "线上课得积分"{
                                                                if type == "详情"{
                                                                                let vc = CourseVideoDetailVC(id: id ?? 0)
                                                                                vc.title = page
                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                }else if type == "列表"{
                                                                                let vc = CourseOnlineSubListVC(classificationId: id ?? 0)
                                                                                vc.title = page
                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                }else if type == "主页"{
                                                                                let vc = CourseOnlineListVC(position: 1)
                                                                                vc.title = page
                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                }
                                                }
 
                                                if page == "看视频得奖励"{
                                                                if type == "详情"{
                                                                                let vc = CourseVideoDetailVC(id: id ?? 0)
                                                                                vc.title = page
                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                }else if type == "列表"{
                                                                                let vc = CourseOnlineSubListVC(classificationId: id ?? 0)
                                                                                vc.title = page
                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                }else if type == "主页"{
                                                                                let vc = CourseOnlineListVC(position: 2)
                                                                                vc.title = page
                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                }
                                                }
 
                                                if page == "预约场地"{
                                                                if type == "详情"{
                                                                                JQ_currentViewController().jq_push(vc: YardDetailVC(id: id ?? 0))
                                                                }else{
                                                                                JQ_currentViewController().jq_push(vc: YardListVC(selectStore: storeModel))
                                                                }
                                                }
 
                                                if page == "智慧球场"{
                                                                JQ_currentViewController().jq_push(vc: GamesVC())
                                                }
 
                                                if page == "成为会员"{
                                                                JQ_currentViewController().jq_push(vc: JoinMemberIntroduceVC())
                                                }
 
                                                if page == "社区世界杯"{
                                                                if type == "详情"{
                                                                                JQ_currentViewController().jq_push(vc: WorldCupContentApplyVC(id: id!))
                                                                }
                                                                if type == "主页" || type == "列表"{
                                                                                JQ_currentViewController().jq_push(vc: WorldCupListVC())
                                                                }
                                                }
 
                                case "开始课程":
                                                if page == "主页"{
                                                                JQ_currentViewController().navigationController?.popToRootViewController(animated: true)
                                                                DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
                                                                                JQ_currentViewController().tabBarController?.selectedIndex = 1
                                                                }
                                                }
 
                                case "使用福利":
                                                if page == "主页"{
                                                                JQ_currentViewController().navigationController?.popToRootViewController(animated: true)
                                                                DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
                                                                                JQ_currentViewController().tabBarController?.selectedIndex = 2
                                                                }
                                                }
 
                                                if page == "充值中心"{
                                                                JQ_currentViewController().jq_push(vc: RechargeCenterVC())
                                                }
 
                                                if page == "积分商城"{
                                                                if type == "主页"{
                                                                                JQ_currentViewController().jq_push(vc: CoinStoreCenterVC())
                                                                }
                                                                if type == "指定商品"{
                                                                                JQ_currentViewController().jq_push(vc: WelfareRedeemGoodsDetailVC(commodityId: id ?? 0, goodsType:nil))
                                                                }
                                                }
 
                                                if page == "本周福利"{
                                                                if type == "限时折扣(主页)"{
                                                                                JQ_currentViewController().jq_push(vc: WelfareWeeklyListVC(page: 0))
                                                                }
                                                                if type == "赠送课时(主页)"{
                                                                                JQ_currentViewController().jq_push(vc: WelfareWeeklyListVC(page: 1))
                                                                }
                                                                if type == "指定折扣"{
                                                                                JQ_currentViewController().jq_push(vc: WelfareWeeklyDetailVC(id: id ?? 0))
                                                                }
                                                }
 
                                case "探索玩湃":
                                                if page == "门店列表"{
                                                                let vc = SearchStoreListVC()
                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                //                JQ_currentViewController().navigationController?.popToRootViewController(animated: true)
                                                                //                DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
                                                                //                    JQ_currentViewController().tabBarController?.selectedIndex = 3
                                                                //                }
                                                }
 
                                                if page == "常见问题"{
                                                                if type == "列表"{
                                                                                JQ_currentViewController().jq_push(vc: CustomerListVC(page: 1))
                                                                }
                                                                if type == "详情"{
                                                                                JQ_currentViewController().jq_push(vc: CustomerContentDetailVC(id: id ?? 0, type: .QA))
                                                                }
                                                }
 
                                                if page == "公告发布"{
                                                                if type == "列表"{
                                                                                JQ_currentViewController().jq_push(vc: CustomerListVC(page: 0))
                                                                }
                                                                if type == "详情"{
                                                                                JQ_currentViewController().jq_push(vc: CustomerContentDetailVC(id: id ?? 0, type: .notice))
                                                                }
                                                }
                                default:break
                }
}