wx.getImageInfo在真机调试获取不到wx.writeFile的图片信息?
图片是通过接口返回的小程序码,由于格式是buffer/array,所以通过wx.getFileSystemManager.writeFile写入文件,
wx.getImageInfo在开发工具中是可以获取到wx.getFileSystemManager.writeFile写入的图片的信息的,
但是在真机调试中,wx.getImageInfo就获取不到图片信息了
附代码:
获取小程序码代码:
method: 'POST',
url: _this.$url.goods,
responseType: 'arraybuffer',
header: {
'Authorization': token
},
data: {
sign: sign,
data: json
},
success: res => {
const fsm = wx.getFileSystemManager();
const FILE_BASE_NAME = 'tmp_img_src';
let filePath =
`${wx.env.USER_DATA_PATH}/${FILE_BASE_NAME}.jpg`; //图片临时地址
fsm.writeFile({
filePath,
data: res.data,
encoding: 'utf8',
success() {
console.log(filePath)
// _this.imgSrc = filePath;
resolve(filePath)
},
fail() {
this.canvasFlag = true;
wx.showToast({
title: '海报生成失败',
duration: 2000,
icon: 'none'
});
},
});
},
fail: res => {
this.canvasFlag = true;
wx.showToast({
title: '海报生成失败',
duration: 2000,
icon: 'none'
});
}
//获取图片信息
wx.getImageInfo({
src: code,
success(res) {
ctx.drawImage(res.path, (_this.phoneW - 80) / 2, 380 * scaleH, 80, 80)
ctx.draw(true)
},
fail() {
_this.canvasFlag = true;
ws.showToast({
title: code,
duration: 2000,
icon: 'none'
});
}
})