海报:修复海报保存报错

pull/55/head
puhui999 2024-05-27 15:26:05 +08:00
parent 6b8a4fec29
commit f00a8052ea
5 changed files with 19 additions and 13 deletions

View File

@ -29,6 +29,7 @@
<!-- 海报画板默认隐藏只用来生成海报生成方式为主动调用 -->
<l-painter
isCanvasToTempFilePath
pathType="url"
@success="setPainterImageUrl"
hidden
ref="painterRef"
@ -65,7 +66,7 @@
css: {
//
width: sheep.$platform.device.windowWidth * 0.9,
height: 600,
height: 550,
},
views: [],
});
@ -92,6 +93,7 @@
sheep.$helper.toast('请长按图片保存');
return;
}
// H5
uni.saveImageToPhotosAlbum({
filePath: painterImageUrl.value,

View File

@ -1,11 +1,10 @@
import sheep from '@/sheep';
import third from '@/sheep/api/migration/third';
import { formatImageUrlProtocol } from './index';
import { formatImageUrlProtocol, getWxaQrcode } from './index';
const goods = async (poster) => {
const width = poster.width;
const userInfo = sheep.$store('user').userInfo;
const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query);
return [
{
type: 'image',
@ -62,7 +61,7 @@ const goods = async (poster) => {
top: width * 1.18,
color: '#333',
fontSize: 14,
lineHeight: 5,
lineHeight: 15,
maxWidth: width * 0.91,
},
},
@ -72,7 +71,7 @@ const goods = async (poster) => {
css: {
position: 'fixed',
left: width * 0.04,
top: width * 1.3,
top: width * 1.31,
fontSize: 20,
fontFamily: 'OPPOSANS',
color: '#333',
@ -87,7 +86,7 @@ const goods = async (poster) => {
css: {
position: 'fixed',
left: width * 0.3,
top: width * 1.32,
top: width * 1.33,
color: '#999',
fontSize: 10,
fontFamily: 'OPPOSANS',

View File

@ -1,11 +1,10 @@
import sheep from '@/sheep';
import { formatImageUrlProtocol } from './index';
import third from '@/sheep/api/migration/third';
import { formatImageUrlProtocol, getWxaQrcode } from './index';
const groupon = async (poster) => {
const width = poster.width;
const userInfo = sheep.$store('user').userInfo;
const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query);
return [
{
type: 'image',

View File

@ -1,6 +1,7 @@
import user from './user';
import goods from './goods';
import groupon from './groupon';
import third from '@/sheep/api/migration/third';
export function getPosterData(options) {
switch (options.shareInfo.poster.type) {
@ -30,3 +31,9 @@ export function formatImageUrlProtocol(url) {
return url;
}
// 获得微信小程序码 Base64 image
export async function getWxaQrcode(path, query) {
const res = await third.wechat.getWxacode(path, query);
return 'data:image/png;base64,' + res.data;
}

View File

@ -1,11 +1,10 @@
import sheep from '@/sheep';
import { formatImageUrlProtocol } from './index';
import third from '@/sheep/api/migration/third';
import { formatImageUrlProtocol, getWxaQrcode } from './index';
const user = async (poster) => {
const width = poster.width;
const userInfo = sheep.$store('user').userInfo;
const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query);
return [
{
type: 'image',