UIRuneShopBTCtr.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. local UIRuneShopBTCtr = class("UIRuneShopBTCtr", require("UICtrBase"))
  2. function UIRuneShopBTCtr:Init(view)
  3. self.view = view
  4. end
  5. function UIRuneShopBTCtr:SetData(data)
  6. self.asyncIdx = 0
  7. self.data = data
  8. end
  9. function UIRuneShopBTCtr:GetAsyncIdx()
  10. self.asyncIdx = self.asyncIdx + 1
  11. return self.asyncIdx
  12. end
  13. function UIRuneShopBTCtr:GetData()
  14. return self.data
  15. end
  16. function UIRuneShopBTCtr:OnDispose()
  17. self.data = nil
  18. self.view = nil
  19. self.shopType = nil
  20. self.shopSubType = nil
  21. end
  22. function UIRuneShopBTCtr:InitData()
  23. local shopType = nil
  24. local shopSubType = nil
  25. if self.data then
  26. shopType = self.data[1]
  27. shopSubType = self.data[2]
  28. if shopType == Enum.RuneShopType.Gifts then
  29. if shopSubType ~= Enum.RuneShopSubType.Daily
  30. and shopSubType ~= Enum.RuneShopSubType.Week
  31. and shopSubType ~= Enum.RuneShopSubType.Gold then
  32. shopSubType = Enum.RuneShopSubType.ROCoin
  33. end
  34. elseif shopType == Enum.RuneShopType.SpecialPrivilege
  35. or shopType == Enum.RuneShopType.MonthCard
  36. or shopType == Enum.RuneShopType.PassCheck
  37. or shopType == Enum.RuneShopType.LimitTime then
  38. shopSubType = nil
  39. else
  40. shopType = Enum.RuneShopType.SpecialPrivilege
  41. shopSubType = nil
  42. end
  43. else
  44. shopType = Enum.RuneShopType.SpecialPrivilege
  45. shopSubType = nil
  46. end
  47. self.shopType = shopType
  48. self.shopSubType = shopSubType
  49. self:RefreshCurShopData(true)
  50. end
  51. function UIRuneShopBTCtr:RefreshCurShopData(forceRefresh)
  52. if self.shopType == Enum.RuneShopType.SpecialPrivilege
  53. or self.shopType == Enum.RuneShopType.PassCheck then
  54. self.curShopData = nil
  55. return
  56. end
  57. ManagerContainer.DataMgr.RuneShopDataMgr:RefreshShopData(self.shopType, self.shopSubType, forceRefresh)
  58. self.curShopData = ManagerContainer.DataMgr.RuneShopDataMgr:GetShopData(self.shopType, self.shopSubType)
  59. if self.curShopData then
  60. if not self.curShopData:IsValidShow() then
  61. self.curShopData:RefreshShowGoodsDatas()
  62. end
  63. end
  64. end
  65. function UIRuneShopBTCtr:GetShopType()
  66. return self.shopType
  67. end
  68. function UIRuneShopBTCtr:ChangeShopType(shopType)
  69. if self.shopType == shopType then
  70. return false
  71. end
  72. self.shopType = shopType
  73. if shopType == Enum.RuneShopType.Gifts then
  74. self.shopSubType = Enum.RuneShopSubType.ROCoin
  75. else
  76. self.shopSubType = nil
  77. end
  78. self:RefreshCurShopData(true)
  79. return true
  80. end
  81. function UIRuneShopBTCtr:GetShopSubType()
  82. return self.shopSubType
  83. end
  84. function UIRuneShopBTCtr:ChangeShopSubType(shopSubType)
  85. if self.shopSubType == shopSubType then
  86. return false
  87. end
  88. self.shopSubType = shopSubType
  89. self:RefreshCurShopData(true)
  90. return true
  91. end
  92. function UIRuneShopBTCtr:GetCurVipLv()
  93. return ManagerContainer.DataMgr.UserData:GetVipLv()
  94. end
  95. function UIRuneShopBTCtr:GetShowGoodsDatas()
  96. return self.curShopData and self.curShopData:GetShowGoodsDatas() or nil
  97. end
  98. function UIRuneShopBTCtr:GetRemainTime()
  99. return self.curShopData and self.curShopData:RefreshRemainTime() or nil
  100. end
  101. function UIRuneShopBTCtr:GetShowGoodsDataByIdx(idx)
  102. if self.curShopData then
  103. local showGoodsDatas = self.curShopData:GetShowGoodsDatas()
  104. if showGoodsDatas then
  105. return showGoodsDatas[idx]
  106. end
  107. end
  108. return nil
  109. end
  110. function UIRuneShopBTCtr:GetOwnResCountByItemId(cfgId)
  111. return CommonUtil.GetOwnResCountByItemId(cfgId)
  112. end
  113. function UIRuneShopBTCtr:GetSpecialPrivilegeId()
  114. return ManagerContainer.DataMgr.RuneShopDataMgr:GetSpecialPrivilegeId()
  115. end
  116. function UIRuneShopBTCtr:CanGetSpecialPrivilegeReward()
  117. return ManagerContainer.DataMgr.RuneShopDataMgr:CanGetSpecialPrivilegeReward()
  118. end
  119. function UIRuneShopBTCtr:GetRoPassStatus()
  120. return ManagerContainer.DataMgr.RuneShopDataMgr:GetRoPassStatus()
  121. end
  122. function UIRuneShopBTCtr:SendPay(goodsId)
  123. local errorCode = ManagerContainer.PayMgr:RuneShopPay(self.shopType, self.shopSubType, goodsId)
  124. local errorCodeKey = ManagerContainer.PayMgr:GetInitPayErrorCodeLangKey(errorCode)
  125. return errorCodeKey
  126. end
  127. function UIRuneShopBTCtr:SendRuneSpecialPrvilegeRewardReq()
  128. if not ManagerContainer.DataMgr.RuneShopDataMgr:SendRuneSpecialPrvilegeRewardReq() then
  129. return 100007
  130. end
  131. return 0
  132. end
  133. return UIRuneShopBTCtr