feat: 增加下载分享检查功能
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
"van-cell": "@vant/weapp/cell/index",
|
||||
"van-icon": "@vant/weapp/icon/index",
|
||||
"van-popup": "@vant/weapp/popup/index",
|
||||
"van-dialog": "@vant/weapp/dialog/index",
|
||||
"word-input": "../../components/word-input/word-input",
|
||||
"word-card": "../../components/word-card/word-card",
|
||||
"color-picker": "../../components/color-picker/color-picker",
|
||||
|
||||
@@ -6,6 +6,10 @@ import {
|
||||
TemplateType,
|
||||
} from '../../service/drawServiceFactory';
|
||||
import { checkAndSaveImage } from '../../utils/saveImage';
|
||||
import {
|
||||
shouldShowShareGuide,
|
||||
recordShareSuccess,
|
||||
} from '../../utils/shareGuide';
|
||||
|
||||
Page({
|
||||
canvas: null as Canvas | null,
|
||||
@@ -25,6 +29,7 @@ Page({
|
||||
selectedTemplate: 'find', // 选中的模板类型
|
||||
env: 'release',
|
||||
isPCDevtool: false,
|
||||
showShareDialog: false, // 显示分享引导弹窗
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -280,10 +285,55 @@ Page({
|
||||
|
||||
/** 下载打印 */
|
||||
exportToPrint() {
|
||||
if (this.canvas && this.data.cardList.length > 0) {
|
||||
checkAndSaveImage(this.canvas);
|
||||
if (!this.canvas || this.data.cardList.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否需要显示分享引导
|
||||
if (shouldShowShareGuide()) {
|
||||
this.setData({ showShareDialog: true });
|
||||
return;
|
||||
}
|
||||
|
||||
// 直接下载
|
||||
checkAndSaveImage(this.canvas);
|
||||
},
|
||||
|
||||
/** 关闭分享引导弹窗 */
|
||||
onCloseShareDialog() {
|
||||
this.setData({ showShareDialog: false });
|
||||
},
|
||||
|
||||
/** 点击转发按钮 */
|
||||
onShareToFriend() {
|
||||
// 记录分享成功(用户点击了分享按钮,视为已分享)
|
||||
recordShareSuccess();
|
||||
this.setData({ showShareDialog: false });
|
||||
// 允许继续下载
|
||||
if (this.canvas && this.data.cardList.length > 0) {
|
||||
checkAndSaveImage(this.canvas);
|
||||
}
|
||||
wx.showToast({
|
||||
title: '分享后即可继续下载',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
});
|
||||
},
|
||||
|
||||
/** 点击分享到朋友圈按钮 */
|
||||
onShareToTimeline() {
|
||||
// 记录分享成功(用户点击了分享按钮,视为已分享)
|
||||
recordShareSuccess();
|
||||
this.setData({ showShareDialog: false });
|
||||
// 允许继续下载
|
||||
if (this.canvas && this.data.cardList.length > 0) {
|
||||
checkAndSaveImage(this.canvas);
|
||||
}
|
||||
wx.showToast({
|
||||
title: '分享后即可继续下载',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
});
|
||||
},
|
||||
|
||||
onColorTap(e: WechatMiniprogram.CustomEvent) {
|
||||
@@ -324,12 +374,16 @@ Page({
|
||||
},
|
||||
|
||||
onShareAppMessage() {
|
||||
// 记录分享成功(用户真正分享了)
|
||||
recordShareSuccess();
|
||||
return {
|
||||
title: '涂鸦丫-涂色|识字|画画|打印',
|
||||
path: '/pages/index/index',
|
||||
};
|
||||
},
|
||||
onShareTimeline() {
|
||||
// 记录分享成功(用户真正分享了)
|
||||
recordShareSuccess();
|
||||
return {
|
||||
title: '涂鸦丫-涂色|识字|画画|打印',
|
||||
query: '/pages/index/index',
|
||||
|
||||
@@ -135,6 +135,16 @@
|
||||
下载打印
|
||||
</toy-button>
|
||||
</view>
|
||||
<introduction-popup
|
||||
wx:if="{{showIntroductionPopup}}"
|
||||
bind:onClose="onCloseIntroductionPopup" />
|
||||
<introduction-popup
|
||||
wx:if="{{showIntroductionPopup}}"
|
||||
bind:onClose="onCloseIntroductionPopup" />
|
||||
<van-dialog
|
||||
show="{{showShareDialog}}"
|
||||
title="分享解锁下载"
|
||||
message="今日免费下载次数已用完,分享给好友或朋友圈后即可继续免费下载"
|
||||
show-cancel-button
|
||||
confirm-button-text="转发给好友"
|
||||
cancel-button-text="分享到朋友圈"
|
||||
bind:confirm="onShareToFriend"
|
||||
bind:cancel="onShareToTimeline"
|
||||
bind:close="onCloseShareDialog" />
|
||||
|
||||
Reference in New Issue
Block a user