KMUserInfoViewController.swift 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363
  1. //
  2. // KMUserInfoViewController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/10/30.
  6. //
  7. import Cocoa
  8. import Combine
  9. class KMGradationBox: NSBox {
  10. override func draw(_ dirtyRect: NSRect){
  11. super.draw(dirtyRect)
  12. guard let context = NSGraphicsContext.current?.cgContext else { return }
  13. // 定义渐变颜色
  14. let colors = [NSColor(hex: "EBDABD").cgColor, NSColor(hex: "E5CCA8").cgColor]
  15. let gradient = CGGradient(colorsSpace: nil, colors: colors as CFArray, locations: nil)
  16. // 定义渐变起始和结束点
  17. let startPoint = CGPoint(x: bounds.minX, y: bounds.minY)
  18. let endPoint = CGPoint(x: bounds.maxX, y: bounds.maxY)
  19. // 绘制圆角矩形路径
  20. let roundedPath = NSBezierPath(roundedRect: bounds, xRadius: 4, yRadius: 4) // 你的圆角半径
  21. roundedPath.addClip() // 添加路径为剪切区域
  22. context.clip() // 使路径生效
  23. // 绘制渐变
  24. context.drawLinearGradient(gradient!, start: startPoint, end: endPoint, options: [])
  25. context.restoreGState()
  26. }
  27. }
  28. @objcMembers
  29. class KMUserInfoViewController: NSViewController {
  30. @IBOutlet weak var userImageView: NSImageView!
  31. @IBOutlet weak var emailLabel: NSTextField!
  32. @IBOutlet weak var productLabel: NSTextField!
  33. @IBOutlet weak var spliLineImageView: NSImageView!
  34. @IBOutlet weak var endDateLabel: NSTextField!
  35. @IBOutlet weak var membershipLabel: NSTextField!
  36. @IBOutlet weak var lockedImageView: NSImageView!
  37. @IBOutlet weak var lockedLabel: NSTextField!
  38. @IBOutlet var lockedLabelWidthffset:NSLayoutConstraint!
  39. @IBOutlet var lockedBox:KMGradationBox!
  40. @IBOutlet weak var centerBackgroud: NSImageView!
  41. @IBOutlet weak var rightsBox: NSBox!
  42. @IBOutlet var rightsView: NSView!
  43. @IBOutlet weak var number1Label: NSTextField!
  44. @IBOutlet weak var number1ImageView: NSImageView!
  45. @IBOutlet weak var number2Label: NSTextField!
  46. @IBOutlet weak var iconBox: NSBox!
  47. @IBOutlet var iconView1: NSView!
  48. @IBOutlet weak var icon1ImageView: NSImageView!
  49. @IBOutlet weak var icon2ImageView: NSImageView!
  50. @IBOutlet weak var icon3ImageView: NSImageView!
  51. @IBOutlet weak var icon4ImageView: NSImageView!
  52. @IBOutlet var iconView2: NSView!
  53. @IBOutlet weak var icon5ImageView: NSImageView!
  54. @IBOutlet weak var icon6ImageView: NSImageView!
  55. @IBOutlet weak var icon7ImageView: NSImageView!
  56. @IBOutlet var iconView3: NSView!
  57. @IBOutlet weak var icon8ImageView: NSImageView!
  58. @IBOutlet weak var icon9ImageView: NSImageView!
  59. @IBOutlet var iconView4: NSView!
  60. @IBOutlet weak var icon10ImageView: NSImageView!
  61. @IBOutlet weak var number3Label: NSTextField!
  62. @IBOutlet weak var number4Label: NSTextField!
  63. @IBOutlet weak var number4_1Label: NSTextField!
  64. @IBOutlet weak var number5Label: NSTextField!
  65. @IBOutlet weak var buyBox: NSBox!
  66. @IBOutlet var buyView1: NSView!
  67. @IBOutlet weak var buyNow1Box: KMBox!
  68. @IBOutlet weak var buyNow1ImageView: NSImageView!
  69. @IBOutlet weak var buyNow1Label: NSTextField!
  70. @IBOutlet weak var arrow1ImageView: NSImageView!
  71. @IBOutlet weak var buyNow2Box: KMBox!
  72. @IBOutlet weak var buyNow2ImageView: NSImageView!
  73. @IBOutlet weak var buyNow2Label: NSTextField!
  74. @IBOutlet weak var arrow2ImageView: NSImageView!
  75. @IBOutlet var buyNow1BoxLeftConst: NSLayoutConstraint!
  76. @IBOutlet weak var accountCenterBox: KMBox!
  77. @IBOutlet weak var accountImageView: NSImageView!
  78. @IBOutlet weak var accountLabel: NSTextField!
  79. @IBOutlet weak var signOutBox: KMBox!
  80. @IBOutlet weak var signOutImageView: NSImageView!
  81. @IBOutlet weak var signOutLabel: NSTextField!
  82. @IBOutlet weak var closeAccountBox: KMBox!
  83. @IBOutlet weak var closeAccountImageView: NSImageView!
  84. @IBOutlet weak var closeAccountLabel: NSTextField!
  85. private var viewModel = KMUserInfoVCModel()
  86. private var cancellables = Set<AnyCancellable>()
  87. deinit {
  88. KMPrint("KMUserInfoViewController deinit.")
  89. }
  90. @objc class func refreshTokenUserInfo(callback: ((Bool,KMMemberCenterResult?)->Void)?) -> Void {
  91. if KMMemberCenterManager.manager.isConnectionAvailable() == false {
  92. let alert = NSAlert()
  93. alert.alertStyle = .critical
  94. alert.messageText = NSLocalizedString("Error Information", comment: "")
  95. alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
  96. alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
  97. alert.runModal()
  98. let res = KMMemberCenterResult(code: 500, msg: "", result: false)
  99. callback?(false,res)
  100. return
  101. }
  102. KMUserInfoVCModel().refreshUserInfo(networkAlert: false) { success, msg,resDic in
  103. callback?(success,resDic)
  104. if success {
  105. KMMemberInfo.shared.isLogin = true
  106. } else {
  107. KMMemberInfo.shared.isLogin = false
  108. }
  109. }
  110. }
  111. override func viewDidLoad() {
  112. super.viewDidLoad()
  113. // Do view setup here.
  114. self.view.wantsLayer = true
  115. self.view.layer?.backgroundColor = .white
  116. #if VERSION_FREE
  117. #if VERSION_DMG
  118. // DMG
  119. languageLocalized_DMG()
  120. initializeUI_DMG()
  121. #else
  122. // AppStore 免费版本
  123. languageLocalized()
  124. initializeUI()
  125. #endif
  126. #else
  127. // AppStore 付费版
  128. languageLocalized()
  129. initializeUI()
  130. #endif
  131. if let data = KMMemberInfo.shared.avatarImage {
  132. userImageView.image = data
  133. } else {
  134. userImageView.image = KMAdvertisementImage.imageWithURL(url: URL(string: KMMemberInfo.shared.avatarUrl) , completion: { [weak self] image in
  135. self?.userImageView.image = image
  136. KMMemberInfo.shared.avatarImage = image
  137. })
  138. }
  139. NotificationCenter.default.addObserver(self, selector: #selector(changeEffectiveAppearance), name: NSNotification.Name(rawValue: "kEffectiveAppearance"), object: nil)
  140. addWaitingView(to: self.view)
  141. KMUserInfoViewController.refreshTokenUserInfo {[weak self] success, resDic in
  142. DispatchQueue.main.async {
  143. self?.removeWaitingView(from: self?.view ?? NSView())
  144. if(success) {
  145. if KMMemberInfo.shared.isLogin {
  146. KMCheckInManager.default.checkIn(refreshData: true, callback: nil)
  147. }
  148. } else {
  149. let code = resDic?.code
  150. if code == 304 {
  151. KMLoginWindowsController.shared.showWindow(nil)
  152. NotificationCenter.default.post(name: NSNotification.Name("CloseMenuNotification"), object: nil)
  153. }
  154. }
  155. }
  156. }
  157. }
  158. @objc func changeEffectiveAppearance() {
  159. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  160. if isDarkModel {
  161. self.view.appearance = NSAppearance(named: .darkAqua)
  162. } else {
  163. self.view.appearance = NSAppearance(named: .aqua)
  164. }
  165. #if VERSION_FREE
  166. #if VERSION_DMG
  167. // DMG
  168. initializeUI_DMG()
  169. #else
  170. // AppStore 免费版本
  171. initializeUI()
  172. #endif
  173. #else
  174. // AppStore 付费版
  175. initializeUI()
  176. #endif
  177. }
  178. // MARK: Private Method
  179. private func languageLocalized() -> Void {
  180. emailLabel.stringValue = KMMemberInfo.shared.userEmail
  181. productLabel.stringValue = NSLocalizedString("Personal Account", tableName: "MemberCenterLocalizable", comment: "")
  182. endDateLabel.stringValue = String(format: "%@ %@", KMMemberInfo.shared.vip_endDate,NSLocalizedString("expires", tableName: "MemberCenterLocalizable", comment: ""))
  183. membershipLabel.stringValue = NSLocalizedString("Membership Benefits", tableName: "MemberCenterLocalizable", comment: "")
  184. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  185. accountLabel.stringValue = NSLocalizedString("Account Center", tableName: "MemberCenterLocalizable", comment: "")
  186. signOutLabel.stringValue = NSLocalizedString("Sign out", tableName: "MemberCenterLocalizable", comment: "")
  187. if KMMemberInfo.shared.validFlag == "5" {
  188. closeAccountLabel.stringValue = NSLocalizedString("Undo Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  189. } else {
  190. closeAccountLabel.stringValue = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  191. }
  192. if KMMemberInfo.shared.vip_maxDeviceNum == 1 {
  193. number4Label.stringValue = NSLocalizedString("device", tableName: "MemberCenterLocalizable", comment: "")
  194. } else {
  195. number4Label.stringValue = NSLocalizedString("devices", tableName: "MemberCenterLocalizable", comment: "")
  196. }
  197. number4_1Label.stringValue = String(KMMemberInfo.shared.vip_maxDeviceNum)
  198. number5Label.stringValue = NSLocalizedString("Devices Access", tableName: "MemberCenterLocalizable", comment: "")
  199. let platforms = viewModel.getPlatformsImages()
  200. if platforms.count == 4 {
  201. number3Label.stringValue = NSLocalizedString("All-platform Available", tableName: "MemberCenterLocalizable", comment: "")
  202. } else {
  203. number3Label.stringValue = NSLocalizedString("Platform", tableName: "MemberCenterLocalizable", comment: "")
  204. }
  205. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  206. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  207. var isTrialPeriod = false
  208. #if !VERSION_DMG
  209. if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isTrialPeriod == true {
  210. isTrialPeriod = true
  211. }
  212. #else
  213. #endif
  214. if !isTrialPeriod {
  215. buyNow2Label.stringValue = NSLocalizedString("7-Day Free Trial", tableName: "MemberCenterLocalizable", comment: "")
  216. } else {
  217. buyNow2Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  218. }
  219. } else if KMMemberInfo.shared.userScenarioType == .lite_type9 {
  220. if(KMMemberInfo.shared.vip_status == 2) {
  221. buyNow1Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
  222. } else if (KMMemberInfo.shared.vip_status == 4) {
  223. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  224. } else {
  225. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  226. }
  227. } else if KMMemberInfo.shared.userScenarioType == .lite_type3 {
  228. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  229. } else if KMMemberInfo.shared.userScenarioType == .lite_type11 {
  230. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  231. } else if KMMemberInfo.shared.userScenarioType == .lite_type5 ||
  232. KMMemberInfo.shared.userScenarioType == .pro_type1 ||
  233. KMMemberInfo.shared.userScenarioType == .pro_type4 {
  234. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  235. } else if KMMemberInfo.shared.userScenarioType == .pro_type3 {
  236. if(KMMemberInfo.shared.vip_status == 2) {
  237. buyNow1Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
  238. } else {
  239. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  240. }
  241. } else if KMMemberInfo.shared.userScenarioType == .lite_type7 ||
  242. KMMemberInfo.shared.userScenarioType == .lite_type8 ||
  243. KMMemberInfo.shared.userScenarioType == .lite_type13 {
  244. buyNow1Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
  245. }
  246. }
  247. private func refreshEquity() -> Void {
  248. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  249. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  250. lockedImageView.image = NSImage(named: "LockedImage")
  251. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  252. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  253. number1ImageView.isHidden = true
  254. number1Label.isHidden = false
  255. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  256. number1Label.textColor = NSColor(hex: "0E1114")
  257. membershipLabel.textColor = NSColor(hex: "42464D")
  258. } else if KMMemberInfo.shared.userScenarioType == .lite_type2 {
  259. lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  260. lockedImageView.image = NSImage(named: "UpgradeImage2")
  261. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  262. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  263. number1ImageView.isHidden = false
  264. number1Label.isHidden = true
  265. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  266. } else if KMMemberInfo.shared.userScenarioType == .lite_type3 {
  267. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  268. lockedImageView.image = NSImage(named: "LockedImage")
  269. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  270. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  271. number1ImageView.isHidden = true
  272. number1Label.isHidden = false
  273. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  274. number1Label.textColor = NSColor(hex: "0E1114")
  275. } else if KMMemberInfo.shared.userScenarioType == .lite_type4 {
  276. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  277. lockedImageView.image = NSImage(named: "UpgradeImage2")
  278. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  279. if KMMemberInfo.shared.vip_levels == "2" {
  280. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  281. } else {
  282. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  283. }
  284. number1ImageView.isHidden = false
  285. number1Label.isHidden = true
  286. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  287. } else if KMMemberInfo.shared.userScenarioType == .lite_type5 {
  288. lockedLabel.stringValue = NSLocalizedString("Permanent", tableName: "MemberCenterLocalizable", comment: "")
  289. lockedImageView.image = NSImage(named: "UpgradeImage2")
  290. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  291. if KMMemberInfo.shared.vip_levels == "2" {
  292. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  293. } else {
  294. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  295. }
  296. number1ImageView.isHidden = false
  297. number1Label.isHidden = true
  298. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
  299. } else if KMMemberInfo.shared.userScenarioType == .lite_type6 {
  300. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  301. lockedImageView.image = NSImage(named: "UpgradeImage2")
  302. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  303. if KMMemberInfo.shared.vip_levels == "2" {
  304. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  305. } else {
  306. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  307. }
  308. number1ImageView.isHidden = false
  309. number1Label.isHidden = true
  310. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  311. } else if KMMemberInfo.shared.userScenarioType == .lite_type7 {
  312. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  313. lockedImageView.image = NSImage(named: "LockedImage")
  314. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  315. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  316. number1ImageView.isHidden = true
  317. number1Label.isHidden = false
  318. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  319. number1Label.textColor = NSColor(hex: "0E1114")
  320. } else if KMMemberInfo.shared.userScenarioType == .lite_type8 {
  321. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  322. lockedImageView.image = NSImage(named: "UpgradeImage2")
  323. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  324. if KMMemberInfo.shared.vip_levels == "2" {
  325. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  326. } else {
  327. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  328. }
  329. number1ImageView.isHidden = false
  330. number1Label.isHidden = true
  331. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  332. } else if KMMemberInfo.shared.userScenarioType == .lite_type9 ||
  333. KMMemberInfo.shared.userScenarioType == .pro_type1 {
  334. if(KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels != "1") { //永久
  335. lockedLabel.stringValue = NSLocalizedString("Permanent", tableName: "MemberCenterLocalizable", comment: "")
  336. lockedImageView.image = NSImage(named: "UpgradeImage2")
  337. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  338. if KMMemberInfo.shared.vip_levels == "2" {
  339. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  340. } else {
  341. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  342. }
  343. number1ImageView.isHidden = false
  344. number1Label.isHidden = true
  345. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
  346. } else { //免费+订阅过期+试用过期
  347. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  348. lockedImageView.image = NSImage(named: "LockedImage")
  349. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  350. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  351. number1ImageView.isHidden = true
  352. number1Label.isHidden = false
  353. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  354. number1Label.textColor = NSColor(hex: "0E1114")
  355. }
  356. } else if KMMemberInfo.shared.userScenarioType == .lite_type10 {
  357. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  358. lockedImageView.image = NSImage(named: "UpgradeImage2")
  359. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  360. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  361. number1ImageView.isHidden = false
  362. number1Label.isHidden = true
  363. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  364. } else if KMMemberInfo.shared.userScenarioType == .lite_type11 {
  365. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  366. lockedImageView.image = NSImage(named: "LockedImage")
  367. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  368. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  369. number1ImageView.isHidden = true
  370. number1Label.isHidden = false
  371. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  372. number1Label.textColor = NSColor(hex: "0E1114")
  373. } else if KMMemberInfo.shared.userScenarioType == .lite_type12 {
  374. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  375. lockedImageView.image = NSImage(named: "UpgradeImage2")
  376. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  377. if(KMMemberInfo.shared.vip_levels == "2") {
  378. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  379. } else if((KMMemberInfo.shared.vip_levels == "3")) {
  380. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  381. }
  382. number1ImageView.isHidden = false
  383. number1Label.isHidden = true
  384. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  385. } else if KMMemberInfo.shared.userScenarioType == .lite_type13 {
  386. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  387. lockedImageView.image = NSImage(named: "UpgradeImage2")
  388. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  389. if KMMemberInfo.shared.vip_levels == "2" {
  390. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  391. } else {
  392. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  393. }
  394. number1ImageView.isHidden = false
  395. number1Label.isHidden = true
  396. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  397. } else if KMMemberInfo.shared.userScenarioType == .pro_type2 {
  398. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  399. lockedImageView.image = NSImage(named: "UpgradeImage2")
  400. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  401. if KMMemberInfo.shared.vip_levels == "2" {
  402. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  403. } else {
  404. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  405. }
  406. number1ImageView.isHidden = false
  407. number1Label.isHidden = true
  408. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  409. number1Label.textColor = NSColor(named: "FFFFFF")
  410. } else if KMMemberInfo.shared.userScenarioType == .pro_type3 {
  411. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  412. lockedImageView.image = NSImage(named: "LockedImage")
  413. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  414. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  415. number1ImageView.isHidden = true
  416. number1Label.isHidden = false
  417. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  418. number1Label.textColor = NSColor(hex: "0E1114")
  419. } else if KMMemberInfo.shared.userScenarioType == .pro_type4 {
  420. lockedLabel.stringValue = NSLocalizedString("Permanent", tableName: "MemberCenterLocalizable", comment: "")
  421. lockedImageView.image = NSImage(named: "UpgradeImage2")
  422. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  423. if KMMemberInfo.shared.vip_levels == "2" {
  424. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  425. } else {
  426. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  427. }
  428. number1ImageView.isHidden = false
  429. number1Label.isHidden = true
  430. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
  431. } else if KMMemberInfo.shared.userScenarioType == .pro_type5 {
  432. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  433. lockedImageView.image = NSImage(named: "UpgradeImage2")
  434. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  435. if KMMemberInfo.shared.vip_levels == "2" {
  436. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  437. } else {
  438. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  439. }
  440. number1ImageView.isHidden = false
  441. number1Label.isHidden = true
  442. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  443. } else {
  444. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  445. lockedImageView.image = NSImage(named: "LockedImage")
  446. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  447. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  448. number1ImageView.isHidden = true
  449. number1Label.isHidden = false
  450. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  451. number1Label.textColor = NSColor(hex: "0E1114")
  452. }
  453. if lockedLabel.stringValue == NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "") {
  454. lockedLabel.textColor = NSColor(hex: "#42464D")
  455. } else if lockedLabel.stringValue == NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "") {
  456. lockedLabel.textColor = NSColor(hex: "#42464D")
  457. } else if lockedLabel.stringValue == NSLocalizedString("Permanent", tableName: "MemberCenterLocalizable", comment: "") {
  458. lockedLabel.textColor = NSColor(hex: "#273C62")
  459. } else if lockedLabel.stringValue == NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "") {
  460. lockedLabel.textColor = NSColor(hex: "#42464D")
  461. }
  462. }
  463. func addWaitingView(to view: NSView) {
  464. removeWaitingView(from: view)
  465. let waitingView = WaitingView(frame: view.bounds)
  466. waitingView.autoresizingMask = [.width, .height]
  467. view.addSubview(waitingView)
  468. waitingView.startAnimation()
  469. }
  470. func removeWaitingView(from view: NSView) {
  471. for subview in view.subviews {
  472. if subview is WaitingView {
  473. subview.removeFromSuperview()
  474. break
  475. }
  476. }
  477. }
  478. private func initializeUI() -> Void {
  479. refreshEquity()
  480. self.view.wantsLayer = true
  481. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  482. if isDarkModel {
  483. self.view.layer?.backgroundColor = NSColor(hex: "0E1114").cgColor;
  484. } else {
  485. self.view.layer?.backgroundColor = NSColor(hex: "FFFFFF").cgColor;
  486. }
  487. userImageView.image = NSImage(named: "UserProfilePicture_Size")
  488. emailLabel.textColor = NSColor(named: "0E1114")
  489. emailLabel.font = NSFont.SFMediumFontWithSize(14)
  490. productLabel.textColor = NSColor(named: "42464D_1")
  491. productLabel.font = NSFont.SFProTextRegularFont(12)
  492. endDateLabel.textColor = NSColor(named: "42464D_1")
  493. endDateLabel.font = NSFont.SFProTextRegularFont(12)
  494. spliLineImageView.isHidden = true
  495. endDateLabel.isHidden = true
  496. if KMMemberInfo.shared.vip_levels != "1" &&
  497. KMMemberInfo.shared.vip_paymentModel == "1" &&
  498. (KMMemberInfo.shared.vip_status == 1 || KMMemberInfo.shared.vip_status == 3) {
  499. // 订阅中、试用中,显示到期日期
  500. if KMMemberInfo.shared.vip_endDate.count > 0 {
  501. spliLineImageView.isHidden = false
  502. endDateLabel.isHidden = false
  503. }
  504. } else if KMMemberInfo.shared.vip_status == 2 {
  505. // 订阅到期,显示到期日期
  506. if KMMemberInfo.shared.vip_endDate.count > 0 {
  507. spliLineImageView.isHidden = false
  508. endDateLabel.isHidden = false
  509. endDateLabel.textColor = NSColor(named: "FA1E5D")
  510. }
  511. }
  512. membershipLabel.font = NSFont.SFMediumFontWithSize(16)
  513. lockedLabel.font = NSFont.SFMediumFontWithSize(12)
  514. rightsBox.contentView = rightsView
  515. number1Label.font = NSFont.SFMediumFontWithSize(24)
  516. number1ImageView.image = NSImage(named: "UpgradeImage")
  517. number2Label.font = NSFont.SFProTextRegularFont(12)
  518. number3Label.font = NSFont.SFProTextRegularFont(12)
  519. number5Label.font = NSFont.SFProTextRegularFont(12)
  520. buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  521. buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  522. buyNow1Label.textColor = NSColor(named: "FFFFFF")
  523. buyNow1Label.font = NSFont.SFProTextRegularFont(14)
  524. buyNow2Label.textColor = NSColor(named: "FFFFFF")
  525. buyNow2Label.font = NSFont.SFProTextRegularFont(14)
  526. accountCenterBox.borderColor = NSColor(named: "3091FF") ?? .blue
  527. accountCenterBox.fillColor = .clear
  528. accountLabel.textColor = NSColor(named: "3091FF")
  529. accountLabel.font = NSFont.SFProTextRegularFont(14)
  530. accountImageView.image = NSImage(named: "AccountCenterImage")
  531. signOutLabel.textColor = NSColor(named: "3091FF")
  532. signOutLabel.font = NSFont.SFProTextRegularFont(14)
  533. signOutImageView.image = NSImage(named: "SignOutImage")
  534. closeAccountLabel.textColor = NSColor(named: "3091FF")
  535. closeAccountLabel.font = NSFont.SFProTextRegularFont(14)
  536. closeAccountImageView.image = NSImage(named: "CloseAccountImage")
  537. var isNoOldSubscribed = false
  538. var isTrialPeriod = false
  539. #if VERSION_FREE
  540. #if !VERSION_DMG
  541. isNoOldSubscribed = IAPProductsManager.default().allAccessPack6months_lite.isSubscribed == false && IAPProductsManager.default().allAccessPack12months_lite.isSubscribed == false
  542. if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isTrialPeriod == true {
  543. isTrialPeriod = true
  544. }
  545. #endif
  546. #endif
  547. var isShowFreeTraalBtn = false
  548. if KMMemberInfo.shared.userScenarioType == .lite_type1 { //未试用
  549. buyBox.contentView = buyView1
  550. buyNow1ImageView.isHidden = false
  551. buyNow2ImageView.isHidden = false
  552. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  553. arrow2ImageView.image = NSImage(named: "BuyNewArrowImage1")
  554. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  555. buyNow2Label.textColor = NSColor(hex: "FFFFFF")
  556. if isTrialPeriod == true {
  557. buyNow2Box.isHidden = true
  558. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  559. } else {
  560. isShowFreeTraalBtn = true
  561. }
  562. } else if KMMemberInfo.shared.userScenarioType == .pro_type3 {
  563. buyBox.contentView = buyView1
  564. buyNow1ImageView.isHidden = false
  565. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  566. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  567. buyNow2Box.isHidden = true
  568. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  569. } else if KMMemberInfo.shared.userScenarioType == .lite_type9 ||
  570. KMMemberInfo.shared.userScenarioType == .pro_type1 {
  571. buyBox.contentView = buyView1
  572. buyNow2Box.isHidden = true
  573. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  574. if((KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels != "1")) { //永久
  575. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
  576. buyNow1Label.textColor = NSColor(hex: "42464D")
  577. } else {
  578. buyNow1ImageView.isHidden = false
  579. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  580. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  581. }
  582. } else if KMMemberInfo.shared.userScenarioType == .lite_type11 { //试用过期
  583. if(!isNoOldSubscribed) {
  584. buyBox.contentView = buyView1
  585. buyNow1ImageView.isHidden = false
  586. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  587. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  588. buyNow2Box.isHidden = true
  589. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  590. }
  591. } else if KMMemberInfo.shared.userScenarioType == .lite_type2 ||
  592. KMMemberInfo.shared.userScenarioType == .lite_type4 ||
  593. KMMemberInfo.shared.userScenarioType == .lite_type6 ||
  594. KMMemberInfo.shared.userScenarioType == .lite_type8 ||
  595. KMMemberInfo.shared.userScenarioType == .lite_type10 ||
  596. KMMemberInfo.shared.userScenarioType == .lite_type12 ||
  597. KMMemberInfo.shared.userScenarioType == .lite_type13 ||
  598. KMMemberInfo.shared.userScenarioType == .pro_type2 ||
  599. KMMemberInfo.shared.userScenarioType == .pro_type5 { //有订阅+试用中
  600. } else if KMMemberInfo.shared.userScenarioType == .lite_type7 ||
  601. KMMemberInfo.shared.userScenarioType == .lite_type3 { //试用过期+会员到期
  602. buyBox.contentView = buyView1
  603. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  604. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  605. buyNow2Box.isHidden = true
  606. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  607. } else {
  608. buyBox.contentView = buyView1
  609. buyNow2Box.isHidden = true
  610. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  611. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
  612. buyNow1Label.textColor = NSColor(hex: "42464D")
  613. }
  614. if KMMemberInfo.shared.userScenarioType == .lite_type2 ||
  615. KMMemberInfo.shared.userScenarioType == .lite_type4 ||
  616. KMMemberInfo.shared.userScenarioType == .lite_type5 ||
  617. KMMemberInfo.shared.userScenarioType == .lite_type6 ||
  618. KMMemberInfo.shared.userScenarioType == .lite_type8 ||
  619. KMMemberInfo.shared.userScenarioType == .lite_type10 ||
  620. KMMemberInfo.shared.userScenarioType == .lite_type12 ||
  621. KMMemberInfo.shared.userScenarioType == .lite_type13 ||
  622. KMMemberInfo.shared.userScenarioType == .pro_type2 ||
  623. KMMemberInfo.shared.userScenarioType == .pro_type4 ||
  624. KMMemberInfo.shared.userScenarioType == .pro_type5 { //订阅或者买断
  625. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  626. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  627. buyNow1ImageView.isHidden = true
  628. buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
  629. number2Label.textColor = NSColor(hex: "FFFFFF")
  630. number3Label.textColor = NSColor(hex: "FFFFFF")
  631. number4Label.textColor = NSColor(hex: "FFFFFF")
  632. number4_1Label.textColor = NSColor(hex: "FFFFFF")
  633. number5Label.textColor = NSColor(hex: "FFFFFF")
  634. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  635. } else if(KMMemberInfo.shared.userScenarioType == .lite_type9 ||
  636. KMMemberInfo.shared.userScenarioType == .pro_type1) {
  637. if(KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels != "1") { //永久
  638. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  639. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  640. buyNow1ImageView.isHidden = true
  641. buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
  642. number2Label.textColor = NSColor(hex: "FFFFFF")
  643. number3Label.textColor = NSColor(hex: "FFFFFF")
  644. number4Label.textColor = NSColor(hex: "FFFFFF")
  645. number4_1Label.textColor = NSColor(hex: "FFFFFF")
  646. number5Label.textColor = NSColor(hex: "FFFFFF")
  647. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  648. } else {
  649. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  650. membershipLabel.textColor = NSColor(hex: "42464D")
  651. buyNow1ImageView.isHidden = false
  652. buyNow1Box.fillColor = NSColor.clear
  653. number2Label.textColor = NSColor(hex:"42464D")
  654. number3Label.textColor = NSColor(hex:"42464D")
  655. number4Label.textColor = NSColor(hex: "42464D")
  656. number4_1Label.textColor = NSColor(hex: "42464D")
  657. number5Label.textColor = NSColor(hex: "42464D")
  658. membershipLabel.textColor = NSColor(hex: "42464D")
  659. }
  660. } else {
  661. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  662. membershipLabel.textColor = NSColor(hex: "42464D")
  663. buyNow1ImageView.isHidden = false
  664. buyNow1Box.fillColor = NSColor.clear
  665. number2Label.textColor = NSColor(hex:"42464D")
  666. number3Label.textColor = NSColor(hex:"42464D")
  667. number4Label.textColor = NSColor(hex: "42464D")
  668. number4_1Label.textColor = NSColor(hex: "42464D")
  669. number5Label.textColor = NSColor(hex: "42464D")
  670. membershipLabel.textColor = NSColor(hex: "42464D")
  671. }
  672. lockedLabel.textColor = NSColor(hex: "42464D")
  673. let platforms = viewModel.getPlatformsImages()
  674. if platforms.count == 4 {
  675. iconBox.contentView = iconView1
  676. icon1ImageView.image = platforms[0]
  677. icon2ImageView.image = platforms[1]
  678. icon3ImageView.image = platforms[2]
  679. icon4ImageView.image = platforms[3]
  680. } else if platforms.count == 3 {
  681. iconBox.contentView = iconView2
  682. icon5ImageView.image = platforms[0]
  683. icon6ImageView.image = platforms[1]
  684. icon7ImageView.image = platforms[2]
  685. } else if platforms.count == 2 {
  686. iconBox.contentView = iconView3
  687. icon8ImageView.image = platforms[0]
  688. icon9ImageView.image = platforms[1]
  689. } else if platforms.count == 1 {
  690. iconBox.contentView = iconView4
  691. icon10ImageView.image = platforms[0]
  692. }
  693. buyNow1Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  694. guard let self = self else { return }
  695. if KMMemberInfo.shared.userScenarioType == .lite_type2 ||
  696. KMMemberInfo.shared.userScenarioType == .lite_type4 ||
  697. KMMemberInfo.shared.userScenarioType == .lite_type5 ||
  698. KMMemberInfo.shared.userScenarioType == .lite_type6 ||
  699. KMMemberInfo.shared.userScenarioType == .lite_type8 ||
  700. KMMemberInfo.shared.userScenarioType == .lite_type10 ||
  701. KMMemberInfo.shared.userScenarioType == .lite_type12 ||
  702. KMMemberInfo.shared.userScenarioType == .lite_type13 ||
  703. KMMemberInfo.shared.userScenarioType == .pro_type2 ||
  704. KMMemberInfo.shared.userScenarioType == .pro_type4 ||
  705. KMMemberInfo.shared.userScenarioType == .pro_type5 { //订阅或者买断
  706. if mouseEntered {
  707. self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2Hover")
  708. self.buyNow1Label.textColor = NSColor(hex: "4982E6")
  709. } else {
  710. self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
  711. self.buyNow1Label.textColor = NSColor(hex: "0E1114")
  712. }
  713. } else {
  714. if mouseEntered {
  715. self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
  716. } else {
  717. self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  718. }
  719. }
  720. }
  721. buyNow1Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  722. guard let self = self else { return }
  723. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  724. // 免费版,免费账号跳转购买比较表
  725. self.viewModel.skipCompare(.lite_Base)
  726. } else {
  727. // 其它情况根据账号状态跳转不同比较表
  728. NotificationCenter.default.post(name: NSNotification.Name("CloseMenuNotification"), object: nil)
  729. KMMemberInfo.shared.productCompareShow()
  730. }
  731. }
  732. buyNow2Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  733. guard let self = self else { return }
  734. if mouseEntered {
  735. self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
  736. } else {
  737. self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  738. }
  739. }
  740. buyNow2Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  741. guard let self = self else { return }
  742. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  743. // 免费版,免费账号跳转试用比较表
  744. self.viewModel.skipCompare(.trial)
  745. }
  746. }
  747. accountCenterBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  748. guard let self = self else { return }
  749. if mouseEntered {
  750. self.accountCenterBox.fillColor = NSColor(named: "F5FAFF") ?? .white
  751. self.accountLabel.textColor = NSColor(named: "3091FF")
  752. self.accountImageView.image = NSImage(named: "AccountCenterImage_Hov")
  753. } else {
  754. self.accountCenterBox.fillColor = .clear
  755. self.accountLabel.textColor = NSColor(named: "3091FF")
  756. self.accountImageView.image = NSImage(named: "AccountCenterImage")
  757. }
  758. }
  759. accountCenterBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  760. guard let self = self else { return }
  761. self.viewModel.skipAccountCenter()
  762. }
  763. signOutBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  764. guard let self = self else { return }
  765. if mouseEntered {
  766. self.signOutLabel.textColor = NSColor(named: "3091FF")
  767. self.signOutImageView.image = NSImage(named: "SignOutImage_Hov")
  768. } else {
  769. self.signOutLabel.textColor = NSColor(named: "3091FF")
  770. self.signOutImageView.image = NSImage(named: "SignOutImage")
  771. }
  772. }
  773. signOutBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  774. guard let self = self else { return }
  775. self.viewModel.signOutAction()
  776. }
  777. closeAccountBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  778. guard let self = self else { return }
  779. if mouseEntered {
  780. self.closeAccountLabel.textColor = NSColor(named: "3091FF")
  781. self.closeAccountImageView.image = NSImage(named: "CloseAccountImage_hover")
  782. } else {
  783. self.closeAccountLabel.textColor = NSColor(named: "3091FF")
  784. self.closeAccountImageView.image = NSImage(named: "CloseAccountImage")
  785. }
  786. }
  787. closeAccountBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  788. guard let self = self else { return }
  789. self.viewModel.closeAccountAction()
  790. }
  791. if isShowFreeTraalBtn == true { //没有试用过,才能显示,不然就算远程支持,功能上也不支持远程控制
  792. //远程控制
  793. if let userViewInfoContent = KMAdvertisementManager.manager.info.userViewInfoContent {
  794. if userViewInfoContent.content?.isEmpty == false {
  795. buyNow2Box.isHidden = true
  796. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  797. }
  798. }
  799. }
  800. }
  801. // MARK: Action Method
  802. private func languageLocalized_DMG() -> Void {
  803. emailLabel.stringValue = KMMemberInfo.shared.userEmail
  804. productLabel.stringValue = NSLocalizedString("Personal Account", tableName: "MemberCenterLocalizable", comment: "")
  805. endDateLabel.stringValue = String(format: "%@ %@", KMMemberInfo.shared.vip_endDate,NSLocalizedString("expires", tableName: "MemberCenterLocalizable", comment: ""))
  806. membershipLabel.stringValue = NSLocalizedString("Membership Benefits", tableName: "MemberCenterLocalizable", comment: "")
  807. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  808. accountLabel.stringValue = NSLocalizedString("Account Center", tableName: "MemberCenterLocalizable", comment: "")
  809. signOutLabel.stringValue = NSLocalizedString("Sign out", tableName: "MemberCenterLocalizable", comment: "")
  810. if KMMemberInfo.shared.validFlag == "5" {
  811. closeAccountLabel.stringValue = NSLocalizedString("Undo Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  812. } else {
  813. closeAccountLabel.stringValue = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  814. }
  815. if KMMemberInfo.shared.vip_maxDeviceNum == 1 {
  816. number4Label.stringValue = NSLocalizedString("device", tableName: "MemberCenterLocalizable", comment: "")
  817. } else {
  818. number4Label.stringValue = NSLocalizedString("devices", tableName: "MemberCenterLocalizable", comment: "")
  819. }
  820. number4_1Label.stringValue = String(KMMemberInfo.shared.vip_maxDeviceNum)
  821. number5Label.stringValue = NSLocalizedString("Devices Access", tableName: "MemberCenterLocalizable", comment: "")
  822. let platforms = viewModel.getPlatformsImages()
  823. if platforms.count == 4 {
  824. number3Label.stringValue = NSLocalizedString("All-platform Available", tableName: "MemberCenterLocalizable", comment: "")
  825. } else {
  826. number3Label.stringValue = NSLocalizedString("Platform", tableName: "MemberCenterLocalizable", comment: "")
  827. }
  828. if KMMemberInfo.shared.userScenarioType == .dmg_type5 ||
  829. KMMemberInfo.shared.userScenarioType == .dmg_type6 ||
  830. KMMemberInfo.shared.userScenarioType == .dmg_type7 ||
  831. KMMemberInfo.shared.userScenarioType == .dmg_type28 ||
  832. KMMemberInfo.shared.userScenarioType == .dmg_type29 ||
  833. KMMemberInfo.shared.userScenarioType == .dmg_type30 ||
  834. KMMemberInfo.shared.userScenarioType == .dmg_type43 ||
  835. KMMemberInfo.shared.userScenarioType == .dmg_type44 ||
  836. KMMemberInfo.shared.userScenarioType == .dmg_type45 { // 买断
  837. lockedLabel.stringValue = NSLocalizedString("Permanent", tableName: "MemberCenterLocalizable", comment: "")
  838. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  839. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  840. } else if KMMemberInfo.shared.userScenarioType == .dmg_type8 ||
  841. KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
  842. KMMemberInfo.shared.userScenarioType == .dmg_type10 ||
  843. KMMemberInfo.shared.userScenarioType == .dmg_type12 ||
  844. KMMemberInfo.shared.userScenarioType == .dmg_type13 ||
  845. KMMemberInfo.shared.userScenarioType == .dmg_type14 ||
  846. KMMemberInfo.shared.userScenarioType == .dmg_type15 ||
  847. KMMemberInfo.shared.userScenarioType == .dmg_type16 ||
  848. KMMemberInfo.shared.userScenarioType == .dmg_type17 ||
  849. KMMemberInfo.shared.userScenarioType == .dmg_type20 ||
  850. KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
  851. KMMemberInfo.shared.userScenarioType == .dmg_type23 ||
  852. KMMemberInfo.shared.userScenarioType == .dmg_type24 ||
  853. KMMemberInfo.shared.userScenarioType == .dmg_type25 ||
  854. KMMemberInfo.shared.userScenarioType == .dmg_type26 ||
  855. KMMemberInfo.shared.userScenarioType == .dmg_type27 ||
  856. KMMemberInfo.shared.userScenarioType == .dmg_type31 ||
  857. KMMemberInfo.shared.userScenarioType == .dmg_type32 ||
  858. KMMemberInfo.shared.userScenarioType == .dmg_type35 ||
  859. KMMemberInfo.shared.userScenarioType == .dmg_type36 ||
  860. KMMemberInfo.shared.userScenarioType == .dmg_type38 ||
  861. KMMemberInfo.shared.userScenarioType == .dmg_type39 ||
  862. KMMemberInfo.shared.userScenarioType == .dmg_type40 ||
  863. KMMemberInfo.shared.userScenarioType == .dmg_type41 ||
  864. KMMemberInfo.shared.userScenarioType == .dmg_type42 ||
  865. KMMemberInfo.shared.userScenarioType == .dmg_type46 ||
  866. KMMemberInfo.shared.userScenarioType == .dmg_type47 { // 订阅
  867. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  868. if KMMemberInfo.shared.userScenarioType == .dmg_type8 ||
  869. KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
  870. KMMemberInfo.shared.userScenarioType == .dmg_type20 ||
  871. KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
  872. KMMemberInfo.shared.userScenarioType == .dmg_type35 ||
  873. KMMemberInfo.shared.userScenarioType == .dmg_type36 {
  874. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  875. } else {
  876. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  877. }
  878. } else { // 免费 & 到期
  879. if KMMemberInfo.shared.userScenarioType == .dmg_type4 ||
  880. KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
  881. KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
  882. KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
  883. KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
  884. KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
  885. KMMemberInfo.shared.userScenarioType == .dmg_type34 ||
  886. KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
  887. KMMemberInfo.shared.userScenarioType == .dmg_type48 {
  888. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  889. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  890. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  891. if KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
  892. KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
  893. KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
  894. KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
  895. KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
  896. KMMemberInfo.shared.userScenarioType == .dmg_type48 { // 到期
  897. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  898. } else { // 免费
  899. }
  900. if KMMemberInfo.shared.userScenarioType == .dmg_type4 ||
  901. KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
  902. KMMemberInfo.shared.userScenarioType == .dmg_type34 {
  903. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  904. buyNow2Label.stringValue = NSLocalizedString("7-Day Free Trial", tableName: "MemberCenterLocalizable", comment: "")
  905. } else if KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
  906. KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
  907. KMMemberInfo.shared.userScenarioType == .dmg_type37 {
  908. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  909. } else if KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
  910. KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
  911. KMMemberInfo.shared.userScenarioType == .dmg_type48 {
  912. buyNow1Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
  913. }
  914. }
  915. }
  916. }
  917. private func initializeUI_DMG() -> Void {
  918. self.view.wantsLayer = true
  919. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  920. if isDarkModel {
  921. self.view.layer?.backgroundColor = NSColor(hex: "0E1114").cgColor;
  922. } else {
  923. self.view.layer?.backgroundColor = NSColor(hex: "FFFFFF").cgColor;
  924. }
  925. rightsBox.contentView = rightsView
  926. buyBox.contentView = buyView1
  927. userImageView.image = NSImage(named: "UserProfilePicture_Size")
  928. emailLabel.textColor = NSColor(named: "0E1114")
  929. emailLabel.font = NSFont.SFMediumFontWithSize(14)
  930. productLabel.textColor = NSColor(named: "42464D_1")
  931. productLabel.font = NSFont.SFProTextRegularFont(12)
  932. endDateLabel.textColor = NSColor(named: "42464D_1")
  933. endDateLabel.font = NSFont.SFProTextRegularFont(12)
  934. spliLineImageView.isHidden = true
  935. endDateLabel.isHidden = true
  936. number1Label.font = NSFont.SFMediumFontWithSize(24)
  937. number1Label.textColor = NSColor(hex: "0E1114")
  938. number2Label.font = NSFont.SFProTextRegularFont(12)
  939. number3Label.font = NSFont.SFProTextRegularFont(12)
  940. number5Label.font = NSFont.SFProTextRegularFont(12)
  941. membershipLabel.font = NSFont.SFMediumFontWithSize(16)
  942. lockedLabel.font = NSFont.SFMediumFontWithSize(12)
  943. lockedLabel.textColor = NSColor(hex: "42464D")
  944. accountCenterBox.borderColor = NSColor(named: "3091FF") ?? .blue
  945. accountCenterBox.fillColor = .clear
  946. accountLabel.textColor = NSColor(named: "3091FF")
  947. accountLabel.font = NSFont.SFProTextRegularFont(14)
  948. accountImageView.image = NSImage(named: "AccountCenterImage")
  949. signOutLabel.textColor = NSColor(named: "3091FF")
  950. signOutLabel.font = NSFont.SFProTextRegularFont(14)
  951. signOutImageView.image = NSImage(named: "SignOutImage")
  952. closeAccountLabel.textColor = NSColor(named: "3091FF")
  953. closeAccountLabel.font = NSFont.SFProTextRegularFont(14)
  954. closeAccountImageView.image = NSImage(named: "CloseAccountImage")
  955. buyNow1Label.font = NSFont.SFProTextRegularFont(14)
  956. buyNow2Label.font = NSFont.SFProTextRegularFont(14)
  957. let platforms = viewModel.getPlatformsImages()
  958. if platforms.count == 4 {
  959. iconBox.contentView = iconView1
  960. icon1ImageView.image = platforms[0]
  961. icon2ImageView.image = platforms[1]
  962. icon3ImageView.image = platforms[2]
  963. icon4ImageView.image = platforms[3]
  964. } else if platforms.count == 3 {
  965. iconBox.contentView = iconView2
  966. icon5ImageView.image = platforms[0]
  967. icon6ImageView.image = platforms[1]
  968. icon7ImageView.image = platforms[2]
  969. } else if platforms.count == 2 {
  970. iconBox.contentView = iconView3
  971. icon8ImageView.image = platforms[0]
  972. icon9ImageView.image = platforms[1]
  973. } else if platforms.count == 1 {
  974. iconBox.contentView = iconView4
  975. icon10ImageView.image = platforms[0]
  976. }
  977. buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  978. buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  979. if KMMemberInfo.shared.userScenarioType == .dmg_type5 ||
  980. KMMemberInfo.shared.userScenarioType == .dmg_type6 ||
  981. KMMemberInfo.shared.userScenarioType == .dmg_type7 ||
  982. KMMemberInfo.shared.userScenarioType == .dmg_type28 ||
  983. KMMemberInfo.shared.userScenarioType == .dmg_type29 ||
  984. KMMemberInfo.shared.userScenarioType == .dmg_type30 ||
  985. KMMemberInfo.shared.userScenarioType == .dmg_type43 ||
  986. KMMemberInfo.shared.userScenarioType == .dmg_type44 ||
  987. KMMemberInfo.shared.userScenarioType == .dmg_type45 { // 买断
  988. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
  989. lockedImageView.image = NSImage(named: "UpgradeImage2")
  990. number1ImageView.isHidden = false
  991. number1ImageView.image = NSImage(named: "UpgradeImage")
  992. number1Label.isHidden = true
  993. number2Label.textColor = NSColor(hex: "FFFFFF")
  994. number3Label.textColor = NSColor(hex: "FFFFFF")
  995. number4Label.textColor = NSColor(hex: "FFFFFF")
  996. number4_1Label.textColor = NSColor(hex: "FFFFFF")
  997. number5Label.textColor = NSColor(hex: "FFFFFF")
  998. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  999. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  1000. buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
  1001. buyNow1ImageView.isHidden = true
  1002. buyNow2Box.isHidden = true
  1003. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  1004. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
  1005. buyNow1Label.textColor = NSColor(hex: "42464D")
  1006. } else if KMMemberInfo.shared.userScenarioType == .dmg_type8 ||
  1007. KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
  1008. KMMemberInfo.shared.userScenarioType == .dmg_type10 ||
  1009. KMMemberInfo.shared.userScenarioType == .dmg_type12 ||
  1010. KMMemberInfo.shared.userScenarioType == .dmg_type13 ||
  1011. KMMemberInfo.shared.userScenarioType == .dmg_type14 ||
  1012. KMMemberInfo.shared.userScenarioType == .dmg_type15 ||
  1013. KMMemberInfo.shared.userScenarioType == .dmg_type16 ||
  1014. KMMemberInfo.shared.userScenarioType == .dmg_type17 ||
  1015. KMMemberInfo.shared.userScenarioType == .dmg_type20 ||
  1016. KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
  1017. KMMemberInfo.shared.userScenarioType == .dmg_type23 ||
  1018. KMMemberInfo.shared.userScenarioType == .dmg_type24 ||
  1019. KMMemberInfo.shared.userScenarioType == .dmg_type25 ||
  1020. KMMemberInfo.shared.userScenarioType == .dmg_type26 ||
  1021. KMMemberInfo.shared.userScenarioType == .dmg_type27 ||
  1022. KMMemberInfo.shared.userScenarioType == .dmg_type31 ||
  1023. KMMemberInfo.shared.userScenarioType == .dmg_type32 ||
  1024. KMMemberInfo.shared.userScenarioType == .dmg_type35 ||
  1025. KMMemberInfo.shared.userScenarioType == .dmg_type36 ||
  1026. KMMemberInfo.shared.userScenarioType == .dmg_type38 ||
  1027. KMMemberInfo.shared.userScenarioType == .dmg_type39 ||
  1028. KMMemberInfo.shared.userScenarioType == .dmg_type40 ||
  1029. KMMemberInfo.shared.userScenarioType == .dmg_type41 ||
  1030. KMMemberInfo.shared.userScenarioType == .dmg_type42 ||
  1031. KMMemberInfo.shared.userScenarioType == .dmg_type46 ||
  1032. KMMemberInfo.shared.userScenarioType == .dmg_type47 { // 订阅
  1033. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  1034. lockedImageView.image = NSImage(named: "UpgradeImage2")
  1035. number1ImageView.isHidden = false
  1036. number1ImageView.image = NSImage(named: "UpgradeImage")
  1037. number1Label.isHidden = true
  1038. number2Label.textColor = NSColor(hex: "FFFFFF")
  1039. number3Label.textColor = NSColor(hex: "FFFFFF")
  1040. number4Label.textColor = NSColor(hex: "FFFFFF")
  1041. number4_1Label.textColor = NSColor(hex: "FFFFFF")
  1042. number5Label.textColor = NSColor(hex: "FFFFFF")
  1043. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  1044. if KMMemberInfo.shared.vip_endDate.count > 0 {
  1045. spliLineImageView.isHidden = false
  1046. endDateLabel.isHidden = false
  1047. }
  1048. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  1049. buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
  1050. buyNow1ImageView.isHidden = true
  1051. buyNow2ImageView.isHidden = true
  1052. buyNow2Label.isHidden = true
  1053. buyNow1Box.isHidden = true
  1054. buyNow2Box.isHidden = true
  1055. } else { // 免费 & 到期
  1056. if KMMemberInfo.shared.userScenarioType == .dmg_type4 ||
  1057. KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
  1058. KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
  1059. KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
  1060. KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
  1061. KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
  1062. KMMemberInfo.shared.userScenarioType == .dmg_type34 ||
  1063. KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
  1064. KMMemberInfo.shared.userScenarioType == .dmg_type48 {
  1065. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  1066. lockedImageView.image = NSImage(named: "LockedImage")
  1067. number1ImageView.isHidden = true
  1068. number1Label.isHidden = false
  1069. number2Label.textColor = NSColor(hex:"42464D")
  1070. number3Label.textColor = NSColor(hex:"42464D")
  1071. number4Label.textColor = NSColor(hex: "42464D")
  1072. number4_1Label.textColor = NSColor(hex: "42464D")
  1073. number5Label.textColor = NSColor(hex: "42464D")
  1074. membershipLabel.textColor = NSColor(hex: "42464D")
  1075. rightsBox.fillColor = NSColor(named: "7094F6_0.1") ?? .white
  1076. buyNow1Box.fillColor = NSColor.clear
  1077. buyNow2Box.fillColor = NSColor.clear
  1078. buyNow1ImageView.isHidden = false
  1079. buyNow2ImageView.isHidden = false
  1080. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  1081. arrow2ImageView.image = NSImage(named: "BuyNewArrowImage1")
  1082. buyNow1Label.textColor = NSColor(named: "FFFFFF")
  1083. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  1084. buyNow2Label.textColor = NSColor(hex: "FFFFFF")
  1085. if KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
  1086. KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
  1087. KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
  1088. KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
  1089. KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
  1090. KMMemberInfo.shared.userScenarioType == .dmg_type48 { // 到期
  1091. if KMMemberInfo.shared.vip_endDate.count > 0 &&
  1092. KMMemberInfo.shared.vip_status == 2 {
  1093. spliLineImageView.isHidden = false
  1094. endDateLabel.isHidden = false
  1095. endDateLabel.textColor = NSColor(named: "FA1E5D")
  1096. }
  1097. buyNow2Box.isHidden = true
  1098. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  1099. } else { // 免费
  1100. if KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
  1101. KMMemberInfo.shared.userScenarioType == .dmg_type34 {
  1102. buyNow2Box.isHidden = true
  1103. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  1104. }
  1105. }
  1106. }
  1107. }
  1108. buyNow1Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  1109. guard let self = self else { return }
  1110. if KMMemberInfo.shared.userScenarioType == .dmg_type5 ||
  1111. KMMemberInfo.shared.userScenarioType == .dmg_type6 ||
  1112. KMMemberInfo.shared.userScenarioType == .dmg_type7 ||
  1113. KMMemberInfo.shared.userScenarioType == .dmg_type28 ||
  1114. KMMemberInfo.shared.userScenarioType == .dmg_type29 ||
  1115. KMMemberInfo.shared.userScenarioType == .dmg_type30 ||
  1116. KMMemberInfo.shared.userScenarioType == .dmg_type43 ||
  1117. KMMemberInfo.shared.userScenarioType == .dmg_type44 ||
  1118. KMMemberInfo.shared.userScenarioType == .dmg_type45 { // 买断
  1119. if mouseEntered {
  1120. self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2Hover")
  1121. self.buyNow1Label.textColor = NSColor(hex: "4982E6")
  1122. } else {
  1123. self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
  1124. self.buyNow1Label.textColor = NSColor(hex: "0E1114")
  1125. }
  1126. } else if KMMemberInfo.shared.userScenarioType == .dmg_type8 ||
  1127. KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
  1128. KMMemberInfo.shared.userScenarioType == .dmg_type10 ||
  1129. KMMemberInfo.shared.userScenarioType == .dmg_type12 ||
  1130. KMMemberInfo.shared.userScenarioType == .dmg_type13 ||
  1131. KMMemberInfo.shared.userScenarioType == .dmg_type14 ||
  1132. KMMemberInfo.shared.userScenarioType == .dmg_type15 ||
  1133. KMMemberInfo.shared.userScenarioType == .dmg_type16 ||
  1134. KMMemberInfo.shared.userScenarioType == .dmg_type17 ||
  1135. KMMemberInfo.shared.userScenarioType == .dmg_type20 ||
  1136. KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
  1137. KMMemberInfo.shared.userScenarioType == .dmg_type23 ||
  1138. KMMemberInfo.shared.userScenarioType == .dmg_type24 ||
  1139. KMMemberInfo.shared.userScenarioType == .dmg_type25 ||
  1140. KMMemberInfo.shared.userScenarioType == .dmg_type26 ||
  1141. KMMemberInfo.shared.userScenarioType == .dmg_type27 ||
  1142. KMMemberInfo.shared.userScenarioType == .dmg_type31 ||
  1143. KMMemberInfo.shared.userScenarioType == .dmg_type32 ||
  1144. KMMemberInfo.shared.userScenarioType == .dmg_type35 ||
  1145. KMMemberInfo.shared.userScenarioType == .dmg_type36 ||
  1146. KMMemberInfo.shared.userScenarioType == .dmg_type38 ||
  1147. KMMemberInfo.shared.userScenarioType == .dmg_type39 ||
  1148. KMMemberInfo.shared.userScenarioType == .dmg_type40 ||
  1149. KMMemberInfo.shared.userScenarioType == .dmg_type41 ||
  1150. KMMemberInfo.shared.userScenarioType == .dmg_type42 ||
  1151. KMMemberInfo.shared.userScenarioType == .dmg_type46 ||
  1152. KMMemberInfo.shared.userScenarioType == .dmg_type47 { // 订阅
  1153. if mouseEntered {
  1154. self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2Hover")
  1155. self.buyNow1Label.textColor = NSColor(hex: "4982E6")
  1156. } else {
  1157. self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
  1158. self.buyNow1Label.textColor = NSColor(hex: "0E1114")
  1159. }
  1160. } else {
  1161. if mouseEntered {
  1162. self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
  1163. } else {
  1164. self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  1165. }
  1166. }
  1167. }
  1168. buyNow1Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  1169. guard let self = self else { return }
  1170. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  1171. // 免费版,免费账号跳转购买比较表
  1172. self.viewModel.skipCompare(.lite_Base)
  1173. } else {
  1174. // 其它情况根据账号状态跳转不同比较表
  1175. NotificationCenter.default.post(name: NSNotification.Name("CloseMenuNotification"), object: nil)
  1176. #if VERSION_DMG
  1177. let member = KMMemberInfo.shared
  1178. let man = KMNewUserGiftManager.default
  1179. let type = member.userScenarioType
  1180. if man.needShow() && member.isFreeAccount {
  1181. let winC = KMProductCompareWC.shared
  1182. winC.orientation = true
  1183. winC.orientationType = .dmg_Base
  1184. winC.openWindow(discountType: .newUserGift)
  1185. } else if (member.isMemberAllFunction == false || type == .dmg_type13) && KMCheckInManager.default.trailCancel {
  1186. let winC = KMProductCompareWC.shared
  1187. winC.orientation = true
  1188. winC.orientationType = .dmg_Base
  1189. winC.openWindow(discountType: .advancedYearSubscribeTrialingCancel)
  1190. } else {
  1191. KMMemberInfo.shared.productCompareShow()
  1192. }
  1193. #else
  1194. KMMemberInfo.shared.productCompareShow()
  1195. #endif
  1196. }
  1197. }
  1198. buyNow2Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  1199. guard let self = self else { return }
  1200. if mouseEntered {
  1201. self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
  1202. } else {
  1203. self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  1204. }
  1205. }
  1206. buyNow2Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  1207. guard let self = self else { return }
  1208. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  1209. self.viewModel.skipCompare(.trial)
  1210. } else if KMMemberInfo.shared.userScenarioType == .dmg_type4 ||
  1211. KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
  1212. KMMemberInfo.shared.userScenarioType == .dmg_type34 {
  1213. self.viewModel.skipCompare(.trial)
  1214. }
  1215. }
  1216. accountCenterBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  1217. guard let self = self else { return }
  1218. if mouseEntered {
  1219. self.accountCenterBox.fillColor = NSColor(named: "F5FAFF") ?? .white
  1220. self.accountLabel.textColor = NSColor(named: "3091FF")
  1221. self.accountImageView.image = NSImage(named: "AccountCenterImage_Hov")
  1222. } else {
  1223. self.accountCenterBox.fillColor = .clear
  1224. self.accountLabel.textColor = NSColor(named: "3091FF")
  1225. self.accountImageView.image = NSImage(named: "AccountCenterImage")
  1226. }
  1227. }
  1228. accountCenterBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  1229. guard let self = self else { return }
  1230. self.viewModel.skipAccountCenter()
  1231. }
  1232. signOutBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  1233. guard let self = self else { return }
  1234. if mouseEntered {
  1235. self.signOutLabel.textColor = NSColor(named: "3091FF")
  1236. self.signOutImageView.image = NSImage(named: "SignOutImage_Hov")
  1237. } else {
  1238. self.signOutLabel.textColor = NSColor(named: "3091FF")
  1239. self.signOutImageView.image = NSImage(named: "SignOutImage")
  1240. }
  1241. }
  1242. signOutBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  1243. guard let self = self else { return }
  1244. self.viewModel.signOutAction()
  1245. }
  1246. closeAccountBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  1247. guard let self = self else { return }
  1248. if mouseEntered {
  1249. self.closeAccountLabel.textColor = NSColor(named: "3091FF")
  1250. self.closeAccountImageView.image = NSImage(named: "CloseAccountImage_hover")
  1251. } else {
  1252. self.closeAccountLabel.textColor = NSColor(named: "3091FF")
  1253. self.closeAccountImageView.image = NSImage(named: "CloseAccountImage")
  1254. }
  1255. }
  1256. closeAccountBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  1257. guard let self = self else { return }
  1258. self.viewModel.closeAccountAction()
  1259. }
  1260. //远程控制
  1261. if let userViewInfoContent = KMAdvertisementManager.manager.info.userViewInfoContent {
  1262. buyNow1BoxLeftConst.constant = 0
  1263. buyNow2Box.isHidden = false
  1264. if userViewInfoContent.content?.isEmpty == false {
  1265. buyNow2Box.isHidden = true
  1266. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  1267. }
  1268. }
  1269. }
  1270. }