更新
This commit is contained in:
@@ -433,7 +433,7 @@ export function mostValue(arr) {
|
||||
|
||||
|
||||
// 海报生成
|
||||
export function posterCreate(option, imageArr, textArr, theme) {
|
||||
export function posterCreate(option, imageArr, textArr, theme,eqcode) {
|
||||
let posterUrl = ''
|
||||
const { width, height } = option
|
||||
Toast.loading({
|
||||
@@ -445,8 +445,10 @@ export function posterCreate(option, imageArr, textArr, theme) {
|
||||
|
||||
let mycanvas = document.createElement('canvas') // 创建一个canvas画布元素
|
||||
let ctx = mycanvas.getContext('2d')
|
||||
mycanvas.width = width; //设置canvas的宽
|
||||
mycanvas.height = height; //设置canvas的高
|
||||
mycanvas.style.width = '750px'; //设置canvas的宽
|
||||
mycanvas.style.height = '1500px'; //设置canvas的高
|
||||
mycanvas.width = width
|
||||
mycanvas.height = height
|
||||
console.log('imgs:', imageArr);
|
||||
//Promise对象加载资源
|
||||
let loader_p = [];
|
||||
@@ -464,14 +466,22 @@ export function posterCreate(option, imageArr, textArr, theme) {
|
||||
//Promise的.all方法,当所有预加载的图像加载好的回调函数
|
||||
Promise.all(loader_p)
|
||||
.then(imgList => {
|
||||
console.log('海报数组:', imgList);
|
||||
|
||||
imgList.map((item, index) => {
|
||||
console.log('item', imageArr[index].pos);
|
||||
// console.log('item',imageArr[index]);
|
||||
if (imageArr[index].name != 'eqcode') {
|
||||
ctx.drawImage(item, imageArr[index].pos.x, imageArr[index].pos.y, imageArr[index].pos.w, imageArr[index].pos.h); //原生canvas的绘制图片方法,直接百度搜索 `js drawImage`查看方法的参数
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
ctx.rotate(-4.3 * (Math.PI / 180));
|
||||
|
||||
// console.log('imgList[2]',imgList[2]);
|
||||
ctx.drawImage(imgList[2], imageArr[2].pos.x, imageArr[2].pos.y, imageArr[2].pos.w, imageArr[2].pos.h)
|
||||
|
||||
// 画签文
|
||||
ctx.rotate(-4 * (Math.PI / 180));
|
||||
// ctx.rotate(-4 * (Math.PI / 180));
|
||||
ctx.textAlign = 'start'; //type2
|
||||
ctx.textBaseline = 'top'
|
||||
textArr.map((item, index) => {
|
||||
@@ -490,17 +500,7 @@ export function posterCreate(option, imageArr, textArr, theme) {
|
||||
ctx.fillText(textArr[index].content, x, y); //绘制文字
|
||||
})
|
||||
|
||||
// let mbtiLogo = 'MBTI MBTI MBTI'
|
||||
// let radius = 75
|
||||
// var angleStep = ((3 / 4) * Math.PI) / mbtiLogo.length;
|
||||
// for (var i = 0; i < mbtiLogo.length; i++) {
|
||||
// var angle = i * angleStep + Math.PI / 250;
|
||||
// var x = 375 + Math.cos(angle) * radius;
|
||||
// var y = 775 + Math.sin(angle) * radius;
|
||||
// ctx.font = 'normal 30px HYYakuHei';
|
||||
// ctx.fillStyle = theme
|
||||
// ctx.fillText(mbtiLogo[i], x, y);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
//海报绘制完 ,转成图片对象
|
||||
|
||||
@@ -16,7 +16,7 @@ export function wxShare(option) {
|
||||
console.log('分享配置:', {
|
||||
'title': option.title,
|
||||
'desc': option.desc,
|
||||
'link': linkUrl + option.link
|
||||
'link': import.meta.env.VITE_URL
|
||||
});
|
||||
|
||||
let data = res.data;
|
||||
@@ -42,7 +42,7 @@ export function wxShare(option) {
|
||||
menuList: ["menuItem:copyUrl", "menuItem:share:appMessage", "menuItem:share:timeline"] // 屏蔽复制链接
|
||||
});
|
||||
wx.onMenuShareTimeline({
|
||||
link: linkUrl + option.link, // 分享链接
|
||||
link: import.meta.env.VITE_URL, // 分享链接
|
||||
title: option.title, // 分享标题
|
||||
desc: option.desc, // 分享描述
|
||||
imgUrl: imgUrl, // 分享图标
|
||||
@@ -51,7 +51,7 @@ export function wxShare(option) {
|
||||
},
|
||||
});
|
||||
wx.onMenuShareAppMessage({
|
||||
link: linkUrl + option.link, // 分享链接
|
||||
link: import.meta.env.VITE_URL, // 分享链接
|
||||
title: option.title, // 分享标题
|
||||
desc: option.desc, // 分享描述
|
||||
imgUrl: imgUrl, // 分享图标
|
||||
|
||||
Reference in New Issue
Block a user