KMMemberInfo.swift 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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.ai_status == 1 { //订阅中
  290. return .pro_type2
  291. } else {
  292. return .pro_type1
  293. }
  294. } else {
  295. if KMMemberInfo.shared.vip_paymentModel == "2" { //买断
  296. return .pro_type4
  297. } else {
  298. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.ai_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. if(platformsArray.contains("mac")) {
  330. return true
  331. }
  332. } else if userScenarioType == .lite_type2 ||
  333. userScenarioType == .lite_type6 {
  334. return true
  335. }
  336. return false
  337. }
  338. } else {
  339. if IAPProductsManager.default().allAccessPackPermanent_lite.isSubscribed == true || IAPProductsManager.default().isAvailableAllFunction() == true {
  340. return true
  341. }
  342. return false
  343. }
  344. #endif
  345. #else
  346. // AppStore 付费版
  347. return true
  348. #endif
  349. return false
  350. }
  351. }
  352. // 是否允许使用转档
  353. var isPermitConvert: Bool {
  354. get {
  355. #if VERSION_FREE
  356. #if VERSION_DMG
  357. // DMG
  358. if KMMemberInfo.shared.isLogin {
  359. }
  360. return false
  361. #else
  362. // AppStore 免费版本
  363. if KMMemberInfo.shared.isLogin {
  364. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  365. return true
  366. } else {
  367. let platforms = KMMemberInfo.shared.vip_platforms
  368. let platformsArray = platforms
  369. .components(separatedBy: ",")
  370. .map { $0.trimmingCharacters(in: .whitespaces) }
  371. if(userScenarioType == .lite_type2) {
  372. return true
  373. } else if userScenarioType == .lite_type5 ||
  374. userScenarioType == .lite_type4 {
  375. if(platformsArray.contains("mac")) { //购买了
  376. return true
  377. }
  378. } else if userScenarioType == .lite_type6 || userScenarioType == .lite_type12 {
  379. if KMMemberInfo.shared.vip_levels == "3" { //高级版本支持转档功能
  380. return true
  381. }
  382. }
  383. return false
  384. }
  385. } else {
  386. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  387. return true
  388. }
  389. return false
  390. }
  391. #endif
  392. #else
  393. // AppStore 付费版
  394. if KMMemberInfo.shared.isLogin {
  395. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  396. return true
  397. } else {
  398. let platforms = KMMemberInfo.shared.vip_platforms
  399. let platformsArray = platforms
  400. .components(separatedBy: ",")
  401. .map { $0.trimmingCharacters(in: .whitespaces) }
  402. if userScenarioType == .pro_type5 {
  403. if(platformsArray.contains("mac")) { //购买了mac
  404. return true
  405. }
  406. } else if userScenarioType == .pro_type1 ||
  407. userScenarioType == .pro_type2 ||
  408. userScenarioType == .pro_type4 {
  409. return true
  410. }
  411. return false
  412. }
  413. } else {
  414. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  415. return true
  416. }
  417. return false
  418. }
  419. #endif
  420. }
  421. }
  422. // 是否允许使用AI
  423. var isPermitAI: Bool {
  424. // let oldAIPoints = AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes // 旧版AI点数
  425. // if KMMemberInfo.shared.isLogin {
  426. // if oldAIPoints > 0 {
  427. // return true
  428. // } else {
  429. // if userScenarioType == .lite_type4 || userScenarioType == .lite_type5 || userScenarioType == .lite_type6 || userScenarioType == .lite_type12 {
  430. // if KMMemberInfo.shared.aiPoint > 0 {
  431. // return true
  432. // } else {
  433. // return false
  434. // }
  435. // }
  436. // return false
  437. // }
  438. // } else {
  439. // if AIInfoManager.default().aiInfoValid && oldAIPoints > 0 {
  440. // return true
  441. // }
  442. // return false
  443. // }
  444. if KMMemberInfo.shared.isLogin {
  445. if KMMemberInfo.shared.ai_productName != "" || AIInfoManager.default().aiInfoValid {
  446. return true
  447. }
  448. return false
  449. } else {
  450. if AIInfoManager.default().aiInfoValid {
  451. return true
  452. }
  453. return false
  454. }
  455. }
  456. // MARK: Public Method
  457. func memberUserInfo(model: KMMemberUserInfo) -> Void {
  458. userID = model.id
  459. userEmail = model.email
  460. fullName = model.fullName
  461. aiPoint = model.aiPoint
  462. validFlag = model.validFlag
  463. isHaveAIDiscount = model.isHaveAIDiscount
  464. if model.canTrail == "1" {
  465. canTrail = true
  466. } else {
  467. canTrail = false
  468. }
  469. activeVips = model.activeVIP
  470. activeAis = model.activeAI
  471. }
  472. func advancedFunctionUsage() -> Void {
  473. let platforms = KMMemberInfo.shared.vip_platforms
  474. let platformsArray = platforms
  475. .components(separatedBy: ",")
  476. .map { $0.trimmingCharacters(in: .whitespaces) }
  477. if KMMemberInfo.shared.isLogin {
  478. if userScenarioType == .lite_type1 ||
  479. userScenarioType == .lite_type3 ||
  480. userScenarioType == .lite_type11 ||
  481. userScenarioType == .lite_type4 ||
  482. userScenarioType == .lite_type5 ||
  483. userScenarioType == .lite_type9 ||
  484. userScenarioType == .lite_type13 ||
  485. userScenarioType == .lite_type7 ||
  486. userScenarioType == .lite_type8 {
  487. KMProductCompareWC.shared.orientation = true
  488. if userScenarioType == .lite_type1 {
  489. KMProductCompareWC.shared.orientationType = .trial
  490. } else if userScenarioType == .lite_type3 || userScenarioType == .lite_type11 {
  491. KMProductCompareWC.shared.orientationType = .lite_Base
  492. } else if userScenarioType == .lite_type4 || userScenarioType == .lite_type5 || userScenarioType == .lite_type9 || userScenarioType == .lite_type13 {
  493. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  494. } else if userScenarioType == .lite_type7 || userScenarioType == .lite_type8 {
  495. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
  496. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  497. } else {
  498. KMProductCompareWC.shared.orientationType = .lite_Base
  499. }
  500. }
  501. KMProductCompareWC.shared.showWindow(nil)
  502. } else if userScenarioType == .lite_type2 ||
  503. userScenarioType == .lite_type6 ||
  504. userScenarioType == .lite_type10 ||
  505. userScenarioType == .lite_type12 ||
  506. userScenarioType == .pro_type2 ||
  507. userScenarioType == .pro_type5 {
  508. } else if userScenarioType == .pro_type1 ||
  509. userScenarioType == .pro_type3 ||
  510. userScenarioType == .pro_type4 {
  511. KMProductCompareWC.shared.orientation = true
  512. if userScenarioType == .pro_type1 ||
  513. userScenarioType == .pro_type4 {
  514. KMProductCompareWC.shared.orientationType = .pro_Advanced
  515. } else if userScenarioType == .pro_type3 {
  516. KMProductCompareWC.shared.orientationType = .pro_Base
  517. }
  518. KMProductCompareWC.shared.showWindow(nil)
  519. }
  520. } else {
  521. KMLoginWindowsController.shared.openWindow() { [weak self] success in
  522. guard let self = self else { return }
  523. if success {
  524. if self.userScenarioType == .lite_type1 ||
  525. self.userScenarioType == .lite_type3 ||
  526. self.userScenarioType == .lite_type11 ||
  527. self.userScenarioType == .lite_type4 ||
  528. self.userScenarioType == .lite_type5 ||
  529. self.userScenarioType == .lite_type9 ||
  530. self.userScenarioType == .lite_type13 ||
  531. self.userScenarioType == .lite_type7 ||
  532. self.userScenarioType == .lite_type8 {
  533. KMProductCompareWC.shared.orientation = true
  534. if self.userScenarioType == .lite_type1 {
  535. KMProductCompareWC.shared.orientationType = .trial
  536. } else if self.userScenarioType == .lite_type3 || self.userScenarioType == .lite_type11 {
  537. KMProductCompareWC.shared.orientationType = .lite_Base
  538. } else if self.userScenarioType == .lite_type4 || self.userScenarioType == .lite_type5 || self.userScenarioType == .lite_type9 || self.userScenarioType == .lite_type13 {
  539. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  540. } else if self.userScenarioType == .lite_type7 || self.userScenarioType == .lite_type8 {
  541. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
  542. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  543. } else {
  544. KMProductCompareWC.shared.orientationType = .lite_Base
  545. }
  546. }
  547. KMProductCompareWC.shared.showWindow(nil)
  548. } else if self.userScenarioType == .lite_type2 ||
  549. self.userScenarioType == .lite_type6 ||
  550. self.userScenarioType == .lite_type10 ||
  551. self.userScenarioType == .lite_type12 ||
  552. self.userScenarioType == .pro_type2 ||
  553. self.userScenarioType == .pro_type5{
  554. } else if self.userScenarioType == .pro_type1 ||
  555. self.userScenarioType == .pro_type3 ||
  556. self.userScenarioType == .pro_type4 {
  557. KMProductCompareWC.shared.orientation = true
  558. if self.userScenarioType == .pro_type1 ||
  559. self.userScenarioType == .pro_type4 {
  560. KMProductCompareWC.shared.orientationType = .pro_Advanced
  561. } else if self.userScenarioType == .pro_type3 {
  562. KMProductCompareWC.shared.orientationType = .pro_Base
  563. }
  564. KMProductCompareWC.shared.showWindow(nil)
  565. }
  566. }
  567. }
  568. }
  569. }
  570. func aiSubscription() -> Bool {
  571. let oldAIPoints = AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes // 旧版AI点数
  572. if oldAIPoints > 0 {
  573. return true
  574. } else {
  575. if KMMemberInfo.shared.isLogin {
  576. if KMMemberInfo.shared.aiPoint > 0 {
  577. return true
  578. } else {
  579. AIPurchaseWindowController.currentWC().showWindow(nil)
  580. return false
  581. }
  582. } else {
  583. KMLoginWindowsController.shared.openWindow() { success in
  584. if success {
  585. AIPurchaseWindowController.currentWC().showWindow(nil)
  586. }
  587. }
  588. return false
  589. }
  590. }
  591. }
  592. }