KMUserInfoViewController.swift 68 KB

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