49 lines
802 B
JavaScript
49 lines
802 B
JavaScript
const drawQrcode = require('../../utils/weapp.qrcode.esm.js').default
|
|
|
|
Component({
|
|
properties: {
|
|
visible: {
|
|
type: Boolean,
|
|
value: false
|
|
},
|
|
qrcodeId: {
|
|
type: String,
|
|
value: ''
|
|
}
|
|
},
|
|
|
|
data: {
|
|
loading: true
|
|
},
|
|
|
|
observers: {
|
|
'visible'(val) {
|
|
if (val && this.data.qrcodeId) {
|
|
this.setData({ loading: true })
|
|
this.draw()
|
|
}
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
draw() {
|
|
wx.nextTick(() => {
|
|
drawQrcode({
|
|
width: 200,
|
|
height: 200,
|
|
canvasId: 'qrcodeCanvas',
|
|
_this: this,
|
|
text: this.data.qrcodeId,
|
|
callback: () => {
|
|
this.setData({ loading: false })
|
|
}
|
|
})
|
|
})
|
|
},
|
|
|
|
onClose() {
|
|
this.triggerEvent('close')
|
|
}
|
|
}
|
|
})
|