KMMemberInfo.swift 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. //
  2. // KMMemberInfo.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/10/22.
  6. //
  7. import Cocoa
  8. // 用户场景类型
  9. @objc enum KMUserScenarioType : Int {
  10. case lite_type1 = 0 // 免费版 无旧买断 免费未试用 (右上角导航栏按钮 - “登录领福利” + “试用”)
  11. case lite_type2 // 免费版 无旧买断 免费试用中 (右上角导航栏按钮 - “登录领福利”)
  12. case lite_type3 // 免费版 无旧买断 试用过期或取消 (右上角导航栏按钮 - “登录领福利” + 开通会员)
  13. case lite_type4 // 免费版 无旧买断 可升级订阅 (右上角导航栏按钮 - “登录领福利”)
  14. case lite_type5 // 免费版 无旧买断 多平台永久 (右上角导航栏按钮 - “登录领福利” + 升级全平台)
  15. case lite_type6 // 免费版 无旧买断 全平台年订阅 (右上角导航栏按钮 - “登录领福利”)
  16. case lite_type7 // 免费版 无旧买断 会员到期 (右上角导航栏按钮 - “登录领福利” + 续费)
  17. case lite_type8 // 免费版 无旧买断 订阅未过期且取消订阅 (右上角导航栏按钮 - “登录领福利” + 续费)
  18. case lite_type9 // 免费版 有旧买断 免费未试用 (右上角导航栏按钮 - “登录领福利” + “升级至Pro”)
  19. case lite_type10 // 免费版 有旧买断 免费试用中 (右上角导航栏按钮 - “登录领福利”)
  20. case lite_type11 // 免费版 有旧买断 试用过期或取消 (右上角导航栏按钮 - “登录领福利” + 开通会员)
  21. case lite_type12 // 免费版 有旧买断 订阅中 (右上角导航栏按钮 - “登录领福利”)
  22. case lite_type13 // 免费版 有旧买断 订阅未过期且取消订阅 (右上角导航栏按钮 - “登录领福利” + 续费)
  23. case pro_type1 // 付费版 有旧PDF To Office未订阅 (右上角导航栏按钮 - “登录领福利” + 升级(全平台))
  24. case pro_type2 // 付费版 有旧PDF To Office 订阅且未过期 (右上角导航栏按钮 - “登录领福利”)
  25. case pro_type3 // 付费版 无旧PDF To Office未订阅 (右上角导航栏按钮 - “登录领福利” + 升级(全平台/高级版永久))
  26. case pro_type4 // 付费版 无旧PDF To Office 高级版永久 (右上角导航栏按钮 - Info + 升级(全平台))
  27. case pro_type5 // 付费版 无旧PDF To Office 订阅且未过期 (右上角导航栏按钮 - Info)
  28. }
  29. // 当前权益类型
  30. @objc enum KMCurrentUserEquityType : Int {
  31. case lite_free = 0 // 免费版 免费
  32. case lite_old
  33. }
  34. // 当前注销状态
  35. @objc enum KMCurrentLogoutStatus : Int {
  36. case null = 0 //
  37. case prompt_unsubscribe
  38. case prompt_signout
  39. case closeAccount
  40. case closeVerification
  41. case closeApply
  42. }
  43. @objcMembers class KMMemberInfo: NSObject {
  44. static let shared = KMMemberInfo()
  45. var isLogin: Bool = false
  46. var currentLogoutStatus: KMCurrentLogoutStatus = .null
  47. /**
  48. 登录
  49. */
  50. private var _refresh_token: String = "" // 刷新Token
  51. private var _access_token: String = "" // 访问Token
  52. private var _token_type: String = "" // Token 类型
  53. private var _expires_in: String = ""
  54. private var _scope: String = ""
  55. /**
  56. 登录
  57. */
  58. var userID: String = "" // 用户ID
  59. var userEmail: String = "" // 用户邮箱
  60. var fullName: String = "" // 用户名称
  61. var _activeVips: [KMMemberUserInfoActiveVIP] = [] // 活跃的会员
  62. var _activeAis: [KMMemberUserInfoActiveVIP] = [] // 活跃的AI
  63. var vip_id: String = "" // id
  64. var vip_userId: String = "" // 用户id
  65. var vip_status: Int = 0 // 状态 0注册1订阅中2订阅过期3试用中4试用过期
  66. var vip_endDate: String = "" // 到期时间
  67. var vip_payType: Int = 0 // 0未开启自动续订 1自动续订
  68. var vip_productName: String = "" // 产品名字
  69. var vip_levels: String = "" // 会员等级 1是免费 2是标准 3是高级
  70. var vip_platforms: String = "" // 支持的平台
  71. var vip_point: Int = 0 // 剩余ai点数(svip才有)
  72. var vip_maxDeviceNum: Int = 0 // 最大登录设备限制数
  73. var vip_paymentModel: String = "" // 支付方式 付费模式(1自动续订(vip svip) 2单次付费(永久会员))
  74. var vip_isAi: String = "" // 是否是ai产品(0否1是)
  75. var vip_cycle: Int = 0 // 订阅周期:1、月(30天);2、季(90天);3、半年(183天);4、年(365天)
  76. var ai_id: String = "" // id
  77. var ai_userId: String = "" // 用户id
  78. var ai_status: Int = 0 // 状态 0注册1订阅中2订阅过期3试用中4试用过期
  79. var ai_endDate: String = "" // 到期时间
  80. var ai_payType: Int = 0 // 0未开启自动续订 1自动续订
  81. var ai_productName: String = "" // 产品名字
  82. var ai_levels: String = "" // 会员等级 1是免费 2是标准 3是高级
  83. var ai_platforms: String = "" // 支持的平台
  84. var ai_point: Int = 0 // 剩余ai点数(svip才有)
  85. var ai_maxDeviceNum: Int = 0 // 最大登录设备限制数
  86. var ai_paymentModel: String = "" // 支付方式 付费模式(1自动续订(vip svip) 2单次付费(永久会员))
  87. var ai_isAi: String = "" // 是否是ai产品(0否1是)
  88. var ai_cycle: Int = 0 // 订阅周期:1、月(30天);2、季(90天);3、半年(183天);4、年(365天)
  89. var aiPoint: Int = 0 // AI 点数
  90. var validFlag: String = "" // 注销(0), * 正常(1), * 停用(2), * 注销中(5);
  91. var isHaveAIDiscount: String = "" // 是否有ai折扣
  92. var canTrail: Bool = false // 是否能试用
  93. // var currentTime: String = "" // 当前注销时间
  94. // var logOffTime: String = "" // 注销时间
  95. // MARK: Get & Set
  96. var refresh_token: String {
  97. get {
  98. let token = UserDefaults.standard.value(forKey: "MemberRefreshToken")
  99. if token is String {
  100. return token as! String
  101. }
  102. return _refresh_token
  103. }
  104. set {
  105. _refresh_token = newValue
  106. UserDefaults.standard.setValue(newValue, forKey: "MemberRefreshToken")
  107. UserDefaults.standard.synchronize()
  108. }
  109. }
  110. var access_token: String {
  111. get {
  112. let token = UserDefaults.standard.value(forKey: "MemberAccessToken")
  113. if token is String {
  114. return token as! String
  115. }
  116. return _access_token
  117. }
  118. set {
  119. _access_token = newValue
  120. UserDefaults.standard.setValue(newValue, forKey: "MemberAccessToken")
  121. UserDefaults.standard.synchronize()
  122. }
  123. }
  124. var token_type: String {
  125. get {
  126. return _token_type
  127. }
  128. set {
  129. _token_type = newValue
  130. }
  131. }
  132. var activeVips: [KMMemberUserInfoActiveVIP] {
  133. get {
  134. return _activeVips
  135. }
  136. set {
  137. _activeVips = newValue
  138. for index in 0..<_activeVips.count {
  139. let vip = _activeVips[index]
  140. if index == 0 {
  141. vip_id = vip.id
  142. vip_userId = vip.userId
  143. vip_status = vip.status
  144. vip_endDate = vip.endDate
  145. vip_payType = vip.payType
  146. vip_productName = vip.productName
  147. vip_levels = vip.levels
  148. vip_platforms = vip.platforms
  149. vip_point = vip.point
  150. vip_maxDeviceNum = vip.maxDeviceNum
  151. vip_paymentModel = vip.paymentModel
  152. vip_isAi = vip.isAi
  153. vip_cycle = vip.cycle
  154. } else {
  155. if let vipLevelsInt = Int(vip_levels), let vipOtherLevelsInt = Int(vip.levels), vipLevelsInt < vipOtherLevelsInt {
  156. vip_id = vip.id
  157. vip_userId = vip.userId
  158. vip_status = vip.status
  159. vip_endDate = vip.endDate
  160. vip_payType = vip.payType
  161. vip_productName = vip.productName
  162. vip_levels = vip.levels
  163. vip_platforms = vip.platforms
  164. vip_point = vip.point
  165. vip_maxDeviceNum = vip.maxDeviceNum
  166. vip_paymentModel = vip.paymentModel
  167. vip_isAi = vip.isAi
  168. vip_cycle = vip.cycle
  169. }
  170. }
  171. }
  172. }
  173. }
  174. var activeAis: [KMMemberUserInfoActiveVIP] {
  175. get {
  176. return _activeAis
  177. }
  178. set {
  179. _activeAis = newValue
  180. for index in 0..<_activeAis.count {
  181. let vip = _activeAis[index]
  182. if index == 0 {
  183. ai_id = vip.id
  184. ai_userId = vip.userId
  185. ai_status = vip.status
  186. ai_endDate = vip.endDate
  187. ai_payType = vip.payType
  188. ai_productName = vip.productName
  189. ai_levels = vip.levels
  190. ai_platforms = vip.platforms
  191. ai_point = vip.point
  192. ai_maxDeviceNum = vip.maxDeviceNum
  193. ai_paymentModel = vip.paymentModel
  194. ai_isAi = vip.isAi
  195. ai_cycle = vip.cycle
  196. } else {
  197. if let vipLevelsInt = Int(ai_levels), let vipOtherLevelsInt = Int(vip.levels), vipLevelsInt < vipOtherLevelsInt {
  198. ai_id = vip.id
  199. ai_userId = vip.userId
  200. ai_status = vip.status
  201. ai_endDate = vip.endDate
  202. ai_payType = vip.payType
  203. ai_productName = vip.productName
  204. ai_levels = vip.levels
  205. ai_platforms = vip.platforms
  206. ai_point = vip.point
  207. ai_maxDeviceNum = vip.maxDeviceNum
  208. ai_paymentModel = vip.paymentModel
  209. ai_isAi = vip.isAi
  210. ai_cycle = vip.cycle
  211. }
  212. }
  213. }
  214. }
  215. }
  216. // 用户当前的状态
  217. var userScenarioType: KMUserScenarioType {
  218. get {
  219. let oldAIPoints = AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes // 旧版AI点数
  220. let dateFormatter = DateFormatter()
  221. dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
  222. var startTime = Date()
  223. if KMMemberInfo.shared.vip_endDate.count > 0 {
  224. if let data = dateFormatter.date(from: KMMemberInfo.shared.vip_endDate) {
  225. startTime = data
  226. }
  227. }
  228. let currentTime = Date()
  229. let platforms = KMMemberInfo.shared.vip_platforms
  230. let platformsArray = platforms
  231. .components(separatedBy: ",")
  232. .map { $0.trimmingCharacters(in: .whitespaces) }
  233. #if VERSION_FREE
  234. #if VERSION_DMG
  235. // DMG
  236. if KMMemberInfo.shared.isLogin {
  237. } else {
  238. }
  239. #else
  240. // AppStore 免费版本
  241. if IAPProductsManager.default().allAccessPack6months_lite.isSubscribed == true ||
  242. IAPProductsManager.default().allAccessPackNew6months_lite.isSubscribed == true ||
  243. IAPProductsManager.default().allAccessPack12months_lite.isSubscribed == true ||
  244. IAPProductsManager.default().allAccessProduct.isSubscribed == true {
  245. // 有旧买断
  246. if KMMemberInfo.shared.canTrail && KMMemberInfo.shared.vip_levels == "1" {
  247. return .lite_type9
  248. }
  249. if KMMemberInfo.shared.vip_status == 3 {
  250. return .lite_type10
  251. } else if KMMemberInfo.shared.vip_status == 4 {
  252. return .lite_type11
  253. } else if(KMMemberInfo.shared.vip_status == 1 && KMMemberInfo.shared.vip_paymentModel == "1") {
  254. // 订阅中
  255. return .lite_type12
  256. }
  257. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_payType == 0 && KMMemberInfo.shared.vip_status == 1 {
  258. return .lite_type13
  259. }
  260. return .lite_type9
  261. } else {
  262. // 无旧买断
  263. if KMMemberInfo.shared.canTrail && KMMemberInfo.shared.vip_levels == "1" {
  264. return .lite_type1
  265. }
  266. if KMMemberInfo.shared.vip_status == 3 {
  267. return .lite_type2
  268. } else if KMMemberInfo.shared.vip_status == 4 {
  269. return .lite_type3
  270. } else if KMMemberInfo.shared.vip_status == 2 {
  271. return .lite_type7
  272. } else if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_payType == 0 && KMMemberInfo.shared.vip_status == 1 {
  273. return .lite_type8
  274. }
  275. if KMMemberInfo.shared.vip_paymentModel == "2" {
  276. return .lite_type5
  277. } else {
  278. if KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
  279. return .lite_type6
  280. } else {
  281. return .lite_type4
  282. }
  283. }
  284. }
  285. #endif
  286. #else
  287. // AppStore 付费版
  288. if IAPProductsManager.default().pdfToOfficeProduct.isSubscribed == true {
  289. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_status == 1 { //订阅中
  290. return .pro_type2
  291. } else {
  292. return .pro_type1
  293. }
  294. } else {
  295. if KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_status == 1 { //买断
  296. return .pro_type4
  297. } else {
  298. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_status == 1 {//订阅中
  299. return .pro_type5
  300. } else {
  301. return .pro_type3
  302. }
  303. }
  304. }
  305. #endif
  306. return .lite_type1
  307. }
  308. }
  309. // 是否允许全部功能
  310. var isMemberAllFunction: Bool {
  311. get {
  312. #if VERSION_FREE
  313. #if VERSION_DMG
  314. // DMG
  315. if KMMemberInfo.shared.isLogin {
  316. }
  317. #else
  318. // AppStore 免费版本
  319. if KMMemberInfo.shared.isLogin {
  320. if IAPProductsManager.default().isAvailableAllFunction() == true {
  321. return true
  322. } else {
  323. let platforms = KMMemberInfo.shared.vip_platforms
  324. let platformsArray = platforms
  325. .components(separatedBy: ",")
  326. .map { $0.trimmingCharacters(in: .whitespaces) }
  327. if userScenarioType == .lite_type5 ||
  328. userScenarioType == .lite_type4 ||
  329. userScenarioType == .lite_type8 {
  330. if(platformsArray.contains("mac")) {
  331. return true
  332. }
  333. } else if userScenarioType == .lite_type2 ||
  334. userScenarioType == .lite_type6 {
  335. return true
  336. }
  337. return false
  338. }
  339. } else {
  340. if IAPProductsManager.default().allAccessPackPermanent_lite.isSubscribed == true || IAPProductsManager.default().isAvailableAllFunction() == true {
  341. return true
  342. }
  343. return false
  344. }
  345. #endif
  346. #else
  347. // AppStore 付费版
  348. return true
  349. #endif
  350. return false
  351. }
  352. }
  353. // 是否允许使用转档
  354. var isPermitConvert: Bool {
  355. get {
  356. #if VERSION_FREE
  357. #if VERSION_DMG
  358. // DMG
  359. if KMMemberInfo.shared.isLogin {
  360. }
  361. return false
  362. #else
  363. // AppStore 免费版本
  364. if KMMemberInfo.shared.isLogin {
  365. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  366. return true
  367. } else {
  368. let platforms = KMMemberInfo.shared.vip_platforms
  369. let platformsArray = platforms
  370. .components(separatedBy: ",")
  371. .map { $0.trimmingCharacters(in: .whitespaces) }
  372. if(userScenarioType == .lite_type2) {
  373. return true
  374. } else if userScenarioType == .lite_type5 ||
  375. userScenarioType == .lite_type4 ||
  376. userScenarioType == .lite_type8 {
  377. if(platformsArray.contains("mac")) { //购买了
  378. return true
  379. }
  380. } else if userScenarioType == .lite_type6 || userScenarioType == .lite_type12 {
  381. if KMMemberInfo.shared.vip_levels == "3" { //高级版本支持转档功能
  382. return true
  383. }
  384. }
  385. return false
  386. }
  387. } else {
  388. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  389. return true
  390. }
  391. return false
  392. }
  393. #endif
  394. #else
  395. // AppStore 付费版
  396. if KMMemberInfo.shared.isLogin {
  397. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  398. return true
  399. } else {
  400. let platforms = KMMemberInfo.shared.vip_platforms
  401. let platformsArray = platforms
  402. .components(separatedBy: ",")
  403. .map { $0.trimmingCharacters(in: .whitespaces) }
  404. if userScenarioType == .pro_type5 {
  405. if(platformsArray.contains("mac")) { //购买了mac
  406. return true
  407. }
  408. } else if userScenarioType == .pro_type1 ||
  409. userScenarioType == .pro_type2 ||
  410. userScenarioType == .pro_type4 {
  411. return true
  412. }
  413. return false
  414. }
  415. } else {
  416. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  417. return true
  418. }
  419. return false
  420. }
  421. #endif
  422. }
  423. }
  424. // 是否允许使用AI
  425. var isPermitAI: Bool {
  426. // let oldAIPoints = AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes // 旧版AI点数
  427. // if KMMemberInfo.shared.isLogin {
  428. // if oldAIPoints > 0 {
  429. // return true
  430. // } else {
  431. // if userScenarioType == .lite_type4 || userScenarioType == .lite_type5 || userScenarioType == .lite_type6 || userScenarioType == .lite_type12 {
  432. // if KMMemberInfo.shared.aiPoint > 0 {
  433. // return true
  434. // } else {
  435. // return false
  436. // }
  437. // }
  438. // return false
  439. // }
  440. // } else {
  441. // if AIInfoManager.default().aiInfoValid && oldAIPoints > 0 {
  442. // return true
  443. // }
  444. // return false
  445. // }
  446. if KMMemberInfo.shared.isLogin {
  447. if KMMemberInfo.shared.ai_productName != "" || AIInfoManager.default().aiInfoValid {
  448. return true
  449. }
  450. return false
  451. } else {
  452. if AIInfoManager.default().aiInfoValid {
  453. return true
  454. }
  455. return false
  456. }
  457. }
  458. // MARK: Public Method
  459. func memberUserInfo(model: KMMemberUserInfo) -> Void {
  460. userID = model.id
  461. userEmail = model.email
  462. fullName = model.fullName
  463. aiPoint = model.aiPoint
  464. validFlag = model.validFlag
  465. isHaveAIDiscount = model.isHaveAIDiscount
  466. if model.canTrail == "1" {
  467. canTrail = true
  468. } else {
  469. canTrail = false
  470. }
  471. activeVips = model.activeVIP
  472. activeAis = model.activeAI
  473. }
  474. func advancedFunctionUsage() -> Void {
  475. let platforms = KMMemberInfo.shared.vip_platforms
  476. let platformsArray = platforms
  477. .components(separatedBy: ",")
  478. .map { $0.trimmingCharacters(in: .whitespaces) }
  479. if KMMemberInfo.shared.isLogin {
  480. if userScenarioType == .lite_type1 ||
  481. userScenarioType == .lite_type3 ||
  482. userScenarioType == .lite_type11 ||
  483. userScenarioType == .lite_type4 ||
  484. userScenarioType == .lite_type5 ||
  485. userScenarioType == .lite_type9 ||
  486. userScenarioType == .lite_type13 ||
  487. userScenarioType == .lite_type7 ||
  488. userScenarioType == .lite_type8 {
  489. KMProductCompareWC.shared.orientation = true
  490. if userScenarioType == .lite_type1 {
  491. KMProductCompareWC.shared.orientationType = .trial
  492. } else if userScenarioType == .lite_type3 || userScenarioType == .lite_type11 {
  493. KMProductCompareWC.shared.orientationType = .lite_Base
  494. } else if userScenarioType == .lite_type4 || userScenarioType == .lite_type5 || userScenarioType == .lite_type9 || userScenarioType == .lite_type13 {
  495. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  496. } else if userScenarioType == .lite_type7 || userScenarioType == .lite_type8 {
  497. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
  498. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  499. } else {
  500. KMProductCompareWC.shared.orientationType = .lite_Base
  501. }
  502. }
  503. KMProductCompareWC.shared.showWindow(nil)
  504. } else if userScenarioType == .lite_type2 ||
  505. userScenarioType == .lite_type6 ||
  506. userScenarioType == .lite_type10 ||
  507. userScenarioType == .lite_type12 ||
  508. userScenarioType == .pro_type2 ||
  509. userScenarioType == .pro_type5 {
  510. } else if userScenarioType == .pro_type1 ||
  511. userScenarioType == .pro_type3 ||
  512. userScenarioType == .pro_type4 {
  513. KMProductCompareWC.shared.orientation = true
  514. if userScenarioType == .pro_type1 ||
  515. userScenarioType == .pro_type4 {
  516. KMProductCompareWC.shared.orientationType = .pro_Advanced
  517. } else if userScenarioType == .pro_type3 {
  518. KMProductCompareWC.shared.orientationType = .pro_Base
  519. }
  520. KMProductCompareWC.shared.showWindow(nil)
  521. }
  522. } else {
  523. KMLoginWindowsController.shared.openWindow() { [weak self] success in
  524. guard let self = self else { return }
  525. if success {
  526. if self.userScenarioType == .lite_type1 ||
  527. self.userScenarioType == .lite_type3 ||
  528. self.userScenarioType == .lite_type11 ||
  529. self.userScenarioType == .lite_type4 ||
  530. self.userScenarioType == .lite_type5 ||
  531. self.userScenarioType == .lite_type9 ||
  532. self.userScenarioType == .lite_type13 ||
  533. self.userScenarioType == .lite_type7 ||
  534. self.userScenarioType == .lite_type8 {
  535. KMProductCompareWC.shared.orientation = true
  536. if self.userScenarioType == .lite_type1 {
  537. KMProductCompareWC.shared.orientationType = .trial
  538. } else if self.userScenarioType == .lite_type3 || self.userScenarioType == .lite_type11 {
  539. KMProductCompareWC.shared.orientationType = .lite_Base
  540. } else if self.userScenarioType == .lite_type4 || self.userScenarioType == .lite_type5 || self.userScenarioType == .lite_type9 || self.userScenarioType == .lite_type13 {
  541. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  542. } else if self.userScenarioType == .lite_type7 || self.userScenarioType == .lite_type8 {
  543. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
  544. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  545. } else {
  546. KMProductCompareWC.shared.orientationType = .lite_Base
  547. }
  548. }
  549. KMProductCompareWC.shared.showWindow(nil)
  550. } else if self.userScenarioType == .lite_type2 ||
  551. self.userScenarioType == .lite_type6 ||
  552. self.userScenarioType == .lite_type10 ||
  553. self.userScenarioType == .lite_type12 ||
  554. self.userScenarioType == .pro_type2 ||
  555. self.userScenarioType == .pro_type5{
  556. } else if self.userScenarioType == .pro_type1 ||
  557. self.userScenarioType == .pro_type3 ||
  558. self.userScenarioType == .pro_type4 {
  559. KMProductCompareWC.shared.orientation = true
  560. if self.userScenarioType == .pro_type1 ||
  561. self.userScenarioType == .pro_type4 {
  562. KMProductCompareWC.shared.orientationType = .pro_Advanced
  563. } else if self.userScenarioType == .pro_type3 {
  564. KMProductCompareWC.shared.orientationType = .pro_Base
  565. }
  566. KMProductCompareWC.shared.showWindow(nil)
  567. }
  568. }
  569. }
  570. }
  571. }
  572. func aiSubscription() -> Bool {
  573. let oldAIPoints = AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes // 旧版AI点数
  574. if oldAIPoints > 0 {
  575. return true
  576. } else {
  577. if KMMemberInfo.shared.isLogin {
  578. if KMMemberInfo.shared.aiPoint > 0 {
  579. return true
  580. } else {
  581. AIPurchaseWindowController.currentWC().showWindow(nil)
  582. return false
  583. }
  584. } else {
  585. KMLoginWindowsController.shared.openWindow() { success in
  586. if success {
  587. AIPurchaseWindowController.currentWC().showWindow(nil)
  588. }
  589. }
  590. return false
  591. }
  592. }
  593. }
  594. }