fix: point exp

This commit is contained in:
zzc
2026-02-25 10:27:30 +08:00
parent 1fef1818d8
commit a6e9c1c9ce
4 changed files with 79 additions and 20 deletions

View File

@@ -91,6 +91,7 @@
@logind="handleLogind"
:share-token="shareToken"
/>
<RewardAd ref="rewardAdRef" @onReward="handleAdReward" />
</view>
</template>
@@ -103,16 +104,18 @@ import {
getShareToken,
} from "@/utils/common.js";
import { onShareAppMessage, onShareTimeline, onLoad } from "@dcloudio/uni-app";
import { getShareReward, abilityCheck } from "@/api/system.js";
import { getShareReward, abilityCheck, watchAdReward } from "@/api/system.js";
import { useUserStore } from "@/stores/user";
import { saveViewRequest, trackRecord } from "@/utils/common.js";
import NavBar from "@/components/NavBar/NavBar.vue";
import RewardAd from "@/components/RewardAd/RewardAd.vue";
const userStore = useUserStore();
const loginPopupRef = ref(null);
const rewardAdRef = ref(null);
const isLoggedIn = computed(() => !!userStore.userInfo.nickName);
const userScore = computed(() => userStore.userInfo.score || 0);
const userScore = computed(() => userStore.userInfo.points || 0);
const downloadCost = ref(20);
const categories = ref([]);
@@ -267,6 +270,22 @@ const previewImage = (index) => {
});
};
const handleAdReward = async (token) => {
try {
const res = await watchAdReward(token);
if (res) {
uni.showToast({
title: "获得50积分",
icon: "success",
});
await userStore.fetchUserAssets();
}
} catch (e) {
console.error("Reward claim failed", e);
uni.showToast({ title: "奖励发放失败", icon: "none" });
}
};
const downloadWallpaper = async (item) => {
trackRecord({
eventName: "wallpaper_download_click",
@@ -290,6 +309,21 @@ const downloadWallpaper = async (item) => {
});
return;
}
if (
abilityRes?.blockType === "need_ad" &&
abilityRes?.message === "观看广告可继续"
) {
uni.showModal({
title: "积分不足",
content: "观看广告可获得50积分继续下载",
success: (res) => {
if (res.confirm) {
rewardAdRef.value.show();
}
},
});
return;
}
uni.showToast({
title: "您今日壁纸下载次数已用完,明日再试",
icon: "none",
@@ -299,7 +333,10 @@ const downloadWallpaper = async (item) => {
uni.showLoading({ title: "下载中..." });
await saveRemoteImageToLocal(item.imageUrl);
saveRecordRequest("", item.id, "wallpaper_download", item.imageUrl);
await saveRecordRequest("", item.id, "wallpaper_download", item.imageUrl);
await userStore.fetchUserAssets();
uni.showToast({ title: "保存成功 消耗 20 积分", icon: "success" });
};
const shareWallpaper = (item) => {};