//
|
// 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
|
}
|
}
|