using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using TableConfig;
|
using System;
|
|
namespace Snxxz.UI
|
{
|
public class RechargeBehaviour : MonoBehaviour
|
{
|
[SerializeField] Button m_ChargeButton;
|
[SerializeField] RectTransform m_ContainerTitle;
|
[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;
|
|
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 _ctgConfig = Config.Instance.Get<CTGConfig>(_id);
|
if (_ctgConfig == null)
|
{
|
return;
|
}
|
chargeId = _id;
|
if (m_ContainerTitle != null)
|
{
|
//m_Title.text = _ctgConfig.Title;
|
}
|
m_ChargeIcon.SetSprite(_ctgConfig.Icon);
|
m_PriceValue.text = StringUtility.Contact("¥", model.GetPayRmb(_ctgConfig.RecordID));
|
m_GetGoldValue.gameObject.SetActive(_ctgConfig.GainGold > 0);
|
if(_ctgConfig.GainGold > 0)
|
{
|
m_GetGoldValue.text = _ctgConfig.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(_ctgConfig.DailyBuyCount > 0 &&
|
_ctgConfig.DailyBuyCount <= _rechargeCount.todayCount);
|
}
|
}
|
m_ContainerAdded.gameObject.SetActive((_firstRecharge && _ctgConfig.FirstGoldPaperPrize > 0)
|
|| _ctgConfig.GainGoldPaper > 0);
|
if(_firstRecharge && _ctgConfig.FirstGoldPaperPrize > 0)
|
{
|
m_AddedValue.text = _ctgConfig.FirstGoldPaperPrize.ToString();
|
}
|
else if (_ctgConfig.GainGoldPaper > 0)
|
{
|
m_AddedValue.text = _ctgConfig.GainGoldPaper.ToString();
|
}
|
|
if (m_BuyLimitIcon != null)
|
{
|
m_BuyLimitIcon.gameObject.SetActive(_ctgConfig.PayType == 1 && _ctgConfig.DailyBuyCount > 0 && !_firstRecharge);
|
}
|
if (m_FirstBuy != null)
|
{
|
m_FirstBuy.gameObject.SetActive(_ctgConfig.PayType == 1 && _firstRecharge);
|
}
|
}
|
|
private void OnChargeClick()
|
{
|
var _ctgConfig = Config.Instance.Get<CTGConfig>(chargeId);
|
if (_ctgConfig != null)
|
{
|
if (model.m_RechargeGainItemDict.ContainsKey(chargeId))
|
{
|
model.ShowRechargeBox(chargeId);
|
return;
|
}
|
model.CTG(chargeId);
|
}
|
}
|
}
|
}
|
|