// 获取二维码
getscan: function (e) {
var that = this;
var userinfo = wx.getStorageSync('userinfo'); // 微信返回的用户信息
var OpenId = userinfo.openId;
var CodeCreateTime = util.formatTime(new Date()); // 当前生成二维码的时间
console.log(CodeCreateTime)
var text = OpenId + ';' + CodeCreateTime
console.log('sssssss', text)
that.setData({
text: text
})
qrcode = new QRCode('canvas', {
text: text,
width: 155,
height: 155,
colorDark: "#000",
colorLight: "#fff",
});
console.log('132', that.data.text)
// 把canvase做成图片显示,就没有了层级问题
// canvas 转图片的时候
const ctx = wx.createCanvasContext('canvas')
console.log(ctx)
console.log(ctx.draw)
ctx.draw(true, setTimeout(()=>{
console.log('执行回调')
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: 80,
height: 80,
canvasId: 'canvas',
success: function (res) {
console.log('wwweer', res)
that.setData({
radarImg: res.tempFilePath
});
console.log('147', that.data.text)
console.log('325', that.data.radarImg)
}
});
},300))
},
wx.createCanvasContext 放在周期函数onshow里面就可以,但是点击事件不触发,不执行
你好,建议使用新 Canvas 2D 接口