feat: 下载次数限制,免费额度用完后第一次需要分享,之后需要看广告

This commit is contained in:
R524809
2026-05-20 16:51:54 +08:00
parent d52339c0fa
commit 51650db04e
9 changed files with 282 additions and 225 deletions
+24 -3
View File
@@ -1,7 +1,11 @@
import { SHAPES, ShapeCard } from '../../constants/shapes';
import { WATER_COLORS, PAPER_SIZE } from '../../constants/colors';
import ShapeDrawService from '../../service/shapeDrawService';
import { downloadPrint } from '../../utils/downloadPrint';
import { downloadPrint, tryUnlockWithRewardedAd } from '../../utils/downloadPrint';
import {
shouldShowShareGuide,
shouldUnlockWithAd,
} from '../../utils/shareGuide';
Page({
canvas: null as Canvas | null,
@@ -289,6 +293,18 @@ Page({
return;
}
if (shouldUnlockWithAd()) {
const unlocked = await tryUnlockWithRewardedAd();
if (!unlocked) {
return;
}
}
if (shouldShowShareGuide()) {
this.setData({ showShareDialog: true });
return;
}
await downloadPrint(this.canvas, {
errorToast: '请先生成图形',
trackerName: '图形涂色',
@@ -324,9 +340,14 @@ Page({
},
/** 分享成功回调(由组件触发) */
onShareSuccess() {
// 只关闭弹窗,不触发下载
async onShareSuccess() {
this.setData({ showShareDialog: false });
if (this.canvas && this.data.shapeList.length > 0) {
await downloadPrint(this.canvas, {
errorToast: '请先生成图形',
trackerName: '图形涂色',
});
}
},
onUnload() {