feat:1.0.2 bug修复,引导页优化

This commit is contained in:
2025-07-03 11:04:52 +08:00
parent fdf8a31f32
commit ef39c86d5f
9 changed files with 120 additions and 39 deletions
+6 -1
View File
@@ -13,5 +13,10 @@
"componentFramework": "glass-easel", "componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json", "sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents", "lazyCodeLoading": "requiredComponents",
"enablePullDownRefresh": false "enablePullDownRefresh": false,
"permission": {
"scope.writePhotosAlbum": {
"desc": "需要保存涂色卡到相册"
}
}
} }
@@ -30,38 +30,38 @@
position: absolute; position: absolute;
&--first { &--first {
top: 122rpx; top: 114rpx;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
width: 680rpx; width: 680rpx;
height: 96rpx; height: 96rpx;
&.android { &.android {
top: 128rpx; top: 116rpx;
} }
} }
&--second { &--second {
top: 248rpx; top: 244rpx;
left: 50rpx; left: 48rpx;
width: 96rpx; width: 96rpx;
height: 96rpx; height: 96rpx;
&.android { &.android {
top: 256rpx; top: 248rpx;
left: 54rpx; left: 52rpx;
} }
} }
&--third { &--third {
top: 248rpx; top: 244rpx;
left: 232rpx; left: 252rpx;
width: 96rpx; width: 96rpx;
height: 96rpx; height: 96rpx;
&.android { &.android {
top: 254rpx; top: 246rpx;
left: 236rpx; left: 260rpx;
} }
} }
@@ -266,11 +266,11 @@ Page({
fileType: 'png', fileType: 'png',
quality: 1, quality: 1,
success: (res) => { success: (res) => {
wx.getImageInfo({ // wx.getImageInfo({
src: res.tempFilePath, // src: res.tempFilePath,
success: (res) => // success: (res) =>
console.log('getImageInfo image size :', res.width, res.height), // 应输出2480x3508 // console.log('getImageInfo image size :', res.width, res.height), // 应输出2480x3508
}); // });
wx.saveImageToPhotosAlbum({ wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath, filePath: res.tempFilePath,
success: () => wx.showToast({ title: '保存成功' }), success: () => wx.showToast({ title: '保存成功' }),
+2 -1
View File
@@ -9,6 +9,7 @@
"van-radio": "@vant/weapp/radio/index", "van-radio": "@vant/weapp/radio/index",
"van-radio-group": "@vant/weapp/radio-group/index", "van-radio-group": "@vant/weapp/radio-group/index",
"van-cell": "@vant/weapp/cell/index", "van-cell": "@vant/weapp/cell/index",
"van-cell-group": "@vant/weapp/cell-group/index" "van-cell-group": "@vant/weapp/cell-group/index",
"van-switch": "@vant/weapp/switch/index"
} }
} }
+7
View File
@@ -4,6 +4,7 @@
background-color: #F6F6F6; background-color: #F6F6F6;
.debug-wrapper { .debug-wrapper {
margin-top: 30rpx;
background-color: #fff; background-color: #fff;
border-radius: 20rpx; border-radius: 20rpx;
overflow: hidden; overflow: hidden;
@@ -13,6 +14,12 @@
color: #666; color: #666;
border-top: 0 none; border-top: 0 none;
} }
.debug-cell {
display: flex;
align-items: center;
justify-content: space-between;
}
} }
.btn-area { .btn-area {
+13 -2
View File
@@ -1,11 +1,13 @@
Page({ Page({
data: { data: {
header: 'wechat' header: 'wechat',
enableDebug: false
}, },
onLoad() { onLoad() {
const header = getApp().getPrintHeader() || 'wechat'; const header = getApp().getPrintHeader() || 'wechat';
this.setData({ header }); const enableDebug = wx.getStorageSync('enableDebug') || false;
this.setData({ header, enableDebug });
}, },
onChangeHeader(e: WechatMiniprogram.CustomEvent) { onChangeHeader(e: WechatMiniprogram.CustomEvent) {
@@ -20,6 +22,15 @@ Page({
onConfirm() { onConfirm() {
getApp().setPrintHeader(this.data.header); getApp().setPrintHeader(this.data.header);
const enableDebug = this.data.enableDebug;
wx.setStorageSync('enableDebug', enableDebug);
wx.setEnableDebug({ enableDebug });
wx.navigateBack(); wx.navigateBack();
},
/** 真机调试线上包 */
toggleDebug() {
const enableDebug = !this.data.enableDebug;
this.setData({ enableDebug });
} }
}); });
+20
View File
@@ -36,6 +36,26 @@
</van-cell> </van-cell>
</van-radio-group> </van-radio-group>
</van-cell-group> </van-cell-group>
<van-cell-group custom-class="debug-wrapper">
<van-cell
title="debug调整"
size="large"
custom-class="centered-title" />
<van-cell
custom-class="debug-cell"
title="真机调试线上包"
clickable
data-name="enableDebug"
border="{{ false }}"
bind:click="toggleDebug">
<van-switch
slot="right-icon"
name="enableDebug"
checked="{{enableDebug}}" />
</van-cell>
</van-cell-group>
<view class="btn-area"> <view class="btn-area">
<toy-button type="green" bind:click="onConfirm" width="360rpx"> <toy-button type="green" bind:click="onConfirm" width="360rpx">
确定 确定
+2 -20
View File
@@ -1,6 +1,7 @@
import { WATER_COLORS, PAPER_SIZE } from '../../constants/colors'; import { WATER_COLORS, PAPER_SIZE } from '../../constants/colors';
import { WORDS } from '../../constants/words'; import { WORDS } from '../../constants/words';
import TextDrawService from '../../service/textDrawService'; import TextDrawService from '../../service/textDrawService';
import { checkAndSaveImage } from '../../utils/saveImage';
Page({ Page({
canvas: null as Canvas | null, canvas: null as Canvas | null,
@@ -196,26 +197,7 @@ Page({
/** 下载打印 */ /** 下载打印 */
exportToPrint() { exportToPrint() {
if (this.canvas && this.data.cardList.length > 0) { if (this.canvas && this.data.cardList.length > 0) {
wx.canvasToTempFilePath({ checkAndSaveImage(this.canvas);
canvas: this.canvas,
fileType: 'png',
quality: 1,
success: (res) => {
wx.getImageInfo({
src: res.tempFilePath,
success: (res) =>
console.log(
'getImageInfo image size :',
res.width,
res.height,
), // 应输出2480x3508
});
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => wx.showToast({ title: '保存成功' }),
});
},
});
return; return;
} }
}, },
+55
View File
@@ -0,0 +1,55 @@
const doSaveImage = (canvas: Canvas) => {
wx.canvasToTempFilePath({
canvas: canvas,
fileType: 'png',
quality: 1,
success: (res) => {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => wx.showToast({
title: '保存成功,请在相册中查看',
icon: 'success',
duration: 2000,
}),
// fail: () => wx.showToast({
// title: '保存涂色卡失败,请重试!',
// icon: 'none',
// duration: 2000,
// })
});
},
fail: (err: any) => {
wx.showToast({
title: '生成涂色卡失败,请重试!',
icon: 'none',
duration: 2000,
})
}
});
}
const requestPhotoPermission = (canvas: Canvas) => {
wx.authorize({
scope: 'scope.writePhotosAlbum',
success: () => doSaveImage(canvas),
fail: () => wx.showToast({
title: '请在“设置-添加到相册”中开启相册权限以保存涂色卡',
icon: 'none',
duration: 3000,
})
})
}
export const checkAndSaveImage = (canvas: Canvas) => {
wx.getSetting({
success: res => {
if (!res.authSetting['scope.writePhotosAlbum']) {
requestPhotoPermission(canvas)
} else {
doSaveImage(canvas)
}
}
})
};