This commit is contained in:
2026-07-23 15:07:51 +08:00
parent 83699675e1
commit c91dbde7cb
4 changed files with 50 additions and 25 deletions
@@ -188,11 +188,18 @@ namespace Assets.MyGame.Scripts.Net.APIRequest.Params
public int type; // �������� 1=��Ӣ 2=����
}
/// <summary>��ȡ�û������б���GET��</summary>
/// <summary>获取用户任务列表(GET)</summary>
[Serializable]
public class GetUserTaskListParam : RequestParamBase
{
public int taskType = -1; // -1=ȫ��
public int taskType = -1; // -1=全部
}
/// <summary>领取 Vip 每日礼包(GET)参数:当前 vip 等级,领取 V1~vipLevel 所有每日礼包</summary>
[Serializable]
public class GetVipDayGiftParam : RequestParamBase
{
public int vipLevel;
}
/// <summary>发送全服广播(GET)</summary>
@@ -164,12 +164,13 @@ namespace Assets.MyGame.Scripts.Net
/// <summary>
/// 领取 Vip 每日礼包(GET)
/// 参数:用户ID
/// 参数:当前 vip 等级(领取 V1~vipLevel 所有每日礼包)
/// 返回:GiftInfo(礼包信息)
/// </summary>
public static void GetVipDayGift( Action<GiftInfo> callback)
public static void GetVipDayGift(int vipLevel, Action<GiftInfo> callback)
{
APIManager.Response<GiftInfo>(APIType.Hall_GetVipDayGift, callback);
APIManager.Response<GiftInfo>(APIType.Hall_GetVipDayGift,
new GetVipDayGiftParam { vipLevel = vipLevel }, callback);
}
/// <summary>
@@ -218,6 +218,11 @@ public class UIHome_BY_ShopPanel : SubUIBase
foreach (var item in gameConfig.propConfig)
{
if (item.isSale == false || item.isEnable == false) continue;
// 炮台/翅膀/战神已有单独的 Tab,这里剔除
if (item.type == (int)PropEnum.炮台
|| item.type == (int)PropEnum.翅膀
|| item.type == (int)PropEnum.VIP经验
|| item.type == (int)PropEnum.战神) continue;
var obj = Instantiate(obj_ItemPrefab, tra_PrefabParent).transform;
if (item.sprite_Icon == null)
@@ -35,6 +35,7 @@ public class UIHome_BY_VIPPanel : SubUIBase
public List<GameObject> img_VIPNumBG;
private int vipLevel = 0;
private int currentDisplayLevel = 0; // 当前正在查看的等级(用于数据刷新后还原显示)
private List<VipLevelConfig> vipConfigs;
public override void Awake()
@@ -51,6 +52,9 @@ public class UIHome_BY_VIPPanel : SubUIBase
private void OnUserDataChanged()
{
vipLevel = GameManager.Instance.user.assets.vipLevel;
// 拉取到最新 UserToken 后,刷新当前查看等级的 UI(经验、进度条、按钮状态等)
if (currentDisplayLevel > 0 && vipConfigs != null)
UpdateVIPPanel(currentDisplayLevel);
}
protected override void OnShow(object args = null)
@@ -115,6 +119,8 @@ public class UIHome_BY_VIPPanel : SubUIBase
var config = vipConfigs?.Find(v => v.level == level);
if (config == null) return;
currentDisplayLevel = level;
txt_VIPLevel.text = $"{level}";
txt_VIPContent.text = config.remark;
@@ -170,32 +176,38 @@ public class UIHome_BY_VIPPanel : SubUIBase
}
else
{
btn_Award_Get.gameObject.SetActive(true);
btn_Award_GetEnd.SetActive(false);
btn_Award_NotUnlock.SetActive(false);
btn_Award_Get.onClick.RemoveAllListeners();
btn_Award_Get.onClick.AddListener(() =>
// 按等级独立判断:vipGift 为未领取的 Vip 礼包等级集合,包含当前等级则可领取
bool canReceive = assets?.vipGift != null && System.Array.IndexOf(assets.vipGift, level) >= 0;
btn_Award_Get.gameObject.SetActive(canReceive);
btn_Award_GetEnd.SetActive(!canReceive);
if (canReceive)
{
APIRequestList.GetVipDayGift(result =>
btn_Award_Get.onClick.RemoveAllListeners();
btn_Award_Get.onClick.AddListener(() =>
{
if (result != null)
// 传入当前查看的等级,领取该等级的每日礼包
APIRequestList.GetVipDayGift(level, result =>
{
UIManager.Instance.ShowBoardError("领取成功");
btn_Award_Get.gameObject.SetActive(false);
btn_Award_GetEnd.SetActive(true);
var userId = GameManager.Instance?.user?.id;
if (!string.IsNullOrEmpty(userId))
APIRequestList.GetUser(userId, a => GameManager.Instance.UpdataUserData(a));
}
else
{
UIManager.Instance.ShowBoardError("领取失败");
}
if (result != null)
{
UIManager.Instance.ShowBoardError("领取成功");
// 拉取服务器最新 UserToken(含更新后的 vipGift),触发 OnUserDataChanged 刷新 UI
APIRequestList.GetUser(user =>
{
if (user != null)
GameManager.Instance.UpdataUserData(user);
});
}
else
{
UIManager.Instance.ShowBoardError("领取失败");
}
});
});
});
}
}
}