using System.Collections.Generic;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
public class LianQiRechargeGiftActCell : CellView
|
{
|
[SerializeField] TextEx txtTitle;
|
|
[SerializeField] List<CustomizedItemCell> itemCells;
|
[SerializeField] ButtonEx btnBuy;
|
[SerializeField] ImageEx imgBuy;
|
[SerializeField] TextEx txtPrice;
|
[SerializeField] ImageEx imgBuyYet;
|
[SerializeField] ImageEx imgProfitRatio;
|
[SerializeField] TextEx txtProfitRatio;
|
[SerializeField] TextEx txtLimitCount;
|
[SerializeField] ImageEx imgRed;
|
[SerializeField] TextEx orgPrice;
|
|
LianQiRechargeGiftActModel model { get { return ModelCenter.Instance.GetModel<LianQiRechargeGiftActModel>(); } }
|
VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
|
LianQiActModel lianQiActModel { get { return ModelCenter.Instance.GetModel<LianQiActModel>(); } }
|
StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
|
CustomizedRechargeModel customizedRechargeModel { get { return ModelCenter.Instance.GetModel<CustomizedRechargeModel>(); } }
|
|
public void Display(int index)
|
{
|
OperationRechargeGiftAct act;
|
OperationTimeHepler.Instance.TryGetOperation(LianQiRechargeGiftActModel.operaType, out act);
|
if (act == null)
|
return;
|
imgRed.SetActive(false);
|
|
List<StoreConfig> _list = null;
|
StoreConfig.TryGetStoreConfigs(act.shopType, out _list);
|
|
if (_list != null && index < _list.Count)
|
{
|
DisplayStore(_list[index]);
|
return;
|
}
|
index = index - (_list != null ? _list.Count : 0);
|
|
int ctgID = act.ctgIDs[index];
|
var ctgConfig = CTGConfig.Get(ctgID);
|
txtTitle.text = ctgConfig.Title;
|
|
var countInfo = model.GetBuyCntInfo(ctgID);
|
|
int buyCnt = countInfo.x;
|
int totalCnt = countInfo.y;
|
imgBuy.SetSprite("RechargeGiftActBuyButton");
|
customizedRechargeModel.ShowUIItems(itemCells, ctgID);
|
btnBuy.SetActive(buyCnt < totalCnt);
|
btnBuy.SetListener(() =>
|
{
|
if (PlayerDatas.Instance.baseData.VIPLv < ctgConfig.VipLevel)
|
{
|
SysNotifyMgr.Instance.ShowTip("VIPNotEnough", ctgConfig.VipLevel);
|
return;
|
}
|
|
if (lianQiActModel.IsOpen)
|
{
|
//²ÎÓëʱ¼ä½áÊøÇ°Ö±½Ó¹ºÂò£¬Ê±¼ä½áÊøºóÔÙ¹ºÂòÐèÒªµ¯´°Ìáʾ
|
if (lianQiActModel.IsPrepareTime || lianQiActModel.IsJoin)
|
vipModel.CTG(ctgID);
|
else
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("LianQi21"), (bool isOk) =>
|
{
|
if (isOk)
|
{
|
vipModel.CTG(ctgID);
|
}
|
});
|
}
|
}
|
else
|
{
|
vipModel.CTG(ctgID);
|
}
|
});
|
imgBuyYet.SetActive(buyCnt >= totalCnt);
|
|
OrderInfoConfig orderConfig;
|
vipModel.TryGetOrderInfo(ctgID, out orderConfig);
|
imgProfitRatio.SetActive(orderConfig != null);
|
txtPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderConfig.PayRMBNum));
|
txtLimitCount.SetActive(true);
|
txtLimitCount.text = Language.Get("YunShi03", UIHelper.AppendColor(buyCnt >= totalCnt ? TextColType.Red : TextColType.DarkGreen, Mathf.Max(0, totalCnt - buyCnt).ToString(), true));
|
|
if (orgPrice != null)
|
{
|
orgPrice.SetActive(PlayerDatas.Instance.baseData.IsActive90Off);
|
orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderConfig.m_PayRMBNum));
|
}
|
|
txtProfitRatio.text = Language.Get("BlessedLand039", ctgConfig.Percentage);
|
}
|
|
private void DisplayStore(StoreConfig storeConfig)
|
{
|
bool isFree = storeConfig.MoneyNumber == 0;
|
imgBuy.SetSprite(isFree ? "RechargeGiftActHaveButton" : "RechargeGiftActBuyButton");
|
txtTitle.text = isFree ? Language.Get("StoreName_free") : Language.Get("StoreName_money");
|
imgRed.SetActive(isFree);
|
orgPrice.SetActive(false);
|
int remainNum;
|
storeModel.TryGetIsSellOut(storeConfig, out remainNum);
|
|
var items = storeModel.GetShopItemlistByIndex(storeConfig);
|
|
for (int i = 0; i < itemCells.Count; i++)
|
{
|
var itemBaisc = itemCells[i];
|
if (i < items.Count)
|
{
|
var itemInfo = items[i];
|
itemBaisc.SetActive(true);
|
ItemCellModel cellModel = new ItemCellModel(itemInfo.itemId, false, (ulong)itemInfo.count);
|
itemBaisc.Init(cellModel);
|
itemBaisc.button.AddListener(() =>
|
{
|
ItemTipUtility.Show(itemInfo.itemId);
|
});
|
}
|
else
|
{
|
itemBaisc.SetActive(false);
|
}
|
}
|
|
btnBuy.SetActive(remainNum > 0);
|
btnBuy.SetListener(() =>
|
{
|
storeModel.SendBuyShopItemWithPopCheck(storeConfig, 1, (int)BuyStoreItemCheckType.ActGift);
|
});
|
imgBuyYet.SetActive(remainNum <= 0);
|
|
txtPrice.text = isFree ? Language.Get("RealmPractice109") : Language.Get("ItemOverdue105", storeConfig.MoneyNumber);
|
imgProfitRatio.SetActive(false);
|
txtLimitCount.SetActive(!isFree);
|
txtLimitCount.text = Language.Get("CycleHall06", UIHelper.AppendColor(remainNum == 0 ? TextColType.Red : TextColType.DarkGreen, Mathf.Max(0, remainNum).ToString(), true));
|
}
|
}
|
}
|