KMUserInfoViewController.swift 74 KB

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