EnduringGiftBoxView.cs 23 KB

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