|
@@ -1,10 +1,10 @@
|
|
import Notify from '../miniprogram_npm/@vant/weapp/notify/notify';
|
|
import Notify from '../miniprogram_npm/@vant/weapp/notify/notify';
|
|
const config = {
|
|
const config = {
|
|
- // baseURL: 'http://192.168.1.2:8801', // 基础URL
|
|
|
|
- baseURL: 'https://www.xsip.cn', // 基础URL
|
|
|
|
|
|
+ baseURL: 'http://192.168.2.111:8802', // 基础URL
|
|
|
|
+ // baseURL: 'https://www.xsip.cn', // 基础URL
|
|
timeout: 30000, // 超时时间(单位ms)
|
|
timeout: 30000, // 超时时间(单位ms)
|
|
header: {
|
|
header: {
|
|
- // 'content-type': 'application/json', // 默认请求头
|
|
|
|
|
|
+ 'content-type': 'application/xls', // 默认请求头
|
|
// 其他全局请求头...
|
|
// 其他全局请求头...
|
|
|
|
|
|
},
|
|
},
|
|
@@ -29,7 +29,9 @@ function downLoad(url){
|
|
wx.downloadFile({
|
|
wx.downloadFile({
|
|
url:config.baseURL + '/fileManager/downloadFile?fileId=' + url,
|
|
url:config.baseURL + '/fileManager/downloadFile?fileId=' + url,
|
|
// filePath: 'filePath',
|
|
// filePath: 'filePath',
|
|
- // header: header,
|
|
|
|
|
|
+ header: {
|
|
|
|
+ ...config.header
|
|
|
|
+ },
|
|
// timeout: 0,
|
|
// timeout: 0,
|
|
success: (result) => {
|
|
success: (result) => {
|
|
wx.hideLoading()
|
|
wx.hideLoading()
|
|
@@ -40,19 +42,26 @@ function downLoad(url){
|
|
console.log(result)
|
|
console.log(result)
|
|
if (result.statusCode === 200) {
|
|
if (result.statusCode === 200) {
|
|
const tempFilePath = result.tempFilePath; // 临时文件路径
|
|
const tempFilePath = result.tempFilePath; // 临时文件路径
|
|
- wx.saveFile({
|
|
|
|
- tempFilePath: tempFilePath, // 传入临时文件路径
|
|
|
|
- success(saveRes) {
|
|
|
|
- const savedFilePath = saveRes.savedFilePath;
|
|
|
|
- console.log('文件已保存到本地', savedFilePath);
|
|
|
|
- resolve(saveRes)
|
|
|
|
- // 可以在这里做后续操作,如打开文件或通知用户
|
|
|
|
- },
|
|
|
|
- fail(error) {
|
|
|
|
- console.error('保存文件失败', error);
|
|
|
|
- reject('保存文件失败')
|
|
|
|
- }
|
|
|
|
|
|
+ wx.openDocument({
|
|
|
|
+ filePath: tempFilePath,
|
|
|
|
+ showMenu:true,
|
|
|
|
+ success: function (res) {
|
|
|
|
+ console.log('打开文档成功')
|
|
|
|
+ }
|
|
})
|
|
})
|
|
|
|
+ // wx.saveFile({
|
|
|
|
+ // tempFilePath: tempFilePath, // 传入临时文件路径
|
|
|
|
+ // success(saveRes) {
|
|
|
|
+ // const savedFilePath = saveRes.savedFilePath;
|
|
|
|
+ // console.log('文件已保存到本地', savedFilePath);
|
|
|
|
+ // resolve(saveRes)
|
|
|
|
+ // // 可以在这里做后续操作,如打开文件或通知用户
|
|
|
|
+ // },
|
|
|
|
+ // fail(error) {
|
|
|
|
+ // console.error('保存文件失败', error);
|
|
|
|
+ // reject('保存文件失败')
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|