fix
无故事王国
2024-02-28 4468d9f9b3b8c70597f04e5f1ecb61118c404d2c
WanPai/Config/Def.swift
@@ -10,6 +10,7 @@
import JQTools
import SVProgressHUD
import QMUIKit
import OSLog
let SHAKEY = "BT7NPhA0f775uzcUuftWjCE1TYZlWmHZ"
let WechatUniversalLinks = "https://www.weparklife.com/"
@@ -25,269 +26,287 @@
let locationTool = JQ_LocationTool.instance()
var sceneDelegate:SceneDelegate? = {
    var uiScreen:UIScene?
    UIApplication.shared.connectedScenes.forEach { scenes in
        uiScreen = scenes
    }
    return (uiScreen?.delegate as? 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
    let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
    print("✅✅✅ SUCCESS: \(file)  \(function) [Line: \(line)]: \(items)",separator);
            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
    let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
    print("❌❌❌ ERROR: \(file)  \(function) [Line: \(line)]: \(items)",separator);
            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
    let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
    print("⚠️⚠️⚠️INFO: \(file)  \(function) [Line: \(line)]: \(items)",separator);
            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);
            print("返回数据")
            print(items);
#endif
}
    //提示框
//提示框
func alert(msg: String) {
   SVProgressHUD.showInfo(withStatus: msg)
            SVProgressHUD.showInfo(withStatus: msg)
}
func alertError(msg:String){
   SVProgressHUD.showError(withStatus: msg)
            SVProgressHUD.showError(withStatus: msg)
}
func alertSuccess(msg:String){
    SVProgressHUD.showSuccess(withStatus: msg)
            SVProgressHUD.showSuccess(withStatus: msg)
}
func showHUD(_ text:String? = nil){
   SVProgressHUD.show(withStatus: text)
            SVProgressHUD.show(withStatus: text)
}
func hiddenHUD(_ delay:TimeInterval? = nil){
   if delay != nil{
      SVProgressHUD.dismiss(withDelay: delay!)
   }else{
      SVProgressHUD.dismiss()
   }
            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)
   }
            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()
   }
            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
            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)
                        }
            }
         }
         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())
            }
         }
            switch model {
                        case "加入会员":
                                    if page == "成为会员"{
                                                let vc = JoinMemberIntroduceVC()
                                                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: 1)
               vc.title = page
               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))
                                    }
                                    ///===============
         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))
            }
         }
                        case "加入玩湃":
                                    if page == "主页"{
                                                JQ_currentViewController().navigationController?.popToRootViewController(animated: true)
                                                DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
                                                            JQ_currentViewController().tabBarController?.selectedIndex = 0
                                                }
                                    }
         if page == "智慧球场"{
            JQ_currentViewController().jq_push(vc: GamesVC())
         }
                                    if page == "课程列表"{
                                                if type == "详情"{
                                                            JQ_currentViewController().jq_push(vc: CourseDetailVC(id:id ?? 0))
                                                }else{
                                                            JQ_currentViewController().jq_push(vc: CourseListVC(selectStore: storeModel))
                                                }
                                    }
         if page == "成为会员"{
            JQ_currentViewController().jq_push(vc: JoinMemberIntroduceVC())
         }
                                    if page == "赛事活动列表"{
                                                if type == "详情"{
                                                            JQ_currentViewController().jq_push(vc: ActivityDetailVC(id: id ?? 0))
                                                }else{
                                                            JQ_currentViewController().jq_push(vc: ActivityListVC())
                                                }
                                    }
      case "开始课程":
         if page == "主页"{
            JQ_currentViewController().navigationController?.popToRootViewController(animated: true)
            DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
               JQ_currentViewController().tabBarController?.selectedIndex = 1
            }
         }
                                    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)
                                                }
                                    }
      case "使用福利":
         if page == "主页"{
            JQ_currentViewController().navigationController?.popToRootViewController(animated: true)
            DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
               JQ_currentViewController().tabBarController?.selectedIndex = 2
            }
         }
                                    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 == "充值中心"{
            JQ_currentViewController().jq_push(vc: RechargeCenterVC())
         }
                                    if page == "预约场地"{
                                                if type == "详情"{
                                                            JQ_currentViewController().jq_push(vc: YardDetailVC(id: id ?? 0))
                                                }else{
                                                            JQ_currentViewController().jq_push(vc: YardListVC(selectStore: storeModel))
                                                }
                                    }
         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 == "智慧球场"{
                                                JQ_currentViewController().jq_push(vc: GamesVC())
                                    }
         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))
            }
         }
                                    if page == "成为会员"{
                                                JQ_currentViewController().jq_push(vc: JoinMemberIntroduceVC())
                                    }
      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 == "社区世界杯"{
                                                JQ_currentViewController().jq_push(vc: WorldCupListVC())
                                    }
         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))
            }
         }
                        case "开始课程":
                                    if page == "主页"{
                                                JQ_currentViewController().navigationController?.popToRootViewController(animated: true)
                                                DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
                                                            JQ_currentViewController().tabBarController?.selectedIndex = 1
                                                }
                                    }
         if page == "公告发布"{
            if type == "列表"{
               JQ_currentViewController().jq_push(vc: CustomerListVC(page: 0))
                        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
            }
            if type == "详情"{
               JQ_currentViewController().jq_push(vc: CustomerContentDetailVC(id: id ?? 0, type: .notice))
            }
         }
      default:break
   }
}