使用官方的uni.getFileSystemManager().writeFile()方法可将base64码转成的二维码显示在画布上,代码如下:
const obj = {
page: 'pages/sort/goodsDetail',
co_Nu: this.goodInfo.co_Nu
}
const _this = this
cenerateQrCode(obj).then(res => {
if (res.success) {
// 图片路径
var codeimg = wx.env.USER_DATA_PATH + '/ewm.jpg';
uni.getFileSystemManager().writeFile({
filePath:codeimg, // 图片路径
data: res.data, // 返回的base64
encoding: 'base64',
success() {
_this.posterData.codeImg.url = codei