KLRechargeLinkPanel.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. ---@class KLRechargeLinkPanel:UIKmlLuaPanelBase
  2. ---@field view KLRechargeLinkPanelView
  3. local KLRechargeLinkPanel = class(UIKmlLuaPanelBase)
  4. local this = KLRechargeLinkPanel
  5. function this:AsyncLoadUI()
  6. end
  7. ---创建时调用一次
  8. function this:Init()
  9. self.careerId = SL:GetMetaValue(EMetaVarGetKey.JOB)
  10. self.ItemList = {}
  11. self.giftTbl = SL:GetConfigTable("cfg_newServerGIft")
  12. self.bigAwardTbl = self.giftTbl[table.count(self.giftTbl)]
  13. self.dataList = {}
  14. GUI:DataListInitData(self.view.ItemDataList, function()
  15. return table.count(self.giftTbl) - 1
  16. end, function()
  17. end, function()
  18. end, function(realIndex)
  19. return self:UpDataList(realIndex)
  20. end)
  21. --[[ GUI:DataListUpdateData(self.view.ItemDataList)
  22. self:UpDataBigAward()]]
  23. end
  24. function this:UpDataList(realIndex)
  25. local index = realIndex + 1
  26. local strengthInfo = self.giftTbl[index]
  27. local ItemBg = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'ItemBg')
  28. local ItemBg_BtnMask = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'ItemBg_BtnMask')
  29. local ItemGet = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'ItemGet')
  30. local Txt = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'Txt')
  31. local TextTitle = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'TextTitle')
  32. local model = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'model')
  33. local GetBtn = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'GetBtn')
  34. local RedDot = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'RedDot')
  35. GUI:Text_setString(TextTitle, "连续达成目标" .. index .. "天")
  36. for ItemIndex, v in pairs(strengthInfo.reward) do
  37. if v[1] == self.careerId or v[1] == 0 then
  38. local itemId = v[2]
  39. local count = v[3]
  40. self:SetItem(itemId, count, index, ItemIndex, model)
  41. ---@type cfg_item_column
  42. local ItemTbl = SL:GetConfig("cfg_item", itemId)
  43. GUI:Text_setString(Txt, ItemTbl.name)
  44. end
  45. end
  46. GUI:SetActive(RedDot, false)
  47. if self.dataList[strengthInfo.id] then
  48. if self.dataList[strengthInfo.id].state == 2 then
  49. GUI:SetActive(ItemGet, false)
  50. GUI:SetActive(ItemBg_BtnMask, false)
  51. GUI:SetActive(GetBtn, false)
  52. elseif self.dataList[strengthInfo.id].state == 1 then
  53. GUI:SetActive(ItemGet, false)
  54. GUI:SetActive(ItemBg_BtnMask, true)
  55. GUI:SetActive(GetBtn, true)
  56. GUI:SetActive(RedDot, true)
  57. GUI:AddOnClickEvent(GetBtn, self, function()
  58. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION, { type = ERechargeType.RechargeLink, action = "reward", id = strengthInfo.id })
  59. end)
  60. elseif self.dataList[strengthInfo.id].state == 3 then
  61. GUI:SetActive(ItemGet, true)
  62. GUI:SetActive(ItemBg_BtnMask, false)
  63. GUI:SetActive(GetBtn, false)
  64. end
  65. end
  66. end
  67. function this:SetItem(itemId, count, index, ItemIndex, model)
  68. ---列表index和道具index
  69. local data = {
  70. width = "70",
  71. height = "70",
  72. itemid = itemId,
  73. mfixsize = "70,70",
  74. tips = "1",
  75. itemcustomcount = count
  76. }
  77. if not self.ItemList[index] then
  78. self.ItemList[index] = {}
  79. end
  80. if self.ItemList[index][ItemIndex] then
  81. GUI:Item_UpdataData(self.ItemList[index][ItemIndex], data)
  82. else
  83. local item = GUI:Item_Create(model, data)
  84. self.ItemList[index][ItemIndex] = item
  85. end
  86. GUI:AddOnClickEvent(self.ItemList[index][ItemIndex], self, function()
  87. SL:OpenTips(nil, itemId)
  88. end)
  89. end
  90. function this:UpDataBigAward()
  91. local index = table.count(self.giftTbl)
  92. local data = self.dataList[self.bigAwardTbl.id]
  93. GUI:Text_setString(self.view.BigTitle, "连续达成目标" .. index .. "天")
  94. for ItemIndex, v in pairs(self.bigAwardTbl.reward) do
  95. if v[1] == self.careerId or v[1] == 0 then
  96. local itemId = v[2]
  97. ---@type cfg_item_column
  98. local ItemTbl = SL:GetConfig("cfg_item", itemId)
  99. GUI:Text_setString(self.view.ItemTex, ItemTbl.name)
  100. GUI:AddOnClickEvent(self.view.BigGetBtn, self, function()
  101. if not data then return end
  102. if data.state == 2 then
  103. SL:OpenTips(nil, itemId)
  104. elseif data.state == 1 then
  105. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION, { type = ERechargeType.RechargeLink, action = "reward", id = self.bigAwardTbl.id })
  106. elseif data.state == 3 then
  107. return
  108. end
  109. end)
  110. end
  111. end
  112. self:ShowBigModel(self.bigAwardTbl)
  113. GUI:SetActive(self.view.BigRedDot, false)
  114. if not data then return end
  115. if data.state == 2 then
  116. GUI:SetActive(self.view.Get, false)
  117. GUI:SetActive(self.view.bg_BtnMask, false)
  118. elseif data.state == 1 then
  119. GUI:SetActive(self.view.Get, false)
  120. GUI:SetActive(self.view.bg_BtnMask, true)
  121. GUI:SetActive(self.view.BigRedDot, true)
  122. elseif data.state == 3 then
  123. GUI:SetActive(self.view.Get, true)
  124. GUI:SetActive(self.view.bg_BtnMask, false)
  125. end
  126. if self.bigAwardTbl.previewVedio ~= "" and not table.isNullOrEmpty(self.bigAwardTbl.previewVedio) then
  127. for _, v in pairs(self.bigAwardTbl.previewVedio) do
  128. if tonumber(v[1]) == self.careerId or tonumber(v[1]) == 0 then
  129. GUI:SetActive(self.view.button_watchVideo,true)
  130. GUI:Text_setString(self.view.text19, v[2])
  131. end
  132. end
  133. else
  134. GUI:SetActive(self.view.button_watchVideo,false)
  135. end
  136. end
  137. function this:ShowBigModel(Tbl)
  138. if not Tbl then
  139. return
  140. end
  141. local scale = 40
  142. local mrotate = "-70,-70,0"
  143. local x = "0"
  144. local y = "-50"
  145. local z = "-200"
  146. local path = ""
  147. local ani = ""
  148. local rX = 1
  149. local rY = 0
  150. local rZ = 0
  151. for _, model1 in pairs(Tbl.showModel) do
  152. if tonumber(model1[1]) == self.careerId or tonumber(model1[1]) == 0 then
  153. path = model1[2]
  154. end
  155. end
  156. for _, model2 in pairs(Tbl.modelCondition) do
  157. if tonumber(model2[5]) == self.careerId or tonumber(model2[1]) == 0 then
  158. x=model2[1]
  159. y =model2[2]
  160. z = model2[3]
  161. scale = tonumber(model2[4])
  162. end
  163. end
  164. for _, model3 in pairs(Tbl.modelRevolve) do
  165. if tonumber(model3[4]) == self.careerId or tonumber(model3[1]) == 0 then
  166. --mrotate = model3[1].. "," .. model3[2] .. "," .. model3[3]
  167. rX = tonumber(model3[1])
  168. rY = tonumber(model3[2])
  169. rZ = tonumber(model3[3])
  170. end
  171. end
  172. for _, model4 in pairs(Tbl.modelBehavior) do
  173. if tonumber(model4[2]) == self.careerId or tonumber(model4[1]) == 0 then
  174. ani=model4[1]
  175. end
  176. end
  177. local data = {
  178. mscale = 1 .. "," .. 1 .. "," .. 1,
  179. mrotate = mrotate,
  180. x = x,
  181. y = y,
  182. z = z,
  183. a = "00",
  184. src = path,
  185. ani = ani,
  186. }
  187. if self.model then
  188. GUI:Item_UpdataData(self.model, data)
  189. else
  190. self.model = GUI:Model_Create(self.view.ItemModel, data)
  191. end
  192. GUI:setScale(self.model, scale)
  193. GUI:setRotationSkewX(self.model,rX)
  194. GUI:setRotationSkewY(self.model,rY)
  195. GUI:setRotation(self.model,rZ)
  196. end
  197. function this:SetFillAmount(value)
  198. GUI:SetLoadingbar_startper(self.view.scheduleImg, math.floor(value*100))
  199. end
  200. ---注册UI事件和服务器消息
  201. function this:RegistEvents()
  202. GUI:AddOnClickEvent(self.view.button_watchVideo, self, self.VideoOnClick)
  203. SL:RegisterLUAEvent(LUA_EVENT_RECHARGE_LINK_CHANGE, self.LUA_EVENT_RECHARGE_LINK_CHANGE, self)
  204. GUI:AddOnClickEvent(self.view.btnUp, self, self.btnUpOnClick)
  205. end
  206. function this:btnUpOnClick()
  207. if self.bigAwardTbl then
  208. GUI:UIPanel_Close("dev/outui/MainRecharge/Panel/KLMainRecharge/KLMainRechargePanel")
  209. shortcutOutMgr.DO(self.bigAwardTbl.Jump)
  210. SL:HideMainPanel()
  211. end
  212. end
  213. function this:LUA_EVENT_RECHARGE_LINK_CHANGE()
  214. self.RechargeLinkData = InfoManager.rechargeLinkInfo.RechargeLinkData
  215. self:SetFillAmount(self.RechargeLinkData.totalMoney / 100)
  216. GUI:Text_setString(self.view.RechargeTargetTextBName, "今日充值达标:<color=#5DE367>" .. "100" .. "</color>元")
  217. GUI:Text_setString(self.view.schedule_Text, self.RechargeLinkData.totalMoney .. "/" .. 100)
  218. for _, v in pairs(self.RechargeLinkData.data) do
  219. self.dataList[tonumber(v.id)] = v
  220. end
  221. GUI:DataListUpdateData(self.view.ItemDataList)
  222. self:UpDataBigAward()
  223. end
  224. function this:VideoOnClick()
  225. if self.bigAwardTbl.previewVedio ~= "" then
  226. for _, v in pairs(self.bigAwardTbl.previewVedio) do
  227. if tonumber(v[1]) == self.careerId or tonumber(v[1]) == 0 then
  228. GUI:UIPanel_Open("dev/outui/Recharge/Panel/KLPlayVideo/KLPlayVideoPanel", nil, nil, { path = v[3] })
  229. GUI:Text_setString(self.view.text19, v[2])
  230. end
  231. end
  232. end
  233. end
  234. ---界面显示时调用一次
  235. function this:Show()
  236. local mainTbl = SL:GetConfig("sub_mainRecharge",9)
  237. local showCondition = mainTbl.showCondition
  238. local conditionTbl=ConditionManager.GetConditionParams(showCondition)
  239. local reTime=SL:GetEndTimeStamp(tonumber(conditionTbl[1]),0)
  240. self:ShowTime(reTime)
  241. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION, { type = tostring(ERechargeType.RechargeLink), action = "panel" })
  242. --SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION,{type=tostring(ERechargeType.RechargeLink),action="reward",id = "10001"})
  243. end
  244. ---创建或者刷新界面数据时调用
  245. function this:Refresh()
  246. end
  247. function this:ShowTime(endTime)
  248. self.Timer = SL:Schedule(self.Timer, 0, 1, endTime + 1, function()
  249. local timeText = endTime - Time.GetServerTime()
  250. GUI:Text_setString(self.view.Timer,"活动剩余时间:<color=#5DE367>".. GUIUtil.FormatTimeDHM(timeText // 1000).."</color>")
  251. if timeText <= 0 then
  252. GUI:Text_setString(self.view.Timer,"")
  253. for _,v in pairs(self.dataList) do
  254. if v.state == 1 then
  255. v.state = 3
  256. end
  257. end
  258. self:SetFillAmount(0/ 100)
  259. GUI:Text_setString(self.view.schedule_Text, 0 .. "/" .. 100)
  260. GUI:DataListUpdateData(self.view.ItemDataList)
  261. self:UpDataBigAward()
  262. if self.bigAwardTbl and self.bigAwardTbl.previewVedio ~= "" and not table.isNullOrEmpty(self.bigAwardTbl.previewVedio) then
  263. for _, v in pairs(self.bigAwardTbl.previewVedio) do
  264. if tonumber(v[1]) == self.careerId or tonumber(v[1]) == 0 then
  265. GUI:SetActive(self.view.button_watchVideo,true)
  266. GUI:Text_setString(self.view.text19, v[2])
  267. end
  268. end
  269. else
  270. GUI:SetActive(self.view.button_watchVideo,false)
  271. end
  272. InfoManager.mainRechargeInfo:RefreshMainRechargeRedPoint("tog_NewServerRecharge",false)
  273. if self.Timer then
  274. SL:UnSchedule(self.Timer)
  275. end
  276. end
  277. end)
  278. end
  279. function this:Close()
  280. if self.Timer then
  281. SL:UnSchedule(self.Timer)
  282. end
  283. self.Timer = nil
  284. end
  285. return this