UIVipCtr.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. local UIVipCtr = class("UIVipCtr", require("UICtrBase"))
  2. function UIVipCtr:Init(view)
  3. self.view = view
  4. end
  5. function UIVipCtr:SetData(data)
  6. self.asyncIdx = 0
  7. self.data = data
  8. self:InitData()
  9. end
  10. function UIVipCtr:GetAsyncIdx()
  11. self.asyncIdx = self.asyncIdx + 1
  12. return self.asyncIdx
  13. end
  14. function UIVipCtr:GetData()
  15. return self.data
  16. end
  17. function UIVipCtr:OnDispose()
  18. self.data = nil
  19. self.view = nil
  20. self.curShowVipLv = nil
  21. self.showCustomerVipLv = nil
  22. self.lockedVipLv = nil
  23. end
  24. function UIVipCtr:InitData()
  25. local curVipLv = self:GetCurVipLv()
  26. if self.data then
  27. self.curShowVipLv = self.data
  28. else
  29. if curVipLv <= 0 then
  30. self.curShowVipLv = 1
  31. else
  32. self.curShowVipLv = curVipLv
  33. end
  34. end
  35. self.showCustomerVipLv = GlobalConfig.Instance:GetConfigIntValue(319)
  36. end
  37. function UIVipCtr:GetCurVipLv()
  38. return ManagerContainer.DataMgr.UserData:GetVipLv()
  39. end
  40. function UIVipCtr:GetCurVipExp()
  41. return ManagerContainer.DataMgr.UserData:GetVipExp()
  42. end
  43. function UIVipCtr:GetCurShowVipLv()
  44. return self.curShowVipLv
  45. end
  46. function UIVipCtr:ChangeCurShowVipLv(next)
  47. if next then
  48. if self:HasNext() then
  49. self.curShowVipLv = self.curShowVipLv + 1
  50. return true
  51. end
  52. else
  53. if self:HasPrev() then
  54. self.curShowVipLv = self.curShowVipLv - 1
  55. return true
  56. end
  57. end
  58. return false
  59. end
  60. function UIVipCtr:HasPrev()
  61. local prevLv = self.curShowVipLv - 1
  62. if prevLv <= 0 then return false end
  63. local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(prevLv)
  64. if vipCfg then
  65. return true
  66. end
  67. return false
  68. end
  69. function UIVipCtr:HasNext()
  70. local nextLv = self.curShowVipLv + 1
  71. local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(nextLv)
  72. if not vipCfg then
  73. return false
  74. end
  75. if self:GetCurVipLv() < self.curShowVipLv then
  76. local curVipCfg = ManagerContainer.CfgMgr:GetVipCfgById(self.curShowVipLv)
  77. if curVipCfg and curVipCfg.PreviewLock and curVipCfg.PreviewLock > 0 then
  78. return false
  79. end
  80. end
  81. return true
  82. end
  83. function UIVipCtr:IsReachLv()
  84. return self.curShowVipLv <= self:GetCurVipLv()
  85. end
  86. function UIVipCtr:IsShowCustomerVipLv()
  87. if not self.showCustomerVipLv or self.showCustomerVipLv <= 0 then
  88. return false
  89. end
  90. return self.showCustomerVipLv <= self:GetCurVipLv()
  91. end
  92. return UIVipCtr