KMProductModel.swift 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. //
  2. // KMProductModel.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/11/6.
  6. //
  7. import Foundation
  8. import Combine
  9. @objc enum KMCompareTableType : Int {
  10. case trial = 0 // 试用比较表
  11. case dmg_Base // DMG 基础版
  12. case dmg_MacWindows // DMG Mac&Windows双平台高级版永久
  13. case lite_Base // Lite 基础版
  14. case lite_MacWindows // Lite Mac&Windows双平台高级版永久
  15. case pro_Base // Pro 基础版
  16. case pro_Advanced // Pro Mac单平台高级版永久
  17. }
  18. @objc enum KMCompareProductType : Int {
  19. case free = 0 // 免费
  20. case freeTrial // 试用
  21. case allPlatformStandard // 全平台标准版年订阅
  22. case dualPlatformAdvanced // Mac&Windows双平台高级版永久
  23. case allPlatformAdvanced_6 // 全平台高级版6个月订阅
  24. case allPlatformAdvanced_12 // 全平台高级版12个月订阅
  25. case macPlatformAdvanced // MAC单平台高级版永久
  26. }
  27. @objc enum KMPurchasedProductType : Int {
  28. case fourDevicesAllAccessPackNew6months_lite = 0 // 4_devices_all_access_pack_new_6months(订阅)
  29. case fourDevicesAllAccessPackNew12months_lite // 4_devices_all_access_pack_12months(订阅)
  30. case allAccessPackNew6months_lite // all_access_pack_new_6months(订阅)
  31. case allAccessPack12months_lite // all_access_pack_12months(订阅)
  32. case allAccessPack6months_lite // all_access_pack_6months(订阅)
  33. case aiAllAccessPack1month_lite // ai_all_access_pack_1month(订阅)
  34. case aiAllAccessPack12month_lite // ai_all_access_pack_12month(订阅)
  35. case allAccessPackPermanent_lite // all_access_pack_permanent(永久)
  36. case advancedAddDevicesAllAccessPack12months_lite // advanced_add_devices_all_access_pack_12months(订阅)
  37. case advancedAdd2DevicesAllAccessPack12months_lite // advanced_add_2_devices_all_access_pack_12months(订阅)
  38. case aiAllAccessPack1month_pro // ai_all_access_pack_1month(订阅)
  39. case aiAllAccessPack12month_pro // ai_all_access_pack_1month(订阅)
  40. case pdfToOfficePackPermanent_pro // pdf_to_office_pack_permanent(永久)
  41. case fourDevicesAllAccessPack12months_pro // 4_devices_all_access_pack_12months(全平台高级年订阅)
  42. case standardAddDevicesAllAccessPack12months_pro // standard_add_devices_all_access_pack_12months(订阅)
  43. case advancedAddDevicesAllAccessPack12months_pro // advanced_add_devices_all_access_pack_12months(订阅)
  44. case advancedAdd2DevicesAllAccessPack12months_pro // advanced_add_2_devices_all_access_pack_12months(订阅)
  45. }
  46. @objcMembers
  47. class KMProductModel: ObservableObject {
  48. /**
  49. 比较表类型
  50. */
  51. @Published var state: KMCompareTableType = .trial
  52. /**
  53. 高级版半年 或 年订阅,true为年订阅,false为半年订阅,默认true为年订阅
  54. */
  55. @Published var isPurchaseSwitch: Bool = true
  56. // MARK: Public Method
  57. /**
  58. @abstract 根据当前权益获取比较表类型
  59. @param
  60. */
  61. func getCurrentComparisonTableType() -> Void {
  62. if KMMemberInfo.shared.canTrail {
  63. state = .trial
  64. } else {
  65. #if VERSION_FREE
  66. #if VERSION_DMG
  67. // DMG
  68. if KMMemberInfo.shared.vip_levels == "1" {
  69. state = .dmg_Base
  70. } else if KMMemberInfo.shared.vip_levels == "2" {
  71. state = .dmg_MacWindows
  72. }
  73. #else
  74. // AppStore 免费版本
  75. if KMMemberInfo.shared.vip_levels == "1" {
  76. state = .lite_Base
  77. } else if KMMemberInfo.shared.vip_levels == "2" {
  78. state = .lite_MacWindows
  79. }
  80. #endif
  81. #else
  82. // AppStore 付费版
  83. if KMMemberInfo.shared.vip_levels == "1" {
  84. state = .pro_Base
  85. } else if KMMemberInfo.shared.vip_levels == "2" {
  86. state = .pro_Advanced
  87. }
  88. #endif
  89. }
  90. }
  91. /**
  92. 对应商品价格
  93. */
  94. func getProductPrice(_ type: KMCompareProductType) -> String {
  95. if type == .freeTrial {
  96. } else if type == .allPlatformStandard {
  97. } else if type == .dualPlatformAdvanced {
  98. } else if type == .allPlatformAdvanced_6 {
  99. if let allAccessProduct = IAPProductsManager.default().advancedSixMonthPlan_lite, allAccessProduct.isOffers {
  100. return allAccessProduct.offersPrice()
  101. }
  102. } else if type == .allPlatformAdvanced_12 {
  103. #if VERSION_FREE
  104. #if VERSION_DMG
  105. // DMG
  106. #else
  107. // AppStore 免费版本
  108. if let allAccessProduct = IAPProductsManager.default().advancedAnnualPlan_lite, allAccessProduct.isOffers {
  109. return allAccessProduct.offersPrice()
  110. } else {
  111. return IAPProductsManager.default().advancedAnnualPlan_lite.price()
  112. }
  113. #endif
  114. #else
  115. // AppStore 付费版
  116. #endif
  117. } else if type == .macPlatformAdvanced {
  118. }
  119. return ""
  120. }
  121. // MARK: Private Method
  122. // MARK: Action Method
  123. /**
  124. 恢复购买
  125. */
  126. func productRestore() -> Void {
  127. IAPProductsManager.default().restoreSubscriptions()
  128. }
  129. func privacyPolicyAction() -> Void {
  130. NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/privacy-policy")!)
  131. }
  132. func termOfSerAction() -> Void {
  133. NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/terms_of_service")!)
  134. }
  135. // MARK: Get & Set
  136. /**
  137. 当前比较表产品列表内容
  138. */
  139. var products: [KMCompareProductType] {
  140. if state == .trial {
  141. return [.free, .freeTrial]
  142. } else if state == .dmg_Base {
  143. return [.free, .allPlatformStandard, .allPlatformAdvanced_12, .dualPlatformAdvanced]
  144. } else if state == .dmg_MacWindows {
  145. return [.allPlatformAdvanced_12]
  146. } else if state == .lite_Base {
  147. return [.free, .allPlatformAdvanced_6, .allPlatformAdvanced_12, .dualPlatformAdvanced]
  148. } else if state == .lite_MacWindows {
  149. return [.allPlatformAdvanced_12]
  150. } else if state == .pro_Base {
  151. return [.allPlatformAdvanced_12, .macPlatformAdvanced]
  152. } else if state == .pro_Advanced {
  153. return [.allPlatformAdvanced_12]
  154. }
  155. return []
  156. }
  157. /**
  158. 比较表数据源
  159. */
  160. var dataSource: [Any] {
  161. if isPurchaseSwitch {
  162. // 试用 全平台标准版年订阅 全平台高级版6/12个月订阅 Mac&Windows双平台高级版永久 MAC单平台高级版永久
  163. //MAC单平台标准版永久
  164. return [
  165. "Benefit",
  166. ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
  167. ["Maximum number of accessible devices", "2 devices", "4 devices", "4 devices", "2 devices", "1 devices"],
  168. "PDF to Office",
  169. ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "Only first 10 pages", "Standard", "Advanced", "Advanced", "Advanced"],
  170. ["Turn PDF to PPT, Excel, RTF, CSV, and more", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"],
  171. ["Convert PDF to TIFF, BMP, GIF or TGA files", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"],
  172. "Edit PDF",
  173. ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
  174. ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
  175. "OCR",
  176. ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
  177. "Organize Pages",
  178. ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
  179. ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
  180. "Advanced Editing Tools",
  181. ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "∞", "∞"],
  182. ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
  183. ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
  184. ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
  185. ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
  186. ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
  187. ["Extract Images", "X", "✓", "✓", "✓", "✓"],
  188. ["Extract tables", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"],
  189. ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
  190. "Fill & Sign",
  191. ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
  192. ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
  193. "Security",
  194. ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
  195. ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
  196. ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
  197. "Create PDF",
  198. ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
  199. ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
  200. "Annotations",
  201. ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
  202. ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
  203. ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
  204. ["Table", "X", "✓", "✓", "✓", "✓"],
  205. "View PDF",
  206. ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
  207. ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
  208. ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
  209. ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
  210. "Subscription Based Solution",
  211. ["Access all premium features in app", "X", "12 months", "12 months", "∞", "∞"],
  212. ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
  213. ["Ad-free", "X", "✓", "✓", "✓", "✓"]
  214. ]
  215. } else {
  216. return [
  217. "Benefit",
  218. ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
  219. ["Maximum number of accessible devices", "2 devices", "4 devices", "4 devices", "2 devices", "1 devices"],
  220. "PDF to Office",
  221. ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "Only first 10 pages", "Standard", "Advanced", "Advanced", "Advanced"],
  222. ["Turn PDF to PPT, Excel, RTF, CSV, and more", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"],
  223. ["Convert PDF to TIFF, BMP, GIF or TGA files", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"],
  224. "Edit PDF",
  225. ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
  226. ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
  227. "OCR",
  228. ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
  229. "Organize Pages",
  230. ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
  231. ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
  232. "Advanced Editing Tools",
  233. ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "∞", "∞"],
  234. ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
  235. ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
  236. ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
  237. ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
  238. ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
  239. ["Extract Images", "X", "✓", "✓", "✓", "✓"],
  240. ["Extract tables", "Only first 10 pages", "Only first 10 pages", "✓", "✓", "✓"],
  241. ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
  242. "Fill & Sign",
  243. ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
  244. ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
  245. "Security",
  246. ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
  247. ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
  248. ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
  249. "Create PDF",
  250. ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
  251. ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
  252. "Annotations",
  253. ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
  254. ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
  255. ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
  256. ["Table", "X", "✓", "✓", "✓", "✓"],
  257. "View PDF",
  258. ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
  259. ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
  260. ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
  261. ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
  262. "Subscription Based Solution",
  263. ["Access all premium features in app", "X", "6 months", "6 months", "∞", "∞"],
  264. ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
  265. ["Ad-free", "X", "✓", "✓", "✓", "✓"]
  266. ]
  267. }
  268. }
  269. }