js部分
//生成二维码
createQRCode: function(){
wx.cloud.callFunction({
name: 'createQRCode',
data: {
// openid: 1,
id: "oskUN5hwrBJ7EqZSIwUEI6EkWNlA"
}
}).then(res => {
console.log(res)
let fileManager = wx.getFileSystemManager()
let filePath = wx.env.USER_DATA_PATH + '/qr.jpg'
console.log('filePath', filePath)
fileManager.writeFile({
filePath: filePath,
encoding: 'binary',
data: res.result.buffer,
success: (res => {
console.log(res)
console.log(filePath)
wx.hideLoading()
this.setData({
img: filePath
})
})
})
})
},
云函数部分
// 云函数入口函数
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.wxacode.getUnlimited({
"path": 'pages/square/userInfo/userInfo?id='+event.openId,
"width": 280,
"isHyaline":true,
"scene": 'oskUN5hwrBJ7EqZSIwUEI6EkWNlA',
"checkPath": false, //设置不透明底色
"envVersion": 'release'
})
return result
} catch (err) {
return err
}
}
参数哪不对呢?
生成了二维码,就是扫码没反应。
码是什么颜色呢,码要求是深色的才能扫的出来