KMUserInfoViewController.swift 75 KB

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