1.js get后面携带参数值不能用引号包裹
var appid = 'wx27affeb9e3336157'
var secret = '69e0dac741e19432fc0a3ab662281800'
wx.request({
url: `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appid}&secret=${secret}`,
method: 'GET',
success: function(res) {
console.log('res.access_token',res.data.access_token)
wx.request({
url: 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' + res.data.access_token,
method: 'POST',
data: {
scene: 1012,
// 是否为Png,默认jpeg
is_hyaline: true,
// 是否自动取色
auto_color:true,
page: 'pages/mine/mine',
},
responseType: 'arraybuffer',
complete: function(res) {
that.setData({
code: wx.arrayBufferToBase64(res.data)
})
},
})
}
})
2.wxml 显示小程序码
<image src="data:image/png;base64,{{code}}" mode="widthFix"></image>