| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 | 
							- using System;
 
- using UI.CommonGame;
 
- using UnityEngine;
 
- namespace GFGGame
 
- {
 
-     public class BuyConfirmView : BaseWindow
 
-     {
 
-         private UI_BuyConfirmUI _ui;
 
-         private int _itemId;
 
-         private int _count;//本次购买次数
 
-         private int _buyTimes = 0;//已购次数
 
-         private Action _onSuccess;
 
-         private int _maxTimes = 0;
 
-         private string _message = "";
 
-         public override void Dispose()
 
-         {
 
-             if (_ui != null)
 
-             {
 
-                 _ui.Dispose();
 
-                 _ui = null;
 
-             }
 
-             BuyConfirmController.Dispose();
 
-             base.Dispose();
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             _ui = UI_BuyConfirmUI.Create();
 
-             this.viewCom = _ui.target;
 
-             this.viewCom.Center();
 
-             this.modal = true;
 
-             viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
 
-             _ui.m_btnSure.onClick.Add(OnClickBtnSure);
 
-             _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
 
-         }
 
-         public void SetParams(int itemId, int count, Action onSuccess, string message = "")
 
-         {
 
-             _itemId = itemId;
 
-             _count = count;
 
-             _onSuccess = onSuccess;
 
-             _message = message;
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             UpdateView();
 
-         }
 
-         private void UpdateView()
 
-         {
 
-             _buyTimes = ItemDataManager.GetItemExchangeTimes(_itemId);
 
-             ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _count, out int costId, out int coustNum, out int buyNum);
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
 
-             ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
 
-             _ui.m_txtNeed.text = string.Format("是否花费{0}{1} 购买{2}{3}", coustNum, costCfg.name, buyNum, itemCfg.name);
 
-             _ui.m_txtNum.text = "";
 
-             _maxTimes = ItemExchangeCfgArray.Instance.GetCfg(_itemId).maxLimit;
 
-             if (_maxTimes != 0)
 
-             {
 
-                 _ui.m_txtNum.text = string.Format("今日剩余购买次数{0}/{1}", _maxTimes - _buyTimes, _maxTimes);
 
-             }
 
-             if (_message != "")
 
-             {
 
-                 _ui.m_txtNum.text = _message;
 
-             }
 
-         }
 
-         private async void OnClickBtnSure()
 
-         {
 
-             if (_maxTimes > 0 && (_buyTimes + _count) > _maxTimes)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("购买次数不足");
 
-                 return;
 
-             }
 
-             ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _count, out int costId, out int coustNum, out int buyNum);
 
-             Debug.Log(costId + "数量:" + ItemDataManager.GetItemNum(costId));
 
-             if (ItemDataManager.GetItemNum(costId) < coustNum)
 
-             {
 
-                 ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
 
-                 if (_itemId == ConstItemID.DIAMOND_PURPLE)
 
-                 {
 
-                     PromptController.Instance.ShowFloatTextPrompt(string.Format("{0}不足,请前往商城选购", costCfg.name));
 
-                 }
 
-                 else
 
-                 {
 
-                     AlertUI.Show(costCfg.name + "不足,是否前往购买?").SetLeftButton(true).SetRightButton(true, "确认", (AlertWindow.AlertCallback)((object data) =>
 
-                     {
 
-                         long costNeedCount = coustNum - ItemDataManager.GetItemNum(costId);
 
-                         BuyItemConteoller.Show(costId, costNeedCount, ConstBuyType.TYPE_ITEM, 0, null, true, true, GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED);
 
-                     }));
 
-                     OnClickBtnCancel();
 
-                 }
 
-                 return;
 
-             }
 
-             bool result = await ItemExchangeSProxy.ItemExchange(_itemId, _count);
 
-             if (result)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("购买成功", MessageType.SUCCESS);
 
-                 if (_onSuccess != null)
 
-                 {
 
-                     _onSuccess();
 
-                 }
 
-             }
 
-             this.Hide();
 
-         }
 
-         private void OnClickBtnCancel()
 
-         {
 
-             this.Hide();
 
-         }
 
-     }
 
- }
 
 
  |