KLOpenServiceWingTaskItem.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ---@class KLOpenServiceWingTaskItem:UIKmlLuaPanelBase
  2. ---@field view KLOpenServiceWingTaskItemView
  3. local KLOpenServiceWingTaskItem = class(UIKmlLuaPanelBase)
  4. local this = KLOpenServiceWingTaskItem
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---注册UI事件和服务器消息
  9. function this:RegistEvents()
  10. GUI:AddOnClickEvent(self.view.GoBT,self,self.GoBTOnClick)
  11. end
  12. function this:GoBTOnClick()
  13. if self.taskInfo.state == E_ChapterState.ACCPT then
  14. local inst = SL:GetConfig('cfg_task_target', self.taskInfo.target_id).instruction
  15. self:ClosePanel()
  16. SL:ShortcutDO(inst[1])
  17. elseif self.taskInfo.state == E_ChapterState.FINISH then
  18. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_SUBMIT_WINGS_TASK,self.taskInfo.task_id)
  19. end
  20. end
  21. function this:ClosePanel()
  22. GUI:UIPanel_Close("dev/outui/MainActivity/Panel/KLMainActivity/KLMainActivityPanel")
  23. end
  24. ---界面显示时调用一次
  25. function this:Show()
  26. end
  27. ---创建或者刷新界面数据时调用
  28. function this:Refresh()
  29. end
  30. function this:RefreshItem(data)
  31. self.taskInfo = data
  32. local cfg = SL:GetConfig("cfg_wingstask", data.task_id)
  33. GUI:Item_setItemId(self.view.ItemPoint, cfg.rewardItem[1])
  34. GUI:Item_setItemCount(self.view.ItemPoint, cfg.rewardItem[2])
  35. GUI:AddOnClickEvent(self.view.ItemPoint, self, function()
  36. SL:OpenTips(nil, cfg.rewardItem[1])
  37. end)
  38. GUI:Text_setString(self.view.TaskDes, cfg.text)
  39. GUI:setVisible(self.view.GoBT, data.state ~= E_ChapterState.REWARD)
  40. GUI:setVisible(self.view.IsGet, data.state == E_ChapterState.REWARD)
  41. if data.goal_count < data.max_count then
  42. GUI:Text_setString(self.view.CountText, string.format('<color="#9b1818">%d</color>/%d', data.goal_count, data.max_count))
  43. else
  44. GUI:Text_setString(self.view.CountText, string.format('<color="#2a8430">%d</color>/%d', data.goal_count, data.max_count))
  45. end
  46. if data.state == 1 then
  47. GUI:Text_setString(self.view.GoBT, "前往")
  48. elseif data.state == 2 then
  49. GUI:Text_setString(self.view.GoBT, "领取")
  50. end
  51. end
  52. function this:Close()
  53. end
  54. return this