Commit be463285584fb29f51759470e2c7d561ab1e9b50

Authored by “张旭”
1 parent 1b2ce5b2

根据版本号动态控制忽必烈gift开关

metaCode.xcodeproj/project.pbxproj
... ... @@ -2968,7 +2968,7 @@
2968 2968 CODE_SIGN_ENTITLEMENTS = metaCode/metaCode.entitlements;
2969 2969 CODE_SIGN_IDENTITY = "Apple Development";
2970 2970 CODE_SIGN_STYLE = Automatic;
2971   - CURRENT_PROJECT_VERSION = 1.1.7.25.04.26.16;
  2971 + CURRENT_PROJECT_VERSION = 1.1.8.25.04.27.12;
2972 2972 DEBUG_INFORMATION_FORMAT = dwarf;
2973 2973 DEVELOPMENT_TEAM = 94X49GG3ZW;
2974 2974 ENABLE_BITCODE = NO;
... ... @@ -3041,7 +3041,7 @@
3041 3041 "$(inherited)",
3042 3042 "@executable_path/Frameworks",
3043 3043 );
3044   - MARKETING_VERSION = 1.1.7;
  3044 + MARKETING_VERSION = 1.1.8;
3045 3045 OTHER_LDFLAGS = (
3046 3046 "$(inherited)",
3047 3047 "-all_load",
... ... @@ -3224,7 +3224,7 @@
3224 3224 CODE_SIGN_ENTITLEMENTS = metaCode/metaCode.entitlements;
3225 3225 CODE_SIGN_IDENTITY = "Apple Development";
3226 3226 CODE_SIGN_STYLE = Automatic;
3227   - CURRENT_PROJECT_VERSION = 1.1.7.25.04.26.16;
  3227 + CURRENT_PROJECT_VERSION = 1.1.8.25.04.27.12;
3228 3228 DEVELOPMENT_TEAM = 94X49GG3ZW;
3229 3229 ENABLE_BITCODE = NO;
3230 3230 ENABLE_MODULE_VERIFIER = NO;
... ... @@ -3296,7 +3296,7 @@
3296 3296 "$(inherited)",
3297 3297 "@executable_path/Frameworks",
3298 3298 );
3299   - MARKETING_VERSION = 1.1.7;
  3299 + MARKETING_VERSION = 1.1.8;
3300 3300 OTHER_LDFLAGS = (
3301 3301 "$(inherited)",
3302 3302 "-all_load",
... ...
metaCode/Classes/Extensions/String+Extension.swift
... ... @@ -10,6 +10,27 @@ import UIKit
10 10 import CommonCrypto
11 11  
12 12 extension String {
  13 + //比较两个版本号 //.orderedDescending前者version1版本更大 //.orderedAscending前者版本更小 //.orderedSame版本相等
  14 + func compareVersion(_ version2: String) -> ComparisonResult {
  15 + let v1Components = self.components(separatedBy: ".")
  16 + let v2Components = version2.components(separatedBy: ".")
  17 + let maxLength = max(v1Components.count, v2Components.count)
  18 +
  19 + for i in 0..<maxLength {
  20 + // 处理空位补 0
  21 + let v1 = i < v1Components.count ? (Int(v1Components[i]) ?? 0) : 0
  22 + let v2 = i < v2Components.count ? (Int(v2Components[i]) ?? 0) : 0
  23 +
  24 + if v1 > v2 {
  25 + return .orderedDescending // 当前版本更大
  26 + } else if v1 < v2 {
  27 + return .orderedAscending // 当前版本更小
  28 + }
  29 + }
  30 + return .orderedSame // 版本相等
  31 + }
  32 +
  33 +
13 34 /// Calculate text's height from `width` and `front`.
14 35 func calculateHeightWith(width: CGFloat, font: UIFont)-> CGFloat {
15 36 let attr = [NSAttributedString.Key.font: font]
... ...
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineViewModel.swift
... ... @@ -882,8 +882,17 @@ class CNLiveMineViewModel: NSObject {
882 882 let userInfoModel = dictionaryToModel(resp as! [String : Any], UpdateInfoModel.self,"data") as! UpdateInfoModel
883 883 let ver1 = "\(userInfoModel.version.split(separator: "_").last ?? "0")"
884 884 let ver2 = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String
885   - print("获取的新版本号=>\(ver1),原来的版本号=>\(ver2)")
886   - metaAppDelegate.isGift = userInfoModel.gift
  885 + print("获取的新版本号=>\(ver1),本版本号=>\(ver2)")
  886 + //ver1后台版本 ver2本版本
  887 + let compareResult = ver1.compareVersion(ver2)
  888 + if compareResult == .orderedAscending{
  889 + //ver1后台版本 < ver2本版本
  890 + metaAppDelegate.isGift = false
  891 + }else{
  892 + //ver1后台版本 >= ver2本版本
  893 + metaAppDelegate.isGift = userInfoModel.gift
  894 + }
  895 +
887 896 if CNLiveMineViewModel.compare(v1: ver1, v2: ver2) {
888 897 resultBlock(userInfoModel,.success)
889 898 } else {
... ...