微信小程序保存到本地的话,我的理解是每个人每种型号的手机不一样,所以实现起来很繁琐,所以可以下载到临时文件区后转发好友!!!
临时文件存放区:wx.env.USER_DATA_PATH
// 下载资料
downloadDrawingZip() {
this.canDownload = true
uni.showLoading({ title: '正在下载......' })
let realFileName = orderId + '.zip'
let fileSavePath = wx.env.USER_DATA_PATH + '/' + realFileName
console.log('106', fileSavePath)
wx.downloadFile({
url: '#你的接口url',
header: {
'Content-Type': 'application/octet-stream'
},
filePath: fileSavePath,
success: (res) => {
console.log(111, res)
uni.hideLoading()
wx.shareFileMessage({
filePath: res.filePath,
fileName: realFileName,
success(data) {
uni.showToast({
icon: 'success',
mask: true,
title: '转发成功!',
duration: 2000,
});
},
fail: console.error,
})
this.canDownload = false
},
fail: (err) => {
console.error(err)
uni.showToast({
icon: 'error',
title: '下载失败!',
duration: 3000
})
this.canDownload = false
}
})
}