|
|
@ -29,7 +29,8 @@ |
|
|
|
components : { VueQrcode }, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
qrCodeValue: import.meta.env.VITE_REDIRECT_URI + `?vid=${this.getUserInfo()}`, |
|
|
|
qrCodeValue: '', |
|
|
|
// qrCodeValue: import.meta.env.VITE_REDIRECT_URI + `?vid=${this.getUserInfo()}`, |
|
|
|
qrCodeSize: 180 * (window.innerWidth / 750), |
|
|
|
qrCodeDarkColor: '#000', |
|
|
|
qrCodeLightColor: '#fff', |
|
|
@ -49,8 +50,18 @@ |
|
|
|
_center: 0 |
|
|
|
} |
|
|
|
}, |
|
|
|
created(){ |
|
|
|
console.log(this.configList); |
|
|
|
console.log(this.configList.user_url); |
|
|
|
this.qrCodeValue = `${this.configList.user_url}?vid=${this.userInfo.id}` |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
async draw() { //绘制海报 |
|
|
|
|
|
|
|
uni.showLoading({ |
|
|
|
title: '拼命绘画中...' |
|
|
|
}) |
|
|
|
|
|
|
|
let self = this |
|
|
|
//获取设备信息 |
|
|
|
self.systemInfo = await self.getSystemInfo(); |
|
|
@ -63,17 +74,23 @@ |
|
|
|
|
|
|
|
//海报背景 |
|
|
|
let bg = new Image(); |
|
|
|
bg.src = import.meta.env.VITE_REDIRECT_URI + '/static/placard/placard-bg.png' |
|
|
|
bg.src = this.configList.qr_code_image |
|
|
|
// bg.src = this.configList.user_url + '/static/placard/placard-bg.png' |
|
|
|
//logo |
|
|
|
let logo = new Image(); |
|
|
|
logo.src = import.meta.env.VITE_REDIRECT_URI + '/static/placard/logo.png' |
|
|
|
|
|
|
|
logo.src = this.configList.logo_image |
|
|
|
// logo.src = import.meta.env.VITE_REDIRECT_URI + '/static/placard/logo.png' |
|
|
|
|
|
|
|
console.log(this.configList.logo_image); |
|
|
|
|
|
|
|
bg.onload = () => { |
|
|
|
logo.onload = () => { //确保背景和logo加载完成(不然海报可能会少logo) |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
let ctx = document.querySelector('canvas').getContext('2d') |
|
|
|
let img = document.querySelector('.qrcode img') |
|
|
|
|
|
|
|
|
|
|
|
let center = self.canvasW / 2; //画布中心位置 |
|
|
|
self._center = center |
|
|
|
|
|
|
@ -120,7 +137,7 @@ |
|
|
|
|
|
|
|
////画海报最后的标签列表 |
|
|
|
this.drawList(ctx, 135 * rpx, 650 * rpx, 60 * rpx, 20 * rpx, 10 * rpx, '#59B495') |
|
|
|
|
|
|
|
|
|
|
|
uni.canvasToTempFilePath({ |
|
|
|
x: 0, // 起点坐标 |
|
|
|
y: 0, |
|
|
@ -128,6 +145,7 @@ |
|
|
|
height: self.canvasH, // canvas 高 |
|
|
|
canvasId: 'myCanvas', // canvas id |
|
|
|
success(res) { |
|
|
|
uni.hideLoading() |
|
|
|
self.tempFilePath = res.tempFilePath //相对路径 |
|
|
|
} |
|
|
|
}) |
|
|
@ -218,15 +236,6 @@ |
|
|
|
currentTagInfo = { x : next } |
|
|
|
}) |
|
|
|
}, |
|
|
|
getUserInfo(){ |
|
|
|
if(localStorage.getItem('userInfo')){ |
|
|
|
return JSON.parse(localStorage.getItem('userInfo')).id |
|
|
|
}else{ |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/pages/login/login' |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
@ -267,7 +276,7 @@ |
|
|
|
} |
|
|
|
|
|
|
|
canvas{ |
|
|
|
opacity: 0; |
|
|
|
opacity: 1; |
|
|
|
position: fixed; |
|
|
|
top: 100%; |
|
|
|
left: 0; |
|
|
|