UIRuneShopExploreView.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. local UIRuneShopExploreView = require("UIRuneShop/UIRuneShopExploreView_Generate")
  2. function UIRuneShopExploreView:OnAwake(data)
  3. self.controller = require("UIRuneShop/UIRuneShopExploreCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIRuneShopExploreView:AddEventListener()
  8. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ROCOIN_CHANGED, self, self.OnRoCoinChanged)
  9. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.COIN_CHANGED, self, self.OnCoinChanged)
  10. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.DIAMOND_CHANGED, self, self.OnDiamondChanged)
  11. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.VIP_LV_CHANGED, self, self.OnVipLvChanged)
  12. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.RUNE_SHOP_REWARDS_DATA_CHANGED, self, self.OnRuneShopRewardsDataChanged)
  13. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.UI_CLOSEED_TASK_PAGE, self, self.OnCloseTask)
  14. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.UI_TASK_JUMP, self, self.OnCloseAirShip)
  15. end
  16. function UIRuneShopExploreView:FillContent(data, uiBase)
  17. self.uiBase = uiBase
  18. local gameObject = self.uiBase:GetRoot()
  19. if gameObject ~= nil then
  20. self.gameObject = gameObject
  21. self.transform = gameObject.transform
  22. end
  23. self:InitGenerate(self.transform, data)
  24. self:Init()
  25. end
  26. function UIRuneShopExploreView:Init()
  27. self.controller:InitData()
  28. self.textBox.text.text = string.formatbykey('DscClub04')
  29. self:RefreshRoCoinView()
  30. self:RefreshCoinView()
  31. self:RefreshGoldView()
  32. self:RefreshVipView()
  33. self.rewardsBoxItem.scrollView.loopGridView:InitGridView(0, function(loopGridView, itemIdx, row, column)
  34. return self:GetItemByRowColumnRewards(loopGridView, itemIdx, row, column)
  35. end, nil, nil)
  36. self:RefreshRewardsView()
  37. end
  38. function UIRuneShopExploreView:RemoveEventListener()
  39. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  40. end
  41. function UIRuneShopExploreView:AddUIEventListener()
  42. self.uiBase:AddButtonUniqueEventListener(self.btnClose.button, self, self.OnClickCloseBtn)
  43. self.uiBase:AddButtonUniqueEventListener(self.btnVIP.button, self, self.OnClickVipBtn)
  44. self.uiBase:AddButtonUniqueEventListener(self.rewardsBoxItem.btnPlayRule.button, self, self.OnClickPlayRuleBtn)
  45. self.uiBase:AddButtonUniqueEventListener(self.rewardsBoxItem.btnBuyMore.button, self, self.OnClickBuyAdvancedRewardsBtn)
  46. self.uiBase:AddButtonUniqueEventListener(self.btnTaskExp.button, self, self.OnClickTaskExpBtn)
  47. end
  48. function UIRuneShopExploreView:OnHide()
  49. end
  50. function UIRuneShopExploreView:OnShow(data)
  51. self.controller:SetData(data)
  52. end
  53. function UIRuneShopExploreView:OnClose()
  54. end
  55. function UIRuneShopExploreView:OnDispose()
  56. self:DisposeRefreshTimer()
  57. if self.rewardsBoxItem then
  58. self.rewardsBoxItem.scrollView.loopGridView:Dispose()
  59. end
  60. self.controller:OnDispose()
  61. end
  62. function UIRuneShopExploreView:OnClickCloseBtn()
  63. ManagerContainer.LuaUIMgr:OpenSourceUI(self)
  64. end
  65. function UIRuneShopExploreView:OnClickVipBtn()
  66. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIVip)
  67. end
  68. function UIRuneShopExploreView:OnClickPlayRuleBtn()
  69. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPlayRule, {'PlayExplainTitle', 'AirshipText'})
  70. end
  71. function UIRuneShopExploreView:OnClickTaskExpBtn()
  72. ManagerContainer.DataMgr.TaskDataNew:OpenTaskPanel();
  73. end
  74. function UIRuneShopExploreView:OnClickBuyAdvancedRewardsBtn()
  75. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRewardsBuyTips)
  76. end
  77. function UIRuneShopExploreView:OnClickGetAdvancedRewardBtn()
  78. if self.rewardsBaseData:GetMaxRewardsNum() > 0 then
  79. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_EXPLORE_EXTRA_REWARD_REQ)
  80. end
  81. end
  82. function UIRuneShopExploreView:OnCloseTask()
  83. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_EXPLORE_INFO_REQ)
  84. end
  85. function UIRuneShopExploreView:OnCloseAirShip()
  86. ManagerContainer.LuaUIMgr:Close(Enum.UIPageName.UIRuneShopExplore)
  87. end
  88. function UIRuneShopExploreView:OnRoCoinChanged()
  89. self:RefreshRoCoinView()
  90. end
  91. function UIRuneShopExploreView:OnCoinChanged()
  92. self:RefreshCoinView()
  93. end
  94. function UIRuneShopExploreView:OnDiamondChanged()
  95. self:RefreshGoldView()
  96. end
  97. function UIRuneShopExploreView:OnVipLvChanged()
  98. self:RefreshVipView()
  99. end
  100. function UIRuneShopExploreView:OnRuneShopRewardsDataChanged()
  101. self:RefreshRewardsView()
  102. end
  103. function UIRuneShopExploreView:RefreshRoCoinView()
  104. self.ro.number.text.text = CommonUtil.FormatNumber(self.controller:GetOwnResCountByItemId(Enum.ItemType.ROCoin))
  105. end
  106. function UIRuneShopExploreView:RefreshCoinView()
  107. self.coin.number.text.text = CommonUtil.FormatNumber(self.controller:GetOwnResCountByItemId(Enum.ItemType.Coin))
  108. end
  109. function UIRuneShopExploreView:RefreshGoldView()
  110. self.gold.number.text.text = CommonUtil.FormatNumber(self.controller:GetOwnResCountByItemId(Enum.ItemType.Diamond))
  111. end
  112. function UIRuneShopExploreView:RefreshVipView()
  113. local curVipLv = self.controller:GetCurVipLv()
  114. local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(curVipLv)
  115. self.vipIcon.image.sprite = nil
  116. self.vipIcon.image.enabled = false
  117. self.vipFrame.image.sprite = nil
  118. self.vipFrame.image.enabled = false
  119. if not vipCfg then
  120. self.vipNameTxt.text.text = ''
  121. return
  122. end
  123. CommonUtil.LoadIcon(self, vipCfg.BigIcon, function(sprite)
  124. if sprite then
  125. self.vipIcon.image.sprite = sprite
  126. self.vipIcon.image.enabled = true
  127. end
  128. end)
  129. CommonUtil.LoadIcon(self, vipCfg.BigFrame, function(sprite)
  130. if sprite then
  131. self.vipFrame.image.sprite = sprite
  132. self.vipFrame.image.enabled = true
  133. end
  134. end)
  135. self.vipNameTxt.text.text = string.formatbykey(vipCfg.Name)
  136. end
  137. --悬赏战令页面
  138. function UIRuneShopExploreView:RefreshRewardsView()
  139. if not self.rewardsBoxItem then return end
  140. if ManagerContainer.DataMgr.RuneShopDataMgr.isRewardsDataDirty then
  141. self.rewardsBoxItem:SetActive(false)
  142. return
  143. end
  144. self.rewardsBoxItem:SetActive(true)
  145. self.rewardsBaseData = self.controller:GetRewardsBaseData()
  146. local showGoodsDatas = self.rewardsBaseData:GetShowRewardsData()
  147. local curLv = self.rewardsBaseData:GetShowRewardsCurLv()
  148. local curExp = self.rewardsBaseData:GetShowRewardsCurExp()
  149. local curCfg = self.rewardsBaseData:GetRewardsCurRoundCfg()
  150. if not curCfg then
  151. self.rewardsBoxItem:SetActive(false)
  152. return
  153. end
  154. self.isShowAirShip = false
  155. local length = (showGoodsDatas and #showGoodsDatas or 0)
  156. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.RuneShopRewards, false)
  157. --页面下方关于当前等级的信息展示
  158. local nextlv = curLv + 1
  159. if nextlv > length then
  160. nextlv = length
  161. end
  162. if curLv == length then
  163. self.rewardsmax:SetActive(true)
  164. self.numexp.text.text = tostring(curExp)..'/'.. tostring(curCfg.ExpCost)
  165. self.expSlider.slider.value = curExp/curCfg.ExpCost
  166. else
  167. self.rewardsmax:SetActive(false)
  168. self.curLvData = self.controller:GetShowRewardsDataByIdx(nextlv)
  169. self.numexp.text.text = tostring(curExp)..'/'.. tostring(self.curLvData.cfgData.Exp)
  170. self.expSlider.slider.value = curExp/self.curLvData.cfgData.Exp
  171. end
  172. self.rewardslv.text.text = tostring(curLv)
  173. self.rewardsBoxItem.btnBuyMore.num.text.text = tostring(curCfg.MissonExpUp)..'%'
  174. self.expUpBlue.num.text.text = tostring(curCfg.MissonExpUp)..'%'
  175. --根据等级经验 刷新小游艇
  176. local newLv =length - curLv
  177. --因为多一个开始节点和结束最终奖励节点,所以+2
  178. self.rewardsBoxItem.scrollView.loopGridView:RecycleAllItem()
  179. if self.isInited then
  180. self.rewardsBoxItem.scrollView.loopGridView:RefreshListByIndex(length+2 )
  181. else
  182. self.rewardsBoxItem.scrollView.loopGridView:RefreshListByIndex(length+2 , newLv)
  183. end
  184. self.rewardsBoxItem.scrollView.loopGridView.mOnBeginDragAction = function(gridView)
  185. self:RefreshBigRewardsFloatTips(gridView)
  186. end
  187. self.rewardsBoxItem.scrollView.loopGridView.mOnDragingAction = function(gridView)
  188. self:RefreshBigRewardsFloatTips(gridView)
  189. end
  190. self.rewardsBoxItem.scrollView.loopGridView.mOnEndDragAction = function(gridView)
  191. self:RefreshBigRewardsFloatTips(gridView)
  192. end
  193. self.isInited = true
  194. local isCash = self.rewardsBaseData:GetRewardsIsCash()
  195. if isCash == 1 then
  196. self.rewardsBoxItem.btnBuyMore:SetActive(false)
  197. self.rewardsBoxItem.labelUnLocked:SetActive(true)
  198. self.expUpBlue:SetActive(true)
  199. else
  200. self.rewardsBoxItem.btnBuyMore:SetActive(true)
  201. self.rewardsBoxItem.labelUnLocked:SetActive(false)
  202. self.expUpBlue:SetActive(false)
  203. end
  204. local endTime = self.rewardsBaseData:RefreshRewaradsRemainTime()
  205. if endTime then
  206. self:StartRefreshTimer(self.rewardsBoxItem, true)
  207. if endTime < 0 then endTime = 0 end
  208. self:RefreshBigRewardsFloatTips(nil)
  209. self.rewardsBoxItem.timeBox:SetActive(true)
  210. self.rewardsBoxItem.timeBox.textTime.text.text = string.formatbykey('AirshipTime', DateTimeUtil.convertSeconds2TimeStr1(endTime, true, true, false))
  211. else
  212. self:StopRefreshTimer(self.rewardsBoxItem)
  213. self.rewardsBoxItem.timeBox:SetActive(false)
  214. end
  215. end
  216. --大奖标签跳转
  217. function UIRuneShopExploreView:JumpToTarget(button , params)
  218. local data = clone(params[0])
  219. self.rewardsBoxItem.scrollView.loopGridView:RefreshListByIndex(#self.controller:GetShowRewardsData()+2 , data.targetid)
  220. self:RefreshBigRewardsFloatTips()
  221. end
  222. --设置悬赏单个对象
  223. function UIRuneShopExploreView:UpdateRewardsItem(itemLua, idx, data, isEnd)
  224. local curExp = self.rewardsBaseData:GetShowRewardsCurExp()
  225. local curLv = self.rewardsBaseData:GetShowRewardsCurLv()
  226. --最终奖励宝箱
  227. if isEnd then
  228. self.uiBase:AddButtonUniqueEventListener(itemLua.btnBuyMore.button, self, self.OnClickGetAdvancedRewardBtn)
  229. local costExp = ManagerContainer.CfgMgr:GetRuneShopExploreCfgByRound(self.rewardsBaseData:GetShowRewardsRoundData()).ExpCost
  230. if self.rewardsBaseData:GetMaxRewardsNum() > 0 then
  231. itemLua.chestAnim.animator:Play('Open')
  232. itemLua.redPoint:SetActive(true)
  233. itemLua.btnBuyMore.num.text.text = tostring(self.rewardsBaseData:GetMaxRewardsNum())
  234. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.RuneShopRewards, true)
  235. else
  236. itemLua.chestAnim.animator:Play('Close')
  237. itemLua.redPoint:SetActive(false)
  238. end
  239. if self.rewardsBaseData:GetRewardsIsMax() then
  240. itemLua.airShip:SetActive(true)
  241. itemLua.levelSlider.slider.value = 1
  242. else
  243. if curLv == #self.rewardsBaseData:GetShowRewardsData() then
  244. itemLua.airShip:SetActive(true)
  245. itemLua.levelSlider.slider.value = curExp/costExp
  246. else
  247. itemLua.airShip:SetActive(false)
  248. end
  249. end
  250. itemLua.dsc.text.text.text = string.formatbykey("DscRewardsMax",tostring(costExp),'1')
  251. --通用item
  252. else
  253. --0级开始
  254. if idx == 0 then
  255. itemLua.startItem:SetActive(true)
  256. itemLua.rewardsBox2:SetActive(false)
  257. itemLua.levelBox2:SetActive(false)
  258. if curLv == 0 and curExp/self.curLvData.cfgData.Exp < 0.15 then
  259. itemLua.startItem.airShip:SetActive(true)
  260. else
  261. itemLua.startItem.airShip:SetActive(false)
  262. end
  263. --常规等级
  264. else
  265. CommonUtil.UpdateItemPrefab(self, itemLua, data, Enum.ItemIEnterType.Bag, self, nil)
  266. --self.tempItemLua = itemLua
  267. itemLua.numlv.text.text = idx
  268. itemLua.startItem:SetActive(false)
  269. itemLua.rewardsBox2:SetActive(true)
  270. itemLua.levelBox2:SetActive(true)
  271. itemLua.rewardsBox2.bgyellow:SetActive(false)
  272. if data.cfgData.RewardSign > 0 then
  273. itemLua.rewardsBox2.bgyellow:SetActive(true)
  274. end
  275. if data.isReward then
  276. --0为 默认状态
  277. if data.isReward == 0 then
  278. itemLua.rewardsLeft.arrived:SetActive(false)
  279. itemLua.rewardsLeft.received:SetActive(false)
  280. --1为已领取
  281. elseif data.isReward == 1 then
  282. itemLua.rewardsLeft.arrived:SetActive(false)
  283. itemLua.rewardsLeft.received:SetActive(true)
  284. --可领取
  285. elseif data.isReward == 2 then
  286. itemLua.rewardsLeft.arrived:SetActive(true)
  287. itemLua.rewardsLeft.received:SetActive(false)
  288. end
  289. else
  290. itemLua.rewardsLeft.arrived:SetActive(false)
  291. itemLua.rewardsLeft.received:SetActive(false)
  292. end
  293. if data.isCashReward and self.rewardsBaseData:GetRewardsIsCash()==1 then
  294. --0为 默认状态
  295. if data.isCashReward == 0 then
  296. itemLua.rewardsRight.arrived:SetActive(false)
  297. itemLua.rewardsRight.received:SetActive(false)
  298. --1为已领取
  299. elseif data.isCashReward == 1 then
  300. itemLua.rewardsRight.arrived:SetActive(false)
  301. itemLua.rewardsRight.received:SetActive(true)
  302. --可领取
  303. elseif data.isCashReward == 2 then
  304. itemLua.rewardsRight.arrived:SetActive(true)
  305. itemLua.rewardsRight.received:SetActive(false)
  306. end
  307. else
  308. itemLua.rewardsRight.arrived:SetActive(false)
  309. itemLua.rewardsRight.received:SetActive(false)
  310. end
  311. itemLua.activity:SetActive(false)
  312. --直接根据等级判断,小于当前等级的直接拉满,大于当前等级的则为空
  313. if curLv+1 > idx then
  314. itemLua.levelSlider.slider.value = 1
  315. itemLua.activity:SetActive(true)
  316. elseif curLv < idx+1 then
  317. itemLua.levelSlider.slider.value = 0
  318. end
  319. --左侧经验条slider,因遮挡问题,只有经验超出10%,小飞机才会飞到下一级
  320. if curLv == #self.rewardsBaseData:GetShowRewardsData() then
  321. itemLua.airShip:SetActive(false)
  322. else
  323. if curLv+1 == idx and curExp/self.curLvData.cfgData.Exp > 0.15 then
  324. itemLua.airShip:SetActive(true)
  325. --LogError('aaacc'..curExp.."aac"..self.curLvData.cfgData.Exp)
  326. itemLua.levelSlider.slider.value = curExp/self.curLvData.cfgData.Exp
  327. self.isShowAirShip = true
  328. else
  329. if curLv == idx and not self.isShowAirShip then
  330. itemLua.airShip:SetActive(true)
  331. --itemLua.levelSlider.slider.value = self.controller:GetShowRewardsCurExp()/self.curLvData.cfgData.Exp
  332. else
  333. itemLua.airShip:SetActive(false)
  334. end
  335. end
  336. end
  337. end
  338. end
  339. end
  340. function UIRuneShopExploreView:RefreshBigRewardsFloatTips(gridView)
  341. --通过content高度计算当前处于哪个位置
  342. local py = self.rewardsBoxItem.scrollView.content.transform.localPosition.y
  343. local mid = #self.rewardsBaseData:GetShowRewardsData() - self:Toint(py/240)
  344. --下方的大奖小图标
  345. local minid = self.controller:GetShowReardsNearMinCashReward(mid -3)
  346. if minid then
  347. self.rewardsBoxItem.btnGotoDown:SetActive(true)
  348. local logicData ={}
  349. local rdata=self.controller:GetShowRewardsDataByIdx(minid)
  350. if rdata.cfgData.RewardSign == 1 then
  351. logicData = {cfgId = rdata.cfgData.Reward[1][1],num = rdata.cfgData.Reward[1][2] , targetid = #self.controller:GetShowRewardsData()-minid}
  352. elseif rdata.cfgData.RewardSign == 2 then
  353. logicData = {cfgId = rdata.cfgData.CashReward[1][1],num = rdata.cfgData.CashReward[1][2] , targetid = #self.controller:GetShowRewardsData()-minid}
  354. end
  355. CommonUtil.UpdateItemPrefab(self, self.rewardsBoxItem.btnGotoDown.iconSmallItem, logicData, Enum.ItemIEnterType.Bag, self, self.JumpToTarget)
  356. else
  357. self.rewardsBoxItem.btnGotoDown:SetActive(false)
  358. end
  359. --上方的大奖小图标
  360. local maxid = self.controller:GetShowReardsNearMaxCashReward(mid +3)
  361. if maxid then
  362. self.rewardsBoxItem.btnGotoUp:SetActive(true)
  363. local logicData ={}
  364. local rdata=self.controller:GetShowRewardsDataByIdx(maxid)
  365. if rdata.cfgData.RewardSign == 1 then
  366. logicData = {cfgId = rdata.cfgData.Reward[1][1],num = rdata.cfgData.Reward[1][2] , targetid = #self.controller:GetShowRewardsData()-maxid}
  367. elseif rdata.cfgData.RewardSign == 2 then
  368. logicData = {cfgId = rdata.cfgData.CashReward[1][1],num = rdata.cfgData.CashReward[1][2] , targetid = #self.controller:GetShowRewardsData()-maxid}
  369. end
  370. CommonUtil.UpdateItemPrefab(self, self.rewardsBoxItem.btnGotoUp.iconSmallItem, logicData, Enum.ItemIEnterType.Bag, self, self.JumpToTarget)
  371. else
  372. self.rewardsBoxItem.btnGotoUp:SetActive(false)
  373. end
  374. end
  375. function UIRuneShopExploreView:Toint(n)
  376. local s = tostring(n)
  377. local i,j = s:find('%.')
  378. if i then
  379. return tonumber(s:sub(1,i-1))
  380. else
  381. return n
  382. end
  383. end
  384. function UIRuneShopExploreView:GetItemByRowColumnRewards(loopGridView, itemIdx, row, column)
  385. --通用等级奖励
  386. local item
  387. if itemIdx == 0 then
  388. item = loopGridView:NewListViewItem('CloudTop')
  389. local itemEndLua = CommonUtil.BindGridViewItem2Lua(self, 'CloudTop', item.gameObject)
  390. self:UpdateRewardsItem(itemEndLua , itemIdx , data ,true)
  391. else
  392. item = loopGridView:NewListViewItem('RuneShopRewardsItem')
  393. local itemLua = CommonUtil.BindGridViewItem2Lua(self, 'RuneShopRewardsItem', item.gameObject)
  394. local data
  395. local showGoodsDatas = self.controller:GetShowRewardsData()
  396. local length = (showGoodsDatas and #showGoodsDatas or 0)
  397. if itemIdx-1 < length then
  398. data = self.controller:GetShowRewardsDataByIdx(length-(itemIdx-1))
  399. end
  400. self:UpdateRewardsItem(itemLua , length-(itemIdx-1) , data)
  401. end
  402. return item
  403. end
  404. function UIRuneShopExploreView:RefreshCurrenyItem(itemLua, itemCfgId, itemNum, ignoreIcon)
  405. if not itemCfgId or not itemNum then
  406. itemLua:SetActive(false)
  407. return
  408. end
  409. itemLua.number.text.text = CommonUtil.FormatNumber(itemNum)
  410. itemLua:SetActive(true)
  411. if ignoreIcon then return end
  412. itemLua.icon.image.sprite = nil
  413. itemLua.icon.image.enabled = false
  414. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(itemCfgId)
  415. if itemCfgData then
  416. CommonUtil.LoadIcon(self, itemCfgData.MiniIcon, function(sprite)
  417. if sprite then
  418. itemLua.icon.image.sprite = sprite
  419. itemLua.icon.image.enabled = true
  420. end
  421. end)
  422. end
  423. end
  424. function UIRuneShopExploreView:StartRefreshTimer(itemLua, goodsData)
  425. local timer = self.refreshTimer
  426. if not timer then
  427. timer = Timer.New(slot(self.RefreshTimer, self), 1, -1)
  428. self.refreshTimer = timer
  429. end
  430. local updateItemMap = timer.updateItemMap
  431. if not updateItemMap then
  432. updateItemMap = {}
  433. timer.updateItemMap = updateItemMap
  434. end
  435. updateItemMap[itemLua] = goodsData
  436. if not timer.running then
  437. timer:Start()
  438. end
  439. end
  440. function UIRuneShopExploreView:StopRefreshTimer(itemLua)
  441. local timer = self.refreshTimer
  442. if timer then
  443. local updateItemMap = timer.updateItemMap
  444. if updateItemMap then
  445. updateItemMap[itemLua] = nil
  446. end
  447. if not updateItemMap or table_is_empty(updateItemMap) then
  448. timer:Stop()
  449. end
  450. end
  451. end
  452. function UIRuneShopExploreView:StopAndClearRefreshTimer()
  453. if self.refreshTimer then
  454. self.refreshTimer:Stop()
  455. self.refreshTimer.time = 1
  456. self.refreshTimer.duration = 1
  457. self.refreshTimer.updateItemMap = nil
  458. end
  459. end
  460. function UIRuneShopExploreView:DisposeRefreshTimer()
  461. self:StopAndClearRefreshTimer()
  462. self.refreshTimer = nil
  463. end
  464. function UIRuneShopExploreView:RefreshTimer()
  465. local timer = self.refreshTimer
  466. if not timer then return end
  467. local updateItemMap = timer.updateItemMap
  468. if not updateItemMap or table_is_empty(updateItemMap) then
  469. timer:Stop()
  470. return
  471. end
  472. local minRemainTime = nil
  473. local endTime = self.controller:GetRewardsRemainTime()
  474. if endTime then
  475. if endTime < 0 then
  476. endTime = 0
  477. end
  478. if endTime <= 0 then
  479. timer.updateItemMap = nil
  480. if ManagerContainer.LuaUIMgr:HasOpenPage(Enum.UIPageName.UIRewardsBuyTips) then
  481. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIRewardsBuyTips)
  482. end
  483. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.RuneShopRewards, false)
  484. ManagerContainer.CfgMgr.RuneShopExploreRewardCfg =nil
  485. ManagerContainer.CfgMgr.RuneShopRoundMap = nil
  486. self.rewardsToggle:SetActive(false)
  487. end
  488. self.rewardsBoxItem.timeBox:SetActive(true)
  489. self.rewardsBoxItem.timeBox.textTime.text.text = string.formatbykey('AirshipTime', DateTimeUtil.convertSeconds2TimeStr1(endTime, true, true, false))
  490. else
  491. self.rewardsBoxItem.timeBox:SetActive(false)
  492. timer.updateItemMap = nil
  493. end
  494. if endTime and endTime > 0 then
  495. if not minRemainTime or minRemainTime > endTime then
  496. minRemainTime = endTime
  497. end
  498. end
  499. if not minRemainTime or minRemainTime <= 0 then
  500. self:StopRefreshTimer()
  501. else
  502. -- 降低刷新频率
  503. if self.refreshTimer then
  504. local validTime = nil
  505. if minRemainTime >= 86400 then
  506. validTime = minRemainTime % 3600
  507. if validTime == 0 then validTime = 3600 end
  508. elseif minRemainTime >= 3600 then
  509. validTime = minRemainTime % 60
  510. if validTime == 0 then validTime = 60 end
  511. else
  512. validTime = 1
  513. end
  514. if validTime then
  515. self.refreshTimer.duration = validTime
  516. else
  517. self:StopRefreshTimer()
  518. end
  519. end
  520. end
  521. end
  522. return UIRuneShopExploreView