123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import UIKit
- class CommonUntils: CommonBaseUntils {
- class func isIphonex() -> Bool {
- if ScreenWidth / ScreenHeight < 0.5 {
- return true
- } else {
- return false
- }
- }
-
-
- class func copyString(str: String) {
- let pasteboard = UIPasteboard.general
- pasteboard.string = str
- }
-
- class func openQQCustomerService(qq: String) {
- if !UIApplication.shared.canOpenURL(URL(string: "mqq://")!) {
- SVProgressHUD.showError(withStatus: "请先安装QQ!")
- return
- }
- let urlStr = "mqq://im/chat?chat_type=wpa&uin=\(qq)&version=1&src_type=web"
- UIApplication.shared.openURL(URL(string: urlStr)!)
- }
-
- class func alert(message: String) {
- AlertView(controller: appDelegate.navController, title: "提示", message: message, buttons: ["确定"], style: .alert)
- }
-
- class func alertNoData() {
- var message = "暂无数据"
- AlertView(controller: appDelegate.navController, title: "提示", message: message, buttons: ["确定"], style: .alert)
- }
-
- class func alertNoData(json: NSDictionary) {
- var message = ""
- message = json.object(forKey: "CNMsg") as! String
- AlertView(controller: appDelegate.navController, title: "提示", message: message, buttons: ["确定"], style: .alert)
- }
- class func alertServiceError() {
- self.alert(message: "服务器异常")
- }
- class func alertNetworkError() {
- self.alert(message: "连接失败,请检查您的网络")
- }
- class func alertLocaltionkError() {
- self.alert(message: "定位失败,请开启定位服务后重试!")
- }
- class func alertError(error: NSError) {
- if !isAlertError {
- isAlertError = true
- AlertView(controller: appDelegate.navController, title: "提示", message: "数据请求失败,请检查网络是否可用并设置允许APP使用网络!", buttons: ["立即设置"], style: .alert, actionHandler: { (_, _) in
- isAlertError = false
- UIApplication.shared.openURL(URL(string: UIApplication.openSettingsURLString)!)
- }, cancelHandler: {
- isAlertError = false
- }, destructiveHandler: {
- isAlertError = false
- })
- }
- }
- class func isConnectionAvailable() -> Bool {
- return true
- }
- }
|