KMUserInfoViewController.swift 69 KB

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