UIBoliShopView.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. local UIBoliShopView = require("UIRuneShop/UIBoliShopView_Generate")
  2. local IsRefreshBtnItem
  3. local LastItemIdx
  4. local redpointState = false
  5. local IconItemCtr = require("Common/IconItemCtr")
  6. function UIBoliShopView:OnAwake(data)
  7. self.controller = require("UIRuneShop/UIBoliShopCtr"):new()
  8. self.controller:Init(self)
  9. self.controller:SetData(data)
  10. end
  11. function UIBoliShopView:AddEventListener()
  12. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  13. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.COIN_CHANGED, self, self.RefreshCoins)
  14. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.DIAMOND_CHANGED, self, self.RefreshDiamond)
  15. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ROCOIN_CHANGED, self, self.RefreshROCoin)
  16. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ROBOLISHOP_EXP_CHANGE, self, self.RefreshCurExp)
  17. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.VIP_LV_CHANGED, self, self.RefreshVipView)
  18. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ON_BOLISHOP_DATA_CHANGE, self, self.RefreshBoliShopData)
  19. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ON_BOLISHOP_INFO_REFRESH, self, self.RefreshGoodsItemsScroll)
  20. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ON_BOLISHOP_REWARD_TIPS, self, self.OpenRewardsView)
  21. end
  22. function UIBoliShopView:OpenRewardsView(data)
  23. if data then
  24. local rewards = {}
  25. for key, value in pairs(data) do
  26. table.insert(rewards,{cfgId = value.key, num = value.value})
  27. end
  28. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPOPGot,{rewards = rewards})
  29. end
  30. end
  31. function UIBoliShopView:RefreshVipView()
  32. local curVipLv = ManagerContainer.DataMgr.UserData:GetVipLv()
  33. local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(curVipLv)
  34. self.vipIcon.image.sprite = nil
  35. self.vipIcon.image.enabled = false
  36. self.vipFrame.image.sprite = nil
  37. self.vipFrame.image.enabled = false
  38. if not vipCfg then
  39. self.vipNameTxt.text.text = ''
  40. return
  41. end
  42. CommonUtil.LoadIcon(self, vipCfg.BigIcon, function(sprite)
  43. if sprite then
  44. self.vipIcon.image.sprite = sprite
  45. self.vipIcon.image.enabled = true
  46. end
  47. end)
  48. CommonUtil.LoadIcon(self, vipCfg.BigFrame, function(sprite)
  49. if sprite then
  50. self.vipFrame.image.sprite = sprite
  51. self.vipFrame.image.enabled = true
  52. end
  53. end)
  54. self.vipNameTxt.text.text = string.formatbykey(vipCfg.Name)
  55. end
  56. function UIBoliShopView:RefreshCoins()
  57. local coin = ManagerContainer.DataMgr.UserData:GetOwnCoin()
  58. self.coin.number.text.text = CommonUtil.FormatNumber(coin)
  59. end
  60. function UIBoliShopView:RefreshROCoin()
  61. local count = CommonUtil.GetOwnResCountByItemId(Enum.ItemType.ROCoin)
  62. self.ro.number.text.text = CommonUtil.FormatNumber(count)
  63. end
  64. function UIBoliShopView:RefreshDiamond()
  65. local count = CommonUtil.GetOwnResCountByItemId(Enum.ItemType.Diamond)
  66. self.gold.number.text.text = CommonUtil.FormatNumber(count)
  67. end
  68. function UIBoliShopView:FillContent(data, uiBase)
  69. self.uiBase = uiBase
  70. local gameObject = self.uiBase:GetRoot()
  71. if gameObject ~= nil then
  72. self.gameObject = gameObject
  73. self.transform = gameObject.transform
  74. end
  75. self:InitGenerate(self.transform, data)
  76. self:Init()
  77. end
  78. function UIBoliShopView:Init()
  79. self:RefreshCoins()
  80. self:RefreshROCoin()
  81. self:RefreshDiamond()
  82. self.shopExpBox:SetActive(true)
  83. self:InitGridView()
  84. local enterType = self.controller:SetCurEnterType(1)
  85. self.privilegeToggle.toggle.isOn = true
  86. self:OnValueChangedToggle(nil,enterType,true)
  87. end
  88. function UIBoliShopView:OnPageInEnd()
  89. self.super.OnPageInEnd(self)
  90. self.scrollViewLv.scrollRect.enabled = true
  91. self.informationScrollView.scrollRect.enabled = true
  92. self.goodsScrollView.scrollRect.enabled = true
  93. end
  94. function UIBoliShopView:RefreshCurExp()
  95. local curlv = ManagerContainer.DataMgr.BoliShopData:GetCurLv()
  96. local curExp = ManagerContainer.DataMgr.BoliShopData:GetCurExp()
  97. local curData = ManagerContainer.CfgMgr:GetBoLiVipCfgById(curlv)
  98. local nextData = ManagerContainer.CfgMgr:GetBoLiVipCfgById(curlv + 1)
  99. local BoliVipCfg = ManagerContainer.CfgMgr:GetBoliVipCfg()
  100. self.maxCfgData = BoliVipCfg[#BoliVipCfg]
  101. local maxcfgData = BoliVipCfg[#BoliVipCfg - 1]
  102. if maxcfgData then
  103. self.maxExp = maxcfgData.VipExp
  104. end
  105. local exp = self.maxCfgData.Lv == curlv and self.maxExp or curData.VipExp
  106. self.numlv.text.text = tostring(curlv)
  107. if curData then
  108. self.numexp.text.text = curExp .."/"..exp
  109. self.expSlider.slider.value = curExp/curData.VipExp
  110. end
  111. self.max:SetActive(nextData == nil)
  112. self.btnLvUp:SetActive(nextData ~= nil)
  113. self.controller:RefreshGoodsData()
  114. end
  115. function UIBoliShopView:InitGridView()
  116. self.scrollViewLv.scrollRect.enabled = false
  117. self.informationScrollView.scrollRect.enabled = false
  118. self.goodsScrollView.scrollRect.enabled = false
  119. self.scrollViewLv.loopGridView:InitGridView(0, function(gridView, itemIndex, row, column)
  120. return self:GetItemByRowColumn(gridView, itemIndex, row, column)
  121. end, nil)
  122. self.informationScrollView.loopGridView:InitGridView(0, function(gridView, itemIndex, row, column)
  123. return self:GetVipDescItemByRowColumn(gridView, itemIndex, row, column)
  124. end, nil)
  125. self.goodsScrollView.loopGridView:InitGridView(0, function(gridView, itemIndex, row, column)
  126. return self:GetGoodsItemByRowColumn(gridView, itemIndex, row, column)
  127. end, nil)
  128. self.controller:RefreshsvipLvShowDatas()
  129. end
  130. function UIBoliShopView:RefreshBtnLvScroll()
  131. if self.controller:GetCurEnterType() ~= 1 then
  132. return
  133. end
  134. redpointState = false
  135. local len = self.controller:GetBoliVipLvDataLengths()
  136. self.scrollViewLv.loopGridView:RefreshListByIndex(len,0)
  137. self.privilegeToggle.redPoint:SetActive(redpointState)
  138. local isHide = self:GetIsHideShopBtn()
  139. self.shopToggle:SetActive(isHide)
  140. end
  141. function UIBoliShopView:GetIsHideShopBtn()
  142. local curLv = ManagerContainer.DataMgr.BoliShopData:GetCurLv()
  143. local showTime = ManagerContainer.DataMgr.BoliShopData:GetShowTime()
  144. local serverTime = ManagerContainer.LuaTimerMgr:CurLuaServerTime()
  145. local time = type(serverTime) == "number" and serverTime or #serverTime
  146. return curLv >= 1 and showTime > 0 and time >= showTime
  147. end
  148. function UIBoliShopView:StartShopGoodsItemTimer(itemLua, goodsData)
  149. local timer = self.shopGoodsItemTimer
  150. if not timer then
  151. timer = Timer.New(function()
  152. self:RefreshShopGoodsItemTimer()
  153. end, 1, -1)
  154. self.shopGoodsItemTimer = timer
  155. end
  156. local updateItemMap = timer.updateItemMap
  157. if not updateItemMap then
  158. updateItemMap = {}
  159. timer.updateItemMap = updateItemMap
  160. end
  161. updateItemMap[itemLua] = goodsData
  162. if not timer.running then
  163. timer:Start()
  164. end
  165. end
  166. function UIBoliShopView:StopShopGoodsItemTimer(itemLua)
  167. local timer = self.shopGoodsItemTimer
  168. if timer then
  169. local updateItemMap = timer.updateItemMap
  170. if updateItemMap then
  171. updateItemMap[itemLua] = nil
  172. end
  173. if not updateItemMap or table_is_empty(updateItemMap) then
  174. timer:Stop()
  175. end
  176. end
  177. end
  178. function UIBoliShopView:DisposeShopGoodsItemTimer()
  179. if self.shopGoodsItemTimer then
  180. self.shopGoodsItemTimer:Stop()
  181. self.shopGoodsItemTimer.updateItemMap = nil
  182. self.shopGoodsItemTimer = nil
  183. end
  184. end
  185. function UIBoliShopView:RefreshShopGoodsItemTimer()
  186. local timer = self.shopGoodsItemTimer
  187. if not timer then return end
  188. local updateItemMap = timer.updateItemMap
  189. if not updateItemMap or table_is_empty(updateItemMap) then
  190. timer:Stop()
  191. return
  192. end
  193. for itemLua, goodsData in pairs(updateItemMap) do
  194. itemLua.limitBox:SetActive(true)
  195. itemLua.timeLimit.text.text = goodsData:CalculateLimitTime()
  196. end
  197. end
  198. function UIBoliShopView:GetGoodsItemByRowColumn(gridView, itemIndex, row, column)
  199. local item = nil
  200. local shopData = ManagerContainer.DataMgr.BoliShopData:GetBoliShopData()
  201. if not shopData then return nil end
  202. local goods = shopData:GetShowGoodsDatas()
  203. if not goods then return nil end
  204. local goodsData = goods[itemIndex + 1]
  205. if not goodsData then return nil end
  206. local item = gridView:NewListViewItem('ShopGoodsItem')
  207. local itemLua = CommonUtil.BindGridViewItem2Lua(self, 'ShopGoodsItem', item.gameObject)
  208. local goodsCfgData = goodsData:GetGoodsCfgData()
  209. local data = {cfgId = goodsCfgData.GoodsItem}
  210. -- CommonUtil.UpdateItemPrefab(self, itemLua.iconItem, data, nil, self, self.ShowItemTips, data)
  211. CommonUtil.UpdateItemPrefab(self, itemLua.iconItem, data, nil)
  212. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(goodsCfgData.PayForType)
  213. CommonUtil.LoadIcon(self, itemCfgData.MiniIcon, function (sprite)
  214. itemLua.presentPrice.icon.image.sprite = sprite
  215. itemLua.originalPrice.icon.image.sprite = sprite
  216. end, itemLua, 'CurrenyIcon')
  217. itemLua.itemName.text.text = I18N.T( goodsCfgData.GoodsName)
  218. itemLua.presentPrice.number.text.text = goodsData.curPrice --现价
  219. if goodsData:IsDiscount() then --折扣
  220. itemLua.discount:SetActive(true)
  221. itemLua.originalPrice:SetActive(true)
  222. local discountNum = goodsData.disPercent
  223. --不是中文环境
  224. if not (ManagerContainer.LuaGameMgr.CurLangKey == "_cn"
  225. or ManagerContainer.LuaGameMgr.CurLangKey == "_tw") then
  226. discountNum = 100 - goodsData.disPercent
  227. else
  228. discountNum = goodsData.disPercent * 0.1
  229. end
  230. itemLua.discount.text.text.text = I18N.SetLanguageValue("ShopDiscount", tostring(discountNum)) -- {0}折,中文是:{0}折,非中文是{0}%off
  231. itemLua.originalPrice.number.text.text = goodsData.price
  232. elseif goodsData.hot then --热销
  233. itemLua.discount:SetActive(true)
  234. itemLua.originalPrice:SetActive(false)
  235. itemLua.discount.text.text.text = I18N.T("ShopSellwell")
  236. else
  237. itemLua.discount:SetActive(false)
  238. itemLua.originalPrice:SetActive(false)
  239. end
  240. local limitType = goodsData.limitType
  241. if limitType == Enum.LimitBuyType.NoLimit then
  242. itemLua.purchaseLimit:SetActive(false)
  243. itemLua.limitBox:SetActive(false)
  244. self:StopShopGoodsItemTimer(itemLua)
  245. elseif limitType == Enum.LimitBuyType.Forever then
  246. itemLua.purchaseLimit:SetActive(true)
  247. local remainNum = (goodsData.count - goodsData.buyNum)
  248. if remainNum < 0 then remainNum = 0 end
  249. itemLua.purchaseLimit.text.text = string.formatbykey("ShopForeverBuy", remainNum)
  250. itemLua.limitBox:SetActive(false)
  251. self:StopShopGoodsItemTimer(itemLua)
  252. elseif limitType == Enum.LimitBuyType.Daily then
  253. itemLua.purchaseLimit:SetActive(true)
  254. local remainNum = (goodsData.count - goodsData.buyNum)
  255. if remainNum < 0 then remainNum = 0 end
  256. itemLua.purchaseLimit.text.text = string.formatbykey("ShopDayBuy", remainNum)
  257. itemLua.limitBox:SetActive(true)
  258. itemLua.timeLimit.text.text = goodsData:CalculateLimitTime()
  259. self:StartShopGoodsItemTimer(itemLua, goodsData)
  260. elseif limitType == Enum.LimitBuyType.Week then
  261. itemLua.purchaseLimit:SetActive(true)
  262. local remainNum = (goodsData.count - goodsData.buyNum)
  263. if remainNum < 0 then remainNum = 0 end
  264. itemLua.purchaseLimit.text.text = string.formatbykey("ShopLoopBuy", remainNum)
  265. itemLua.limitBox:SetActive(true)
  266. itemLua.timeLimit.text.text = goodsData:CalculateLimitTime()
  267. self:StartShopGoodsItemTimer(itemLua, goodsData)
  268. elseif limitType == Enum.LimitBuyType.Time then
  269. itemLua.purchaseLimit:SetActive(true)
  270. local remainNum = (goodsData.count - goodsData.buyNum)
  271. if remainNum < 0 then remainNum = 0 end
  272. itemLua.purchaseLimit.text.text = string.formatbykey("ShopLimitBuy", remainNum)
  273. itemLua.limitBox:SetActive(true)
  274. itemLua.timeLimit.text.text = goodsData:CalculateLimitTime()
  275. self:StartShopGoodsItemTimer(itemLua, goodsData)
  276. elseif limitType == Enum.LimitBuyType.Special then
  277. itemLua.purchaseLimit:SetActive(true)
  278. local remainNum = (goodsData.count - goodsData.buyNum)
  279. if remainNum < 0 then remainNum = 0 end
  280. itemLua.purchaseLimit.text.text = string.formatbykey("ShopLimitBuy", remainNum)
  281. itemLua.limitBox:SetActive(false)
  282. self:StopShopGoodsItemTimer(itemLua)
  283. else
  284. itemLua.purchaseLimit:SetActive(false)
  285. itemLua.limitBox:SetActive(false)
  286. self:StopShopGoodsItemTimer(itemLua)
  287. end
  288. itemLua.soldout:SetActive(goodsData:IsSoldout())
  289. self.uiBase:AddButtonUniqueEventListener(itemLua.button, self, self.OnClickShopGoodsItem, goodsData)
  290. self.uiBase:AddButtonUniqueEventListener(itemLua.presentPrice.button, self, self.OnClickShopGoodsItem, goodsData)
  291. return item
  292. end
  293. function UIBoliShopView:OnClickShopGoodsItem(btn, params)
  294. local shopData = ManagerContainer.DataMgr.BoliShopData:GetBoliShopData()
  295. if not shopData then return end
  296. local goodsData = params[0]
  297. if not goodsData then return end
  298. if not goodsData:IsSoldout() then
  299. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBoliShopBuyTips, goodsData.id)
  300. end
  301. end
  302. function UIBoliShopView:GetVipDescItemByRowColumn(gridView, itemIndex, row, column)
  303. local item = nil
  304. item = gridView:NewListViewItem('PrivilegeDscItem')
  305. local data = self.controller:GetDescDataByIdx(itemIndex + 1)
  306. local itemLua = CommonUtil.BindGridViewItem2Lua(self, 'PrivilegeDscItem', item.gameObject)
  307. if data then
  308. itemLua.desTxt.text.text = string.formatbykey(data[2],data[3],data[4],data[5])
  309. itemLua.new:SetActive(data[1] == 1)
  310. end
  311. return item
  312. end
  313. function UIBoliShopView:GetItemByRowColumn(gridView, itemIndex, row, column)
  314. local item = nil
  315. item = gridView:NewListViewItem('BtnLv')
  316. local data = self.controller:GetBoliVipDataByIdx(itemIndex + 1)
  317. local curlv = ManagerContainer.DataMgr.BoliShopData:GetCurLv()
  318. local itemLua = CommonUtil.BindGridViewItem2Lua(self, 'BtnLv', item.gameObject)
  319. if data then
  320. if LastItemIdx ~= data.Lv then
  321. local lv = curlv
  322. if LastItemIdx == nil or LastItemIdx == curlv then
  323. lv = curlv
  324. else
  325. lv = LastItemIdx
  326. end
  327. itemLua.off:SetActive(lv ~= data.Lv)
  328. local isShow = (lv == 0 and data.Lv == 1) or lv == data.Lv
  329. itemLua.on:SetActive(isShow)
  330. if isShow then
  331. LastItemIdx = itemIndex + 1
  332. end
  333. else
  334. itemLua.off:SetActive(false)
  335. itemLua.on:SetActive(true)
  336. end
  337. itemLua.text.text.text = string.formatbykey("PrivilegeLv01",data.Lv)
  338. itemLua.activeted:SetActive(data.Lv == curlv)
  339. local rewardData = ManagerContainer.DataMgr.BoliShopData:GetRewardListById(data.Lv)
  340. if curlv >= data.Lv then
  341. itemLua.redPoint:SetActive(rewardData == nil)
  342. if not redpointState and rewardData == nil then
  343. redpointState = true
  344. end
  345. else
  346. itemLua.redPoint:SetActive(false)
  347. end
  348. end
  349. self.uiBase:AddButtonUniqueEventListener(itemLua.button, self, self.OnClickBoliLvBtn,{itemIndex,itemLua})
  350. return item
  351. end
  352. function UIBoliShopView:GetShowItemByIdx(idx)
  353. local item = self.scrollViewLv.loopGridView:GetShownItemByItemIndex(idx)
  354. if item then
  355. local itemlua = CommonUtil.GetBindGridViewItem2Lua(self, "BtnLv", item.gameObject)
  356. return itemlua
  357. end
  358. end
  359. function UIBoliShopView:OnClickBoliLvBtn(btn,param)
  360. local parms = param[0]
  361. local itemLua = self:GetShowItemByIdx(parms[1])
  362. local LastItemLua = self:GetShowItemByIdx(LastItemIdx - 1)
  363. if itemLua then
  364. if LastItemLua then
  365. LastItemLua.off:SetActive(true)
  366. LastItemLua.on:SetActive(false)
  367. end
  368. itemLua.off:SetActive(false)
  369. itemLua.on:SetActive(true)
  370. end
  371. local curlv = ManagerContainer.DataMgr.BoliShopData:GetCurLv()
  372. local data = self.controller:GetBoliVipDataByIdx(parms[1] + 1)
  373. LastItemIdx = parms[1] + 1
  374. if data.Lv <= curlv then
  375. self.prompt.text.text = string.formatbykey("BoliTips01")
  376. else
  377. self.prompt.text.text = string.formatbykey("BoliTips02",data.Lv)
  378. end
  379. self.titletext.text.text = string.formatbykey("PrivilegeLv02",data.Lv)
  380. self.labelActiveted:SetActive(data.Lv <= curlv)
  381. self:RefreshVipDescScroll(data)
  382. self:RefreshGiftUI(data)
  383. end
  384. function UIBoliShopView:RefreshVipDescScroll(data)
  385. if self.controller:GetCurEnterType() ~= 1 then
  386. return
  387. end
  388. if data then
  389. local descData = data.UnlockDes
  390. if descData then
  391. self.controller:SetDescData(descData)
  392. self.informationScrollView.loopGridView:RefreshListByIndex(#descData,0)
  393. end
  394. end
  395. end
  396. function UIBoliShopView:RefreshBoliShopData()
  397. local curlv = ManagerContainer.DataMgr.BoliShopData:GetCurLv()
  398. local idx = curlv > 0 and curlv or 1
  399. if LastItemIdx then
  400. idx = LastItemIdx
  401. end
  402. local data = self.controller:GetBoliVipDataByIdx(idx)
  403. if data then
  404. if data.Lv <= curlv then
  405. self.prompt.text.text = string.formatbykey("BoliTips01")
  406. else
  407. self.prompt.text.text = string.formatbykey("BoliTips02",data.Lv)
  408. end
  409. self.titletext.text.text = string.formatbykey("PrivilegeLv02",data.Lv)
  410. self.labelActiveted:SetActive(data.Lv <= curlv)
  411. self:RefreshVipDescScroll(data)
  412. self:RefreshGiftUI(data)
  413. end
  414. self:RefreshBtnLvScroll()
  415. self:RefreshCurExp()
  416. end
  417. function UIBoliShopView:RefreshGiftUI(data)
  418. if self.controller:GetCurEnterType() ~= 1 then
  419. return
  420. end
  421. local curlv = ManagerContainer.DataMgr.BoliShopData:GetCurLv()
  422. local redPoint = true
  423. local GetRewardIdx = 0
  424. local mask = false
  425. if curlv >= data.Lv then
  426. local data = ManagerContainer.DataMgr.BoliShopData:GetRewardListById(data.Lv)
  427. if data then
  428. GetRewardIdx = data
  429. mask = true
  430. end
  431. end
  432. for i = 1, 3 do
  433. local itemLua = self["giftItem"..i]
  434. if itemLua then
  435. local reward = data.GiftRewards[i]
  436. local cfgData = ManagerContainer.CfgMgr:GetItemById(reward[1])
  437. if cfgData then
  438. itemLua.giftname.text.text = cfgData.Name
  439. end
  440. local logicData = {cfgId = reward[1], num = reward[2]}
  441. IconItemCtr:SetData(self, itemLua.iconItem, logicData,nil, self, self.OnItemClick)
  442. itemLua.labelReceived:SetActive(mask)
  443. -- itemLua.btnReceive.button.interactable = curlv >= data.Lv
  444. itemLua.btnReceive.lock:SetActive(curlv < data.Lv)
  445. itemLua.icon:SetActive(GetRewardIdx == i)
  446. local logicData = {idx = i,lv = data.Lv}
  447. self.uiBase:AddButtonUniqueEventListener(itemLua.btnReceive.button, self, self.OnClickReceiveBtn,logicData)
  448. end
  449. end
  450. end
  451. function UIBoliShopView:OnClickReceiveBtn(button,params)
  452. local data = params[0]
  453. local curlv = ManagerContainer.DataMgr.BoliShopData:GetCurLv()
  454. if curlv < data.lv then
  455. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("PrivilegeUnlock")
  456. else
  457. ManagerContainer.DataMgr.BoliShopData:SendBoliShopRewardReq(data.lv,data.idx)
  458. end
  459. end
  460. function UIBoliShopView:OnItemClick(button,params)
  461. local data = params[0]
  462. ManagerContainer.LuaUIMgr:OpenTips(data)
  463. end
  464. function UIBoliShopView:RemoveEventListener()
  465. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  466. end
  467. function UIBoliShopView:AddUIEventListener()
  468. self.uiBase:AddButtonUniqueEventListener(self.btnClose.button, self, self.OnClickCloseBtn)
  469. self.uiBase:AddButtonUniqueEventListener(self.btnVIP.button, self, self.OnClickVipBtn)
  470. self.uiBase:AddButtonUniqueEventListener(self.btnLvUp.button, self, self.OnClickVipLvUpBtn)
  471. self.uiBase:AddToggleEventListener(self.privilegeToggle.toggle, self, self.OnValueChangedToggle,1)
  472. self.uiBase:AddToggleEventListener(self.shopToggle.toggle, self, self.OnValueChangedToggle,2)
  473. end
  474. function UIBoliShopView:OnValueChangedToggle(toggle, idx, isOn)
  475. if not isOn then return end
  476. local enterType = self.controller:SetCurEnterType(idx)
  477. self.privilegeBox:SetActive(enterType == 1)
  478. self.goodsBox:SetActive(enterType == 2)
  479. if enterType == 1 then
  480. self:RefreshVipView()
  481. self:RefreshCurExp()
  482. self:RefreshBoliShopData()
  483. elseif enterType == 2 then
  484. ManagerContainer.DataMgr.BoliShopData:SendBoliShopInfoReq()
  485. end
  486. end
  487. function UIBoliShopView:RefreshGoodsItemsScroll()
  488. if self.controller:GetCurEnterType() ~= 2 then
  489. return
  490. end
  491. local shopData = ManagerContainer.DataMgr.BoliShopData:GetBoliShopData()
  492. local length = 0
  493. if shopData then
  494. local goods = shopData:GetShowGoodsDatas()
  495. if goods then
  496. length = #goods
  497. end
  498. self.goodsScrollView.loopGridView:RefreshListByIndex(length)
  499. end
  500. end
  501. function UIBoliShopView:OnClickVipLvUpBtn()
  502. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBoliShopUpLvTips)
  503. end
  504. function UIBoliShopView:OnClickVipBtn()
  505. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIVip)
  506. end
  507. function UIBoliShopView:OnHide()
  508. end
  509. function UIBoliShopView:OnClickCloseBtn()
  510. ManagerContainer.LuaUIMgr:OpenSourceUI(self)
  511. end
  512. function UIBoliShopView:OnShow(data)
  513. self.controller:SetData(data)
  514. end
  515. function UIBoliShopView:OnClose()
  516. end
  517. function UIBoliShopView:OnDispose()
  518. self.controller:OnDispose()
  519. IsRefreshBtnItem = nil
  520. LastItemIdx = nil
  521. self.scrollViewLv.loopGridView:Dispose()
  522. self.informationScrollView.loopGridView:Dispose()
  523. self.goodsScrollView.loopGridView:Dispose()
  524. self:DisposeShopGoodsItemTimer()
  525. end
  526. return UIBoliShopView