You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
3.1 KiB

const app = getApp(),
Api = require("../../../utils/util.js");
Page({
data: {
list: [],
pageNum: 1,
pageSize: 20,
},
onLoad: function () {
var that = this;
this.setData({
imgUrl: app.globalData.imgUrl
})
that.getNotice()
},
//获取技术资料
getNotice: function () {
var data = {
current: this.data.pageNum,
size: this.data.pageSize,
}
wx.showLoading({
title: '加载中...',
})
Api.req('sf/operationTechnicalData/list', data, 'get').then(res => {
wx.stopPullDownRefresh()
wx.hideLoading()
if(res.code== 200){
this.data.loadEnd = res.data.length < this.data.pageSize
if (this.data.pageNum == 1) {
this.data.records = res.data.records
} else {
this.data.records = this.data.records.concat(res.data.records)
}
if (!this.data.loadEnd) {
this.data.pageNum++;
}
this.setData({
list: this.data.records,
loadEnd: this.data.loadEnd,
})
}else{
wx.showToast({
title: res.errMsg,
icon: 'none'
})
}
})
},
//资料详情
detail: function (e) {
var that = this;
var last = e.currentTarget.dataset.detail.slice(-3)
if(last ==''){
wx.navigateTo({
url: '../technicaDetail/technicaDetail?id=' + e.currentTarget.dataset.id
})
}else{
let openFileType;
switch (last) {
case "ocx":
openFileType = "docx";
break;
case "ord":
openFileType = "docx";
break;
case "cel":
openFileType = "xlsx";
break;
case "lsx":
openFileType = "xlsx";
break;
case "xls":
openFileType = "xls";
break;
case "ppt":
openFileType = "ppt";
break;
case "ptx":
openFileType = "pptx";
break;
case "pdf":
openFileType = "pdf";
break;
default:
openFileType = "doc";
break;
}
if (last == 'png' || last == 'jpg' || last == 'gif' || last == 'peg'){
wx.navigateTo({
url: '../lookImg/lookImg?img=' + e.currentTarget.dataset.detail,
})
}else{
wx.downloadFile({
url: that.data.imgUrl + e.currentTarget.dataset.detail,
success: function (res) {
const filePath = res.tempFilePath
console.log(filePath)
wx.openDocument({
filePath: filePath,
fileType: openFileType,
success: function (res) {
console.log(1)
}
})
}
})
}
}
},
/** 下拉刷新 **/
onPullDownRefresh(e) {
this.setData({
pageNum: 1,
pageSize: 20,
loadEnd: false,
})
this.getNotice()
},
/** 页面触底上拉刷新 **/
onReachBottom(e) {
if (!this.data.loadEnd) {
this.getNotice()
} else {
wx.showToast({
title: '暂无更多数据',
icon: 'none',
duration: 500
})
}
},
})