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",
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents",
"enablePullDownRefresh": false
"enablePullDownRefresh": false,
"permission": {
"scope.writePhotosAlbum": {
"desc": "需要保存涂色卡到相册"
}
}
}
@@ -30,38 +30,38 @@
position: absolute;
&--first {
top: 122rpx;
top: 114rpx;
left: 50%;
transform: translateX(-50%);
width: 680rpx;
height: 96rpx;
&.android {
top: 128rpx;
top: 116rpx;
}
}
&--second {
top: 248rpx;
left: 50rpx;
top: 244rpx;
left: 48rpx;
width: 96rpx;
height: 96rpx;
&.android {
top: 256rpx;
left: 54rpx;
top: 248rpx;
left: 52rpx;
}
}
&--third {
top: 248rpx;
left: 232rpx;
top: 244rpx;
left: 252rpx;
width: 96rpx;
height: 96rpx;
&.android {
top: 254rpx;
left: 236rpx;
top: 246rpx;
left: 260rpx;
}
}
@@ -266,11 +266,11 @@ Page({
fileType: 'png',
quality: 1,
success: (res) => {
wx.getImageInfo({
src: res.tempFilePath,
success: (res) =>
console.log('getImageInfo image size :', res.width, res.height), // 应输出2480x3508
});
// 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: '保存成功' }),
+2 -1
View File
@@ -9,6 +9,7 @@
"van-radio": "@vant/weapp/radio/index",
"van-radio-group": "@vant/weapp/radio-group/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;
.debug-wrapper {
margin-top: 30rpx;
background-color: #fff;
border-radius: 20rpx;
overflow: hidden;
@@ -13,6 +14,12 @@
color: #666;
border-top: 0 none;
}
.debug-cell {
display: flex;
align-items: center;
justify-content: space-between;
}
}
.btn-area {
+13 -2
View File
@@ -1,11 +1,13 @@
Page({
data: {
header: 'wechat'
header: 'wechat',
enableDebug: false
},
onLoad() {
const header = getApp().getPrintHeader() || 'wechat';
this.setData({ header });
const enableDebug = wx.getStorageSync('enableDebug') || false;
this.setData({ header, enableDebug });
},
onChangeHeader(e: WechatMiniprogram.CustomEvent) {
@@ -20,6 +22,15 @@ Page({
onConfirm() {
getApp().setPrintHeader(this.data.header);
const enableDebug = this.data.enableDebug;
wx.setStorageSync('enableDebug', enableDebug);
wx.setEnableDebug({ enableDebug });
wx.navigateBack();
},
/** 真机调试线上包 */
toggleDebug() {
const enableDebug = !this.data.enableDebug;
this.setData({ enableDebug });
}
});
+20
View File
@@ -36,6 +36,26 @@
</van-cell>
</van-radio-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">
<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 { WORDS } from '../../constants/words';
import TextDrawService from '../../service/textDrawService';
import { checkAndSaveImage } from '../../utils/saveImage';
Page({
canvas: null as Canvas | null,
@@ -196,26 +197,7 @@ Page({
/** 下载打印 */
exportToPrint() {
if (this.canvas && this.data.cardList.length > 0) {
wx.canvasToTempFilePath({
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: '保存成功' }),
});
},
});
checkAndSaveImage(this.canvas);
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)
}
}
})
};