using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
using System;
|
|
namespace Snxxz.UI
|
{
|
public class RechargeBehaviour : MonoBehaviour
|
{
|
[SerializeField] Button m_ChargeButton;
|
[SerializeField] Image m_ChargeIcon;
|
[SerializeField] Text m_PriceValue;
|
[SerializeField] Text m_GetGoldValue;
|
[SerializeField] RectTransform m_ContainerAdded;
|
[SerializeField] Text m_AddedValue;
|
[SerializeField] Image m_BuyLimitIcon;
|
[SerializeField] Image m_BuyComplete;
|
[SerializeField] Image m_FirstBuy;
|
[SerializeField] Image m_FisrtRechargeSign;
|
|
VipModel m_Model;
|
VipModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<VipModel>());
|
}
|
}
|
|
public int chargeId { get; private set; }
|
|
private void Awake()
|
{
|
m_ChargeButton.onClick.AddListener(OnChargeClick);
|
}
|
|
public void Display(int _id)
|
{
|
var config = CTGConfig.Get(_id);
|
if (config == null)
|
{
|
return;
|
}
|
chargeId = _id;
|
m_ChargeIcon.SetSprite(config.Icon);
|
m_PriceValue.text = StringUtility.Contact("¥", model.GetPayRmb(config.RecordID));
|
m_GetGoldValue.gameObject.SetActive(config.GainGold > 0);
|
if(config.GainGold > 0)
|
{
|
m_GetGoldValue.text = config.GainGold.ToString();
|
}
|
VipModel.RechargeCount _rechargeCount;
|
bool _firstRecharge = true;
|
if (model.TryGetRechargeCount(_id, out _rechargeCount))
|
{
|
if (_rechargeCount.totalCount > 0)
|
{
|
_firstRecharge = false;
|
}
|
if (m_BuyComplete != null)
|
{
|
m_BuyComplete.gameObject.SetActive(config.DailyBuyCount > 0 &&
|
config.DailyBuyCount <= _rechargeCount.todayCount);
|
}
|
}
|
m_ContainerAdded.gameObject.SetActive((_firstRecharge && config.FirstGoldPaperPrize > 0)
|
|| config.GainGoldPaper > 0);
|
if (config.PayType == 2)
|
{
|
m_FisrtRechargeSign.gameObject.SetActive(false);
|
}
|
if (_firstRecharge && config.FirstGoldPaperPrize > 0)
|
{
|
m_AddedValue.text = config.FirstGoldPaperPrize.ToString();
|
m_FisrtRechargeSign.gameObject.SetActive(true);
|
}
|
else if (config.GainGoldPaper > 0)
|
{
|
m_AddedValue.text = config.GainGoldPaper.ToString();
|
}
|
|
if (m_BuyLimitIcon != null)
|
{
|
m_BuyLimitIcon.gameObject.SetActive(config.PayType == 1 && config.DailyBuyCount > 0 && !_firstRecharge);
|
}
|
if (m_FirstBuy != null)
|
{
|
m_FirstBuy.gameObject.SetActive(config.PayType == 1 && _firstRecharge);
|
}
|
}
|
|
private void OnChargeClick()
|
{
|
var _ctgConfig = CTGConfig.Get(chargeId);
|
if (_ctgConfig != null)
|
{
|
if (model.m_RechargeGainItemDict.ContainsKey(chargeId))
|
{
|
model.ShowRechargeBox(chargeId);
|
return;
|
}
|
model.CTG(chargeId);
|
}
|
}
|
}
|
}
|
|