KMUserInfoViewController.swift 73 KB

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