|
|
@ -41,20 +41,25 @@ import index from '../../uni_modules/uv-ui-tools' |
|
|
|
} |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
if(this.promotionUrl){ |
|
|
|
this.imagePath = this.promotionUrl |
|
|
|
let that = this; |
|
|
|
if(that.promotionUrl){ |
|
|
|
that.imagePath = that.promotionUrl |
|
|
|
console.log("当前地址:"+that.imagePath) |
|
|
|
}else{ |
|
|
|
this.getQrCode() |
|
|
|
that.getQrCode() |
|
|
|
} |
|
|
|
this.$store.commit('getUserInfo') |
|
|
|
that.$store.commit('getUserInfo') |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getQrCode() { |
|
|
|
this.$api('getInviteCode', res => { |
|
|
|
let that = this; |
|
|
|
that.$api('getInviteCode', res => { |
|
|
|
if (res.code == 200) { |
|
|
|
this.url = res.result.url |
|
|
|
this.title = res.result.name |
|
|
|
this.draw() |
|
|
|
console.log("----------") |
|
|
|
console.log(res) |
|
|
|
that.url = res.result.url |
|
|
|
that.title = res.result.name |
|
|
|
that.draw() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
@ -63,6 +68,7 @@ import index from '../../uni_modules/uv-ui-tools' |
|
|
|
uni.showLoading({ |
|
|
|
title: "拼命绘画中..." |
|
|
|
}) |
|
|
|
let that = this; |
|
|
|
|
|
|
|
wx.createSelectorQuery() |
|
|
|
.select('#myCanvas') // 绘制的canvas的id |
|
|
@ -71,6 +77,7 @@ import index from '../../uni_modules/uv-ui-tools' |
|
|
|
size: true |
|
|
|
}) |
|
|
|
.exec((res) => { |
|
|
|
console.log("----------1") |
|
|
|
const canvas = res[0].node |
|
|
|
// 渲染上下文 |
|
|
|
const ctx = canvas.getContext('2d') |
|
|
@ -90,7 +97,7 @@ import index from '../../uni_modules/uv-ui-tools' |
|
|
|
canvas.width = width * dpr |
|
|
|
canvas.height = height * dpr |
|
|
|
|
|
|
|
this.canvas = canvas |
|
|
|
that.canvas = canvas |
|
|
|
ctx.scale(dpr, dpr) |
|
|
|
ctx.clearRect(0, 0, width, height) |
|
|
|
|
|
|
@ -100,14 +107,14 @@ import index from '../../uni_modules/uv-ui-tools' |
|
|
|
|
|
|
|
//图片 |
|
|
|
const bgImage = canvas.createImage() |
|
|
|
bgImage.src = this.configList.qr_code |
|
|
|
bgImage.src = that.configList.qr_code |
|
|
|
|
|
|
|
//二维码图片 |
|
|
|
const coderImage = canvas.createImage() |
|
|
|
coderImage.src = this.baseUrl + this.url |
|
|
|
coderImage.src = that.baseUrl + that.url |
|
|
|
|
|
|
|
let size = 0; |
|
|
|
|
|
|
|
console.log("----------2") |
|
|
|
bgImage.onload = () => { |
|
|
|
canvas.width = bgImage.width |
|
|
|
canvas.height = bgImage.height |
|
|
@ -115,21 +122,22 @@ import index from '../../uni_modules/uv-ui-tools' |
|
|
|
0, 0, bgImage.width, bgImage.height) |
|
|
|
|
|
|
|
size = Math.floor(canvas.width / 3) |
|
|
|
this.canvasToTempFilePath() |
|
|
|
that.canvasToTempFilePath() |
|
|
|
} |
|
|
|
|
|
|
|
console.log("----------3") |
|
|
|
coderImage.onload = () => { |
|
|
|
ctx.drawImage(coderImage, |
|
|
|
canvas.width / 2 - (size / 2), canvas.height * 0.6, size, size) |
|
|
|
this.canvasToTempFilePath() |
|
|
|
that.canvasToTempFilePath() |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
canvasToTempFilePath(){ |
|
|
|
this.index++ |
|
|
|
if(this.index < 2){ |
|
|
|
let that = this; |
|
|
|
that.index++ |
|
|
|
if(that.index < 2){ |
|
|
|
return |
|
|
|
} |
|
|
|
// 绘制完成后存储路径 |
|
|
@ -137,17 +145,17 @@ import index from '../../uni_modules/uv-ui-tools' |
|
|
|
wx.canvasToTempFilePath({ |
|
|
|
x: 0, |
|
|
|
y: 0, |
|
|
|
width: this.canvas.width, |
|
|
|
height: this.canvas.height, |
|
|
|
canvas : this.canvas, |
|
|
|
width: that.canvas.width, |
|
|
|
height: that.canvas.height, |
|
|
|
canvas : that.canvas, |
|
|
|
success: (res) => { |
|
|
|
var tempFilePath = res.tempFilePath; |
|
|
|
this.imagePath = tempFilePath |
|
|
|
that.imagePath = tempFilePath |
|
|
|
|
|
|
|
this.$store.commit('setPromotionUrl', res.tempFilePath) |
|
|
|
that.$store.commit('setPromotionUrl', res.tempFilePath) |
|
|
|
|
|
|
|
uni.hideLoading() |
|
|
|
this.load = false |
|
|
|
that.load = false |
|
|
|
} |
|
|
|
}); |
|
|
|
}, 200); |
|
|
|