fix: lock resousers

This commit is contained in:
zzc
2026-03-11 16:36:54 +08:00
parent c2b889ac8f
commit 9c4f0c5650
3 changed files with 37 additions and 18 deletions

View File

@@ -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,
},
});
};

View File

@@ -210,17 +210,7 @@
>
<!-- Badge -->
<view class="unlock-badge" :class="tpl.unlockType">
{{
tpl.unlockType === "sing3"
? "登录3天"
: tpl.unlockType === "sing1"
? "登录1天"
: tpl.unlockType === "ad"
? "广告"
: tpl.unlockType === "vip"
? "VIP"
: "解锁"
}}
{{ getUnlockLabel(tpl.unlockType) }}
</view>
<!-- Center Lock -->
@@ -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: "解锁成功",

View File

@@ -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 "解锁";
}
};