285 lines
6.4 KiB
JavaScript
285 lines
6.4 KiB
JavaScript
// pages/meeting/meeting.js
|
|
import {
|
|
previewFile,
|
|
sliceFileTypeByFileName
|
|
} from '../../assets/js/preview'
|
|
|
|
import MeetingApi from '../../assets/js/http/meetingApi'
|
|
import signUpApi from '../../assets/js/http/signUp'
|
|
import UserApi from '../../assets/js/http/userApi'
|
|
import {baseUrl, URL_CONFIG} from '../../assets/js/project.config.js'
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
payProveImage: '',
|
|
// 会议详情
|
|
meetingInfo: {},
|
|
// 参会人信息
|
|
singInPersonInfo: {},
|
|
// 会议通知文件资料数组
|
|
meetingFilesList: [],
|
|
// 会议资料文件数组
|
|
meetingDataList: [],
|
|
// 缴费凭证id
|
|
imageIds: [],
|
|
// 订单后四位
|
|
ordeCode: '',
|
|
// 缴费凭证的回显
|
|
payRecordImgSrc: '',
|
|
// 签到图片的回显
|
|
signImgSrc: '',
|
|
userId: ''
|
|
},
|
|
|
|
// 获取图片的id
|
|
getImagesId(e) {
|
|
this.setData({
|
|
imageIds: e.detail.join(',')
|
|
})
|
|
},
|
|
// 订单后四位
|
|
setOrdeCode(e) {
|
|
this.setData({
|
|
ordeCode: e.detail.value
|
|
})
|
|
},
|
|
// 上传汇款凭证
|
|
editPayRecord() {
|
|
if(this.data.ordeCode === '' || this.data.ordeCode === undefined ){
|
|
wx.showToast({
|
|
title: '请输入缴费订单号后四位数',
|
|
icon:'none'
|
|
})
|
|
return
|
|
}else if(this.data.ordeCode && this.data.ordeCode.length < 4){
|
|
wx.showToast({
|
|
title: '请输入四位缴费订单号后四位数',
|
|
icon:'none'
|
|
})
|
|
return
|
|
}
|
|
if(this.data.imageIds === '' || this.data.imageIds === undefined){
|
|
wx.showToast({
|
|
title: '请上传缴费凭证',
|
|
icon:'none'
|
|
})
|
|
return
|
|
}
|
|
const param = {
|
|
id: this.data.meetingInfo.situationId,
|
|
orderCode: this.data.ordeCode,
|
|
paymentRecord: this.data.imageIds
|
|
}
|
|
if (Array.isArray(this.data.imageIds)) {
|
|
param.paymentRecord = this.data.imageIds.join(',')
|
|
}
|
|
signUpApi.uploadPayRecord(param).then(res => {
|
|
console.log(res);
|
|
if (res.success) {
|
|
wx.showToast({
|
|
title: res.message,
|
|
icon: "success",
|
|
duration: 2000,
|
|
success() {
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
})
|
|
}
|
|
});
|
|
|
|
} else {
|
|
wx.showToast({
|
|
title: res.message,
|
|
icon: "none",
|
|
duration: 800,
|
|
});
|
|
}
|
|
})
|
|
},
|
|
//参会人信息
|
|
queryPeronInfo(id) {
|
|
MeetingApi.queryPersongInfoById({
|
|
id: id
|
|
}).then(res => {
|
|
if (res.success) {
|
|
this.setData({
|
|
singInPersonInfo: res.result,
|
|
ordeCode: res.result.orderCode,
|
|
})
|
|
if (!!res.result.paymentRecord) {
|
|
this.setData({
|
|
// 这是为了不点击图片上传的bug
|
|
imageIds: res.result.paymentRecord.split(',')
|
|
})
|
|
}
|
|
// 已经审核的获取审核凭证的src
|
|
if (res.result.checkResult !== 0) {
|
|
this.setData({
|
|
payRecordImgSrc: baseUrl + URL_CONFIG + 'sys/common/download/' + res.result.paymentRecord,
|
|
})
|
|
}
|
|
console.log(this.data.payRecordImgSrc);
|
|
// 已经签到的获取签到的图片的src
|
|
if (res.result.checkIn === 1) {
|
|
this.setData({
|
|
signImgSrc: baseUrl + URL_CONFIG + 'sys/common/download/' + res.result.checkFile
|
|
})
|
|
console.log(this.data.signImgSrc, 'this.data.signImgSrc');
|
|
}
|
|
}
|
|
})
|
|
},
|
|
// 通过文件id获取文件的相关信息
|
|
getFileInfo(id) {
|
|
return new Promise(resolve => {
|
|
let result = {}
|
|
MeetingApi.queryFileInfoById({
|
|
id: id
|
|
}).then(res => {
|
|
if (res.success) {
|
|
result = res.result
|
|
}
|
|
}).finally(() => {
|
|
resolve(result)
|
|
})
|
|
})
|
|
},
|
|
// 获取文件信息
|
|
async initFileList(fileIds) {
|
|
if (fileIds) {
|
|
const fileList = []
|
|
let arr = fileIds.split(',')
|
|
for (let i = 0; i < arr.length; i++) {
|
|
let fileObj = {}
|
|
fileObj = await this.getFileInfo(arr[i])
|
|
fileList.push({
|
|
id: fileObj.id,
|
|
name: fileObj.fileName
|
|
})
|
|
}
|
|
return fileList
|
|
}
|
|
},
|
|
// 预览
|
|
previewFile(e) {
|
|
const fileObj = e.currentTarget.dataset.file
|
|
let fileType = sliceFileTypeByFileName(fileObj.name)
|
|
// 文件类型不是docx,doc,pdf时,已邮件形式发送到参会人的邮箱
|
|
if (fileType !== 'docx' && fileType !== 'doc' && fileType !== 'pdf') {
|
|
let params = {
|
|
fileId: fileObj.id,
|
|
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.name)
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
|
|
// 获取上一个页面的会议数据
|
|
const meetingInfo = JSON.parse(options.meetingInfo)
|
|
console.log(meetingInfo);
|
|
const that = this
|
|
this.setData({
|
|
meetingInfo: meetingInfo
|
|
})
|
|
|
|
wx.getStorage({
|
|
key: 'userInfo',
|
|
success(res) {
|
|
that.setData({
|
|
userId: res.data.id
|
|
})
|
|
}
|
|
})
|
|
//
|
|
let {
|
|
meetingFiles,
|
|
meetingData
|
|
} = meetingInfo
|
|
// 获取参会人信息
|
|
this.queryPeronInfo(meetingInfo.situationId)
|
|
// this.queryFileInfo(meetingFiles)
|
|
// 获取会议资料文件
|
|
this.initFileList(meetingData).then(res => {
|
|
that.setData({
|
|
meetingDataList: res
|
|
})
|
|
})
|
|
|
|
// 会议通知文件
|
|
this.initFileList(meetingFiles).then(res => {
|
|
that.setData({
|
|
meetingFilesList: res
|
|
})
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |