// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2022-03-21 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using TMPro; using UnityEngine; using UnityEngine.UI; namespace G.UI { partial class QingMingWindow { class GiftBagInfo : KUIWidget { #region Fide #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] KUIList __listRewards; [KUIFlag] TextMeshProUGUI _tmpDescription; [KUIFlag] Button _btnReceive; [KUIFlag] TextMeshProUGUI _tmpPrice; [KUIFlag] GameObject _goImageIcon; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null #endregion #region Mothod public override void Refresh() { if (this.data is ActivitySubInfo subInfo) { var gift = RmbShopProxy.Instance.GetGiftBoxInfo(subInfo.item.typeArgs[0]); _tmpDescription.text = "礼包剩余:" + (TimeProxy.Instance.GetTimes(gift.item.timeId)); if (TimeProxy.Instance.GetTimes(gift.item.timeId) > 0) { if (gift.id == 2008) { _goImageIcon.SetActive(false); _tmpPrice.text = "免费"; } else { _goImageIcon.SetActive(true); _tmpPrice.text = gift.rmbPrice.ToString(); } _tmpDescription.color = Color.white; _btnReceive.interactable = true; } else { _goImageIcon.SetActive(false); _tmpPrice.text = "已购买"; _tmpDescription.color = new Color32(255, 182, 91, 255); _btnReceive.interactable = false; } __listRewards.Clear(); foreach (var itemInfo in gift.exchanges) { __listRewards.GetItem().SetItem(itemInfo); } } } private void OnReceiveBtnClick() //购买礼包 { if (this.data is ActivitySubInfo subInfo) { QingMingActivity.Instance.BuyGift(subInfo.item.typeArgs[0], (error, message) => { if (error == 0) { GetWindow().RefreshGiftBagPanle(); PostNotification(GlobalDefine.EVENT_MONEY_CHANGED, "Exchange", "Women_w_Btn"); KStatistics.Instance.ReportEvent_Activity("qingming", 4, subInfo.id, "", "", 1, "", 0, 0);//埋点 } }); } } #endregion #region Unity private void Awake() { SetViewData(); _btnReceive.onClick.AddListener(this.OnReceiveBtnClick); __listRewards.AddTemplate(true); } #endregion } class GiftBag : KUIWidget { #region Field #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] TextMeshProUGUI _tmpPropNumber; [KUIFlag] KUIList __listGifts; [KUIFlag] TextMeshProUGUI _tmpTime3; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null #endregion #region Method public void RefreshView() { var propCount = ItemProxy.Instance.GetPropCount(3001); _tmpPropNumber.text = propCount.ToString(); _tmpTime3.text = QingMingActivity.Instance.sigeInSurplusTime; __listGifts.Clear(); var subInfos = QingMingActivity.Instance.giftBoxActivityInfo.subInfos; foreach (var subInfo in subInfos)//将未购买过的礼包添加进去 { var gift = RmbShopProxy.Instance.GetGiftBoxInfo(subInfo.item.typeArgs[0]); if (TimeProxy.Instance.GetTimes(gift.item.timeId) > 0) __listGifts.GetItem().SetData(subInfo); } foreach (var subInfo in subInfos)//将已购买过的礼包添加进去 { var gift = RmbShopProxy.Instance.GetGiftBoxInfo(subInfo.item.typeArgs[0]); if (TimeProxy.Instance.GetTimes(gift.item.timeId) <= 0) __listGifts.GetItem().SetData(subInfo); } } public void RefreshTimer()//刷新时间 { _tmpTime3.text = QingMingActivity.Instance.sigeInSurplusTime; } #endregion #region Unity private void Awake() { SetViewData(); __listGifts.AddTemplate(true); } private void OnEnable() { RefreshView(); } #endregion } } }