小程序
小游戏
企业微信
微信支付
扫描小程序码分享
手机安卓版本: oppoA11;
canvas多次生成,会有字体大小加颜色,背景颜色 的变化
正常生成的海报:
样式错乱海报,多次生成:
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
draw的回调里面加个setTimeout
ctx.draw(false, () => {
setTimeout(() => {
}, 50)
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
有可能是加载的问题,前面一项没执行,后面就执行完了
这个二维码怎么生成的,有没有源码可以贴一下吗
props: {
//合成海报参数为参数param
param: {
type: Object,
default: function() {
return {
width: 900, //画布宽度
height: 1280, //画布高度
pics: [], //图片资源
paths: {}, //路径
texts: [], //文本
fileType: 'jpg', //保存文件类型
quality: 1 //保存文件质量
};
}
},
data() {
isReady: false,
canvasId: 'myCanvasId',
width: 900, //海报宽度
height: 1280 //海报高度
components: {},
watch: {
param: function(o,n){
// console.log('我變化了嗎',o,n)
this.createPoster();
})
return ;
if (this.posterImg) {
this.$refs.posterImgPopup.open();
uni.hideLoading();
return;
if (!that.canvasData.qrcode) {
await this.getQRcode();
uni.getImageInfo({
src: that.detail.banner[0],
success: function(imgRes) {
that.coverH = imgRes.width > 558 ? parseInt((558 / imgRes.width) * imgRes.height) : imgRes.height;
console.log('coverh',that.coverH)
console.log('subjects', that.subjects);
let regStr = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig;
that.canvasData.userInfo = uni.getStorageSync("userInfo");
that.canvasData.userInfo.imgurl = common.checkAvatarHttps(that.canvasData.userInfo.imgurl);
that.posterParam = setParam({
name: that.canvasData.userInfo.username.replace(regStr,''),
avatar: that.canvasData.userInfo.imgurl,
qrcode: that.canvasData.qrcode,
cover: that.detail.banner[0],
coverH: that.coverH,
title: that.detail.title,
price: that.detail.price,
subjects: that.subjects
});
that.isReady = true;
fail() {
common.toast('获取不到封图数据,请重试');
// 生成海报
fail(e) {
this.isReady = false;
console.log('合成失败:', e);
uni.showToast({
icon: 'none',
title: '生成海报失败,请重试'
this.closePoster();
success(e) {
console.log('合成成功:', e);
this.posterImg = e.res.tempFilePath;
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
draw的回调里面加个setTimeout
ctx.draw(false, () => {
setTimeout(() => {
}, 50)
有可能是加载的问题,前面一项没执行,后面就执行完了
这个二维码怎么生成的,有没有源码可以贴一下吗
props: {
//合成海报参数为参数param
param: {
type: Object,
default: function() {
return {
width: 900, //画布宽度
height: 1280, //画布高度
pics: [], //图片资源
paths: {}, //路径
texts: [], //文本
fileType: 'jpg', //保存文件类型
quality: 1 //保存文件质量
};
}
}
},
data() {
return {
isReady: false,
canvasId: 'myCanvasId',
width: 900, //海报宽度
height: 1280 //海报高度
};
},
components: {},
watch: {
param: function(o,n){
// console.log('我變化了嗎',o,n)
this.createPoster();
}
})
return ;
}
if (this.posterImg) {
this.$refs.posterImgPopup.open();
uni.hideLoading();
return;
}
if (!that.canvasData.qrcode) {
await this.getQRcode();
}
uni.getImageInfo({
src: that.detail.banner[0],
success: function(imgRes) {
that.coverH = imgRes.width > 558 ? parseInt((558 / imgRes.width) * imgRes.height) : imgRes.height;
console.log('coverh',that.coverH)
console.log('subjects', that.subjects);
let regStr = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig;
that.canvasData.userInfo = uni.getStorageSync("userInfo");
that.canvasData.userInfo.imgurl = common.checkAvatarHttps(that.canvasData.userInfo.imgurl);
that.posterParam = setParam({
name: that.canvasData.userInfo.username.replace(regStr,''),
avatar: that.canvasData.userInfo.imgurl,
qrcode: that.canvasData.qrcode,
cover: that.detail.banner[0],
coverH: that.coverH,
title: that.detail.title,
price: that.detail.price,
subjects: that.subjects
});
that.isReady = true;
},
fail() {
uni.hideLoading();
common.toast('获取不到封图数据,请重试');
}
});
},
// 生成海报
fail(e) {
this.isReady = false;
console.log('合成失败:', e);
uni.hideLoading();
uni.showToast({
icon: 'none',
title: '生成海报失败,请重试'
});
this.closePoster();
},
success(e) {
uni.hideLoading();
console.log('合成成功:', e);
this.posterImg = e.res.tempFilePath;
this.$refs.posterImgPopup.open();