|
@@ -758,49 +758,57 @@
|
|
|
|
|
|
|
|
|
downloadFile(url) {
|
|
|
- uni.downloadFile({
|
|
|
- url: url,
|
|
|
- success: (res) => {
|
|
|
- if (res.statusCode === 200) {
|
|
|
- const filePath = res.tempFilePath;
|
|
|
- uni.saveFile({
|
|
|
- tempFilePath: filePath,
|
|
|
- success: (res) => {
|
|
|
- uni.showToast({
|
|
|
- title: '文件已保存:' + res.savedFilePath,
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
- // 打开文档查看(仅支持Android)
|
|
|
- if (plus.os.name === 'Android') {
|
|
|
- uni.openDocument({
|
|
|
- filePath: res.savedFilePath,
|
|
|
- success: () => {
|
|
|
- console.log('打开文档成功');
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: 'iOS系统请自行选择查看方式',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- fail: () => {
|
|
|
- uni.showToast({
|
|
|
- title: '保存文件失败',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- fail: () => {
|
|
|
- uni.showToast({
|
|
|
- title: '下载文件失败',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
+ const a = document.createElement('a');
|
|
|
+ a.href = url; //filePath 这里的地址是 uni.downloadFile 中的返回值里的地址
|
|
|
+ let aa=url.split("&name=")
|
|
|
+ a.download = aa[1]; // 可以设置下载文件名,如果是空字符串,则使用服务器端设置的文件名
|
|
|
+ a.click();
|
|
|
+
|
|
|
+
|
|
|
+ // uni.downloadFile({
|
|
|
+ // url: url,
|
|
|
+ // success: (res) => {
|
|
|
+ // if (res.statusCode === 200) {
|
|
|
+ // const filePath = res.tempFilePath;
|
|
|
+ // uni.saveFile({
|
|
|
+ // tempFilePath: filePath,
|
|
|
+ // success: (res) => {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '文件已保存:' + res.savedFilePath,
|
|
|
+ // icon: 'none'
|
|
|
+ // });
|
|
|
+ // // 打开文档查看(仅支持Android)
|
|
|
+ // if (plus.os.name === 'Android') {
|
|
|
+ // uni.openDocument({
|
|
|
+ // filePath: res.savedFilePath,
|
|
|
+ // success: () => {
|
|
|
+ // console.log('打开文档成功');
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: 'iOS系统请自行选择查看方式',
|
|
|
+ // icon: 'none'
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // fail: () => {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '保存文件失败',
|
|
|
+ // icon: 'none'
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // fail: () => {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '下载文件失败',
|
|
|
+ // icon: 'none'
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // });
|
|
|
},
|
|
|
|
|
|
// 获取上传进度
|