KMMemberInfo.swift 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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 {
  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 {
  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_cycle == 4 && platformsArray.count == 4 {
  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_cycle == 4 && platformsArray.count == 4 {
  299. return .pro_type2
  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. if userScenarioType == .pro_type1 ||
  399. userScenarioType == .pro_type2 ||
  400. userScenarioType == .pro_type4 ||
  401. userScenarioType == .pro_type5 {
  402. return true
  403. } else {
  404. return false
  405. }
  406. }
  407. } else {
  408. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  409. return true
  410. }
  411. return false
  412. }
  413. #endif
  414. }
  415. }
  416. // 是否允许使用AI
  417. var isPermitAI: Bool {
  418. // let oldAIPoints = AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes // 旧版AI点数
  419. // if KMMemberInfo.shared.isLogin {
  420. // if oldAIPoints > 0 {
  421. // return true
  422. // } else {
  423. // if userScenarioType == .lite_type4 || userScenarioType == .lite_type5 || userScenarioType == .lite_type6 || userScenarioType == .lite_type12 {
  424. // if KMMemberInfo.shared.aiPoint > 0 {
  425. // return true
  426. // } else {
  427. // return false
  428. // }
  429. // }
  430. // return false
  431. // }
  432. // } else {
  433. // if AIInfoManager.default().aiInfoValid && oldAIPoints > 0 {
  434. // return true
  435. // }
  436. // return false
  437. // }
  438. if KMMemberInfo.shared.isLogin {
  439. if KMMemberInfo.shared.ai_productName != "" || AIInfoManager.default().aiInfoValid {
  440. return true
  441. }
  442. return false
  443. } else {
  444. if AIInfoManager.default().aiInfoValid {
  445. return true
  446. }
  447. return false
  448. }
  449. }
  450. // MARK: Public Method
  451. func memberUserInfo(model: KMMemberUserInfo) -> Void {
  452. userID = model.id
  453. userEmail = model.email
  454. fullName = model.fullName
  455. aiPoint = model.aiPoint
  456. validFlag = model.validFlag
  457. isHaveAIDiscount = model.isHaveAIDiscount
  458. if model.canTrail == "1" {
  459. canTrail = true
  460. } else {
  461. canTrail = false
  462. }
  463. activeVips = model.activeVIP
  464. activeAis = model.activeAI
  465. }
  466. func advancedFunctionUsage() -> Void {
  467. let platforms = KMMemberInfo.shared.vip_platforms
  468. let platformsArray = platforms
  469. .components(separatedBy: ",")
  470. .map { $0.trimmingCharacters(in: .whitespaces) }
  471. if KMMemberInfo.shared.isLogin {
  472. if userScenarioType == .lite_type1 ||
  473. userScenarioType == .lite_type3 ||
  474. userScenarioType == .lite_type11 ||
  475. userScenarioType == .lite_type4 ||
  476. userScenarioType == .lite_type5 ||
  477. userScenarioType == .lite_type9 ||
  478. userScenarioType == .lite_type13 ||
  479. userScenarioType == .lite_type7 ||
  480. userScenarioType == .lite_type8 {
  481. KMProductCompareWC.shared.orientation = true
  482. if userScenarioType == .lite_type1 {
  483. KMProductCompareWC.shared.orientationType = .trial
  484. } else if userScenarioType == .lite_type3 || userScenarioType == .lite_type11 {
  485. KMProductCompareWC.shared.orientationType = .lite_Base
  486. } else if userScenarioType == .lite_type4 || userScenarioType == .lite_type5 || userScenarioType == .lite_type9 || userScenarioType == .lite_type13 {
  487. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  488. } else if userScenarioType == .lite_type7 || userScenarioType == .lite_type8 {
  489. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
  490. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  491. } else {
  492. KMProductCompareWC.shared.orientationType = .lite_Base
  493. }
  494. }
  495. KMProductCompareWC.shared.showWindow(nil)
  496. } else if userScenarioType == .lite_type2 ||
  497. userScenarioType == .lite_type6 ||
  498. userScenarioType == .lite_type10 ||
  499. userScenarioType == .lite_type12 ||
  500. userScenarioType == .pro_type2 ||
  501. userScenarioType == .pro_type5 {
  502. } else if userScenarioType == .pro_type1 ||
  503. userScenarioType == .pro_type3 ||
  504. userScenarioType == .pro_type4 {
  505. KMProductCompareWC.shared.orientation = true
  506. if userScenarioType == .pro_type1 ||
  507. userScenarioType == .pro_type4 {
  508. KMProductCompareWC.shared.orientationType = .pro_Advanced
  509. } else if userScenarioType == .pro_type3 {
  510. KMProductCompareWC.shared.orientationType = .pro_Base
  511. }
  512. KMProductCompareWC.shared.showWindow(nil)
  513. }
  514. } else {
  515. KMLoginWindowsController.shared.openWindow() { [weak self] success in
  516. guard let self = self else { return }
  517. if success {
  518. if self.userScenarioType == .lite_type1 ||
  519. self.userScenarioType == .lite_type3 ||
  520. self.userScenarioType == .lite_type11 ||
  521. self.userScenarioType == .lite_type4 ||
  522. self.userScenarioType == .lite_type5 ||
  523. self.userScenarioType == .lite_type9 ||
  524. self.userScenarioType == .lite_type13 ||
  525. self.userScenarioType == .lite_type7 ||
  526. self.userScenarioType == .lite_type8 {
  527. KMProductCompareWC.shared.orientation = true
  528. if self.userScenarioType == .lite_type1 {
  529. KMProductCompareWC.shared.orientationType = .trial
  530. } else if self.userScenarioType == .lite_type3 || self.userScenarioType == .lite_type11 {
  531. KMProductCompareWC.shared.orientationType = .lite_Base
  532. } else if self.userScenarioType == .lite_type4 || self.userScenarioType == .lite_type5 || self.userScenarioType == .lite_type9 || self.userScenarioType == .lite_type13 {
  533. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  534. } else if self.userScenarioType == .lite_type7 || self.userScenarioType == .lite_type8 {
  535. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
  536. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  537. } else {
  538. KMProductCompareWC.shared.orientationType = .lite_Base
  539. }
  540. }
  541. KMProductCompareWC.shared.showWindow(nil)
  542. } else if self.userScenarioType == .lite_type2 ||
  543. self.userScenarioType == .lite_type6 ||
  544. self.userScenarioType == .lite_type10 ||
  545. self.userScenarioType == .lite_type12 ||
  546. self.userScenarioType == .pro_type2 ||
  547. self.userScenarioType == .pro_type5{
  548. } else if self.userScenarioType == .pro_type1 ||
  549. self.userScenarioType == .pro_type3 ||
  550. self.userScenarioType == .pro_type4 {
  551. KMProductCompareWC.shared.orientation = true
  552. if self.userScenarioType == .pro_type1 ||
  553. self.userScenarioType == .pro_type4 {
  554. KMProductCompareWC.shared.orientationType = .pro_Advanced
  555. } else if self.userScenarioType == .pro_type3 {
  556. KMProductCompareWC.shared.orientationType = .pro_Base
  557. }
  558. KMProductCompareWC.shared.showWindow(nil)
  559. }
  560. }
  561. }
  562. }
  563. }
  564. func aiSubscription() -> Bool {
  565. let oldAIPoints = AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes // 旧版AI点数
  566. if oldAIPoints > 0 {
  567. return true
  568. } else {
  569. if KMMemberInfo.shared.isLogin {
  570. if KMMemberInfo.shared.aiPoint > 0 {
  571. return true
  572. } else {
  573. AIPurchaseWindowController.currentWC().showWindow(nil)
  574. return false
  575. }
  576. } else {
  577. KMLoginWindowsController.shared.openWindow() { success in
  578. if success {
  579. AIPurchaseWindowController.currentWC().showWindow(nil)
  580. }
  581. }
  582. return false
  583. }
  584. }
  585. }
  586. }