浏览代码

版本更新 提示

openlockPPP 1 年之前
父节点
当前提交
cbbb796fdc

+ 4 - 4
JiaPeiManage/Sources/Main/App/CompositionRoot.swift

@@ -89,10 +89,10 @@ final class CompositionRoot {
         LocalManager.userInfo.openTimes += 1
         //设置环境  --默认是线上环境
         Defaults.currentEnvironment = .res
-#if DEBUG || _DEBUG
-        //设置环境
-        Defaults.currentEnvironment = .dev
-#endif
+//#if DEBUG || _DEBUG
+//        //设置环境
+//        Defaults.currentEnvironment = .dev
+//#endif
 
         //ToastView
         ToastView.appearance().font = NYFont.SysFont.sys_15

+ 2 - 0
JiaPeiManage/Sources/Modulars/Home/Controllers/HomeViewController.swift

@@ -35,6 +35,8 @@ final class HomeViewController: BaseViewController {
     
     override func viewDidLoad() {
         super.viewDidLoad()
+        //验证
+        LocalManager.verifyVersiondo()
         //判断用户登录
         LocalManager.isOpenLogin()
         //UI

+ 43 - 0
JiaPeiManage/Sources/Utils/LocalManager.swift

@@ -49,4 +49,47 @@ class LocalManager {
         
     }
     
+    //验证版本
+    static func verifyVersiondo(){
+        LocalManager.loginService.dictRequest(dictType: "coach_version").subscribe(onSuccess: { cityItems in
+            var server_version = "" //服务端版本
+            var message = "有新版本,请到appstore更新" //提示内容
+            var isSup = 0 //是否强制更新
+            for cityItem in cityItems {
+                if cityItem.dictCode == 207 {
+                    server_version =  cityItem.dictValue.replacingOccurrences(of: ".", with: "")
+                    let array = cityItem.remark.components(separatedBy: ":")
+                    if array.count>1 {
+                        isSup = Int(array[0])!
+                        message = array[1]
+                    }
+                    break
+                }
+            }
+            //当前版本<服务器ios版本提示更新
+            let appVersion:String = (NYMacros.appVersion as! String).replacingOccurrences(of: ".", with: "")
+            if Int(appVersion)!<Int(server_version)! {
+//            https://apps.apple.com/cn/app/%E6%95%99%E7%BB%83%E7%AE%A1%E5%AE%B6/id1214203182
+                let action1 = QMUIAlertAction(title: "取消", style: .cancel, handler: nil)
+                let action2 = QMUIAlertAction(title: "下载", style: .destructive) { vc, action in
+                    if let url = URL(string: "itms-apps://itunes.apple.com/cn/app/jiao-li-guan-jia/id1214203182?l=en&mt=8") {
+                        UIApplication.shared.open(url, options: [:], completionHandler: nil)
+                    }
+                }
+                let alertController = QMUIAlertController(title: "提示", message: message, preferredStyle: .alert)
+                if isSup == 0 {
+                    alertController.addAction(action1)
+                }
+                alertController.addAction(action2)
+                let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .light))
+                visualEffectView.qmui_foregroundColor = UIColor(255, 255, 255,0.7) // UIColorMakeWithRGBA(255, 255, 255, 0.7) // Use the default value in most cases, only demonstrate how to set here
+                alertController.mainVisualEffectView = visualEffectView
+                alertController.alertHeaderBackgroundColor = nil // Remove these background colors when you need to use the blur effect
+                alertController.alertButtonBackgroundColor = nil
+                alertController.showWith(animated: true)
+          
+            }
+        },onError: { Error in
+        }).disposed(by: disposeBag)
+    }
 }