128 lines
3.3 KiB
C#
128 lines
3.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Module.Log;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class WelfareMonthlyCardCtr : WelfarePageBaseCS
|
|
{
|
|
#region Single
|
|
|
|
public static WelfareMonthlyCardCtr Instance;
|
|
void Awake()
|
|
{
|
|
Instance = this;
|
|
if (getAwardBtn != null)
|
|
{
|
|
getAwardBtn.onClick.AddListener(GetAward);
|
|
}
|
|
else
|
|
{
|
|
LogModule.ErrorLog("Can't get button gameObject");
|
|
}
|
|
|
|
if(buyCardBtn != null)
|
|
{
|
|
buyCardBtn.onClick.AddListener(SwitchToShop);
|
|
}
|
|
else
|
|
{
|
|
LogModule.ErrorLog("Can't get button gameObject");
|
|
}
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Display
|
|
|
|
//public Text immediatelyAwardNum;
|
|
public GameObject buyCardPanl; // 未购买月卡显示的面板
|
|
public GameObject awardPanel; // 购买后显示的面版
|
|
public Button buyCardBtn; // 购买按钮 - 跳转商店
|
|
public Button getAwardBtn; // 领取奖励按钮
|
|
public GameObject hasGetTip;
|
|
public Text remainDays; // 剩余天数
|
|
//public Text dailayAwardDesc; // 总共领取的奖励
|
|
private int subId = -1;
|
|
|
|
public void Display(RetMonthlyCard data)
|
|
{
|
|
//immediatelyAwardNum.text = data.jade.ToString();
|
|
|
|
if (data.purchaseState == 0)
|
|
{
|
|
buyCardPanl.SetActive(true);
|
|
awardPanel.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
//dailayAwardDesc.text = data.yuanbao.ToString();
|
|
buyCardPanl.SetActive(false);
|
|
awardPanel.SetActive(true);
|
|
|
|
remainDays.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{3159}",data.lastDay.ToString() + GCGame.Table.StrDictionary.GetClientDictionaryString("#{9906}"));
|
|
if(data.rewardState == 1)
|
|
{
|
|
getAwardBtn.gameObject.SetActive(true);
|
|
hasGetTip.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
getAwardBtn.gameObject.SetActive(false);
|
|
hasGetTip.SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 数据发送与接收
|
|
|
|
public override void OnPacketRec(NodePageInfoRet packet) { /* Do nothing */ }
|
|
|
|
// 月卡采用新的数据协议
|
|
public void OnPacketRec(object newPacket)
|
|
{
|
|
RetMonthlyCard data = newPacket as RetMonthlyCard;
|
|
if (data != null)
|
|
{
|
|
if(data.actID == this._NodeId)
|
|
{
|
|
subId = data.nodeID;
|
|
Display(data);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 领奖
|
|
public void GetAward()
|
|
{
|
|
ReqGetWelfareRew req = new ReqGetWelfareRew();
|
|
req._NodeId = this._NodeId;
|
|
req._SubNodeId = this.subId;
|
|
req.SendMsg();
|
|
}
|
|
|
|
#endregion
|
|
|
|
// 点击购买按钮,跳转到商店界面
|
|
public void SwitchToShop()
|
|
{
|
|
YuanBaoShopLogic.OpenChargePage();
|
|
Close();
|
|
}
|
|
|
|
private void Close()
|
|
{
|
|
if(WelfareRootCtr.Instance != null)
|
|
{
|
|
WelfareRootCtr.Instance.OnCloseBtnClick();
|
|
}
|
|
}
|
|
}
|