feat: share
This commit is contained in:
@ -57,21 +57,21 @@ export default function PartnerIntro() {
|
|||||||
const canvas = res[0].node;
|
const canvas = res[0].node;
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
canvas.width = 1500;
|
canvas.width = 550*2;
|
||||||
canvas.height = 2668;
|
canvas.height = 918*2;
|
||||||
ctx.scale(2, 2);
|
ctx.scale(2, 2);
|
||||||
|
|
||||||
// 绘制背景图片
|
// 绘制背景图片
|
||||||
const bgImage = canvas.createImage();
|
const bgImage = canvas.createImage();
|
||||||
const poster = 'https://publiccdn.neighbourhood.com.cn/img/poster.png'
|
const poster = 'https://publiccdn.neighbourhood.com.cn/img/share-coupon-poster.png';
|
||||||
bgImage.src = poster;
|
bgImage.src = poster;
|
||||||
bgImage.onload = () => {
|
bgImage.onload = () => {
|
||||||
ctx.drawImage(bgImage, 0, 0, 750, 1334);
|
ctx.drawImage(bgImage, 0, 0, 550, 918);
|
||||||
|
|
||||||
const qrCodeImage = canvas.createImage();
|
const qrCodeImage = canvas.createImage();
|
||||||
qrCodeImage.src = qrCode; // 假设 getQrcode() 返回的是二维码图片的路径
|
qrCodeImage.src = qrCode; // 假设 getQrcode() 返回的是二维码图片的路径
|
||||||
qrCodeImage.onload = () => {
|
qrCodeImage.onload = () => {
|
||||||
ctx.drawImage(qrCodeImage, 235, 894, 280, 280); // 绘制二维码,位置和大小
|
ctx.drawImage(qrCodeImage, 196, 600, 160, 160); // 绘制二维码,位置和大小
|
||||||
saveCanvasToTempFile().then(tempPath => {
|
saveCanvasToTempFile().then(tempPath => {
|
||||||
resolve(tempPath);
|
resolve(tempPath);
|
||||||
});
|
});
|
||||||
@ -163,10 +163,10 @@ export default function PartnerIntro() {
|
|||||||
|
|
||||||
<div className={`${PREFIX}__footer`}>
|
<div className={`${PREFIX}__footer`}>
|
||||||
<Button className={`${PREFIX}__download-button`} onClick={savePoster}>
|
<Button className={`${PREFIX}__download-button`} onClick={savePoster}>
|
||||||
下载海报
|
朋友圈海报
|
||||||
</Button>
|
</Button>
|
||||||
<Button className={`${PREFIX}__share-button`} openType="share">
|
<Button className={`${PREFIX}__share-button`} openType="share">
|
||||||
分享邀请
|
赠送会员给好友
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -20,7 +20,12 @@ export default function Partner() {
|
|||||||
};
|
};
|
||||||
useShareAppMessage(() => {
|
useShareAppMessage(() => {
|
||||||
console.log('Partner inviteCode', inviteCode);
|
console.log('Partner inviteCode', inviteCode);
|
||||||
return getCommonShareMessage({ useCapture: false, inviteCode });
|
return getCommonShareMessage({
|
||||||
|
useCapture: false,
|
||||||
|
inviteCode,
|
||||||
|
title: '宝子,送你个播络会员,找工作更方便',
|
||||||
|
imageUrl: 'https://publiccdn.neighbourhood.com.cn/img/share-coupon.png',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -20,6 +20,7 @@ interface ShareAppProps {
|
|||||||
inviteCode?: string;
|
inviteCode?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
path?: PageUrl;
|
path?: PageUrl;
|
||||||
|
imageUrl?: string;
|
||||||
params?: Record<string, BL.Anything>;
|
params?: Record<string, BL.Anything>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ export const getCommonShareMessage = ({
|
|||||||
inviteCode,
|
inviteCode,
|
||||||
title,
|
title,
|
||||||
path,
|
path,
|
||||||
|
imageUrl: _imageUrl,
|
||||||
params = {},
|
params = {},
|
||||||
}: ShareAppProps = {}): ShareAppMessageReturn => {
|
}: ShareAppProps = {}): ShareAppMessageReturn => {
|
||||||
const inviteParams = inviteCode ? { c: inviteCode } : undefined;
|
const inviteParams = inviteCode ? { c: inviteCode } : undefined;
|
||||||
@ -36,6 +38,6 @@ export const getCommonShareMessage = ({
|
|||||||
return {
|
return {
|
||||||
title: title || `昨天新增了${getRandomCount()}条主播通告,宝子快来看看`,
|
title: title || `昨天新增了${getRandomCount()}条主播通告,宝子快来看看`,
|
||||||
path: sharePath,
|
path: sharePath,
|
||||||
imageUrl: useCapture ? undefined : imageUrl,
|
imageUrl: useCapture ? undefined : _imageUrl || imageUrl,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user