KMUserInfoViewController.swift 67 KB

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