Jelajahi Sumber

海报:修复海报保存报错

puhui999 11 bulan lalu
induk
melakukan
f00a8052ea

+ 3 - 1
sheep/components/s-share-modal/canvas-poster/index.vue

@@ -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,

+ 5 - 6
sheep/components/s-share-modal/canvas-poster/poster/goods.js

@@ -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',

+ 2 - 3
sheep/components/s-share-modal/canvas-poster/poster/groupon.js

@@ -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',

+ 7 - 0
sheep/components/s-share-modal/canvas-poster/poster/index.js

@@ -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;
+}

+ 2 - 3
sheep/components/s-share-modal/canvas-poster/poster/user.js

@@ -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',