This commit is contained in:
du 2024-06-14 15:00:33 +08:00
parent 40b6064392
commit 0a6d79e4bc
4 changed files with 56 additions and 7 deletions

4
app.js
View File

@ -50,10 +50,10 @@ App({
globalData: {
versionCode: 'V1',
userInfo: {},
// headerUrl: "http://42.193.40.239:8017/" //线上
headerUrl: "http://42.193.40.239:8017/" //线上
// headerUrl: "http://192.168.110.10:8017/" //线下
// headerUrl: "http://192.168.110.186:8017/"
headerUrl: "https://city.sczysoft.com/df/"
// headerUrl: "https://city.sczysoft.com/df/"
},
// https://city.sczysoft.com/df/doc.html //接口
// https://city.sczysoft.com/dffile //查看拼接

View File

@ -63,7 +63,7 @@ Component({
userId: app.globalData.userInfo.userId,
condition: this.data.condition
}
app.axios("GET", "app", "/Othexpert/performUserPage", params, false).then(res => {
app.axios("GET", "app", "/Othteam/getOthteamPage", params, false).then(res => {
console.log(res,'res===>');
this.data.freshIng = false;
if (res.code == 1) {

View File

@ -13,6 +13,7 @@ Component({
* 组件的初始数据
*/
data: {
baseUrl: app.FILE_SERVER_URL,
condition: '',
curTab: 0,
tabs: [],
@ -21,7 +22,7 @@ Component({
freshIng: false,
page: 1,
pageSize: 10,
list: []
list: [],
},
pageLifetimes: {
@ -90,7 +91,55 @@ Component({
this.setData(this.data)
})
},
download :function (item) {
console.log(item,'item====>');
console.log(this.data.baseUrl+item.currentTarget.dataset.item.filePath);
//触发点击事件使用uni.showLoading()展示交互提示
wx.showLoading({
title: '正在下载……'
});
// 使用wx.downloadFile()开始下载文件
wx.downloadFile({
url: this.data.baseUrl+item.currentTarget.dataset.item.filePath, //url:请求的完整地址
success: function(res) {
wx.hideLoading() //调用结束,隐藏加载框
const filePath = res.tempFilePath //临时文件路径 (本地路径)
if (res.statusCode == 200) {
//判断后端数据接收成功时提示下载完成
wx.showToast({
icon: 'none',
mask: true,
title: '下载完成,正在打开文件...',
duration: 2000,
});
}
//设置定时器2秒后打开文件
setTimeout(() => {
//调用wx.openDocument()打开刚刚下载的文件
wx.openDocument({
filePath: filePath, //上一步存储的临时文件路径 (本地路径)
fileType: item.type, //要打开的文件类型,
showMenu: true, //是否显示右上角菜单
//下面的测试用了,写不写无所谓
success: function(res) {
},
complete: function(msg) {
}
})
}, 2000)
},
//文件下载失败会走这里具体可以把err打印出来看看有什么错误
fail: (err) => {
uni.showToast({
icon: 'none',
mask: true,
title: '文件下载失败',
});
},
})
},
/**
* 获取预案类型
*/

View File

@ -13,7 +13,7 @@
</view>
</view>
<view class="item-bg" wx:for="{{list}}">
<view catchtap="toDetail" data-item="{{item}}" class="item">
<view data-item="{{item}}" class="item">
<view class="h-div v-center">
<text class="lab">预案名称:</text>
<text class="val">{{item.planname}}</text>
@ -29,7 +29,7 @@
<text class="val">{{item.introduction}}</text>
</view>
<view class="line"></view>
<view class="h-div v-center">
<view data-item="{{item}}" catchtap="download" class="h-div v-center" >
<text class="download">附件下载</text>
</view>
</view>