123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- //
- // CommonValue.swift
- // SparkEducation
- //
- // Created by virgil on 16/3/14.
- // Copyright © 2016年 virgil. All rights reserved.
- //
- import UIKit
- let brandList: Array = ["海付POS机", "海科传统POS", "快益刷传统POS", "快闪刷POS", "2021海科传统POS", "海科传统POS(山东河南)","海收付(直营非押)","海收付(渠道/免押)","海收付(渠道/押金)","海收付(直营押金)","小微收银"]
- let brandIdList = ["2", "300595e17ed94b5f8c2b3f437ce26116", "4", "4e7c6d802cf149e9b8e1fc0efca4e965", "5", "f391406346e04510ab6b3be081b2e4aa","777","888","999","9999","1df30df31e5a43c1b468b73a6abf586a"]
- var houseId = -1
- var isPrintLog = true
- var isAlertError = false
- let appDelegate = UIApplication.shared.delegate as! AppDelegate
- var qiNiuUploadImageToken = ""
- /// 获取公用参数
- open class CommonValue: CommonBaseValue {
- class func checkIsAS() -> Bool {
- //CommonValue.setDefaultUserInfoForString(value: "1", key: "apver\(CommonUntils.getSystemVersion())")
- if CommonValue.getDefaultUserInfoForString(key: "apver\(CommonUntils.getSystemVersion())") == "1" {
- return false
- }
- if CommonUntils.getSystemVersion() != appDelegate.dicDefault.getString(key: "appstoreVersion") && appDelegate.dicDefault.getString(key: "appstoreVersion") != "" {
- CommonValue.setDefaultUserInfoForString(value: "1", key: "apver\(CommonUntils.getSystemVersion())")
- return false
- } else {
- return true
- }
- }
- class func formatPhone(phone: String) -> String {
- // if(phone.length() == 11)
- // {
- //
- // return phone.substringTo(index: 3) + "****" + phone.substringFrom(index:7);
- // }
- // else
- if phone.length() > 7 {
- let str = phone.substringFrom(start: 4, end: 8)
- return phone.replacingOccurrences(of: str, with: "****")
- } else {
- return phone
- }
- }
- class func formatCardNum(str: String) -> String {
- if str.length() > 7 {
- let str1 = str.substringFrom(start: 4, end: str.length() - 4)
- return str.replacingOccurrences(of: str1, with: "*********")
- } else {
- return str
- }
- }
- // MARK: ===== 公用部分=====
- ///获取初始化值
- class func getDefaultValueForKey(key: String) -> String {
- if appDelegate.dicDefault[key] as? String != nil {
- return appDelegate.dicDefault[key] as! String
- } else {
- return ""
- }
- }
- class func getHttp() -> AFHTTPSessionManager {
- let http = AFHTTPSessionManager()
- http.requestSerializer.setValue(CommonValue.getUserId(), forHTTPHeaderField: "userId")
- http.requestSerializer.setValue("1", forHTTPHeaderField: "phoneType")
- http.requestSerializer.setValue(CommonUntils.getSystemVersion(), forHTTPHeaderField: "apkVersion")
- return http
- }
- // MARK: ===== 用户登录信息部分 =====
- class func getUserId() -> String {
- //return "c3663a50d44b4cc28f3d721c80409d8a"; // 18005362777
- if self.getLoginUserInfo() == nil {
- return ""
- } else {
- if getLoginUserInfo()!.allKeys.count < 1 {
- CommonValue.clearLoginUser()
- return ""
- } else {
- print(getLoginUserInfo()!["id"] as! String)
- return getLoginUserInfo()!["id"] as! String
- }
- }
- }
- ///是否实名认证 :0:否 1:是 2:通过 3:审核驳回
- class func getUserIsAuthentication() -> Int {
- if self.getLoginUserInfo() == nil {
- return -1
- } else {
- //return 1;
- return getLoginUserInfo()!["isAuthentication"] as! Int
- }
- }
- ///会员等级 0黄金 1白金 2钻石
- class func getUserLevel() -> Int {
- if self.getLoginUserInfo() == nil {
- return 0
- } else {
- //return 1;
- if getLoginUserInfo()!["userLevel"] as? Int != nil {
- return getLoginUserInfo()!["userLevel"] as! Int
- } else {
- return 0
- }
- }
- }
- ///代理 数量
- class func getUserAgentNum() -> Int {
- if self.getLoginUserInfo() == nil {
- return 0
- } else {
- //return 1;
- return getLoginUserInfo()!["agentNum"] as! Int
- }
- }
- ///商户数量
- class func getUserMerchantNum() -> Int {
- if self.getLoginUserInfo() == nil {
- return 0
- } else {
- //return 1;
- return getLoginUserInfo()!["merchantNum"] as! Int
- }
- }
- ///累计收益
- class func getUserProfitTotal() -> Double {
- if self.getLoginUserInfo() == nil {
- return 0.00
- } else {
- //return 1;
- return getLoginUserInfo()!["profitTotal"] as! Double
- }
- }
- ///tu
- class func getULevelPic() -> String {
- if self.getLoginUserInfo() == nil {
- return ""
- } else {
- //return 1;
- return getLoginUserInfo()!["userLevelPic"] as? String ?? ""
- }
- }
- class func getUserLevelName() -> String {
- if self.getLoginUserInfo() == nil {
- return ""
- } else {
- //return 1;
- return getLoginUserInfo()!["userLevelName"] as? String ?? ""
- }
- }
- ///收益余额
- class func getUserProfitBalance() -> Double {
- if self.getLoginUserInfo() == nil || self.getLoginUserInfo()!["profitBalance"] as? Double == nil {
- return 0.00
- } else {
- return getLoginUserInfo()!["profitBalance"] as! Double
- }
- }
- ///pos机收益
- class func getUserProfitPos() -> Double {
- if self.getLoginUserInfo() == nil {
- return 0.00
- } else {
- //return 1;
- return getLoginUserInfo()!["profitPos"] as! Double
- }
- }
- ///办卡收益
- class func getUserProfitCard() -> Double {
- if self.getLoginUserInfo() == nil {
- return 0.00
- } else {
- //return 1;
- return getLoginUserInfo()!["profitCard"] as! Double
- }
- }
- ///积分收益
- class func getUserProfitIntegral() -> Double {
- if self.getLoginUserInfo() == nil {
- return 0.00
- } else {
- //return 1;
- return getLoginUserInfo()!["profitIntegral"] as! Double
- }
- }
- ///激活奖励
- class func getUserProfitActivation() -> Double {
- if self.getLoginUserInfo() == nil {
- return 0.00
- } else {
- //return 1;
- return getLoginUserInfo()!["profitActivation"] as! Double
- }
- }
- class func getUserAge() -> Int {
- if self.getLoginUserInfo() == nil {
- return -1
- } else {
- //return 1;
- return getLoginUserInfo()!["Age"] as! Int
- }
- }
- class func getUserRealName() -> String {
- if CommonValue.getUserId() == "" {
- return "未登录"
- }
- if self.getLoginUserInfo() == nil {
- return "未实名"
- } else {
- //return 1;
- if (getLoginUserInfo()!["realName"] as? String) == nil {
- return "未实名"
- } else {
- if (getLoginUserInfo()!["realName"] as! String) == "" {
- return "未实名"
- } else {
- return (getLoginUserInfo()!["realName"] as! String)
- }
- }
- }
- }
- class func getUserNickName() -> String {
- if self.getLoginUserInfo() == nil {
- return "未登录"
- } else {
- //return 1;
- return (getLoginUserInfo()!["nickName"] as! String)
- }
- }
- class func getUserPhone() -> String {
- if self.getLoginUserInfo() == nil {
- return ""
- } else {
- //return 1;
- return (getLoginUserInfo()!["phone"] as! String)
- }
- }
- class func getUserCardNo() -> String {
- if self.getLoginUserInfo() == nil {
- return ""
- } else {
- //return 1;
- return (getLoginUserInfo()!["cardNo"] as! String)
- }
- }
- class func getUserRecCode() -> String {
- if self.getLoginUserInfo() == nil {
- return ""
- } else {
- //return 1;
- return (getLoginUserInfo()!["recCode"] as! String)
- }
- }
- class func getUserLogo() -> String {
- if self.getLoginUserInfo() == nil {
- return ""
- } else {
- //return 1;
- return (getLoginUserInfo()!["headPortrait"] as! String) //getLoginUserInfo()!["LastName"] as! String + " " +
- }
- }
- ///更新登录用户的信息
- class func setUserLoginUser(key: String, value: Any) {
- let dicUser = NSMutableDictionary(dictionary: getLoginUserInfo()!)
- dicUser.setValue(value, forKey: key)
- setLoginUserInfo(loginUser: dicUser)
- }
- class func getDBPath() -> String {
- let userDefault = UserDefaults.standard
- let dbpath = userDefault.object(forKey: "local_db_path") as? String
- if dbpath != nil {
- return dbpath!
- } else {
- return ""
- }
- }
- class func setDBPath(dbPath: String) {
- let userDefault = UserDefaults.standard
- userDefault.setValue(dbPath, forKey: "local_db_path")
- }
- class func getIsValitePassword() -> Bool {
- if getDefaultUserInfoForString(key: "common_default_is_ss_password") == "1" && getUserId() != "" {
- return true
- } else {
- return false
- }
- }
- class func getInfoAddressId() -> String {
- return getDefaultUserInfoForString(key: "common_info_address_id")
- }
- class func getInfoAddressName() -> String {
- let name = getDefaultUserInfoForString(key: "common_info_address_name")
- if name == "" {
- return "全国"
- } else {
- return name
- }
- }
- class func setInfoAddress(id: String, name: String) {
- setDefaultUserInfoForString(value: id, key: "common_info_address_id")
- setDefaultUserInfoForString(value: name, key: "common_info_address_name")
- }
- }
|