海报:完善小程序码(添加前缀 data:image/png;base64,)

This commit is contained in:
puhui999
2024-05-25 22:20:19 +08:00
parent f46bfc6ee1
commit 2dfe61503f
9 changed files with 29 additions and 36 deletions
@@ -5,7 +5,7 @@ import { formatImageUrlProtocol } from './index';
const goods = async (poster) => {
const width = poster.width;
const userInfo = sheep.$store('user').userInfo;
const wxa_qrcode = (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
return [
{
type: 'image',
@@ -5,7 +5,7 @@ import third from '@/sheep/api/migration/third';
const groupon = async (poster) => {
const width = poster.width;
const userInfo = sheep.$store('user').userInfo;
const wxa_qrcode = (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
return [
{
type: 'image',
@@ -30,30 +30,3 @@ export function formatImageUrlProtocol(url) {
return url;
}
export function getBase64Src(base64data, appType) {
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64data) || [];
switch (appType) {
case 'wechat':
const filePath = `${wx.env.USER_DATA_PATH}/tmp_base64src.${format}`;
return new Promise((resolve, reject) => {
const fileManager = uni.getFileSystemManager();
fileManager.writeFile({
filePath: filePath,
data: bodyData, // base64 数据
encoding: 'base64', // 字符编码
success: () => {
resolve(filePath);
},
file: (err) => {
console.log('base64 保存失败', err);
},
});
});
default:
console.warn('获得 base64 图片地址只做了微信小程序端的转换,其它端请自行实现!!!');
break;
}
}
@@ -5,7 +5,7 @@ import third from '@/sheep/api/migration/third';
const user = async (poster) => {
const width = poster.width;
const userInfo = sheep.$store('user').userInfo;
const wxa_qrcode = (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
return [
{
type: 'image',
@@ -92,6 +92,7 @@
showAuthModal();
return;
}
console.log(props.shareInfo);
unref(SharePosterRef).getPoster();
state.showPosterModal = true;
};