const path = `${wx.env.USER_DATA_PATH}/fistTest.png`
// 获取小程序的文件系统
const fsm = wx.getFileSystemManager()
// 把arraybuffer数据写入到临时目录中
console.log(path,fsm, 'path')
try {
fsm.accessSync('wxfile://ad/interstitialAdExtInfo.txt');
console.log('文件存在');
} catch (e) {
console.error('文件不存在', e);
}
fsm.writeFile({
filePath: path,
data: base64?.replace(/^data:image\/\w+;base64,/, ''),
encoding: 'base64',
success: () => {
wx.getSetting({
success: res => {
console.log(res,8999)
let authSetting = res.authSetting
if (!authSetting['scope.writePhotosAlbum']) {
wx.authorize({
scope: 'scope.writePhotosAlbum',
success() {
console.log('授权了相册')
wx.downloadFile({
url: path, //仅为示例,并非真实的资源
success(res) {
console.log('保存图片')
// 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
if (res.statusCode === 200) {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
wx.showToast({
title: '保存海报成功',
icon: 'success',
duration: 2000
})
}
});
}
}
})
}
})
} else {
console.log('已经授权过相册')
wx.saveImageToPhotosAlbum({
filePath: path,
success: () => {
wx.showToast({
title: '保存海报成功',
icon: 'success',
duration: 2000
})
}
});
}
}
})
}
})
报错是隐私没更新