From e7c6c55786b9cb867f6188d8373037543ce3538c Mon Sep 17 00:00:00 2001 From: ldh Date: Tue, 4 Apr 2023 13:43:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B5=B7=E6=8A=A5=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E8=BD=AC=E6=8D=A2,=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AF=86=E5=88=ABhttps=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas-poster/poster/goods.js | 9 +++++---- .../canvas-poster/poster/groupon.js | 7 ++++--- .../canvas-poster/poster/index.js | 18 ++++++++++++++++++ .../s-share-modal/canvas-poster/poster/user.js | 5 +++-- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/sheep/components/s-share-modal/canvas-poster/poster/goods.js b/sheep/components/s-share-modal/canvas-poster/poster/goods.js index cedad800..c11000a0 100644 --- a/sheep/components/s-share-modal/canvas-poster/poster/goods.js +++ b/sheep/components/s-share-modal/canvas-poster/poster/goods.js @@ -1,11 +1,12 @@ import sheep from '@/sheep'; +import { formatImageUrlProtocol } from './index'; const goods = (poster) => { const width = poster.width; const userInfo = sheep.$store('user').userInfo; return { - background: sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.goods_bg), + background: formatImageUrlProtocol(sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.goods_bg)), list: [ { name: 'nickname', @@ -24,7 +25,7 @@ const goods = (poster) => { { name: 'avatar', type: 'image', - val: sheep.$url.cdn(userInfo.avatar), + val: formatImageUrlProtocol(sheep.$url.cdn(userInfo.avatar)), x: width * 0.04, y: width * 0.04, width: width * 0.14, @@ -34,7 +35,7 @@ const goods = (poster) => { { name: 'goodsImage', type: 'image', - val: poster.shareInfo.poster.image, + val: formatImageUrlProtocol(poster.shareInfo.poster.image), x: width * 0.03, y: width * 0.21, width: width * 0.94, @@ -47,8 +48,8 @@ const goods = (poster) => { val: poster.shareInfo.poster.title, x: width * 0.04, y: width * 1.18, - line: 2, maxWidth: width * 0.91, + line: 2, lineHeight: 5, paintbrushProps: { fillStyle: '#333', diff --git a/sheep/components/s-share-modal/canvas-poster/poster/groupon.js b/sheep/components/s-share-modal/canvas-poster/poster/groupon.js index 2216f9bc..33d097e9 100644 --- a/sheep/components/s-share-modal/canvas-poster/poster/groupon.js +++ b/sheep/components/s-share-modal/canvas-poster/poster/groupon.js @@ -1,11 +1,12 @@ import sheep from '@/sheep'; +import { formatImageUrlProtocol } from './index'; const groupon = (poster) => { const width = poster.width; const userInfo = sheep.$store('user').userInfo; return { - background: sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.groupon_bg), + background: formatImageUrlProtocol(sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.groupon_bg)), list: [ { name: 'nickname', @@ -24,7 +25,7 @@ const groupon = (poster) => { { name: 'avatar', type: 'image', - val: sheep.$url.cdn(userInfo.avatar), + val: formatImageUrlProtocol(sheep.$url.cdn(userInfo.avatar)), x: width * 0.04, y: width * 0.04, width: width * 0.14, @@ -34,7 +35,7 @@ const groupon = (poster) => { { name: 'goodsImage', type: 'image', - val: poster.shareInfo.poster.image, + val: formatImageUrlProtocol(poster.shareInfo.poster.image), x: width * 0.03, y: width * 0.21, width: width * 0.94, diff --git a/sheep/components/s-share-modal/canvas-poster/poster/index.js b/sheep/components/s-share-modal/canvas-poster/poster/index.js index 500f8cbf..a547b1e8 100644 --- a/sheep/components/s-share-modal/canvas-poster/poster/index.js +++ b/sheep/components/s-share-modal/canvas-poster/poster/index.js @@ -12,3 +12,21 @@ export function getPosterData(options) { return groupon(options); } } + +export function formatImageUrlProtocol(url) { + // #ifdef H5 + // H5平台 https协议下需要转换 + if (window.location.protocol === 'https:' && url.indexOf('http:') === 0) { + url = url.replace('http:', 'https:'); + } + // #endif + + // #ifdef MP-WEIXIN + // 小程序平台 需要强制转换为https协议 + if (url.indexOf('http:') === 0) { + url = url.replace('http:', 'https:'); + } + // #endif + + return url; +} diff --git a/sheep/components/s-share-modal/canvas-poster/poster/user.js b/sheep/components/s-share-modal/canvas-poster/poster/user.js index ed134806..cf927184 100644 --- a/sheep/components/s-share-modal/canvas-poster/poster/user.js +++ b/sheep/components/s-share-modal/canvas-poster/poster/user.js @@ -1,11 +1,12 @@ import sheep from '@/sheep'; +import { formatImageUrlProtocol } from './index'; const user = (poster) => { const width = poster.width; const userInfo = sheep.$store('user').userInfo; return { - background: sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.user_bg), + background: formatImageUrlProtocol(sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.user_bg)), list: [ { name: 'nickname', @@ -25,7 +26,7 @@ const user = (poster) => { { name: 'avatar', type: 'image', - val: sheep.$url.cdn(userInfo.avatar), + val: formatImageUrlProtocol(sheep.$url.cdn(userInfo.avatar)), x: width * 0.4, y: width * 0.16, width: width * 0.2,