From 9c4f0c5650a26d1d03ef34a47dd6a19155fa8ee9 Mon Sep 17 00:00:00 2001 From: zzc <1761997216@qq.com> Date: Wed, 11 Mar 2026 16:36:54 +0800 Subject: [PATCH] fix: lock resousers --- api/system.js | 5 ++++- pages/make/index.vue | 29 ++++++++++++----------------- utils/ability.js | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/api/system.js b/api/system.js index 9d4263a..c92ea7d 100644 --- a/api/system.js +++ b/api/system.js @@ -110,12 +110,15 @@ export const createTracking = async (data) => { }); }; -export const watchAdReward = async (token) => { +export const watchAdReward = async (token, scene, type, resourceId) => { return request({ url: "/api/ad/reward", method: "POST", data: { rewardToken: token, + scene, + type, + resourceId, }, }); }; diff --git a/pages/make/index.vue b/pages/make/index.vue index 877c1ea..ae5a07d 100644 --- a/pages/make/index.vue +++ b/pages/make/index.vue @@ -210,17 +210,7 @@ > - {{ - tpl.unlockType === "sing3" - ? "登录3天" - : tpl.unlockType === "sing1" - ? "登录1天" - : tpl.unlockType === "ad" - ? "广告" - : tpl.unlockType === "vip" - ? "VIP" - : "解锁" - }} + {{ getUnlockLabel(tpl.unlockType) }} @@ -564,7 +554,7 @@ import { getCardMusicList, } from "@/api/make"; import { getShareReward, msgCheckApi, watchAdReward } from "@/api/system"; -import { checkAbilityAndHandle } from "@/utils/ability.js"; +import { checkAbilityAndHandle, getUnlockLabel } from "@/utils/ability.js"; import { onShareAppMessage, onShareTimeline, @@ -1383,7 +1373,7 @@ const currentTemplate = ref(templates.value[0]); const currentUnlockTpl = ref(null); const applyTemplate = (tpl) => { - if (tpl.isUnlock === false) { + if (tpl.unlockType && !tpl.isUnlock) { handleUnlock(tpl); return; } @@ -1405,17 +1395,17 @@ const handleUnlock = (tpl) => { break; case "ad": currentUnlockTpl.value = tpl; - rewardAdRef.value.showAd(); + rewardAdRef.value.show(); break; case "sing1": uni.showToast({ - title: "需要连续登录1天解锁", + title: "需要登录1天解锁", icon: "none", }); break; case "sing3": uni.showToast({ - title: "需要连续登录3天解锁", + title: "需要登录3天解锁", icon: "none", }); break; @@ -1429,7 +1419,12 @@ const handleUnlock = (tpl) => { const handleAdReward = async (token) => { try { - const res = await watchAdReward(token); + const res = await watchAdReward( + token, + "unlock", + activeTool.value === "template" ? "card_template" : "card_title_template", + currentUnlockTpl.value.id, + ); if (res) { uni.showToast({ title: "解锁成功", diff --git a/utils/ability.js b/utils/ability.js index 8be67dc..1affb6a 100644 --- a/utils/ability.js +++ b/utils/ability.js @@ -68,3 +68,24 @@ export const checkAbilityAndHandle = async (scene) => { return false; } }; + +/** + * Gets the display label for an unlock type. + * @param {string} unlockType - The unlock type identifier. + * @returns {string} - The display label. + */ +export const getUnlockLabel = (unlockType) => { + if (!unlockType) return "解锁"; + switch (unlockType) { + case "sing3": + return "登录3天"; + case "sing1": + return "登录1天"; + case "ad": + return "广告"; + case "vip": + return "VIP"; + default: + return "解锁"; + } +};