KMMemberInfo.swift 25 KB

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