//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Friday, March 01, 2019
|
//--------------------------------------------------------
|
|
using LitJson;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
namespace vnxbqy.UI
|
{
|
|
public class SuperPushWin : Window
|
{
|
[SerializeField] Button closeBtn;
|
[SerializeField] Button buyBtn;
|
[SerializeField] Text priceText;
|
[SerializeField] Image buyYetImg;
|
[SerializeField] Text infoText;
|
[SerializeField] List<ItemCell> awardObjs = new List<ItemCell>();
|
|
TextEx orgPrice;
|
|
VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
PushCoinModel model { get { return ModelCenter.Instance.GetModel<PushCoinModel>(); } }
|
|
|
#region Built-in
|
|
protected override void BindController()
|
{
|
var obj = buyBtn.FindComponent("Text", "Txt_orgPrice");
|
if (obj != null)
|
orgPrice = obj as TextEx;
|
}
|
|
protected override void AddListeners()
|
{
|
closeBtn.AddListener(() => { CloseImmediately(); });
|
|
buyBtn.AddListener(() => {
|
vipModel.CTG(model.ctgID);
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
vipModel.rechargeCountEvent += VipModel_rechargeCountEvent;
|
ShowBtn();
|
infoText.text = Language.Get("PushCoinRule1", model.superPushGiftGoinInfo[0], model.superPushGiftGoinInfo[1]);
|
|
List<Item> itemList;
|
vipModel.TryGetRechargeItem(model.ctgID, out itemList);
|
for (int i = 0; i < awardObjs.Count; i++)
|
{
|
if (i < itemList.Count)
|
{
|
awardObjs[i].SetActive(true);
|
var itemId = itemList[i].id;
|
var model = new ItemCellModel(itemId, false, (ulong)itemList[i].count);
|
awardObjs[i].Init(model);
|
awardObjs[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemId);
|
});
|
}
|
else
|
{
|
awardObjs[i].SetActiveIL(false);
|
}
|
}
|
}
|
|
private void VipModel_rechargeCountEvent(int obj)
|
{
|
ShowBtn();
|
if (obj == model.ctgID)
|
{
|
Clock.AlarmAfter(0.5f, () =>
|
{
|
CloseImmediately();
|
WindowCenter.Instance.Open<PushCoinWin>();
|
SysNotifyMgr.Instance.ShowTip("SuperPush");
|
});
|
}
|
}
|
|
protected override void OnActived()
|
{
|
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
vipModel.rechargeCountEvent -= VipModel_rechargeCountEvent;
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
|
#endregion
|
|
|
void ShowBtn()
|
{
|
VipModel.RechargeCount rechargeCount;
|
vipModel.TryGetRechargeCount(model.ctgID, out rechargeCount);
|
if (rechargeCount.totalCount > 0)
|
{
|
buyBtn.SetActive(false);
|
buyYetImg.SetActive(true);
|
}
|
else
|
{
|
buyBtn.SetActive(true);
|
buyYetImg.SetActive(false);
|
|
OrderInfoConfig config;
|
vipModel.TryGetOrderInfo(model.ctgID, out config);
|
priceText.text = Language.Get("PayMoneyNum", config.PayRMBNum);
|
if (orgPrice != null)
|
{
|
orgPrice.SetActiveIL(PlayerDatas.Instance.baseData.IsActive90Off);
|
orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(config.m_PayRMBNum));
|
}
|
}
|
}
|
}
|
|
}
|