KMProductModel.swift 21 KB

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