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,