feat: 增加下载分享检查功能
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user