UIGuildWarActivityShopCtr.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. local UIGuildWarActivityShopCtr = class("UIGuildWarActivityShopCtr", require("UICtrBase"))
  2. function UIGuildWarActivityShopCtr:Init(view)
  3. self.view = view
  4. end
  5. function UIGuildWarActivityShopCtr:SetData(data)
  6. self.asyncIdx = 0
  7. if data == nil then return end
  8. self.data = data
  9. end
  10. function UIGuildWarActivityShopCtr:GetAsyncIdx()
  11. self.asyncIdx = self.asyncIdx + 1
  12. return self.asyncIdx
  13. end
  14. function UIGuildWarActivityShopCtr:GetData()
  15. return self.data
  16. end
  17. function UIGuildWarActivityShopCtr:OnDispose()
  18. self.data = nil
  19. self.view = nil
  20. self.shopType = nil
  21. self.shopSubType = nil
  22. self.idx = nil
  23. end
  24. function UIGuildWarActivityShopCtr:InitData()
  25. self.shopType = Enum.RuneShopType.GuildWar
  26. local guildsmenRewords = {}
  27. local mvpRewords = {}
  28. local GuildWarAgainstCfg = ManagerContainer.CfgMgr:GetGuildWarAgainstCfg()
  29. for key, value in pairs(GuildWarAgainstCfg) do
  30. if value.Ranking > 0 and value.GuildsmenReword then
  31. local itemDatas = {}
  32. for _,v in pairs(value.GuildsmenReword) do
  33. local itemData = {cfgId = v[1], num = v[2]}
  34. itemDatas[#itemDatas + 1] = itemData
  35. end
  36. guildsmenRewords[#guildsmenRewords + 1] = {value.Ranking, value.GuildsmenName, itemDatas}
  37. end
  38. if (value.PointMvp > 0 and value.PointMvpReword) then
  39. local itemDatas = {}
  40. for _,v in pairs(value.PointMvpReword) do
  41. local itemData = {cfgId = v[1], num = v[2]}
  42. itemDatas[#itemDatas + 1] = itemData
  43. end
  44. mvpRewords[#mvpRewords + 1] = {1, value.PointMvp, value.PointMvpName, itemDatas}
  45. end
  46. if (value.KillerMvp > 0 and value.KillerMvpReword) then
  47. local itemDatas = {}
  48. for _,v in pairs(value.KillerMvpReword) do
  49. local itemData = {cfgId = v[1], num = v[2]}
  50. itemDatas[#itemDatas + 1] = itemData
  51. end
  52. mvpRewords[#mvpRewords + 1] = {2, value.KillerMvp, value.KillerMvpName, itemDatas}
  53. end
  54. end
  55. table.sort(guildsmenRewords, function (a, b)
  56. return a[1] < b[1]
  57. end)
  58. table.sort(mvpRewords, function (a, b)
  59. if a[2] == b[2] then
  60. return a[1] < b[1]
  61. end
  62. return a[2] < b[2]
  63. end)
  64. self.guildsmenRewords = guildsmenRewords
  65. self.mvpRewords = mvpRewords
  66. end
  67. function UIGuildWarActivityShopCtr:GetIdx()
  68. return self.idx
  69. end
  70. function UIGuildWarActivityShopCtr:GetCurShopType()
  71. return self.shopType, self.shopSubType
  72. end
  73. function UIGuildWarActivityShopCtr:RefreshCurShopData(forceRefresh)
  74. ManagerContainer.DataMgr.RuneShopDataMgr:RefreshShopData(self.shopType, self.shopSubType, forceRefresh)
  75. self.curShopData = ManagerContainer.DataMgr.RuneShopDataMgr:GetShopData(self.shopType, self.shopSubType)
  76. if self.curShopData then
  77. if not self.curShopData:IsValidShow() then
  78. self.curShopData:RefreshShowGoodsDatas()
  79. end
  80. return true
  81. end
  82. return false
  83. end
  84. function UIGuildWarActivityShopCtr:GetGuildsmenRewords()
  85. return self.guildsmenRewords
  86. end
  87. function UIGuildWarActivityShopCtr:GetMvpRewords()
  88. return self.mvpRewords
  89. end
  90. function UIGuildWarActivityShopCtr:GetShowGoodsDatas()
  91. if not self.curShopData then
  92. self.curShopData = ManagerContainer.DataMgr.RuneShopDataMgr:GetShopData(self.shopType, self.shopSubType)
  93. if self.curShopData then
  94. if not self.curShopData:IsValidShow() then
  95. self.curShopData:RefreshShowGoodsDatas()
  96. end
  97. end
  98. end
  99. return self.curShopData and self.curShopData:GetShowGoodsDatas() or nil
  100. end
  101. function UIGuildWarActivityShopCtr:SendPay(goodsId)
  102. local errorCode = ManagerContainer.PayMgr:RuneShopPay(self.shopType, self.shopSubType, goodsId)
  103. local errorCodeKey = ManagerContainer.PayMgr:GetInitPayErrorCodeLangKey(errorCode)
  104. return errorCodeKey
  105. end
  106. function UIGuildWarActivityShopCtr:SendRewardReq(rewardType)
  107. ManagerContainer.DataMgr.RankActivitiesMgr:SendRewardReq(self.type, rewardType)
  108. end
  109. return UIGuildWarActivityShopCtr