KMUserInfoViewController.swift 75 KB

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