fix: user deduct point

This commit is contained in:
zzc
2026-03-10 11:41:05 +08:00
parent d8c5c3a919
commit 2d3cefa43e
10 changed files with 140 additions and 125 deletions

View File

@@ -1,14 +1,14 @@
import { abilityCheck } from "@/api/system";
import adManager from "@/utils/adManager";
/**
* Checks if a user has the ability to perform an action (e.g., download).
* Handles common blocking scenarios like "need_share" or "need_ad".
*
* @param {string} scene - The scene identifier for the ability check (e.g., "wallpaper_download").
* @param {Object} rewardAdRef - The ref to the RewardAd component (must have a .value.show() method or be the instance itself).
* @returns {Promise<boolean>} - Returns true if the action can proceed, false otherwise.
*/
export const checkAbilityAndHandle = async (scene, rewardAdRef) => {
export const checkAbilityAndHandle = async (scene) => {
try {
const abilityRes = await abilityCheck(scene);
if (abilityRes.canUse) {
@@ -35,19 +35,7 @@ export const checkAbilityAndHandle = async (scene, rewardAdRef) => {
content: "观看广告可获得50积分继续下载",
success: (res) => {
if (res.confirm) {
// Check if rewardAdRef is a ref (has .value) or the component instance itself
if (
rewardAdRef &&
rewardAdRef.value &&
typeof rewardAdRef.value.show === "function"
) {
rewardAdRef.value.show();
} else if (rewardAdRef && typeof rewardAdRef.show === "function") {
rewardAdRef.show();
} else {
console.error("RewardAd component reference is invalid");
uni.showToast({ title: "广告加载失败", icon: "none" });
}
adManager.showVideoAd();
}
},
});