93 lines
2.1 KiB
JavaScript
93 lines
2.1 KiB
JavaScript
import UserApi from '../../assets/js/http/userApi'
|
|
import { previewFile, sliceFileTypeByFileName } from '../../assets/js/preview'
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
|
|
userId: '',
|
|
list: [],
|
|
pageNo: 1,
|
|
pageSize: 10
|
|
},
|
|
goBack(){
|
|
wx.navigateBack()
|
|
},
|
|
loadData(){
|
|
wx.showToast({
|
|
title: '加载中...',
|
|
icon: 'loading'
|
|
})
|
|
let params = {
|
|
pageNo: this.data.pageNo,
|
|
pageSize: this.data.pageSize,
|
|
// 创建时间倒叙排序
|
|
column:'createTime',
|
|
order:'desc'
|
|
}
|
|
UserApi.dataList(params).then(res=>{
|
|
if(res.success && res.result.records && res.result.records.length){
|
|
this.setData({
|
|
list: [...this.data.list, ...res.result.records]
|
|
})
|
|
}
|
|
}).catch(err=>{
|
|
wx.showToast({
|
|
title: '加载失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
})
|
|
},
|
|
// 预览
|
|
previewFile(e) {
|
|
const fileObj = e.currentTarget.dataset.file
|
|
let fileType = sliceFileTypeByFileName(fileObj.fileName)
|
|
// 文件类型不是docx,doc,pdf时,已邮件形式发送到参会人的邮箱
|
|
if(fileType !== 'docx' && fileType !== 'doc' && fileType !== 'pdf') {
|
|
let params = {
|
|
fileId: fileObj.fileId,
|
|
userId: this.data.userId
|
|
}
|
|
UserApi.sendEmail(params).then(res=>{
|
|
if(res.success){
|
|
wx.showToast({
|
|
title: '文件已发送到您的邮箱',
|
|
icon: 'none'
|
|
})
|
|
}else{
|
|
wx.showToast({
|
|
title: res.message,
|
|
icon: "none"
|
|
})
|
|
}
|
|
})
|
|
}else {
|
|
previewFile(fileObj.fileId, fileObj.fileName)
|
|
}
|
|
},
|
|
|
|
onLoad: function () {
|
|
const that = this
|
|
that.loadData()
|
|
wx.getStorage({
|
|
key: 'userInfo',
|
|
success(res){
|
|
that.setData({
|
|
userId: res.data.id
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.data.pageNo++
|
|
this.loadData()
|
|
}
|
|
})
|