feat: 下载次数限制,免费额度用完后第一次需要分享,之后需要看广告
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user