微信小程序生成二维码的方案

generateQrcode() {
Parse.Cloud.run(‘getAccessToken’).then(AccessToken => {
uni.request({
url: `https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=${AccessToken}`,
method: ‘POST’,
responseType: ‘arraybuffer’,
header: {
‘content-type’: ‘application/json;charset=utf-8’
},
data: {
‘scene’: `id=1`,
‘page’: ‘pages/location/location’,
‘width’: 300
},
success: res => {
console.log(res);
let base64 = uni.arrayBufferToBase64(res.data);
this.qrcode = “data:image/PNG;base64,”+ base64
},
fail: () => {},
complete: () => {}
});
}).catch(e => console.log(‘e’ + JSON.stringify(e)))
},

Write a Comment

您的电子邮箱地址不会被公开。 必填项已用*标注