KMMemberInfo.swift 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  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 Offic 免费+永久 (右上角导航栏按钮 - “登录领福利” + 升级(全平台))
  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. /** DMG | 未登录 | 未绑定License
  29. 【账户权益:免费; 卡片:空; 状态栏:登入、升级至Pro; 比较表:无; 高级功能:无】*/
  30. case dmg_type1
  31. /** DMG | 未登录 | 有标准版License、无转档License
  32. 【账户权益:免费; 卡片:空; 状态栏:登入、升级至Pro、PDF To Office; 比较表:无; 高级功能:可使用高级功能,无法使用转档】*/
  33. case dmg_type2
  34. /** DMG | 未登录 | 有标准版License、有转档License
  35. 【账户权益:免费; 卡片:空; 状态栏:登入、升级至Pro; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  36. case dmg_type3
  37. /** DMG | 登录 | 未绑定License | 免费未试用
  38. 【账户权益:免费; 卡片:免费试用、立即购买; 状态栏:头像、立即试用; 比较表:试用、购买; 高级功能:无】*/
  39. case dmg_type4
  40. /** DMG | 登录 | 未绑定License | 双平台高级永久
  41. 【账户权益:高级; 卡片:升级; 状态栏:头像、升级; 比较表:升级比较表(39.99); 高级功能:可使用高级功能(含转档)】 */
  42. case dmg_type5
  43. /** DMG | 登录 | 未绑定License | Mac单平台高级永久
  44. 【账户权益:高级; 卡片:升级; 状态栏:头像、升级; 比较表:升级比较表(49.99); 高级功能:可使用高级功能(含转档)】 */
  45. case dmg_type6
  46. /** DMG | 登录 | 未绑定License | iOS单平台高级永久
  47. 【账户权益:高级; 卡片:升级; 状态栏:头像、升级; 比较表:升级比较表(49.99); 高级功能:可使用高级功能(含转档)】 */
  48. case dmg_type7
  49. /** DMG | 登录 | 未绑定License | 全平台标准版12个月订阅
  50. 【账户权益:标准; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能,无法使用转档】 */
  51. case dmg_type8
  52. /** DMG | 登录 | 未绑定License | 全平台标准版12个月订阅取消续订
  53. 【账户权益:标准; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能,无法使用转档】*/
  54. case dmg_type9
  55. /** DMG | 登录 | 未绑定License | 全平台高级版12个月订阅试用中
  56. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  57. case dmg_type10
  58. /** DMG | 登录 | 未绑定License | 全平台高级版12个月试用过期
  59. 【账户权益:免费; 卡片:购买; 状态栏:头像、购买; 比较表:购买比较表; 高级功能:无】*/
  60. case dmg_type11
  61. /** DMG | 登录 | 未绑定License | 全平台高级版12个月订阅
  62. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  63. case dmg_type12
  64. /** DMG | 登录 | 未绑定License | 全平台高级版12个月订阅取消续订
  65. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  66. case dmg_type13
  67. /** DMG | 登录 | 未绑定License | 全平台高级版6个月订阅
  68. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  69. case dmg_type14
  70. /** DMG | 登录 | 未绑定License | 全平台高级版6个月订阅取消续订
  71. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  72. case dmg_type15
  73. /** DMG | 登录 | 未绑定License | Android单平台高级版月订阅
  74. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:无】*/
  75. case dmg_type16
  76. /** DMG | 登录 | 未绑定License | Android单平台高级版月订阅取消续订
  77. 【账户权益:高级; 卡片:; 状态栏:头像; 比较表:无; 高级功能:无】*/
  78. case dmg_type17
  79. /** DMG | 登录 | 未绑定License | 订阅到期
  80. 【账户权益:免费; 卡片:续费; 状态栏:头像、续费; 比较表:购买比较表; 高级功能:无】*/
  81. case dmg_type18
  82. /** DMG | 登录 | 有标准版License、无转档License | 免费未试用
  83. 【账户权益:免费; 卡片:免费试用、购买按钮; 状态栏:头像、免费试用、PDF To Office; 比较表:试用、购买; 高级功能:可使用高级功能,无法使用转档】*/
  84. case dmg_type19
  85. /** DMG | 登录 | 有标准版License、无转档License | 全平台标准版12个月订阅
  86. 【账户权益:标准; 卡片:无; 状态栏:头像、PDF To Office; 比较表:无; 高级功能:可使用高级功能,无法使用转档】*/
  87. case dmg_type20
  88. /** DMG | 登录 | 有标准版License、无转档License | 全平台标准版12个月订阅取消续订
  89. 【账户权益:标准; 卡片:无; 状态栏:头像、PDF To Office; 比较表:无; 高级功能:可使用高级功能,无法使用转档】*/
  90. case dmg_type21
  91. /** DMG | 登录 | 有标准版License、无转档License | 全平台高级版12个月试用过期
  92. 【账户权益:免费; 卡片:购买按钮; 状态栏:头像、购买、PDF To Office; 比较表:购买; 高级功能:可使用高级功能,无法使用转档】*/
  93. case dmg_type22
  94. /** DMG | 登录 | 有标准版License、无转档License | 全平台高级版12个月订阅试用中
  95. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  96. case dmg_type23
  97. /** DMG | 登录 | 有标准版License、无转档License | 全平台高级版12个月订阅
  98. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  99. case dmg_type24
  100. /** DMG | 登录 | 有标准版License、无转档License | 全平台高级版12个月订阅取消续订
  101. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  102. case dmg_type25
  103. /** DMG | 登录 | 有标准版License、无转档License | 全平台高级版6个月订阅
  104. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  105. case dmg_type26
  106. /** DMG | 登录 | 有标准版License、无转档License | 全平台高级版6个月订阅取消续订
  107. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  108. case dmg_type27
  109. /** DMG | 登录 | 有标准版License、无转档License | 双平台高级永久
  110. 【账户权益:高级; 卡片:升级; 状态栏:头像、升级; 比较表:升级(39.99); 高级功能:可使用高级功能(含转档)】*/
  111. case dmg_type28
  112. /** DMG | 登录 | 有标准版License、无转档License | Mac单平台高级永久
  113. 【账户权益:高级; 卡片:升级; 状态栏:头像、升级; 比较表:升级(49.99); 高级功能:可使用高级功能(含转档)】*/
  114. case dmg_type29
  115. /** DMG | 登录 | 有标准版License、无转档License | iOS单平台高级永久
  116. 【账户权益:高级; 卡片:升级; 状态栏:头像、升级、PDF To Office; 比较表:升级(49.99); 高级功能:可使用高级功能(含转档)】*/
  117. case dmg_type30
  118. /** DMG | 登录 | 有标准版License、无转档License | Android单平台高级版月订阅
  119. 【账户权益:高级; 卡片:无; 状态栏:头像、PDF To Office; 比较表:无; 高级功能:可使用高级功能,无法使用转档】*/
  120. case dmg_type31
  121. /** DMG | 登录 | 有标准版License、无转档License | Android单平台高级版月订阅取消续订
  122. 【账户权益:高级; 卡片:无; 状态栏:头像、PDF To Office; 比较表:无; 高级功能:可使用高级功能,无法使用转档】*/
  123. case dmg_type32
  124. /** DMG | 登录 | 有标准版License、无转档License | 订阅到期
  125. 【账户权益:免费; 卡片:续费; 状态栏:头像、续费、PDF To Office; 比较表:购买; 高级功能:可使用高级功能,无法使用转档】*/
  126. case dmg_type33
  127. /** DMG | 登录 | 有标准版License、有转档License | 免费未试用
  128. 【账户权益:免费; 卡片:免费试用、购买按钮; 状态栏:头像、免费试用; 比较表:试用、购买; 高级功能:可使用高级功能(含转档)】*/
  129. case dmg_type34
  130. /** DMG | 登录 | 有标准版License、有转档License | 全平台标准版12个月订阅
  131. 【账户权益:标准; 卡片:无; 状态栏:头像; 比较表:无; 高级功能: 高级功能:可使用高级功能(含转档)】*/
  132. case dmg_type35
  133. /** DMG | 登录 | 有标准版License、有转档License | 全平台标准版12个月订阅取消续订
  134. 【账户权益:标准; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  135. case dmg_type36
  136. /** DMG | 登录 | 有标准版License、有转档License | 全平台高级版12个月试用过期
  137. 【账户权益:免费; 卡片:购买按钮; 状态栏:头像、购买; 比较表:购买; 高级功能:可使用高级功能(含转档)】*/
  138. case dmg_type37
  139. /** DMG | 登录 | 有标准版License、有转档License | 全平台高级版12个月订阅试用中
  140. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  141. case dmg_type38
  142. /** DMG | 登录 | 有标准版License、有转档License | 全平台高级版12个月订阅
  143. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  144. case dmg_type39
  145. /** DMG | 登录 | 有标准版License、有转档License | 全平台高级版12个月订阅取消续订
  146. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  147. case dmg_type40
  148. /** DMG | 登录 | 有标准版License、有转档License | 全平台高级版6个月订阅
  149. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  150. case dmg_type41
  151. /** DMG | 登录 | 有标准版License、有转档License | 全平台高级版6个月订阅取消续订
  152. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  153. case dmg_type42
  154. /** DMG | 登录 | 有标准版License、有转档License | 双平台高级永久
  155. 【账户权益:高级; 卡片:升级; 状态栏:头像、升级; 比较表:升级(39.99); 高级功能:可使用高级功能(含转档)】*/
  156. case dmg_type43
  157. /** DMG | 登录 | 有标准版License、有转档License | Mac单平台高级永久
  158. 【账户权益:高级; 卡片:升级; 状态栏:头像、升级; 比较表:升级(49.99); 高级功能:可使用高级功能(含转档)】*/
  159. case dmg_type44
  160. /** DMG | 登录 | 有标准版License、有转档License | iOS单平台高级永久
  161. 【账户权益:高级; 卡片:升级; 状态栏:头像、升级; 比较表:升级(49.99); 高级功能:可使用高级功能(含转档)】*/
  162. case dmg_type45
  163. /** DMG | 登录 | 有标准版License、有转档License | Android单平台高级版月订阅
  164. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  165. case dmg_type46
  166. /** DMG | 登录 | 有标准版License、有转档License | Android单平台高级版月订阅取消续订
  167. 【账户权益:高级; 卡片:无; 状态栏:头像; 比较表:无; 高级功能:可使用高级功能(含转档)】*/
  168. case dmg_type47
  169. /** DMG | 登录 | 有标准版License、有转档License | 订阅到期
  170. 【账户权益:免费; 卡片:续费; 状态栏:头像、续费; 比较表:购买; 高级功能:可使用高级功能(含转档)】*/
  171. case dmg_type48
  172. }
  173. // 当前权益类型
  174. @objc enum KMCurrentUserEquityType : Int {
  175. case lite_free = 0 // 免费版 免费
  176. case lite_old
  177. }
  178. // 当前注销状态
  179. @objc enum KMCurrentLogoutStatus : Int {
  180. case null = 0 //
  181. case prompt_unsubscribe
  182. case prompt_signout
  183. case closeAccount
  184. case closeVerification
  185. case closeApply
  186. }
  187. @objcMembers class KMMemberInfo: NSObject {
  188. static let shared = KMMemberInfo()
  189. var isLogin: Bool = false
  190. var currentLogoutStatus: KMCurrentLogoutStatus = .null
  191. /**
  192. 登录
  193. */
  194. private var _refresh_token: String = "" // 刷新Token
  195. private var _access_token: String = "" // 访问Token
  196. private var _token_type: String = "" // Token 类型
  197. private var _expires_in: String = ""
  198. private var _scope: String = ""
  199. /**
  200. 登录
  201. */
  202. var userID: String = "" // 用户ID
  203. var userEmail: String = "" // 用户邮箱
  204. var fullName: String = "" // 用户名称
  205. var _activeVips: [KMMemberUserInfoActiveVIP] = [] // 活跃的会员
  206. var _activeAis: [KMMemberUserInfoActiveVIP] = [] // 活跃的AI
  207. var vip_id: String = "" // id
  208. var vip_userId: String = "" // 用户id
  209. var vip_status: Int = 0 // 状态 0注册1订阅中2订阅过期3试用中4试用过期
  210. var vip_endDate: String = "" // 到期时间
  211. var vip_payType: Int = 0 // 0未开启自动续订 1自动续订
  212. var vip_productName: String = "" // 产品名字
  213. var vip_levels: String = "1" // 会员等级 1是免费 2是标准 3是高级
  214. var vip_platforms: String = "" // 支持的平台
  215. var vip_point: Int = 0 // 剩余ai点数(svip才有)
  216. var vip_maxDeviceNum: Int = 0 // 最大登录设备限制数
  217. var vip_paymentModel: String = "" // 支付方式 付费模式(1自动续订(vip svip) 2单次付费(永久会员))
  218. var vip_isAi: String = "" // 是否是ai产品(0否1是)
  219. var vip_cycle: Int = 0 // 订阅周期:1、月(30天);2、季(90天);3、半年(183天);4、年(365天)
  220. var ai_id: String = "" // id
  221. var ai_userId: String = "" // 用户id
  222. var ai_status: Int = 0 // 状态 0注册1订阅中2订阅过期3试用中4试用过期
  223. var ai_endDate: String = "" // 到期时间
  224. var ai_payType: Int = 0 // 0未开启自动续订 1自动续订
  225. var ai_productName: String = "" // 产品名字
  226. var ai_levels: String = "1" // 会员等级 1是免费 2是标准 3是高级
  227. var ai_platforms: String = "" // 支持的平台
  228. var ai_point: Int = 0 // 剩余ai点数(svip才有)
  229. var ai_maxDeviceNum: Int = 0 // 最大登录设备限制数
  230. var ai_paymentModel: String = "" // 支付方式 付费模式(1自动续订(vip svip) 2单次付费(永久会员))
  231. var ai_isAi: String = "" // 是否是ai产品(0否1是)
  232. var ai_cycle: Int = 0 // 订阅周期:1、月(30天);2、季(90天);3、半年(183天);4、年(365天)
  233. var aiPoint: Int = 0 // AI 点数
  234. var validFlag: String = "" // 注销(0), * 正常(1), * 停用(2), * 注销中(5);
  235. var isHaveAIDiscount: String = "" // 是否有ai折扣
  236. var canTrail: Bool = false // 是否能试用
  237. // var currentTime: String = "" // 当前注销时间
  238. // var logOffTime: String = "" // 注销时间
  239. var avatarUrl: String = "" // 头像
  240. var avatarImage: NSImage?
  241. // MARK: Get & Set
  242. var refresh_token: String {
  243. get {
  244. let token = UserDefaults.standard.value(forKey: "MemberRefreshToken")
  245. if token is String {
  246. return token as! String
  247. }
  248. return _refresh_token
  249. }
  250. set {
  251. _refresh_token = newValue
  252. UserDefaults.standard.setValue(newValue, forKey: "MemberRefreshToken")
  253. UserDefaults.standard.synchronize()
  254. }
  255. }
  256. var access_token: String {
  257. get {
  258. let token = UserDefaults.standard.value(forKey: "MemberAccessToken")
  259. if token is String {
  260. return token as! String
  261. }
  262. return _access_token
  263. }
  264. set {
  265. _access_token = newValue
  266. UserDefaults.standard.setValue(newValue, forKey: "MemberAccessToken")
  267. UserDefaults.standard.synchronize()
  268. }
  269. }
  270. var token_type: String {
  271. get {
  272. return _token_type
  273. }
  274. set {
  275. _token_type = newValue
  276. }
  277. }
  278. var activeVips: [KMMemberUserInfoActiveVIP] {
  279. get {
  280. return _activeVips
  281. }
  282. set {
  283. _activeVips = newValue
  284. for index in 0..<_activeVips.count {
  285. let vip = _activeVips[index]
  286. if index == 0 {
  287. vip_id = vip.id
  288. vip_userId = vip.userId
  289. vip_status = vip.status
  290. vip_endDate = vip.endDate
  291. vip_payType = vip.payType
  292. vip_productName = vip.productName
  293. vip_levels = vip.levels
  294. vip_platforms = vip.platforms
  295. vip_point = vip.point
  296. vip_maxDeviceNum = vip.maxDeviceNum
  297. vip_paymentModel = vip.paymentModel
  298. vip_isAi = vip.isAi
  299. vip_cycle = vip.cycle
  300. } else {
  301. if let vipLevelsInt = Int(vip_levels), let vipOtherLevelsInt = Int(vip.levels), vipLevelsInt < vipOtherLevelsInt {
  302. vip_id = vip.id
  303. vip_userId = vip.userId
  304. vip_status = vip.status
  305. vip_endDate = vip.endDate
  306. vip_payType = vip.payType
  307. vip_productName = vip.productName
  308. vip_levels = vip.levels
  309. vip_platforms = vip.platforms
  310. vip_point = vip.point
  311. vip_maxDeviceNum = vip.maxDeviceNum
  312. vip_paymentModel = vip.paymentModel
  313. vip_isAi = vip.isAi
  314. vip_cycle = vip.cycle
  315. }
  316. }
  317. }
  318. }
  319. }
  320. var activeAis: [KMMemberUserInfoActiveVIP] {
  321. get {
  322. return _activeAis
  323. }
  324. set {
  325. _activeAis = newValue
  326. for index in 0..<_activeAis.count {
  327. let vip = _activeAis[index]
  328. if index == 0 {
  329. ai_id = vip.id
  330. ai_userId = vip.userId
  331. ai_status = vip.status
  332. ai_endDate = vip.endDate
  333. ai_payType = vip.payType
  334. ai_productName = vip.productName
  335. ai_levels = vip.levels
  336. ai_platforms = vip.platforms
  337. ai_point = vip.point
  338. ai_maxDeviceNum = vip.maxDeviceNum
  339. ai_paymentModel = vip.paymentModel
  340. ai_isAi = vip.isAi
  341. ai_cycle = vip.cycle
  342. } else {
  343. if let vipLevelsInt = Int(ai_levels), let vipOtherLevelsInt = Int(vip.levels), vipLevelsInt < vipOtherLevelsInt {
  344. ai_id = vip.id
  345. ai_userId = vip.userId
  346. ai_status = vip.status
  347. ai_endDate = vip.endDate
  348. ai_payType = vip.payType
  349. ai_productName = vip.productName
  350. ai_levels = vip.levels
  351. ai_platforms = vip.platforms
  352. ai_point = vip.point
  353. ai_maxDeviceNum = vip.maxDeviceNum
  354. ai_paymentModel = vip.paymentModel
  355. ai_isAi = vip.isAi
  356. ai_cycle = vip.cycle
  357. }
  358. }
  359. }
  360. }
  361. }
  362. // 用户当前的状态
  363. var userScenarioType: KMUserScenarioType {
  364. get {
  365. let oldAIPoints = AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes // 旧版AI点数
  366. let dateFormatter = DateFormatter()
  367. dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
  368. var startTime = Date()
  369. if KMMemberInfo.shared.vip_endDate.count > 0 {
  370. if let data = dateFormatter.date(from: KMMemberInfo.shared.vip_endDate) {
  371. startTime = data
  372. }
  373. }
  374. let currentTime = Date()
  375. let platforms = KMMemberInfo.shared.vip_platforms
  376. let platformsArray = platforms
  377. .components(separatedBy: ",")
  378. .map { $0.trimmingCharacters(in: .whitespaces) }
  379. #if VERSION_FREE
  380. #if VERSION_DMG
  381. // DMG
  382. if KMMemberInfo.shared.isLogin {
  383. if IAPProductsManager.default().isAvailableAllFunction() {
  384. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() { // 有标准版License、有转档License 34 - 48
  385. if KMMemberInfo.shared.canTrail && KMMemberInfo.shared.vip_levels == "1" { // 免费
  386. return .dmg_type34
  387. }
  388. if KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels == "3" { // 高级买断
  389. if platformsArray.count == 2 {
  390. return .dmg_type43
  391. } else if platformsArray.count == 1 {
  392. if(platformsArray.contains("mac")) {
  393. return .dmg_type44
  394. }
  395. if(platformsArray.contains("ios")) {
  396. return .dmg_type45
  397. }
  398. }
  399. }
  400. if KMMemberInfo.shared.vip_status == 1 { // 订阅中
  401. if platformsArray.count == 4 { // 全平台
  402. if KMMemberInfo.shared.vip_cycle == 4 { // 周期:年
  403. // 全平台标准版年订阅
  404. if KMMemberInfo.shared.vip_levels == "2" { // 标准
  405. if KMMemberInfo.shared.vip_payType == 1 { // 是否续订
  406. return .dmg_type35
  407. } else {
  408. return .dmg_type36
  409. }
  410. }
  411. // 全平台高级版年订阅
  412. if KMMemberInfo.shared.vip_levels == "3" { // 高级
  413. if KMMemberInfo.shared.vip_payType == 1 { // 是否续订
  414. return .dmg_type39
  415. } else {
  416. return .dmg_type40
  417. }
  418. }
  419. } else if KMMemberInfo.shared.vip_cycle == 3 { // 周期:6个月
  420. // 全平台高级版6个月订阅
  421. if KMMemberInfo.shared.vip_levels == "3" {
  422. if KMMemberInfo.shared.vip_payType == 1 {
  423. return .dmg_type41
  424. } else {
  425. return .dmg_type42
  426. }
  427. }
  428. }
  429. } else if platformsArray.count == 1 && platformsArray.contains("android") {
  430. if KMMemberInfo.shared.vip_cycle == 1 && KMMemberInfo.shared.vip_levels == "3" {
  431. if KMMemberInfo.shared.vip_payType == 1 {
  432. return .dmg_type46
  433. } else {
  434. return .dmg_type47
  435. }
  436. }
  437. }
  438. } else if KMMemberInfo.shared.vip_status == 2 { // 订阅过期
  439. return .dmg_type48
  440. } else if KMMemberInfo.shared.vip_status == 3 { // 试用中
  441. // 全平台高级版年订阅
  442. if KMMemberInfo.shared.vip_levels == "3" {
  443. return .dmg_type38
  444. }
  445. } else if KMMemberInfo.shared.canTrail == false &&
  446. KMMemberInfo.shared.vip_levels == "1" &&
  447. KMMemberInfo.shared.vip_status != 2 { // 试用过期
  448. return .dmg_type37
  449. }
  450. } else { // 有标准版License、无转档License 19 - 33
  451. if KMMemberInfo.shared.canTrail && KMMemberInfo.shared.vip_levels == "1" { // 免费
  452. return .dmg_type19
  453. }
  454. if KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels == "3" { // 高级买断
  455. if platformsArray.count == 2 {
  456. return .dmg_type28
  457. } else if platformsArray.count == 1 {
  458. if(platformsArray.contains("mac")) {
  459. return .dmg_type29
  460. }
  461. if(platformsArray.contains("ios")) {
  462. return .dmg_type30
  463. }
  464. }
  465. }
  466. if KMMemberInfo.shared.vip_status == 1 { // 订阅中
  467. if platformsArray.count == 4 { // 全平台
  468. if KMMemberInfo.shared.vip_cycle == 4 { // 周期:年
  469. // 全平台标准版年订阅
  470. if KMMemberInfo.shared.vip_levels == "2" { // 标准
  471. if KMMemberInfo.shared.vip_payType == 1 { // 是否续订
  472. return .dmg_type20
  473. } else {
  474. return .dmg_type21
  475. }
  476. }
  477. // 全平台高级版年订阅
  478. if KMMemberInfo.shared.vip_levels == "3" { // 高级
  479. if KMMemberInfo.shared.vip_payType == 1 { // 是否续订
  480. return .dmg_type24
  481. } else {
  482. return .dmg_type25
  483. }
  484. }
  485. } else if KMMemberInfo.shared.vip_cycle == 3 { // 周期:6个月
  486. // 全平台高级版6个月订阅
  487. if KMMemberInfo.shared.vip_levels == "3" {
  488. if KMMemberInfo.shared.vip_payType == 1 {
  489. return .dmg_type26
  490. } else {
  491. return .dmg_type27
  492. }
  493. }
  494. }
  495. } else if platformsArray.count == 1 && platformsArray.contains("android") {
  496. if KMMemberInfo.shared.vip_cycle == 1 && KMMemberInfo.shared.vip_levels == "3" {
  497. if KMMemberInfo.shared.vip_payType == 1 {
  498. return .dmg_type31
  499. } else {
  500. return .dmg_type32
  501. }
  502. }
  503. }
  504. } else if KMMemberInfo.shared.vip_status == 2 { // 订阅过期
  505. return .dmg_type33
  506. } else if KMMemberInfo.shared.vip_status == 3 { // 试用中
  507. // 全平台高级版年订阅
  508. if KMMemberInfo.shared.vip_levels == "3" {
  509. return .dmg_type23
  510. }
  511. } else if KMMemberInfo.shared.canTrail == false &&
  512. KMMemberInfo.shared.vip_levels == "1" &&
  513. KMMemberInfo.shared.vip_status != 2 { // 试用过期
  514. return .dmg_type22
  515. }
  516. }
  517. } else { // 未绑定License 4 - 18
  518. if KMMemberInfo.shared.canTrail && KMMemberInfo.shared.vip_levels == "1" { // 免费
  519. return .dmg_type4
  520. }
  521. if KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels == "3" { // 高级买断
  522. if platformsArray.count == 2 {
  523. return .dmg_type5
  524. } else if platformsArray.count == 1 {
  525. if(platformsArray.contains("mac")) {
  526. return .dmg_type6
  527. }
  528. if(platformsArray.contains("ios")) {
  529. return .dmg_type7
  530. }
  531. }
  532. }
  533. if KMMemberInfo.shared.vip_status == 1 { // 订阅中
  534. if platformsArray.count == 4 { // 全平台
  535. if KMMemberInfo.shared.vip_cycle == 4 { // 周期:年
  536. // 全平台标准版年订阅
  537. if KMMemberInfo.shared.vip_levels == "2" { // 标准
  538. if KMMemberInfo.shared.vip_payType == 1 { // 是否续订
  539. return .dmg_type8
  540. } else {
  541. return .dmg_type9
  542. }
  543. }
  544. // 全平台高级版年订阅
  545. if KMMemberInfo.shared.vip_levels == "3" { // 高级
  546. if KMMemberInfo.shared.vip_payType == 1 { // 是否续订
  547. return .dmg_type12
  548. } else {
  549. return .dmg_type13
  550. }
  551. }
  552. } else if KMMemberInfo.shared.vip_cycle == 3 { // 周期:6个月
  553. // 全平台高级版6个月订阅
  554. if KMMemberInfo.shared.vip_levels == "3" {
  555. if KMMemberInfo.shared.vip_payType == 1 {
  556. return .dmg_type14
  557. } else {
  558. return .dmg_type15
  559. }
  560. }
  561. }
  562. } else if platformsArray.count == 1 && platformsArray.contains("android") {
  563. if KMMemberInfo.shared.vip_cycle == 1 && KMMemberInfo.shared.vip_levels == "3" {
  564. if KMMemberInfo.shared.vip_payType == 1 {
  565. return .dmg_type16
  566. } else {
  567. return .dmg_type17
  568. }
  569. }
  570. }
  571. } else if KMMemberInfo.shared.vip_status == 2 { // 订阅过期
  572. return .dmg_type18
  573. } else if KMMemberInfo.shared.vip_status == 3 { // 试用中
  574. // 全平台高级版年订阅
  575. if KMMemberInfo.shared.vip_levels == "3" {
  576. return .dmg_type10
  577. }
  578. } else if KMMemberInfo.shared.canTrail == false &&
  579. KMMemberInfo.shared.vip_levels == "1" &&
  580. KMMemberInfo.shared.vip_status != 2 { // 试用过期
  581. return .dmg_type11
  582. }
  583. }
  584. } else {
  585. if IAPProductsManager.default().isAvailableAllFunction() {
  586. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  587. return .dmg_type3
  588. }
  589. return .dmg_type2
  590. } else {
  591. return .dmg_type1
  592. }
  593. }
  594. #else
  595. // AppStore 免费版本
  596. if IAPProductsManager.default().allAccessPack6months_lite.isSubscribed == true ||
  597. IAPProductsManager.default().allAccessPackNew6months_lite.isSubscribed == true ||
  598. IAPProductsManager.default().allAccessPack12months_lite.isSubscribed == true {
  599. // 有旧订阅
  600. return .lite_type12
  601. } else if (IAPProductsManager.default().allAccessProduct.isSubscribed == true) {
  602. // 有旧买断
  603. if KMMemberInfo.shared.canTrail && KMMemberInfo.shared.vip_levels == "1" {
  604. return .lite_type9
  605. }
  606. if KMMemberInfo.shared.vip_status == 3 {
  607. return .lite_type10
  608. } else if KMMemberInfo.shared.vip_status == 4 {
  609. return .lite_type11
  610. } else if(KMMemberInfo.shared.vip_status == 1 && KMMemberInfo.shared.vip_paymentModel == "1") {
  611. // 订阅中
  612. return .lite_type12
  613. }
  614. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_payType == 0 && KMMemberInfo.shared.vip_status == 1 {
  615. return .lite_type13
  616. }
  617. return .lite_type9
  618. } else {
  619. if !KMMemberInfo.shared.isLogin {
  620. return .lite_type1
  621. }
  622. // 无旧订阅、买断
  623. if KMMemberInfo.shared.canTrail && KMMemberInfo.shared.vip_levels == "1" {
  624. return .lite_type1
  625. }
  626. if(KMMemberInfo.shared.canTrail == false && KMMemberInfo.shared.vip_levels == "1" && KMMemberInfo.shared.vip_status != 2) { //试用过期
  627. return .lite_type3
  628. }
  629. if KMMemberInfo.shared.vip_status == 3 {
  630. return .lite_type2
  631. } else if KMMemberInfo.shared.vip_status == 4 {
  632. return .lite_type3
  633. } else if KMMemberInfo.shared.vip_status == 2 {
  634. return .lite_type7
  635. } else if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_payType == 0 && KMMemberInfo.shared.vip_status == 1 {
  636. return .lite_type8
  637. }
  638. if KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_status == 1 { //永久买断
  639. return .lite_type5
  640. } else {
  641. if KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
  642. return .lite_type6
  643. } else {
  644. return .lite_type4
  645. }
  646. }
  647. }
  648. #endif
  649. #else
  650. // AppStore 付费版
  651. if IAPProductsManager.default().pdfToOfficeProduct.isSubscribed == true {
  652. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_status == 1 { //订阅中
  653. return .pro_type2
  654. } else {
  655. return .pro_type1
  656. }
  657. } else {
  658. if KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_status == 1 { //买断
  659. return .pro_type4
  660. } else {
  661. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_status == 1 {//订阅中
  662. return .pro_type5
  663. } else {
  664. return .pro_type3
  665. }
  666. }
  667. }
  668. #endif
  669. return .lite_type1
  670. }
  671. }
  672. // 是否允许全部功能
  673. var isMemberAllFunction: Bool {
  674. get {
  675. #if VERSION_FREE
  676. #if VERSION_DMG
  677. // DMG
  678. if userScenarioType == .dmg_type1 ||
  679. userScenarioType == .dmg_type4 ||
  680. userScenarioType == .dmg_type11 ||
  681. userScenarioType == .dmg_type18 ||
  682. userScenarioType == .dmg_type16 ||
  683. userScenarioType == .dmg_type17 { // 无高级功能权益
  684. return false
  685. } else { // 有高级功能权益
  686. return true
  687. }
  688. #else
  689. // AppStore 免费版本
  690. if KMMemberInfo.shared.isLogin {
  691. if IAPProductsManager.default().isAvailableAllFunction() == true {
  692. return true
  693. } else {
  694. let platforms = KMMemberInfo.shared.vip_platforms
  695. let platformsArray = platforms
  696. .components(separatedBy: ",")
  697. .map { $0.trimmingCharacters(in: .whitespaces) }
  698. if userScenarioType == .lite_type5 ||
  699. userScenarioType == .lite_type4 ||
  700. userScenarioType == .lite_type8 {
  701. if(platformsArray.contains("mac")) {
  702. return true
  703. }
  704. } else if userScenarioType == .lite_type2 ||
  705. userScenarioType == .lite_type6 {
  706. return true
  707. }
  708. return false
  709. }
  710. } else {
  711. if IAPProductsManager.default().allAccessPackPermanent_lite.isSubscribed == true || IAPProductsManager.default().isAvailableAllFunction() == true {
  712. return true
  713. }
  714. return false
  715. }
  716. #endif
  717. #else
  718. // AppStore 付费版
  719. return true
  720. #endif
  721. return false
  722. }
  723. }
  724. // 是否允许使用转档
  725. var isPermitConvert: Bool {
  726. get {
  727. #if VERSION_FREE
  728. #if VERSION_DMG
  729. // DMG
  730. if userScenarioType == .dmg_type1 ||
  731. userScenarioType == .dmg_type2 ||
  732. userScenarioType == .dmg_type4 ||
  733. userScenarioType == .dmg_type8 ||
  734. userScenarioType == .dmg_type9 ||
  735. userScenarioType == .dmg_type11 ||
  736. userScenarioType == .dmg_type16 ||
  737. userScenarioType == .dmg_type17 ||
  738. userScenarioType == .dmg_type18 ||
  739. userScenarioType == .dmg_type19 ||
  740. userScenarioType == .dmg_type20 ||
  741. userScenarioType == .dmg_type21 ||
  742. userScenarioType == .dmg_type22 ||
  743. userScenarioType == .dmg_type31 ||
  744. userScenarioType == .dmg_type32 ||
  745. userScenarioType == .dmg_type33 { // 无转档权益
  746. return false
  747. } else { // 有转档权益
  748. return true
  749. }
  750. #else
  751. // AppStore 免费版本
  752. if KMMemberInfo.shared.isLogin {
  753. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  754. return true
  755. } else {
  756. let platforms = KMMemberInfo.shared.vip_platforms
  757. let platformsArray = platforms
  758. .components(separatedBy: ",")
  759. .map { $0.trimmingCharacters(in: .whitespaces) }
  760. if(userScenarioType == .lite_type2) {
  761. return true
  762. } else if userScenarioType == .lite_type5 ||
  763. userScenarioType == .lite_type4 ||
  764. userScenarioType == .lite_type8 {
  765. if(platformsArray.contains("mac") && KMMemberInfo.shared.vip_levels == "3") { //购买了
  766. return true
  767. }
  768. } else if userScenarioType == .lite_type6 || userScenarioType == .lite_type12 {
  769. if KMMemberInfo.shared.vip_levels == "3" { //高级版本支持转档功能,但不支持升级
  770. return true
  771. }
  772. }
  773. return false
  774. }
  775. } else {
  776. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  777. return true
  778. }
  779. return false
  780. }
  781. #endif
  782. #else
  783. // AppStore 付费版
  784. if KMMemberInfo.shared.isLogin {
  785. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  786. return true
  787. } else {
  788. let platforms = KMMemberInfo.shared.vip_platforms
  789. let platformsArray = platforms
  790. .components(separatedBy: ",")
  791. .map { $0.trimmingCharacters(in: .whitespaces) }
  792. if userScenarioType == .pro_type5 {
  793. if(platformsArray.contains("mac")) { //购买了mac
  794. return true
  795. }
  796. } else if userScenarioType == .pro_type1 ||
  797. userScenarioType == .pro_type2 ||
  798. userScenarioType == .pro_type4 {
  799. return true
  800. }
  801. return false
  802. }
  803. } else {
  804. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  805. return true
  806. }
  807. return false
  808. }
  809. #endif
  810. }
  811. }
  812. // 是否允许使用AI
  813. var isPermitAI: Bool {
  814. #if VERSION_FREE
  815. #if VERSION_DMG
  816. // DMG
  817. #else
  818. // AppStore 免费版本
  819. if KMMemberInfo.shared.isLogin {
  820. if KMMemberInfo.shared.aiPoint > 0 {
  821. return true
  822. }
  823. if AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes > 0 {
  824. return true
  825. } else {
  826. return false
  827. }
  828. } else {
  829. if AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes > 0 {
  830. return true
  831. }
  832. }
  833. return false
  834. #endif
  835. #else
  836. // AppStore 付费版
  837. if KMMemberInfo.shared.isLogin {
  838. if IAPProductsManager.default().aiAllAccessPack1month_pro.isSubscribed {
  839. return true
  840. }
  841. return false
  842. } else {
  843. return false
  844. }
  845. #endif
  846. return false
  847. }
  848. //允许继续购买AI
  849. var allowPurchaseAI: Bool {
  850. if KMMemberInfo.shared.isLogin {
  851. if KMMemberInfo.shared.ai_status == 1 {
  852. return false
  853. }
  854. } else {
  855. if AIInfoManager.default().aiInfoValid {
  856. return false
  857. }
  858. }
  859. return true
  860. }
  861. // MARK: Public Method
  862. func memberUserInfo(model: KMMemberUserInfo) -> Void {
  863. userID = model.id
  864. userEmail = model.email
  865. fullName = model.fullName
  866. aiPoint = model.aiPoint
  867. validFlag = model.validFlag
  868. isHaveAIDiscount = model.isHaveAIDiscount
  869. if model.canTrail == "1" {
  870. canTrail = true
  871. } else {
  872. canTrail = false
  873. }
  874. activeVips = model.activeVIP
  875. activeAis = model.activeAI
  876. avatarUrl = model.avatarUrl
  877. }
  878. func advancedFunctionUsage() -> Void {
  879. let platforms = KMMemberInfo.shared.vip_platforms
  880. let platformsArray = platforms
  881. .components(separatedBy: ",")
  882. .map { $0.trimmingCharacters(in: .whitespaces) }
  883. if KMMemberInfo.shared.isLogin {
  884. productCompareShow()
  885. } else {
  886. KMLoginWindowsController.shared.openWindow() { [weak self] success in
  887. guard let self = self else { return }
  888. if success {
  889. self.productCompareShow()
  890. }
  891. }
  892. }
  893. }
  894. func productCompareShow() -> Void {
  895. let platforms = KMMemberInfo.shared.vip_platforms
  896. let platformsArray = platforms
  897. .components(separatedBy: ",")
  898. .map { $0.trimmingCharacters(in: .whitespaces) }
  899. #if VERSION_FREE
  900. #if VERSION_DMG
  901. // DMG
  902. KMProductCompareWC.shared.orientation = true
  903. if userScenarioType == .dmg_type4 ||
  904. userScenarioType == .dmg_type11 ||
  905. userScenarioType == .dmg_type18 ||
  906. userScenarioType == .dmg_type19 ||
  907. userScenarioType == .dmg_type22 ||
  908. userScenarioType == .dmg_type33 ||
  909. userScenarioType == .dmg_type34 ||
  910. userScenarioType == .dmg_type37 ||
  911. userScenarioType == .dmg_type48 {
  912. KMProductCompareWC.shared.orientationType = .dmg_Base
  913. } else if userScenarioType == .dmg_type5 ||
  914. userScenarioType == .dmg_type28 ||
  915. userScenarioType == .dmg_type43 {
  916. KMProductCompareWC.shared.orientationType = .dmg_Upgrades1
  917. } else if userScenarioType == .dmg_type6 ||
  918. userScenarioType == .dmg_type7 ||
  919. userScenarioType == .dmg_type29 ||
  920. userScenarioType == .dmg_type30 ||
  921. userScenarioType == .dmg_type44 ||
  922. userScenarioType == .dmg_type45 {
  923. KMProductCompareWC.shared.orientationType = .dmg_Upgrades2
  924. }
  925. KMProductCompareWC.shared.showWindow(nil)
  926. #else
  927. // AppStore 免费版本
  928. KMProductCompareWC.shared.orientation = true
  929. // 无旧订阅、买断
  930. if userScenarioType == .lite_type1 {
  931. // 试用比较表
  932. KMProductCompareWC.shared.orientationType = .trial
  933. KMProductCompareWC.shared.showWindow(nil)
  934. } else if userScenarioType == .lite_type3 ||
  935. userScenarioType == .lite_type7 {
  936. // 购买比较表
  937. KMProductCompareWC.shared.orientationType = .lite_Base
  938. KMProductCompareWC.shared.showWindow(nil)
  939. } else if userScenarioType == .lite_type5 {
  940. // 升级比较表
  941. // 有账号(单、多平台)高级永久权益,升级全平台权益
  942. if platformsArray.count == 1 {
  943. // 单平台升级
  944. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  945. } else {
  946. // 多平台升级
  947. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  948. }
  949. KMProductCompareWC.shared.showWindow(nil)
  950. } else if userScenarioType == .lite_type2 ||
  951. userScenarioType == .lite_type4 ||
  952. userScenarioType == .lite_type6 ||
  953. userScenarioType == .lite_type8 {
  954. // 订阅中,Android单平台高级版月订阅或者全平台标准版年订阅,不能升级,提示联系客服
  955. if !platformsArray.contains("mac") ||
  956. KMMemberInfo.shared.vip_levels != "3" {
  957. let alert = NSAlert()
  958. alert.alertStyle = .critical
  959. alert.informativeText = NSLocalizedString("Sorry, you do not have the rights to this paid feature and cannot use it. If you have any questions, please contact customer service at support@pdfreaderpro.com", comment: "")
  960. alert.addButton(withTitle: NSLocalizedString("Got it", comment: ""))
  961. alert.runModal()
  962. }
  963. }
  964. // 有旧买断
  965. if userScenarioType == .lite_type9 ||
  966. userScenarioType == .lite_type11 {
  967. // 升级比较表
  968. if KMMemberInfo.shared.vip_paymentModel == "2" &&
  969. KMMemberInfo.shared.vip_levels != "1" {
  970. // 有账号(单、多平台)高级永久权益,升级全平台权益
  971. if (platformsArray.count == 1) {
  972. // 单平台升级
  973. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  974. } else {
  975. // 多平台升级
  976. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  977. }
  978. } else {
  979. // 有本地单平台高级永久权益,升级全平台权益
  980. KMProductCompareWC.shared.orientationType = .lite_MacWindows
  981. }
  982. KMProductCompareWC.shared.showWindow(nil)
  983. }
  984. #endif
  985. #else
  986. // AppStore 付费版
  987. KMProductCompareWC.shared.orientation = true
  988. // 无旧订阅
  989. if userScenarioType == .pro_type3 {
  990. // 升级比较表
  991. // 有本地单平台标准永久权益,升级全平台、升级单平台高级权益
  992. KMProductCompareWC.shared.orientationType = .pro_Base
  993. KMProductCompareWC.shared.showWindow(nil)
  994. } else if userScenarioType == .pro_type4 {
  995. // 升级比较表
  996. // 有账号(单、多平台)高级永久权益,升级全平台权益
  997. if (platformsArray.count == 1) {
  998. // 单平台升级
  999. KMProductCompareWC.shared.orientationType = .pro_Advanced
  1000. } else {
  1001. // 多平台升级
  1002. KMProductCompareWC.shared.orientationType = .pro_Advanced
  1003. }
  1004. KMProductCompareWC.shared.showWindow(nil)
  1005. } else if userScenarioType == .pro_type5 {
  1006. // 订阅中,Android单平台高级版月订阅或者全平台标准版年订阅,不能升级,提示联系客服
  1007. if !platformsArray.contains("mac") ||
  1008. KMMemberInfo.shared.vip_levels != "3" {
  1009. let alert = NSAlert()
  1010. alert.alertStyle = .critical
  1011. alert.informativeText = NSLocalizedString("Sorry, you do not have the rights to this paid feature and cannot use it. If you have any questions, please contact customer service at support@pdfreaderpro.com", comment: "")
  1012. alert.addButton(withTitle: NSLocalizedString("Got it", comment: ""))
  1013. alert.runModal()
  1014. }
  1015. }
  1016. // 有旧订阅
  1017. if userScenarioType == .pro_type1 {
  1018. // 升级比较表
  1019. if KMMemberInfo.shared.vip_paymentModel == "2" &&
  1020. KMMemberInfo.shared.vip_levels != "1" {
  1021. // 有账号(单、多平台)高级永久权益,升级全平台权益
  1022. if (platformsArray.count == 1) {
  1023. // 单平台升级
  1024. KMProductCompareWC.shared.orientationType = .pro_Advanced
  1025. } else {
  1026. // 多平台升级
  1027. KMProductCompareWC.shared.orientationType = .pro_Advanced
  1028. }
  1029. } else {
  1030. // 有本地单平台高级永久权益,升级全平台权益
  1031. KMProductCompareWC.shared.orientationType = .pro_Advanced
  1032. }
  1033. KMProductCompareWC.shared.showWindow(nil)
  1034. }
  1035. #endif
  1036. }
  1037. func aiSubscription() -> Bool {
  1038. let oldAIPoints = AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes // 旧版AI点数
  1039. if oldAIPoints > 0 {
  1040. return true
  1041. } else {
  1042. if KMMemberInfo.shared.isLogin {
  1043. if KMMemberInfo.shared.aiPoint > 0 {
  1044. return true
  1045. } else {
  1046. if KMMemberInfo.shared.ai_status == 1 {
  1047. if KMMemberInfo.shared.aiPoint == 0 {
  1048. let alert = NSAlert()
  1049. alert.alertStyle = .critical
  1050. alert.informativeText = NSLocalizedString("No Value Present", comment: "")
  1051. alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
  1052. alert.runModal()
  1053. return false
  1054. }
  1055. } else {
  1056. AIPurchaseWindowController.currentWC().showWindow(nil)
  1057. return false
  1058. }
  1059. }
  1060. } else {
  1061. KMLoginWindowsController.shared.openWindow() { success in
  1062. if success {
  1063. if KMMemberInfo.shared.aiPoint > 0 {
  1064. } else {
  1065. AIPurchaseWindowController.currentWC().showWindow(nil)
  1066. }
  1067. }
  1068. }
  1069. return false
  1070. }
  1071. }
  1072. return false
  1073. }
  1074. func clearMemberInfoCache() -> Void {
  1075. currentLogoutStatus = .null
  1076. _refresh_token = ""
  1077. _access_token = ""
  1078. _token_type = ""
  1079. _expires_in = ""
  1080. _scope = ""
  1081. userID = ""
  1082. userEmail = ""
  1083. fullName = ""
  1084. _activeVips = []
  1085. _activeAis = []
  1086. vip_id = ""
  1087. vip_userId = ""
  1088. vip_status = 0
  1089. vip_endDate = ""
  1090. vip_payType = 0
  1091. vip_productName = ""
  1092. vip_levels = "1"
  1093. vip_platforms = ""
  1094. vip_point = 0
  1095. vip_maxDeviceNum = 0
  1096. vip_paymentModel = ""
  1097. vip_isAi = ""
  1098. vip_cycle = 0
  1099. ai_id = ""
  1100. ai_userId = ""
  1101. ai_status = 0
  1102. ai_endDate = ""
  1103. ai_payType = 0
  1104. ai_productName = ""
  1105. ai_levels = "1"
  1106. ai_platforms = ""
  1107. ai_point = 0
  1108. ai_maxDeviceNum = 0
  1109. ai_paymentModel = ""
  1110. ai_isAi = ""
  1111. ai_cycle = 0
  1112. aiPoint = 0
  1113. validFlag = ""
  1114. isHaveAIDiscount = ""
  1115. canTrail = false
  1116. }
  1117. }