KLTurnTableGetAwardItem.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ---@class KLTurnTableGetAwardItem:UIKmlLuaPanelBase
  2. ---@field view KLTurnTableGetAwardItemView
  3. local KLTurnTableGetAwardItem = class(UIKmlLuaPanelBase)
  4. local this =KLTurnTableGetAwardItem
  5. ---创建时调用一次
  6. function this:Init()
  7. self.ItemList = nil
  8. end
  9. ---注册UI事件和服务器消息
  10. function this:RegistEvents()
  11. GUI:AddOnClickEvent(self.view.GetButton, self, self.GetButtonOnclick)
  12. end
  13. function this:GetButtonOnclick()
  14. if self.state and self.state == 2 then-- 可领取
  15. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECEIVE_TURNTABLE_RAFFLE_REWARD,{turntableExtId = self.data.id,id = self.groupId})
  16. end
  17. end
  18. ---界面显示时调用一次
  19. function this:Show()
  20. end
  21. ---创建或者刷新界面数据时调用
  22. function this:Refresh()
  23. end
  24. function this:UpDataUI(data,index,totalCount,received,groupId)
  25. self.groupId = groupId
  26. self.index = index
  27. self.data = data
  28. self.state =0
  29. self.careerId = SL:GetMetaValue(EMetaVarGetKey.JOB)
  30. if self.data then
  31. for i, v in pairs(self.data.reward) do
  32. if v[1] == self.careerId then
  33. self:ShowCoustIcon(v)
  34. end
  35. end
  36. end
  37. if self.data.num > totalCount then
  38. self.state = 1
  39. else
  40. self.state = 2
  41. if next(received) then
  42. for _,v in pairs(received) do
  43. if tonumber(v) == self.data.id then
  44. self.state = 3
  45. end
  46. end
  47. end
  48. end
  49. if self.state == 1 then---未达到条件
  50. GUI:SetActive(self.view.GetButton,false)
  51. GUI:SetActive(self.view.RedDot,false)
  52. GUI:SetActive(self.view.HaveGet,false)
  53. GUI:SetActive(self.view.CountText,true)
  54. GUI:Text_setString(self.view.CountText,"累计".. self.data.num.."抽可领取")
  55. elseif self.state == 2 then-- 可领取
  56. GUI:SetActive(self.view.GetButton,true)
  57. GUI:SetActive(self.view.RedDot,true)
  58. GUI:SetActive(self.view.HaveGet,false)
  59. GUI:SetActive(self.view.CountText,false)
  60. GUI:Image_loadTexture(self.view.GetButton,"btn_common1","Atlas/Common.spriteatlas")
  61. GUI:Text_setString(self.view.GetButton,"领取")
  62. elseif self.state == 3 then--- 已领取
  63. GUI:SetActive(self.view.GetButton,true)
  64. GUI:SetActive(self.view.RedDot,false)
  65. GUI:SetActive(self.view.HaveGet,true)
  66. GUI:SetActive(self.view.CountText,false)
  67. GUI:Image_loadTexture(self.view.GetButton,"btn_common8","Atlas/Common.spriteatlas")
  68. GUI:Text_setString(self.view.GetButton,"已领取")
  69. end
  70. end
  71. ---@param v table @例:{1,800502016,1}
  72. function this:ShowCoustIcon(v)
  73. local data = {
  74. itemid = v[2],
  75. mfixsize = "80,80",
  76. tips = "1",
  77. width = "80",
  78. height = "80",
  79. bgtype = "0"
  80. }
  81. if self.ItemList then
  82. GUI:Item_UpdataData(self.ItemList, data)
  83. else
  84. self.ItemList = GUI:Item_Create(self.view.Icon, data)
  85. end
  86. GUI:AddOnClickEvent(self.ItemList, self, function()
  87. SL:OpenTips(nil, data.itemid)
  88. end)
  89. end
  90. function this:Hide()
  91. end
  92. function this:Close()
  93. end
  94. return this