UISummonView.lua 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. local UISummonView = require("UISummon/UISummonView_Generate")
  2. function UISummonView:OnAwake(data)
  3. self.controller = require("UISummon/UISummonCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UISummonView:AddEventListener()
  8. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ITEM_CHANGE, self, self.OnItemChanged)
  9. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.DIAMOND_CHANGED, self, self.OnDiamondChanged)
  10. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SUMMON_DATA_CHANGED, self, self.OnSummonDataChanged)
  11. end
  12. function UISummonView:FillContent(data, uiBase)
  13. self.uiBase = uiBase
  14. local gameObject = self.uiBase:GetRoot()
  15. if gameObject ~= nil then
  16. self.gameObject = gameObject
  17. self.transform = gameObject.transform
  18. end
  19. self:InitGenerate(self.transform, data)
  20. self:Init()
  21. end
  22. function UISummonView:Init()
  23. -- 清除红点信息
  24. self.controller:ReadyData()
  25. self.dot:SetActive(false)
  26. self.isMoving = false
  27. self.window.animator:Play('UIShow')
  28. self.currency:SetActive(false)
  29. local initParam = SuperScrollView.LoopListViewInitParam()
  30. initParam.mSmoothDumpRate = 0.05
  31. initParam.mSnapVecThreshold = 9999
  32. self.scrollView.loopListView.OffsetSnapCenterPercent = 0.4
  33. self.scrollView.loopListView.ItemSnapEnable = true
  34. self.scrollView.loopListView:InitListView(-1, function(loopListView, idx)
  35. return self:GetItemByIndex(loopListView, idx)
  36. end, nil, initParam)
  37. self.scrollView.loopListView:MovePanelToItemIndex(self.controller:GetListIdx(), 0)
  38. self:RefreshView()
  39. local isFromActivity = self.controller:GetEnterType()
  40. self.timeBox:SetActive(isFromActivity)
  41. if isFromActivity then --打开是否来自活动界面
  42. self:InitTop()
  43. end
  44. end
  45. function UISummonView:InitTop()
  46. if not self.updateTimer then
  47. self.updateTimer = Timer.New(slot(self.UpdateMinute, self), 1, -1)
  48. end
  49. if not self.updateTimer.running then
  50. self.updateTimer:Start()
  51. end
  52. self:RefreshRemainTime()
  53. end
  54. function UISummonView:RefreshRemainTime()
  55. local remainTime = self.controller:GetRemainTime()
  56. if not remainTime or remainTime <= 0 then
  57. self:StopRefreshTimer()
  58. self:OnClickCloseBtn()
  59. return false
  60. else
  61. if self.updateTimer then
  62. local validTime = nil
  63. if remainTime >= 86400 then
  64. validTime = remainTime % 3600
  65. if validTime == 0 then validTime = 3600 end
  66. elseif remainTime >= 3600 then
  67. validTime = remainTime % 60
  68. if validTime == 0 then validTime = 60 end
  69. else
  70. validTime = 1
  71. end
  72. if validTime then
  73. self.updateTimer.duration = validTime
  74. else
  75. self:StopRefreshTimer()
  76. end
  77. end
  78. end
  79. self.timeBox.TimeTxt.text.text = DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false)
  80. return true
  81. end
  82. function UISummonView:StopRefreshTimer()
  83. if self.updateTimer then
  84. self.updateTimer:Stop()
  85. end
  86. end
  87. function UISummonView:UpdateMinute()
  88. self:RefreshRemainTime()
  89. end
  90. function UISummonView:RemoveEventListener()
  91. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  92. self.scrollView.loopListView.mOnSnapItemFinished = nil
  93. end
  94. function UISummonView:AddUIEventListener()
  95. self.uiBase:AddButtonUniqueEventListener(self.AnyBtn.button, self, self.OnClickCloseBtn)
  96. self.uiBase:AddButtonUniqueEventListener(self.btnClose.button, self, self.OnClickCloseBtn)
  97. self.uiBase:AddButtonUniqueEventListener(self.btnPlayRule.button, self, self.OnClickPlayRuleBtn)
  98. self.uiBase:AddButtonUniqueEventListener(self.btnOne.button, self, self.OnClickSummonBtn, 1)
  99. self.uiBase:AddButtonUniqueEventListener(self.btnFive.button, self, self.OnClickSummonBtn, 2)
  100. self.uiBase:AddButtonUniqueEventListener(self.btnArrowL.button, self, self.OnClickArrowBtn, false)
  101. self.uiBase:AddButtonUniqueEventListener(self.btnArrowR.button, self, self.OnClickArrowBtn, true)
  102. self.scrollView.loopListView.mOnBeginDragAction = function()
  103. return self:OnBeginDragAction()
  104. end
  105. self.scrollView.loopListView.mOnSnapItemFinished = function(loopListView, loopListViewItem)
  106. return self:OnSnapItemFinished(loopListView, loopListViewItem)
  107. end
  108. end
  109. function UISummonView:OnHide()
  110. end
  111. function UISummonView:OnShow(data)
  112. if data then
  113. self.controller:SetData(data)
  114. end
  115. self.scrollView.loopListView:RefreshAllShownItem()
  116. self:RefreshTopCurrency()
  117. self:RefreshCostCurrency()
  118. self:RefreshSummonBtn()
  119. --打开限时礼包
  120. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.LIMIT_RECHARGE_OPEN_UI_NTF)
  121. end
  122. function UISummonView:OnClose()
  123. if self.updateTimer then
  124. self.updateTimer:Stop()
  125. self.updateTimer = nil
  126. end
  127. end
  128. function UISummonView:OnDispose()
  129. self:DisposeCurrency()
  130. self:DisposeDot()
  131. self.isMoving = nil
  132. self.scrollView.loopListView:Dispose()
  133. self.controller:OnDispose()
  134. end
  135. function UISummonView:OnItemChanged()
  136. self:RefreshTopCurrency()
  137. self:RefreshCostCurrency()
  138. end
  139. function UISummonView:OnDiamondChanged()
  140. self:RefreshTopCurrency()
  141. self:RefreshCostCurrency()
  142. end
  143. function UISummonView:OnSummonDataChanged()
  144. if not ManagerContainer.LuaUIMgr:HasOpenPage(Enum.UIPageName.UISummon) then
  145. return
  146. end
  147. if not ManagerContainer.LuaUIMgr:HasOpenPage(Enum.UIPageName.UISummonAnim) then
  148. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UISummonAnim, nil, self.uiData.id)
  149. end
  150. end
  151. function UISummonView:OnClickCloseBtn()
  152. ManagerContainer.LuaUIMgr:OpenSourceUI(self)
  153. end
  154. function UISummonView:OnClickPlayRuleBtn()
  155. local actId = self.controller:GetActivityId()
  156. if actId then
  157. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPlayRule, {'PlayExplainTitle', 'SummonPlayExplain_'..actId})
  158. else
  159. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPlayRule, {'PlayExplainTitle', 'SummonPlayExplain'})
  160. end
  161. end
  162. function UISummonView:OnClickCurrencyBuyBtn(_, params)
  163. local cfgId = params[0]
  164. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  165. if not itemCfgData then return end
  166. if itemCfgData.ResType == Enum.ItemType.Diamond then
  167. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRuneShopBT, {Enum.RuneShopType.Gifts, Enum.RuneShopSubType.Gold}, self.uiData.id)
  168. end
  169. end
  170. function UISummonView:SureBuy(idx)
  171. local errorCode, summonNum, remainSummonNum, vaildCosts = self.controller:GetSendSummonReqErrorCode(idx)
  172. if errorCode == 0 then
  173. errorCode = self.controller:SendSummonReq(summonNum)
  174. if errorCode ~= 0 then
  175. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  176. end
  177. elseif errorCode == 1 then
  178. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  179. elseif errorCode == 2 then
  180. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  181. elseif errorCode == 3 then
  182. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  183. elseif errorCode == 4 then
  184. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  185. else
  186. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  187. end
  188. end
  189. function UISummonView:SureJumpBuy(idx)
  190. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRuneShopBT, {Enum.RuneShopType.Gifts, Enum.RuneShopSubType.Gold}, self.uiData.id)
  191. end
  192. function UISummonView:OnClickSummonBtn(_, params)
  193. local idx = params[0]
  194. local errorCode, summonNum, remainSummonNum, vaildCosts = self.controller:GetSendSummonReqErrorCode(idx)
  195. if errorCode == 0 then
  196. local len = #vaildCosts
  197. if len > 1 then
  198. local vaildCost = vaildCosts[len]
  199. local cfgId = vaildCost[1]
  200. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  201. if itemCfgData.ResType == Enum.ItemType.Diamond and vaildCost[4] < summonNum then
  202. local paramData = {}
  203. local vaildCost2 = vaildCosts[1]
  204. local cfgId2 = vaildCost2[1]
  205. local itemCfgData2 = ManagerContainer.CfgMgr:GetItemById(cfgId2)
  206. paramData[1] = itemCfgData2 and string.formatbykey(itemCfgData2.Name) or ''
  207. paramData[2] = string.formatbykey('Supplementary', tostring(vaildCost[3] * vaildCost[4]), itemCfgData and string.formatbykey(itemCfgData.Name) or '', tostring(vaildCost[4]), paramData[1])
  208. local data = {"SummonNoItemTip", paramData, idx, self, self.SureBuy}
  209. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UINoticeTips, data)
  210. else
  211. errorCode = self.controller:SendSummonReq(summonNum)
  212. if errorCode ~= 0 then
  213. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  214. end
  215. end
  216. else
  217. errorCode = self.controller:SendSummonReq(summonNum)
  218. if errorCode ~= 0 then
  219. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  220. end
  221. end
  222. elseif errorCode == 1 then
  223. local len = #vaildCosts
  224. if len >= 1 then
  225. local vaildCost = vaildCosts[len]
  226. if Constant.OpenPay then
  227. local cfgId = vaildCost[1]
  228. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  229. if itemCfgData.ResType == Enum.ItemType.Diamond then
  230. local data = {"SummonNoDiamondTip", nil, idx, self, self.SureJumpBuy}
  231. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UINoticeTips, data)
  232. return
  233. end
  234. end
  235. end
  236. local vaildCost = vaildCosts[1]
  237. local cfgId = vaildCost[1]
  238. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  239. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam('InsufficientQuantity', itemCfgData and string.formatbykey(itemCfgData.Name) or '', '')
  240. elseif errorCode == 2 then
  241. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  242. elseif errorCode == 3 then
  243. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  244. elseif errorCode == 4 then
  245. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  246. else
  247. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  248. end
  249. end
  250. function UISummonView:OnClickArrowBtn(_, params)
  251. local isRight = params[0]
  252. local listIdx = self.controller:GetListIdx()
  253. if isRight then
  254. listIdx = listIdx + 1
  255. else
  256. listIdx = listIdx - 1
  257. end
  258. self.scrollView.loopListView:SetSnapTargetItemIndex(listIdx)
  259. self.isMoving = true
  260. self.window.animator:Play('UIRemove')
  261. end
  262. function UISummonView:OnClickDetailsBtn(btn, params)
  263. local showList = params[0]
  264. table.sort(showList,function(a,b)
  265. local cfgA = ManagerContainer.CfgMgr:GetItemById(a)
  266. local cfgB = ManagerContainer.CfgMgr:GetItemById(b)
  267. if cfgA and cfgB then
  268. if cfgA.Quality == cfgB.Quality then
  269. if cfgA.ResType == Enum.ItemType.SkillEquip or cfgB.ResType == Enum.ItemType.SkillEquip then
  270. local artifactA = ManagerContainer.CfgMgr:GetArtifactCfgDataByCfgId(cfgA.Id)
  271. local artifactB = ManagerContainer.CfgMgr:GetArtifactCfgDataByCfgId(cfgB.Id)
  272. if artifactA and artifactB then
  273. if artifactA.ArtifactMaxLevel == artifactB.ArtifactMaxLevel then
  274. return cfgA.Id > cfgB.Id
  275. else
  276. return artifactA.ArtifactMaxLevel > artifactB.ArtifactMaxLevel
  277. end
  278. end
  279. else
  280. return cfgA.Id > cfgB.Id
  281. end
  282. else
  283. return cfgA.Quality > cfgB.Quality
  284. end
  285. end
  286. end)
  287. --LogError("=============="..Inspect(showList))
  288. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIArtifactRewardsList,showList)
  289. end
  290. function UISummonView:OnBeginDragAction()
  291. self.isMoving = true
  292. self.window.animator:Play('UIRemove')
  293. end
  294. function UISummonView:OnSnapItemFinished(loopListView, loopListViewItem)
  295. self.isMoving = false
  296. self.window.animator:Play('UIShow')
  297. if not self.controller:SetListIdx(loopListViewItem.ItemIndex) then
  298. return
  299. end
  300. self:RefreshView()
  301. end
  302. function UISummonView:GetItemByIndex(loopListView, listIdx)
  303. local idx = self.controller:GetSelectIdxByListIdx(listIdx)
  304. local cfg = self.controller:GetCfgByIdx(idx)
  305. if not cfg then return nil end
  306. local item = loopListView:NewListViewItem('UISummonItem')
  307. local itemLua = CommonUtil.BindGridViewItem2Lua(self, 'UISummonItem', item.gameObject)
  308. if itemLua then
  309. itemLua.banner.image.enabled = false
  310. itemLua.banner.image.sprite = nil
  311. CommonUtil.LoadIcon(self, cfg.ShowImg, function(sprite)
  312. if sprite then
  313. itemLua.banner.image.sprite = sprite
  314. itemLua.banner.image.enabled = true
  315. end
  316. end, itemLua, 'BannerIconAsync')
  317. local summonShow = cfg.Show
  318. local isShow = summonShow and #summonShow > 0
  319. itemLua.btnDetails:SetActive(isShow)
  320. if isShow then
  321. self.uiBase:AddButtonUniqueEventListener(itemLua.btnDetails.button, self, self.OnClickDetailsBtn, summonShow)
  322. end
  323. if not cfg.Total or cfg.Total <= 0 then
  324. itemLua.extraBox:SetActive(false)
  325. else
  326. itemLua.extraBox:SetActive(true)
  327. local summonNum = self.controller:GetSummonNumByIdx(idx)
  328. local percent = (summonNum / cfg.Total)
  329. itemLua.extraRewardItem.rewardSlider.slider.value = percent
  330. local validPercent = CommonUtil.GetPreciseDecimal(percent * 100)
  331. if validPercent <= 0 and summonNum > 0 then
  332. validPercent = 1
  333. end
  334. itemLua.extraRewardItem.percentTxt.text.text = tostring(validPercent) .. '%'
  335. end
  336. end
  337. item.CachedRectTransform:SetSizeWithCurrentAnchors(UnityEngine.RectTransform.Axis.Horizontal, loopListView.ViewPortWidth)
  338. return item
  339. end
  340. function UISummonView:RefreshView()
  341. self:RefreshSummonBtn()
  342. self:RefreshTopCurrency()
  343. local selectIdx = self.controller:GetSelectIdx()
  344. local length = self.controller:GetCfgLength()
  345. if length <= 1 then
  346. self.btnArrowL:SetActive(false)
  347. self.btnArrowR:SetActive(false)
  348. else
  349. self.btnArrowL:SetActive(true)
  350. self.btnArrowR:SetActive(true)
  351. end
  352. if not self.dots then self.dots = {} end
  353. local num = #self.dots
  354. local dot = nil
  355. local parent = self.dotToggleGroup.transform
  356. for i = 1, length do
  357. if i <= num then
  358. dot = self.dots[i]
  359. else
  360. dot = CommonUtil.Instantiate(self.dot.gameObject, parent)
  361. if tolua.getpeer(dot) == nil then
  362. tolua.setpeer(dot, {})
  363. end
  364. dot.toggle = dot:GetComponent(Enum.TypeInfo.Toggle)
  365. self.dots[i] = dot
  366. end
  367. dot:SetActive(true)
  368. dot.toggle.isOn = (i == selectIdx)
  369. end
  370. for i = length + 1, num do
  371. dot = self.dots[i]
  372. dot:SetActive(false)
  373. end
  374. end
  375. function UISummonView:RefreshSummonBtn()
  376. local selectIdx = self.controller:GetSelectIdx()
  377. local cfg = self.controller:GetCfgByIdx(selectIdx)
  378. if cfg.UnLock and cfg.UnLock > 0 then
  379. local result, val, content = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(cfg.UnLock)
  380. if not result then
  381. self.leftAnim:SetActive(false)
  382. self.rightAnim:SetActive(false)
  383. self.lockAnim:SetActive(true)
  384. self.lockTxt.text.text = tostring(content)
  385. return
  386. end
  387. end
  388. self.leftAnim:SetActive(true)
  389. self.rightAnim:SetActive(true)
  390. self.lockAnim:SetActive(false)
  391. self:RefreshCostCurrency()
  392. end
  393. function UISummonView:RefreshTopCurrency()
  394. local selectIdx = self.controller:GetSelectIdx()
  395. local cfg = self.controller:GetCfgByIdx(selectIdx)
  396. local costs = cfg.Cost
  397. local num = costs and #costs or 0
  398. local length = 0
  399. if not self.currencys then
  400. self.currencys = {}
  401. else
  402. length = #self.currencys
  403. end
  404. local parent = self.currency.transform.parent
  405. for i = 1, num do
  406. local currency = nil
  407. if i <= length then
  408. currency = self.currencys[i]
  409. else
  410. currency = CommonUtil.Instantiate(self.currency.gameObject, parent)
  411. if tolua.getpeer(currency) == nil then
  412. tolua.setpeer(currency, {})
  413. end
  414. local icon = currency.transform:Find('Icon').gameObject
  415. if tolua.getpeer(icon) == nil then
  416. tolua.setpeer(icon, {})
  417. end
  418. icon.image = icon:GetComponent(Enum.TypeInfo.Image)
  419. currency.icon = icon
  420. local number = currency.transform:Find('Number').gameObject
  421. if tolua.getpeer(number) == nil then
  422. tolua.setpeer(number, {})
  423. end
  424. number.text = number:GetComponent(Enum.TypeInfo.Text)
  425. currency.number = number
  426. local btnBuy = currency.transform:Find('BtnBuy').gameObject
  427. if tolua.getpeer(btnBuy) == nil then
  428. tolua.setpeer(btnBuy, {})
  429. end
  430. btnBuy.button = btnBuy:GetComponent(Enum.TypeInfo.Button)
  431. currency.btnBuy = btnBuy
  432. self.currencys[i] = currency
  433. end
  434. currency:SetActive(true)
  435. currency.icon.image.enabled = false
  436. currency.icon.image.sprite = nil
  437. local cfgId = tonumber(costs[i][1])
  438. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  439. if itemCfgData then
  440. CommonUtil.LoadIcon(self, itemCfgData.MiniIcon, function(sprite)
  441. if sprite then
  442. currency.icon.image.sprite = sprite
  443. currency.icon.image.enabled = true
  444. end
  445. end)
  446. if itemCfgData.ResType == Enum.ItemType.Diamond then
  447. currency.btnBuy:SetActive(Constant.OpenPay)
  448. self.uiBase:AddButtonUniqueEventListener(currency.btnBuy.button, self, self.OnClickCurrencyBuyBtn, cfgId)
  449. else
  450. currency.btnBuy:SetActive(false)
  451. currency.btnBuy.button.onClick:RemoveAllListeners()
  452. end
  453. else
  454. currency.btnBuy:SetActive(false)
  455. currency.btnBuy.button.onClick:RemoveAllListeners()
  456. end
  457. currency.number.text.text = CommonUtil.FormatNumber(self.controller:GetOwnResCountByItemId(cfgId))
  458. end
  459. for i = num + 1, length do
  460. local currency = self.currencys[i]
  461. currency:SetActive(false)
  462. currency.btnBuy:SetActive(false)
  463. currency.btnBuy.button.onClick:RemoveAllListeners()
  464. end
  465. end
  466. function UISummonView:RefreshCostCurrency()
  467. local selectIdx = self.controller:GetSelectIdx()
  468. local cfg = self.controller:GetCfgByIdx(selectIdx)
  469. local method = cfg.Method
  470. local costs = cfg.Cost
  471. local costCfgId, costNum
  472. local cost = nil
  473. if costs then
  474. local costLength = #costs
  475. for i = 1, costLength do
  476. cost = costs[i]
  477. if self.controller:GetOwnResCountByItemId(cost[1]) > 0 or i == costLength then
  478. costCfgId = tonumber(cost[1])
  479. costNum = tonumber(cost[2])
  480. break
  481. end
  482. end
  483. end
  484. self.currencyOne.icon.image.enabled = false
  485. self.currencyOne.icon.image.sprite = nil
  486. self.currencyFive.icon.image.enabled = false
  487. self.currencyFive.icon.image.sprite = nil
  488. if not costCfgId or not costNum or not method then
  489. self.leftAnim:SetActive(false)
  490. self.rightAnim:SetActive(false)
  491. else
  492. local method1 = method[1]
  493. local method2 = method[2]
  494. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(costCfgId)
  495. CommonUtil.LoadIcon(self, itemCfgData.MiniIcon, function(sprite)
  496. if sprite then
  497. self.currencyOne.icon.image.sprite = sprite
  498. self.currencyOne.icon.image.enabled = true
  499. self.currencyFive.icon.image.sprite = sprite
  500. self.currencyFive.icon.image.enabled = true
  501. end
  502. end)
  503. if method1 then
  504. self.currencyOne.number.text.text = tostring(tonumber(method1) * costNum)
  505. self.leftAnim:SetActive(true)
  506. else
  507. self.leftAnim:SetActive(false)
  508. end
  509. if method2 then
  510. self.currencyFive.number.text.text = tostring(tonumber(method2) * costNum)
  511. self.rightAnim:SetActive(true)
  512. else
  513. self.rightAnim:SetActive(false)
  514. end
  515. end
  516. end
  517. function UISummonView:DisposeCurrency()
  518. if not self.currencys then return end
  519. for _, currency in pairs(self.currencys) do
  520. CommonUtil.DestroyGO(currency)
  521. if tolua.getpeer(currency.btnBuy) ~= nil then
  522. tolua.setpeer(currency.btnBuy, nil)
  523. end
  524. if tolua.getpeer(currency.number) ~= nil then
  525. tolua.setpeer(currency.number, nil)
  526. end
  527. if tolua.getpeer(currency.icon) ~= nil then
  528. tolua.setpeer(currency.icon, nil)
  529. end
  530. if tolua.getpeer(currency) ~= nil then
  531. tolua.setpeer(currency, nil)
  532. end
  533. end
  534. self.currencys = nil
  535. end
  536. function UISummonView:DisposeDot()
  537. if not self.dots then return end
  538. for _, dot in pairs(self.dots) do
  539. CommonUtil.DestroyGO(dot)
  540. dot.toggle = nil
  541. if tolua.getpeer(dot) ~= nil then
  542. tolua.setpeer(dot, nil)
  543. end
  544. end
  545. self.dots = nil
  546. end
  547. return UISummonView