fix: bizhi detail

This commit is contained in:
zzc
2026-02-26 10:51:06 +08:00
parent e3c7450d18
commit ff1ce034b4
4 changed files with 691 additions and 39 deletions

View File

@@ -43,16 +43,16 @@
<!-- Action Buttons -->
<view class="action-buttons">
<button class="btn primary-btn" @tap="goToIndex">
<button class="btn primary-btn" @tap="downloadWallpaper">
<text class="btn-icon"></text>
<text>我也要领同款壁纸</text>
<text>下载高清壁纸</text>
</button>
</view>
<!-- More Wallpapers -->
<view class="more-section">
<view class="section-header">
<text class="section-title">我也要领新春壁纸</text>
<text class="section-title">更多同款壁纸</text>
<view class="more-link" @tap="goToIndex">
<text>查看更多</text>
<text class="arrow"></text>
@@ -77,39 +77,6 @@
</scroll-view>
</view>
<!-- Fortune Banner -->
<!-- Wallpaper Banner -->
<view class="wallpaper-banner" @tap="goToFortune">
<view class="banner-icon">
<text>🏮</text>
</view>
<view class="banner-content">
<text class="banner-title">去抽取新年运势</text>
<text class="banner-desc">每日一签开启你的新年好运</text>
</view>
<text class="banner-arrow"></text>
</view>
<view class="wallpaper-banner" @tap="goToGreeting">
<view class="banner-icon">
<text>🧧</text>
</view>
<view class="banner-content">
<text class="banner-title">去制作新年贺卡</text>
<text class="banner-desc">定制专属祝福传递浓浓年味</text>
</view>
<text class="banner-arrow"></text>
</view>
<view class="wallpaper-banner" @tap="goToAvatar">
<view class="banner-icon">
<text>🖼</text>
</view>
<view class="banner-content">
<text class="banner-title">去挑选新年头像</text>
<text class="banner-desc">精选新年头像让手机也过年</text>
</view>
<text class="banner-arrow"></text>
</view>
<!-- Footer -->
<view class="footer">
<view class="footer-divider">
@@ -120,16 +87,33 @@
<view class="footer-sub">新春祝福 · 传递温情</view>
</view>
</view>
<LoginPopup ref="loginPopupRef" @logind="handleLogind" />
<RewardAd ref="rewardAdRef" @onReward="handleAdReward" />
</view>
</template>
<script setup>
import { ref } from "vue";
import { ref, computed } from "vue";
import { onLoad, onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
import { getBavBarHeight } from "@/utils/system";
import { getPageDetail } from "@/api/system";
import { getWallpaperRecommendList } from "@/api/wallpaper";
import { getShareToken, saveViewRequest } from "@/utils/common.js";
import {
getShareToken,
saveViewRequest,
saveRemoteImageToLocal,
saveRecordRequest,
trackRecord,
} from "@/utils/common.js";
import { useUserStore } from "@/stores/user";
import { abilityCheck, watchAdReward } from "@/api/system.js";
import LoginPopup from "@/components/LoginPopup/LoginPopup.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 navHeight = getBavBarHeight();
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
@@ -145,6 +129,12 @@ onLoad(async (options) => {
shareToken.value = options.shareToken;
await fetchDetail();
}
if (options.id) {
detailData.value.id = options.id;
}
if (options.imageUrl) {
detailData.value.imageUrl = decodeURIComponent(options.imageUrl);
}
fetchRecommend();
});
@@ -243,6 +233,97 @@ const goToAvatar = () => {
url: "/pages/avatar/index",
});
};
const handleLogind = async () => {
// Logic after successful login if needed
};
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 () => {
trackRecord({
eventName: "wallpaper_download_click",
eventType: `click`,
elementId: detailData.value?.id || "",
});
if (!isLoggedIn.value) {
loginPopupRef.value.open();
return;
}
const abilityRes = await abilityCheck("wallpaper_download");
if (!abilityRes.canUse) {
if (
abilityRes?.blockType === "need_share" &&
abilityRes?.message === "分享可继续"
) {
uni.showToast({
title: "分享给好友即可下载",
icon: "none",
});
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",
});
return;
}
uni.showLoading({ title: "下载中..." });
try {
// Parallelize save record and download
// Wait for saveRecordRequest to ensure backend deducts points
await Promise.all([
saveRecordRequest(
"",
detailData.value?.id,
"wallpaper_download",
detailData.value?.imageUrl,
),
saveRemoteImageToLocal(detailData.value?.imageUrl),
]);
// Refresh user assets to show updated points
await userStore.fetchUserAssets();
uni.hideLoading();
uni.showToast({ title: "保存成功 消耗 20 积分", icon: "success" });
} catch (e) {
uni.hideLoading();
console.error("Download failed", e);
uni.showToast({ title: "下载失败", icon: "none" });
}
};
</script>
<style lang="scss" scoped>