RechargeStoreView.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. // using UI.Store;
  2. // using UI.CommonGame;
  3. // using FairyGUI;
  4. // using System.Collections.Generic;
  5. // using ET;
  6. // namespace GFGGame
  7. // {
  8. // public class RechargeStoreView : BaseWindow
  9. // {
  10. // private UI_RechargeStoreUI _ui;
  11. // private List<GiftBagCfg> _giftCfgs;
  12. // private List<ShopExchangeCfg> _exchangeCfgs;
  13. // public override void Dispose()
  14. // {
  15. // if (_ui != null)
  16. // {
  17. // _ui.Dispose();
  18. // }
  19. // _ui = null;
  20. // base.Dispose();
  21. // }
  22. // protected override void OnInit()
  23. // {
  24. // base.OnInit();
  25. // packageName = UI_RechargeStoreUI.PACKAGE_NAME;
  26. // _ui = UI_RechargeStoreUI.Create();
  27. // this.viewCom = _ui.target;
  28. // isfullScreen = true;
  29. // this.clickBlankToClose = false;
  30. // _ui.m_list.itemRenderer = ListItemRenderer;
  31. // _ui.m_listGift.itemRenderer = ListGiftItemRenderer;
  32. // _ui.m_listExchange.itemRenderer = ListExchangeItemRenderer;
  33. // _ui.m_comTab.m_c1.onChanged.Add(OnComTabChange);
  34. // _ui.m_c1.onChanged.Add(OnTabChange);
  35. // }
  36. // protected override void AddEventListener()
  37. // {
  38. // base.AddEventListener();
  39. // EventAgent.AddEventListener(ConstMessage.BUY_RECHARGE_SUCCESS, UpdateList);
  40. // EventAgent.AddEventListener(ConstMessage.BUY_EXCHANGE_SUCCESS, UpdateExchangeList);
  41. // EventAgent.AddEventListener(ConstMessage.BUY_GIFT_SUCCESS, UpdateGiftBagList);
  42. // EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  43. // }
  44. // protected override void OnShown()
  45. // {
  46. // base.OnShown();
  47. // _ui.m_c1.selectedIndex = this.viewData == null ? 0 : (int)this.viewData;
  48. // _ui.m_comTab.m_c1.selectedIndex = this.viewData == null ? 0 : (int)this.viewData;
  49. // _ui.m_list.numItems = RechargeCfgArray.Instance.dataArray.Length;
  50. // UpdateExchangeList();
  51. // UpdateGiftBagList();
  52. // OnTabChange();
  53. // Timers.inst.Add(1, 0, UpdateExchangeTime);
  54. // }
  55. // protected override void OnHide()
  56. // {
  57. // base.OnHide();
  58. // Timers.inst.Remove(UpdateExchangeTime);
  59. // }
  60. // protected override void RemoveEventListener()
  61. // {
  62. // base.RemoveEventListener();
  63. // EventAgent.RemoveEventListener(ConstMessage.BUY_RECHARGE_SUCCESS, UpdateList);
  64. // EventAgent.RemoveEventListener(ConstMessage.BUY_EXCHANGE_SUCCESS, UpdateExchangeList);
  65. // EventAgent.RemoveEventListener(ConstMessage.BUY_GIFT_SUCCESS, UpdateGiftBagList);
  66. // EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  67. // }
  68. // private void OnComTabChange()
  69. // {
  70. // _ui.m_c1.selectedIndex = _ui.m_comTab.m_c1.selectedIndex;
  71. // }
  72. // private void OnTabChange()
  73. // {
  74. // _ui.m_list.ScrollToView(0);
  75. // _ui.m_listGift.ScrollToView(0);
  76. // _ui.m_listExchange.ScrollToView(0);
  77. // }
  78. // private void UpdateList()
  79. // {
  80. // _ui.m_list.numItems = RechargeCfgArray.Instance.dataArray.Length;
  81. // }
  82. // private void UpdateGiftBagList()
  83. // {
  84. // _giftCfgs = StoreDataManager.Instance.GetGiftBagCfgs();
  85. // _ui.m_listGift.numItems = _giftCfgs.Count;
  86. // UpdateRedDot();
  87. // }
  88. // private void UpdateExchangeList()
  89. // {
  90. // _exchangeCfgs = StoreDataManager.Instance.GetExchangeCfgs();
  91. // _ui.m_listExchange.numItems = _exchangeCfgs.Count;
  92. // }
  93. // private void UpdateExchangeTime(object param)
  94. // {
  95. // long endTime = TimeUtil.GetTomorrowTime(GlobalCfgArray.globalCfg.refreshTime);
  96. // string time = TimeUtil.FormattingTime(TimeHelper.ServerNow(), endTime);
  97. // _ui.m_txtRefreshTime.text = time + "后刷新";
  98. // for (int i = 0; i < _ui.m_listGift.numItems; i++)
  99. // {
  100. // UI_ListGiftItem item = UI_ListGiftItem.Proxy(_ui.m_listGift.GetChildAt(i));
  101. // GiftBagCfg cfg = _giftCfgs[i];
  102. // item.m_txtEndTime.text = StoreDataManager.Instance.GetEndTime(cfg.id);
  103. // UI_ListGiftItem.ProxyEnd();
  104. // }
  105. // }
  106. // private void ListItemRenderer(int index, GObject obj)
  107. // {
  108. // RechargeCfg itemData = RechargeCfgArray.Instance.dataArray[index];
  109. // UI_StoreListItem item = UI_StoreListItem.Proxy(obj);
  110. // item.m_txtExchangeCount.visible = false;
  111. // item.m_btnBuy.m_c1.selectedIndex = 1;
  112. // item.m_btnBuy.m_txtTitle.text = itemData.price.ToString();
  113. // if (item.target.data == null)
  114. // {
  115. // item.target.onClick.Add(() =>
  116. // {
  117. // if (!AntiAddictionController.CheckAntiAddictionRecharge(itemData.price))
  118. // {
  119. // RechargeSProxy.ReqRecharge(itemData.id).Coroutine();
  120. // LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
  121. // }
  122. // });
  123. // }
  124. // item.target.data = index;
  125. // item.m_txtName.text = string.Format("{0}{1}", itemData.itemNum, itemData.name);
  126. // item.m_txtDesc.text = string.Format("首充赠送+{0}{1}", itemData.itemNum, itemData.name);
  127. // bool isDouble = StoreDataManager.Instance.GetRechargeBuyNumById(itemData.id) < itemData.doubleTimes;
  128. // item.m_imgDouble.visible = isDouble;
  129. // item.m_txtDesc.visible = isDouble;
  130. // item.m_icon.url = "ui://Store/sc_zizhuan_" + itemData.id;
  131. // UI_StoreListItem.ProxyEnd();
  132. // }
  133. // private void ListGiftItemRenderer(int index, GObject obj)
  134. // {
  135. // UI_ListGiftItem item = UI_ListGiftItem.Proxy(obj);
  136. // GiftBagCfg cfg = _giftCfgs[index];
  137. // item.m_txtName.text = cfg.name;
  138. // item.m_icon.url = ResPathUtil.GetIconPath(cfg.res, "png"); // string.Format("ui://RechargeStore/{0}", cfg.res);
  139. // item.m_txtDesc.SetVar("count", cfg.desc).FlushVars(); ;
  140. // item.m_grpDiscount.visible = cfg.desc != "";
  141. // item.m_txtEndTime.text = StoreDataManager.Instance.GetEndTime(cfg.id);
  142. // item.m_grpEndTime.visible = cfg.endTime != "";
  143. // item.m_c2.selectedIndex = StoreDataManager.Instance.GetGiftStateById(cfg.id) ? 0 : 1;
  144. // if (cfg.lockType == LockType.STORY_LV)
  145. // {
  146. // StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId);
  147. // item.m_txtLock.text = string.Format("通关{0}-{1}解锁", StoryUtil.GetChapterOrder(storyLevelCfg.chapterId), storyLevelCfg.order);
  148. // }
  149. // else if (cfg.lockType == LockType.ROLE_LV)
  150. // {
  151. // item.m_txtLock.text = string.Format("角色达到{0}级解锁", cfg.lv);
  152. // }
  153. // int buyNum = StoreDataManager.Instance.GetGiftBuyNumById(cfg.id);
  154. // item.m_txtLimit.text = string.Format("{0}({1}/{2})", StoreDataManager.Instance.refreshType[cfg.refreshType], StringUtil.GetColorText(buyNum.ToString(), "#DA8870"), cfg.maxBuyNum);
  155. // item.m_txtLimit.visible = cfg.maxBuyNum > 0;
  156. // item.m_c1.selectedIndex = cfg.maxBuyNum == 0 || buyNum < cfg.maxBuyNum ? 0 : 1;
  157. // if (item.m_c1.selectedIndex == 0)
  158. // {
  159. // item.m_txtOriginalPrice.text = NumberUtil.ChangeNumberUnit(cfg.originalPrice);// cfg.originalPrice.ToString();
  160. // if (cfg.price > 0 && cfg.costType != CostType.FREE)
  161. // {
  162. // item.m_grpOriginalPrice.visible = cfg.originalPrice > 0;
  163. // item.m_grpIcon.visible = true;
  164. // item.m_txtPrice.text = NumberUtil.ChangeNumberUnit(cfg.price);// cfg.price.ToString();
  165. // if (cfg.costType == CostType.RMB)
  166. // {
  167. // item.m_loaIcon.visible = false;
  168. // item.m_txtIcon.visible = true;
  169. // item.m_txtIcon.text = "¥";
  170. // }
  171. // else
  172. // {
  173. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.costId);
  174. // item.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(itemCfg.res);
  175. // item.m_loaIcon.visible = true;
  176. // item.m_txtIcon.visible = false;
  177. // }
  178. // }
  179. // else
  180. // {
  181. // item.m_grpIcon.visible = false;
  182. // item.m_grpOriginalPrice.visible = false;
  183. // item.m_txtPrice.text = "免费";
  184. // }
  185. // }
  186. // if (item.target.data == null)
  187. // {
  188. // item.target.onClick.Add(OnBtnBuyClick);
  189. // }
  190. // item.target.data = cfg.id;
  191. // bool isRed = item.m_c1.selectedIndex == 0 && item.m_c2.selectedIndex == 0 && cfg.price == 0;
  192. // RedDotController.Instance.SetComRedDot(item.target, isRed, "", -6, 100);
  193. // UI_ListGiftItem.ProxyEnd();
  194. // }
  195. // private void OnBtnBuyClick(EventContext context)
  196. // {
  197. // GObject btn = context.sender as GObject;
  198. // int giftId = (int)btn.data;
  199. // GiftBagCfg cfg = GiftBagCfgArray.Instance.GetCfg(giftId);
  200. // if (cfg.maxBuyNum != 0 && StoreDataManager.Instance.GetGiftBuyNumById(giftId) == cfg.maxBuyNum)
  201. // {
  202. // PromptController.Instance.ShowFloatTextPrompt("已售罄");
  203. // return;
  204. // }
  205. // if (cfg.price == 0 || cfg.costType == CostType.FREE)
  206. // {
  207. // RechargeSProxy.ReqBuyGiftBag((int)btn.data).Coroutine();
  208. // }
  209. // else
  210. // {
  211. // ViewManager.Show<GiftBagBuyView>(btn.data);
  212. // }
  213. // }
  214. // private void ListExchangeItemRenderer(int index, GObject obj)
  215. // {
  216. // ShopExchangeCfg cfg = _exchangeCfgs[index];
  217. // UI_StoreListItem item = UI_StoreListItem.Proxy(obj);
  218. // item.m_btnBuy.m_c1.selectedIndex = 0;
  219. // item.m_btnBuy.m_txtTitle.text = cfg.costNum.ToString();
  220. // item.m_txtExchangeCount.text = string.Format("x{0}", cfg.num);
  221. // // item.m_txtExchangeCount.visible = cfg.num > 1;
  222. // bool isSellOut = cfg.maxLimit > 0 && cfg.maxLimit - StoreDataManager.Instance.GetExchangeBuyNumById(cfg.id) <= 0;
  223. // item.m_c1.selectedIndex = isSellOut ? 1 : 0;
  224. // if (item.target.data == null)
  225. // {
  226. // // item.target.onClick.Add(() =>
  227. // // {
  228. // // bool isSellOut = cfg.maxLimit > 0 && cfg.maxLimit - RechargeDataManager.Instance.GetExchangeBuyNumById(cfg.id) <= 0;
  229. // // if (isSellOut)
  230. // // {
  231. // // PromptController.Instance.ShowFloatTextPrompt("已售罄");
  232. // // return;
  233. // // }
  234. // // ViewManager.Show<ItemExchangeView>(cfg.id);
  235. // // });
  236. // item.target.onClick.Add(OnBtnBugItem);
  237. // }
  238. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.itemId);
  239. // item.target.data = cfg;
  240. // item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(cfg.costId).res);
  241. // item.m_txtName.text = itemCfg.name;
  242. // item.m_txtDesc.text = string.Format("剩余:{0}", cfg.maxLimit - StoreDataManager.Instance.GetExchangeBuyNumById(cfg.id));
  243. // if (cfg.maxLimit == 0) item.m_txtDesc.text = "剩余:不限";
  244. // item.m_imgDouble.visible = false;
  245. // item.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  246. // UI_StoreListItem.ProxyEnd();
  247. // }
  248. // private void OnBtnBugItem(EventContext context)
  249. // {
  250. // ShopExchangeCfg cfg = (context.sender as GObject).data as ShopExchangeCfg;
  251. // bool isSellOut = cfg.maxLimit > 0 && cfg.maxLimit - StoreDataManager.Instance.GetExchangeBuyNumById(cfg.id) <= 0;
  252. // if (isSellOut)
  253. // {
  254. // PromptController.Instance.ShowFloatTextPrompt("已售罄");
  255. // return;
  256. // }
  257. // ViewManager.Show<ItemExchangeView>(cfg.id);
  258. // }
  259. // private void UpdateRedDot()
  260. // {
  261. // RedDotController.Instance.SetComRedDot(_ui.m_comTab.m_btn1.target, RedDotDataManager.Instance.GetRechargeGiftFreeRed());
  262. // }
  263. // }
  264. // }