wx.request({
url: app.api.xxx,
data: {
url: `pages/index/index`,
scene: `id=${that.data.id}`,
},
method: 'POST',
responseType: 'arraybuffer', //十分重要
header: {
'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
success: function (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: 'binary',
success() {
resolve(filePath);
},
fail() {
reject(new Error('ERROR_WRITE'));
},
});
}, fail: function (err) {
reject(err)
}
})
ctx.drawImage(imgPath, 20, imgHeight + 70, 80, 80)