diff --git a/miniprogram/base/pageMixin.ts b/miniprogram/base/pageMixin.ts index 90007b2..a7b1785 100644 --- a/miniprogram/base/pageMixin.ts +++ b/miniprogram/base/pageMixin.ts @@ -1,5 +1,9 @@ import { PAPER_SIZE } from '../constants/colors'; -import { downloadPrint } from '../utils/downloadPrint'; +import { downloadPrint, tryUnlockWithRewardedAd } from '../utils/downloadPrint'; +import { + shouldShowShareGuide, + shouldUnlockWithAd, +} from '../utils/shareGuide'; import { BaseDrawService } from '../core/draw/baseDraw'; import tracker from '../utils/tracker'; import { defaultShareConfig } from '../config/config'; @@ -230,12 +234,28 @@ export function getPageCommonMethods(config: PageCommonMethodsConfig = {}) { typeof this.getWorksheetStatsId === 'function' ? this.getWorksheetStatsId() : this.data.functionId; - await downloadPrint(this.canvas, { + const downloadOptions = { errorToast: '请先生成内容', trackerName: this.data.pageTitle, trackerMode: this.data.currentMode, worksheetId, - }); + }; + + // 第 2 次及以后满批:直接拉激励广告 + if (shouldUnlockWithAd()) { + const unlocked = await tryUnlockWithRewardedAd(); + if (!unlocked) { + return; + } + } + + // 当日首次满批:仅分享解锁,弹窗引导 + if (shouldShowShareGuide()) { + this.setData({ showShareDialog: true }); + return; + } + + await downloadPrint(this.canvas, downloadOptions); }, getShareOptions(this: PageCanvasInstance): ShareOptions { @@ -288,7 +308,6 @@ export function getPageCommonMethods(config: PageCommonMethodsConfig = {}) { typeof this.getWorksheetStatsId === 'function' ? this.getWorksheetStatsId() : this.data.functionId; - // 分享成功后下载(不限制次数) await downloadPrint(this.canvas, { errorToast: '请先生成内容', trackerName: this.data.pageTitle, diff --git a/miniprogram/chinesePages/handwritingSheet/handwritingSheet.ts b/miniprogram/chinesePages/handwritingSheet/handwritingSheet.ts index 4563220..93d16f9 100644 --- a/miniprogram/chinesePages/handwritingSheet/handwritingSheet.ts +++ b/miniprogram/chinesePages/handwritingSheet/handwritingSheet.ts @@ -1,5 +1,4 @@ import WordDrawService from './draw/wordDrawService'; -import { downloadPrint } from '../../utils/downloadPrint'; import { getWordsSvgData } from '../../utils/getWordsSvgJson'; import { WORDS } from '../../core/data/words'; import { CharacterItem } from '../../types/characterType'; @@ -396,13 +395,6 @@ createPage( return characterData; }, - async exportToPrint() { - await downloadPrint(this.canvas, { - errorToast: '请先生成练字贴', - trackerName: '练字贴', - }); - }, - onShare() {}, onShareAppMessage() { @@ -421,14 +413,6 @@ createPage( }; }, - onCloseShareDialog() { - this.setData({ showShareDialog: false }); - }, - - onShareSuccess() { - this.setData({ showShareDialog: false }); - }, - getPublishMeta(): DebugPublishMeta { const meta = getPublishMetaByMode(HANDWRITING_SHEET_WORKSHEET_ID); if (!meta) { diff --git a/miniprogram/components/share-guide-popup/share-guide-popup.less b/miniprogram/components/share-guide-popup/share-guide-popup.less index a5b2c3c..d07013e 100644 --- a/miniprogram/components/share-guide-popup/share-guide-popup.less +++ b/miniprogram/components/share-guide-popup/share-guide-popup.less @@ -55,5 +55,10 @@ background: linear-gradient(135deg, #07c160 0%, #06ad56 100%); color: #ffffff; } + + &--secondary { + background: #f5f5f5; + color: #323233; + } } } \ No newline at end of file diff --git a/miniprogram/components/share-guide-popup/share-guide-popup.ts b/miniprogram/components/share-guide-popup/share-guide-popup.ts index 934bb76..35bbe01 100644 --- a/miniprogram/components/share-guide-popup/share-guide-popup.ts +++ b/miniprogram/components/share-guide-popup/share-guide-popup.ts @@ -1,4 +1,9 @@ -import { recordShareSuccess } from '../../utils/shareGuide'; +import { + getShareGuidePopupCopy, + recordShareSuccess, +} from '../../utils/shareGuide'; + +const popupCopy = getShareGuidePopupCopy(); Component({ options: {}, @@ -14,7 +19,10 @@ Component({ /** * 组件的初始数据 */ - data: {}, + data: { + unlockMessage: popupCopy.message, + unlockHint: popupCopy.hint, + }, /** * 组件的方法列表 */ @@ -31,9 +39,7 @@ Component({ /** 点击分享按钮 */ onShare() { - // 记录分享成功(用户点击了分享按钮,视为已分享) recordShareSuccess(); - // 关闭弹窗并通知父组件分享成功(不触发下载,用户需要重新点击下载按钮) this.triggerEvent('onShareSuccess'); }, }, diff --git a/miniprogram/components/share-guide-popup/share-guide-popup.wxml b/miniprogram/components/share-guide-popup/share-guide-popup.wxml index 004a1cd..2b3a7d9 100644 --- a/miniprogram/components/share-guide-popup/share-guide-popup.wxml +++ b/miniprogram/components/share-guide-popup/share-guide-popup.wxml @@ -8,11 +8,9 @@ bind:click-overlay="onOverlayClick" custom-class="share-guide-popup"> - 分享解锁下载 - 今日免费下载次数已用完 - - 分享给好友后,可重新点击“下载打印”按钮继续下载 - + 解锁继续下载 + {{unlockMessage}} + {{unlockHint}}