EnduringGiftBoxView.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using ET;
  5. using FairyGUI;
  6. using UI.EnduringGiftBox;
  7. using UnityEngine;
  8. namespace GFGGame
  9. {
  10. public class EnduringGiftBoxView : BaseWindow
  11. {
  12. private UI_EnduringGiftBoxUI _ui;
  13. private int _itemId; //道具id,该页面目前只给:体力,金币使用
  14. private int _count; //本次购买次数
  15. private int _buyTimes = 0; //已购次数
  16. private int _type = 0; //0从别的地方跳转过来. 1从点击TOP菜单栏icon跳转过来
  17. private Action _onSuccess;
  18. private int _maxTimes = 0;
  19. private string _message = "";
  20. private List<ShopCfg> _shopCfgList = new List<ShopCfg>();
  21. private EffectUI _effectUI1;
  22. private EffectUI _effectUI2;
  23. private EffectUI _effectUI3;
  24. private EffectUI _effectUI4;
  25. protected override void OnInit()
  26. {
  27. base.OnInit();
  28. packageName = UI_EnduringGiftBoxUI.PACKAGE_NAME;
  29. _ui = UI_EnduringGiftBoxUI.Create();
  30. this.viewCom = _ui.target;
  31. this.viewCom.Center();
  32. this.modal = true;
  33. viewAnimationType = EnumViewAnimationType.None;
  34. _ui.m_btnSure.onClick.Add(OnClickBtnSure);
  35. _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
  36. _ui.m_btnBack.onClick.Add(OnClickBtnCancel);
  37. }
  38. public override void Dispose()
  39. {
  40. EffectUIPool.Recycle(_effectUI1);
  41. _effectUI1 = null;
  42. EffectUIPool.Recycle(_effectUI2);
  43. _effectUI2 = null;
  44. EffectUIPool.Recycle(_effectUI3);
  45. _effectUI3 = null;
  46. EffectUIPool.Recycle(_effectUI4);
  47. _effectUI4 = null;
  48. if (_ui != null)
  49. {
  50. _ui.Dispose();
  51. _ui = null;
  52. }
  53. EnduringGiftBoxController.Dispose();
  54. base.Dispose();
  55. }
  56. protected override void OnShown()
  57. {
  58. base.OnShown();
  59. AddEffect();
  60. _ui.m_t1.Play();
  61. _ui.m_t2.Play();
  62. _ui.m_t3.Play(CheckGuide);
  63. UpdateView();
  64. }
  65. protected override void AddEventListener()
  66. {
  67. base.AddEventListener();
  68. EventAgent.AddEventListener(ConstMessage.CONTINUOUS_REBATE_GIFT_SHOP_BUY, UpDayRebateAndView);
  69. EventAgent.AddEventListener(ConstMessage.CONTINUOUS_REBATE_GIFT, UpdateView);
  70. }
  71. protected override void RemoveEventListener()
  72. {
  73. EventAgent.RemoveEventListener(ConstMessage.CONTINUOUS_REBATE_GIFT_SHOP_BUY, UpDayRebateAndView);
  74. EventAgent.RemoveEventListener(ConstMessage.CONTINUOUS_REBATE_GIFT, UpdateView);
  75. base.RemoveEventListener();
  76. }
  77. private void AddEffect()
  78. {
  79. //小人
  80. if (_itemId == ConstItemID.POWER)
  81. {
  82. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderBaby, "ui_Activity", "Activity_people02");
  83. }
  84. else
  85. {
  86. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderBaby, "ui_Activity", "Activity_people01");
  87. }
  88. //爆发,大泡泡
  89. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holderPaoMax, "ui_Activity", "Activity_baofa");
  90. //持续的小泡泡
  91. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holderPaoMin, "ui_Activity", "Activity_chixu");
  92. //爆发时候的发光
  93. _effectUI4 = EffectUIPool.CreateEffectUI(_ui.m_holderFg, "ui_Activity", "Activity_glow");
  94. }
  95. public void SetParams(int itemId, int count, Action onSuccess, string message = "", int type = 0)
  96. {
  97. _itemId = itemId;
  98. _count = count;
  99. _onSuccess = onSuccess;
  100. _message = message;
  101. _type = type;
  102. }
  103. private void UpdateView()
  104. {
  105. _buyTimes = ItemDataManager.GetItemExchangeTimes(_itemId);
  106. ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _count, out int costId, out int coustNum,
  107. out int buyNum);
  108. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
  109. ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
  110. _ui.m_txtNeed.text = string.Format("是否花费{0}{1} 购买{2}{3}", coustNum, costCfg.name, buyNum, itemCfg.name);
  111. _maxTimes = ItemExchangeCfgArray.Instance.GetCfg(_itemId).maxLimit;
  112. string showTxt = string.Empty;
  113. _shopCfgList.Clear();
  114. //常驻礼包
  115. if (_itemId == ConstItemID.POWER)
  116. {
  117. //体力礼包
  118. _shopCfgList = ShopCfgArray.Instance
  119. .GetCfgsBymenu1Andmenu2(ConstStoreTabId.ENDURING_GIFT_BOX, ConstStoreSubId.ENDURING_GIFT_BOX_POWER)
  120. .OrderBy(a => a.refreshType).ToList();
  121. _ui.m_txtNeed.align = AlignType.Center;
  122. int maxLimit = ItemExchangeCfgArray.Instance.GetCfg(ConstItemID.POWER).maxLimit;
  123. int lastBuyCount = maxLimit - ItemDataManager.GetItemExchangeTimes(ConstItemID.POWER);
  124. showTxt = string.Format("每5分钟回复1点体力\n今日剩余购买次数{0}/{1}次", lastBuyCount, maxLimit);
  125. }
  126. else
  127. {
  128. //金币礼包
  129. _shopCfgList = ShopCfgArray.Instance
  130. .GetCfgsBymenu1Andmenu2(ConstStoreTabId.ENDURING_GIFT_BOX, ConstStoreSubId.ENDURING_GIFT_BOX_GOLD)
  131. .OrderBy(a => a.refreshType).ToList();
  132. _ui.m_txtNeed.align = AlignType.Right;
  133. if (_maxTimes != 0)
  134. {
  135. showTxt = string.Format("今日剩余购买次数{0}/{1}", _maxTimes - _buyTimes, _maxTimes);
  136. }
  137. }
  138. _ui.m_txtNum.text = showTxt;
  139. _ui.m_txtPromptExt.text = string.Format("除了上述购买{0}的途径,我们还提供了更多的优惠礼包选择", itemCfg.name);
  140. _ui.m_list.itemRenderer = ListItemRender;
  141. _ui.m_list.numItems = _shopCfgList.Count;
  142. _ui.m_list.visible = true;
  143. }
  144. // ReSharper disable Unity.PerformanceAnalysis
  145. private void ListItemRender(int index, GObject obj)
  146. {
  147. ShopCfg shopCfg = _shopCfgList[index];
  148. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId); //购买的物品-礼包
  149. UI_ComCurSupplyItem item = UI_ComCurSupplyItem.Proxy(obj);
  150. item.target.data = shopCfg;
  151. //返利包
  152. item.m_txtTitle.text = itemCfg.name;
  153. item.m_txtWeekPrompt.visible = false;
  154. item.m_btnIcoWeekPromptTag.visible = false;
  155. if (itemCfg.param2Arr.Length != 0)
  156. {
  157. item.m_txtWeekPrompt.visible = true;
  158. item.m_btnIcoWeekPromptTag.visible = true;
  159. item.m_txtWeekPrompt.text = string.Format("连续{0}天每日获得", itemCfg.param2Arr[0]);
  160. }
  161. int numItems;
  162. var childItemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
  163. var remainBuyNum = shopCfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
  164. item.m_comLeftGiftBox.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  165. item.m_btnBuy.m_txtOldPrice.text = $"{shopCfg.originalPrice}";
  166. item.m_btnBuy.m_loaIcon.visible = false;
  167. string mTxtOldPrice = string.Empty;
  168. if (shopCfg.costType == CostType.ITEM)
  169. {
  170. //货币
  171. ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(shopCfg.costId);
  172. item.m_btnBuy.m_loaIcon.visible = true;
  173. item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetIconPath(costCfg);
  174. }
  175. else if (shopCfg.costType == CostType.RMB)
  176. {
  177. //人民币
  178. mTxtOldPrice = "元";
  179. }
  180. else
  181. {
  182. //免费
  183. mTxtOldPrice = $"免费";
  184. item.m_btnBuy.m_txtOldPrice.text = "";
  185. item.m_btnBuy.m_txtNewPrice.align = AlignType.Left;
  186. item.m_btnBuy.m_txtNewPrice.x = 90;
  187. }
  188. item.m_btnBuy.m_txtNewPrice.text = $"{shopCfg.price + mTxtOldPrice}";
  189. item.m_comLeftGiftBox.target.data = itemCfg;
  190. item.m_comLeftGiftBox.m_loaIcon.onClick.Add(OnListSelectorItemClick);
  191. if (shopCfg.originalPrice != shopCfg.price)
  192. {
  193. var roundedNumStr = NumberUtil.CalculateDiscount(shopCfg.originalPrice, shopCfg.price);
  194. item.m_comLeftGiftBox.m_comDiscount.target.visible = true;
  195. item.m_comLeftGiftBox.m_comDiscount.m_txtDiscountNum.text = $"{roundedNumStr}折"; //之后再计算赋值
  196. }
  197. else
  198. {
  199. item.m_comLeftGiftBox.m_comDiscount.target.visible = false;
  200. }
  201. if (shopCfg.refreshType == RefreshType.DAY) //也可以换成人民币来做条件
  202. {
  203. //日刷
  204. item.m_comLeftGiftBox.m_comGouMaiGetText.target.visible = false;
  205. item.m_txtUrc.text = string.Format("今日剩余{0}/{1}", remainBuyNum, shopCfg.maxBuyNum);
  206. item.m_txtLrc.text = string.Format("可获得{0}会员积分", shopCfg.price * 10);
  207. item.m_txtWeekPrompt.visible = false;
  208. item.m_btnIcoWeekPromptTag.visible = false;
  209. numItems = childItemCfg.itemsArr.Length;
  210. if (remainBuyNum == 0)
  211. {
  212. //已售完
  213. item.m_btnBuy.target.visible = true;
  214. item.m_btnCurReceive.target.visible = false;
  215. item.m_btnBuy.m_bagYellow.visible = false;
  216. item.m_btnBuy.m_bagGrey.visible = true;
  217. }
  218. else
  219. {
  220. //未售完
  221. item.m_btnBuy.target.visible = true;
  222. item.m_btnCurReceive.target.visible = false;
  223. item.m_btnBuy.m_bagYellow.visible = true;
  224. item.m_btnBuy.m_bagGrey.visible = false;
  225. }
  226. }
  227. else
  228. {
  229. //周刷
  230. var weekGiftBoxState = EnduringGiftBoxDataManager.Instance.DayIsRebateGiftBox(shopCfg.itemId);
  231. item.m_comLeftGiftBox.m_comGouMaiGetText.target.visible = true;
  232. var itemArr = itemCfg.itemsArr[0];
  233. ItemCfg getItemCfg = ItemCfgArray.Instance.GetCfg(itemArr[0]); //及时获得的物品,读取第一个显示ICON
  234. item.m_comLeftGiftBox.m_comGouMaiGetText.m_loaIcon.url = ResPathUtil.GetIconPath(getItemCfg);
  235. item.m_comLeftGiftBox.m_comGouMaiGetText.m_txtGetGold.text = itemArr[1].ToString();
  236. item.m_txtUrc.text = string.Format("每周限购{0}/{1}", remainBuyNum, shopCfg.maxBuyNum);
  237. int rebateDay = EnduringGiftBoxDataManager.Instance.GetItemRebateDay(itemCfg.id);
  238. string mTxtLrc = string.Empty;
  239. if (rebateDay != 0)
  240. {
  241. mTxtLrc = string.Format("剩余{0}天", rebateDay);
  242. }
  243. item.m_txtLrc.text = mTxtLrc;
  244. item.m_txtWeekPrompt.visible = true;
  245. item.m_txtWeekPrompt.text =
  246. string.Format("连续{0}天每日获得",
  247. itemCfg.param2Arr[0] + 1); //NumberUtil.GetChiniseNumberText(itemCfg.param2Arr[0])
  248. item.m_btnIcoWeekPromptTag.visible = true;
  249. numItems = childItemCfg.param1Arr.Length;
  250. //领取加红点
  251. RedDotController.Instance.SetComRedDot(item.m_btnCurReceive.target, weekGiftBoxState);
  252. //是否需要领取
  253. if (weekGiftBoxState)
  254. {
  255. item.m_btnBuy.target.visible = false;
  256. item.m_btnCurReceive.target.visible = true;
  257. item.m_btnCurReceive.m_receive.visible = true;
  258. item.m_btnCurReceive.m_received.visible = false;
  259. item.m_btnCurReceive.m_txtRec.text = "领取";
  260. }
  261. else
  262. {
  263. //是否能购买
  264. if (remainBuyNum == 0)
  265. {
  266. //已经领取
  267. if (EnduringGiftBoxDataManager.Instance.DayRebateItemIds.Contains(shopCfg.itemId))
  268. {
  269. item.m_btnBuy.target.visible = false;
  270. item.m_btnCurReceive.target.visible = true;
  271. item.m_btnCurReceive.m_receive.visible = false;
  272. item.m_btnCurReceive.m_received.visible = true;
  273. item.m_btnCurReceive.m_txtRec.text = "已领取";
  274. }
  275. else
  276. {
  277. item.m_btnCurReceive.target.visible = false;
  278. item.m_btnBuy.target.visible = true;
  279. item.m_btnBuy.m_bagGrey.visible = true;
  280. item.m_btnBuy.m_bagYellow.visible = false;
  281. }
  282. }
  283. else
  284. {
  285. //未售完
  286. item.m_btnBuy.target.visible = true;
  287. item.m_btnBuy.m_bagGrey.visible = false;
  288. item.m_btnBuy.m_bagYellow.visible = true;
  289. item.m_btnCurReceive.target.visible = false;
  290. }
  291. }
  292. }
  293. item.m_btnIcoWeekPromptTag.onClick.Add(RuleController.ShowRuleView);
  294. item.m_btnIcoWeekPromptTag.data = 300013;
  295. //领取按钮点击事件
  296. item.m_btnCurReceive.target.onClick.Add(OnBtnCurReceiveClick);
  297. //购买按钮点击事件
  298. item.m_btnBuy.target.onClick.Add(OnBtnBuyClick);
  299. item.m_list.data = shopCfg;
  300. item.m_list.itemRenderer = ChildListItemRender;
  301. item.m_list.numItems = numItems;
  302. }
  303. //领取按钮点击事件
  304. // ReSharper disable Unity.PerformanceAnalysis
  305. private void OnBtnCurReceiveClick(EventContext context)
  306. {
  307. GObject sender = context.sender as GObject;
  308. GObject obj = sender.parent;
  309. ShopCfg cfg = obj.data as ShopCfg;
  310. bool isSellOut = EnduringGiftBoxDataManager.Instance.DayIsRebateGiftBox(cfg.itemId);
  311. if (isSellOut)
  312. {
  313. EnduringGiftBoxSProxy.ReqGetGiftBagRebate(cfg.id).Coroutine();
  314. }
  315. else
  316. {
  317. PromptController.Instance.ShowFloatTextPrompt("无法领取");
  318. }
  319. }
  320. //购买按钮点击事件
  321. // ReSharper disable Unity.PerformanceAnalysis
  322. private void OnBtnBuyClick(EventContext context)
  323. {
  324. if (_itemId == ConstItemID.POWER && GuideDataManager.IsGuideFinish(ConstGuideId.BUY_POWER) <= 0)
  325. {
  326. GuideController.TryCompleteGuideIndex(ConstGuideId.BUY_POWER, 1);
  327. GuideController.TryCompleteGuide(ConstGuideId.BUY_POWER, 1);
  328. }
  329. GObject sender = context.sender as GObject;
  330. GObject obj = sender.parent;
  331. ShopCfg cfg = obj.data as ShopCfg;
  332. bool isSellOut = cfg.maxBuyNum > 0 &&
  333. cfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(cfg.id) <= 0;
  334. if (isSellOut)
  335. {
  336. PromptController.Instance.ShowFloatTextPrompt("已售罄");
  337. return;
  338. }
  339. if (!ShopDataManager.Instance.GetShopGoodsStateById(cfg.id))
  340. {
  341. PromptController.Instance.ShowFloatTextPrompt(ShopDataManager.Instance.GetShopGoodsStateTips(cfg.id));
  342. return;
  343. }
  344. if (cfg.costType == CostType.FREE)
  345. {
  346. ShopSProxy.ReqShopBuy(cfg.id, 1).Coroutine();
  347. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
  348. }
  349. else
  350. {
  351. ViewManager.Show<ItemExchangeView>(cfg.id);
  352. }
  353. }
  354. // ReSharper disable Unity.PerformanceAnalysis
  355. private void ChildListItemRender(int index, GObject obj)
  356. {
  357. UI_ComRewardIconItem uiItemChild = UI_ComRewardIconItem.Proxy(obj);
  358. var shopCfg = uiItemChild.target.parent.data as ShopCfg;
  359. var itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
  360. // uiItemChild.m_showRreceives.visible = false;
  361. //var curGiftBoxState = EnduringGiftBoxDataManager.GiftBoxStateDic[shopCfg.id];
  362. int[][] result;
  363. if (shopCfg.refreshType == RefreshType.DAY)
  364. {
  365. result = itemCfg.itemsArr;
  366. uiItemChild.m_bagYellow.visible = false;
  367. uiItemChild.m_bagBlue.visible = true;
  368. uiItemChild.m_bagYellowEx.visible = false;
  369. uiItemChild.m_bagBlueEx.visible = true;
  370. }
  371. else
  372. {
  373. //周刷
  374. result = itemCfg.param1Arr;
  375. uiItemChild.m_bagYellow.visible = true;
  376. uiItemChild.m_bagBlue.visible = false;
  377. uiItemChild.m_bagYellowEx.visible = true;
  378. uiItemChild.m_bagBlueEx.visible = false;
  379. }
  380. // if (curGiftBoxState == EnduringGiftBoxBuyStatus.YesGet)
  381. // {
  382. // uiItemChild.m_showRreceives.visible = true;
  383. // }
  384. // else if (curGiftBoxState == EnduringGiftBoxBuyStatus.NoGet)
  385. // {
  386. // uiItemChild.m_showRreceives.visible = false;
  387. // }
  388. var itemArr = result[index];
  389. var itemCfgChild = ItemCfgArray.Instance.GetCfg(itemArr[0]);
  390. uiItemChild.m_loaIcon.onClick.Add(OnListSelectorItemClick);
  391. uiItemChild.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfgChild);
  392. uiItemChild.m_num.text = itemArr[1].ToString();
  393. uiItemChild.target.data = itemCfgChild;
  394. UI_ComRewardIconItem.ProxyEnd();
  395. }
  396. //弹出物品详细描述框
  397. private void OnListSelectorItemClick(EventContext context)
  398. {
  399. GObject sender = context.sender as GObject;
  400. GObject obj = sender.parent;
  401. ItemCfg itemCfg = obj.data as ItemCfg;
  402. GoodsItemTipsController.ShowItemTips(itemCfg.id);
  403. }
  404. // ReSharper disable Unity.PerformanceAnalysis
  405. // ReSharper disable Unity.PerformanceAnalysis
  406. private async void OnClickBtnSure()
  407. {
  408. if (_maxTimes > 0 && (_buyTimes + _count) > _maxTimes)
  409. {
  410. PromptController.Instance.ShowFloatTextPrompt("购买次数不足");
  411. return;
  412. }
  413. ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _count, out int costId, out int coustNum,
  414. out int buyNum);
  415. Debug.Log(costId + "数量:" + ItemDataManager.GetItemNum(costId));
  416. if (ItemDataManager.GetItemNum(costId) < coustNum)
  417. {
  418. ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
  419. if (_itemId == ConstItemID.DIAMOND_PURPLE)
  420. {
  421. PromptController.Instance.ShowFloatTextPrompt(string.Format("{0}不足,请前往商城选购", costCfg.name));
  422. }
  423. else
  424. {
  425. AlertUI.Show(costCfg.name + "不足,是否前往购买?").SetLeftButton(true).SetRightButton(true, "确认",
  426. (AlertWindow.AlertCallback)((object data) =>
  427. {
  428. long costNeedCount = coustNum - ItemDataManager.GetItemNum(costId);
  429. BuyItemConteoller.Show(costId, costNeedCount, ConstBuyType.TYPE_ITEM, null, true, true,
  430. GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED);
  431. }));
  432. OnClickBtnCancel();
  433. }
  434. return;
  435. }
  436. bool result = await ItemExchangeSProxy.ItemExchange(_itemId, _count);
  437. if (result)
  438. {
  439. PromptController.Instance.ShowFloatTextPrompt("购买成功", MessageType.SUCCESS);
  440. if (_onSuccess != null)
  441. {
  442. _onSuccess();
  443. }
  444. }
  445. UpdateView();
  446. //判断一下是不是从主要界面进来的
  447. if (_type == 0)
  448. {
  449. this.Hide();
  450. }
  451. }
  452. //购买连续礼包之后,更新数据+更新界面
  453. // ReSharper disable Unity.PerformanceAnalysis
  454. private void UpDayRebateAndView(EventContext context)
  455. {
  456. ShopCfg shopCfg = context.data as ShopCfg;
  457. var itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
  458. if (itemCfg.itemType == ConstItemType.USEABLE &&
  459. itemCfg.funType == ConstItemFuncType.CONTINUOUS_REWARD_GIFT)
  460. {
  461. int dayNum = EnduringGiftBoxDataManager.Instance.GetItemRebateDay(itemCfg.id);
  462. int totalDayNum = dayNum + itemCfg.param2Arr[0];
  463. EnduringGiftBoxDataManager.Instance.UpDayAllRebateItemDic(itemCfg.id, totalDayNum);
  464. EnduringGiftBoxDataManager.Instance.AddDayRebateItemIds(itemCfg.id);
  465. }
  466. UpdateView();
  467. }
  468. protected override void OnHide()
  469. {
  470. this.RemoveEventListener();
  471. base.Hide();
  472. _onSuccess = null;
  473. Timers.inst.Remove(CheckGuide);
  474. }
  475. private void OnClickBtnCancel()
  476. {
  477. // Dispose();
  478. this.Hide();
  479. }
  480. private void CheckGuide()
  481. {
  482. Timers.inst.AddUpdate(CheckGuide);
  483. }
  484. private void CheckGuide(object param)
  485. {
  486. if (GuideDataManager.IsGuideFinish(ConstGuideId.BUY_POWER) <= 0)
  487. {
  488. UpdateToCheckGuide(null);
  489. }
  490. else
  491. {
  492. Timers.inst.Remove(CheckGuide);
  493. }
  494. }
  495. protected override void UpdateToCheckGuide(object param)
  496. {
  497. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  498. if (_itemId == ConstItemID.POWER)
  499. {
  500. GuideController.TryGuide(_ui.m_list.GetChildAt(1).asCom.GetChild("btnCurReceive").asButton,
  501. ConstGuideId.BUY_POWER, 1, "这里可以购买体力超值返利包,每天都能领体力哦~");
  502. }
  503. }
  504. }
  505. }