调用
const draw = await eyeCopyFun({
cvs:this.cvs,
bg:'#FFFFFF',
canvasId:'poster',
title:{
title:'20元代金券',
validity:'2021-04-05'
},
content:[
{
img:{
width: 150,
url:'https://weixin.hotapp.cn/src/home/img/qrcode_example.png',
type:'url'
},
code:'47387554894'
},
{
img:{
width: 150,
base64:data.data.QRCode,
type:'base64'
},
code:'47387554894'
},
{
img:{
width: 150,
base64:data.data.QRCode,
type:'base64'
},
code:'47387554894'
}
],
footer:{
title:'可用商家',
name:'一屋子薯片韩式大头贴(上虞区店)'
}
})
const path = await draw.getImg();
const save = await saveImgPhotosAlbum(path)
效果
eyeCopy.js
import {
removeSavedFile,downloadFile, writeFileBase64} from '@/common/saveImgAlbum.js'
class eyeCopy {
constructor(data = {
}) {
this.data = data
this.width = this.data.cvs.w
this.height = this.data.cvs.h
this.bg = this.data.bg
this.ctx = uni.createCanvasContext(this.data.canvasId)
this.totalH = 0