Files
income_payments_applet/pages/meetingDetailSigned/meetingDetailSigned.js
T

536 lines
14 KiB
JavaScript

// pages/meeting/meeting.js
import {
appName
} from '../../assets/js/project.config'
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: [],
// 会议纪要文件数组
meetingJiyaoList:[],
// 演讲ppt
speechPptList: [],
// 照片
photoSrc: '',
// 缴费凭证id
imageIds: [],
// 订单后四位
ordeCode: '',
// 缴费凭证的回显
payRecordImgSrc: '',
// 收费二维码的回显
paymentQrCodeSrc:'',
// 签到图片的回显
signImgSrc: '',
userId: '',
form: {},
showSignInBtn:false, // 是否显示签到按钮
isMoreTime:false, // 是否超过 会议截止报名时间
meetingTypeText:"", // 会议类型
questionList: [], // 标协会议 存储官宣答疑的数组
},
/*
* 会议类型
* */
initMeetingType(val) {
if (val) {
switch (val +'') {
case '1':
return '工作组会议'
case '2':
switch (this.data.meetingInfo.tbMeetingType + '') {
case '1':
return '标协会议-标准宣贯'
case '2':
return '标协会议-培训会'
case '3':
return '标协会议-信息交流会'
}
break
case '3':
return '国际研讨会'
case '4':
return '其他会议'
case '5':
return '分标委会议'
case '6':
return '理事会会议'
}
} else {
return ''
}
},
compareCurrentTime(time) {
let date = new Date()
let compareTime = new Date(time)
if (date.getTime() > compareTime.getTime()) {
return true
} else {
return false
}
},
// 获取图片的id
getImagesId(e) {
this.setData({
imageIds: e.detail.join(',')
})
},
// 订单后四位
setOrdeCode(e) {
this.setData({
ordeCode: e.detail.value
})
},
// 上传汇款凭证
editPayRecord() {
if (this.data.imageIds.length === 0) {
wx.showToast({
title: '请上传缴费凭证',
icon: 'none'
})
return
}
if (this.data.singInPersonInfo.payMode === 2 && (this.data.ordeCode === '' || this.data.ordeCode === undefined || this.data.ordeCode === null)) {
wx.showToast({
title: '请输入缴费订单号后四位数',
icon: 'none'
})
return
} else if (this.data.singInPersonInfo.payMode === 2 && this.data.ordeCode && this.data.ordeCode.length < 4) {
// 线上缴费才去校验
wx.showToast({
title: '请输入四位缴费订单号后四位数',
icon: 'none'
})
return
}
const param = {
id: this.data.singInPersonInfo.id,
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,
});
}
})
},
// 查看物流
lookProgress(e) {
let num = e.currentTarget.dataset.progress.postNo
wx.navigateTo({
url: `plugin://kdPlugin/index?num=${num}&appName=${appName}`,
})
},
//参会人信息
queryPeronInfo(id) {
MeetingApi.queryPersongInfoById({
id: id
}).then(res => {
if (res.success) {
this.setData({
singInPersonInfo: res.result,
ordeCode: res.result.orderCode,
})
// 演讲ppt、
if (res.result.speechPpt) {
this.initFileList(res.result.speechPpt).then(res => {
this.setData({
speechPptList: res
})
})
}
// 照片
if (res.result.photo) {
this.setData({
photoSrc: baseUrl + URL_CONFIG + 'sys/common/download/' + res.result.photo,
})
}
if (!!res.result.paymentRecord) {
this.setData({
// 这是为了不点击图片上传的bug
imageIds: res.result.paymentRecord.split(',')
})
}
// 已经审核的获取审核凭证的src
if (res.result.checkResult !== 0 && res.result.paymentRecord) {
this.setData({
payRecordImgSrc: baseUrl + URL_CONFIG + 'sys/common/download/' + res.result.paymentRecord,
})
}
console.log(this.data.payRecordImgSrc);
// 已经签到的获取签到的图片的src
if (res.result.checkIn === 1 && res.result.checkFile) {
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
}
},
// 是否可以下载会议文件
downMeetingFile(param){
return new Promise(resolve => {
UserApi.downFileDownWeb(param.fileId,param.meetingId,{type:param.type}).then(res => {
resolve(res)
})
})
},
// 会议文件的预览
async previewFileMeetingData(e) {
const fileObj = e.currentTarget.dataset.file
const param = {
fileId:fileObj.id,
meetingId:this.data.meetingInfo.id,
type:'download'
}
let res = await this.downMeetingFile(param)
// r如果可以下载 那么res 是一个文件流 否则就不可以下载
let flag = typeof(res) === 'string'
const that = this
// 只有审核通过的才可以去下载
if (!flag && this.data.singInPersonInfo.checkResult !== 1) {
wx.showToast({
title: '会议报名并审核通过后才可查看文件',
icon: 'none',
duration: 3000
})
return
}
let fileType = sliceFileTypeByFileName(fileObj.name)
// 文件类型不是docx,doc,pdf时,已邮件形式发送到参会人的邮箱
if (fileType !== 'docx' && fileType !== 'doc' && fileType !== 'pdf') {
wx.showModal({
title: '提示',
content: '将附件发送到您的邮箱',
success: function (res) {
if (res.confirm) {
//这里是点击了确定以后
let params = {
fileId: fileObj.id,
userId: that.data.userId
}
UserApi.sendEmail(params).then(res => {
if (res.success) {
wx.showToast({
title: '文件已发送到您的邮箱',
icon: 'none'
})
} else {
wx.showToast({
title: res.message,
icon: "none"
})
}
})
} else {
//这里是点击了取消以后
}
}
})
} else {
previewFile(fileObj.id, fileObj.name)
}
},
// 预览
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.id, fileObj.name)
}
},
// 去签到
toSignUp(){
let meetingId = this.data.meetingInfo.id
wx.navigateTo({
url: `../scanSign/scanSign?type=meetingDetail&meetingId=${meetingId}`,
})
},
// 报名
joinMeeting(e){
const that = this
// 如果是去报名页面需要在缓存中存储会议信息 当报名结束后 需要清除缓存中的当前会议信息 meetingSignUpType 1 可报名 2报名
let meetingItem = this.data.meetingInfo
if (meetingItem.meetingSignUpType === 1) {
// 从消息报名的参会单位不可更改
wx.setStorage({
key:'companyDisabled',
data:true
})
wx.setStorage({
key: "currentMeetingInfo",
data: that.data.meetingInfo,
success() {
// 国际研讨会去国际研讨会的报名页面
if (meetingItem.meetingType !== 3) {
wx.navigateTo({
url: `../signUpPage/signUpPage?type=indexMsg`
})
} else {
wx.navigateTo({
url: `../signUpPageGuoji/signUpPageGuoji?meetingId=${meetingItem.id}`
})
}
}
})
}
},
// 国际研讨会嘉宾编辑个人信息
editSignupInfo(){
wx.navigateTo({
url: `../guestEditSignUpinfo/guestEditSignUpInfo?&situationId=${this.data.singInPersonInfo.id}`,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// 获取上一个页面的会议数据
const meetingInfo = JSON.parse(options.meetingInfo)
console.log("---------meetingInfo----------", meetingInfo)
const that = this
this.setData({
paymentQrCodeSrc:baseUrl + URL_CONFIG + 'sys/common/download/' + meetingInfo.paymentQrCode
})
if(meetingInfo){
meetingInfo.meetingType = meetingInfo.meetingType + ''
meetingInfo.tbMeetingType = meetingInfo.tbMeetingType + ''
this.setData({
meetingInfo:meetingInfo,
questionList: meetingInfo.questionList || []
})
let flag = this.compareCurrentTime(meetingInfo.registerDeadline)
this.setData({
isMoreTime:flag,
meetingTypeText:this.initMeetingType(meetingInfo.meetingType)
})
}else{
MeetingApi.meetingDetail({id:meetingInfo.id}).then(res => {
if(res.success){
this.setData({
meetingInfo:res.result,
questionList: res.result.questionList || []
})
let flag = this.compareCurrentTime(res.result.registerDeadline)
this.setData({
isMoreTime:flag,
meetingTypeText:this.initMeetingType(meetingInfo.meetingType)
})
}
})
}
// 如果会议的报名状态是待签到则显示去签到按钮 待签到的报名状态时 6 并且会议的不是已结束
if(this.data.meetingInfo.signUpStatus == 6 && this.data.meetingInfo.signUpStatus +'' !== '4' ){
this.setData({
showSignInBtn:true
})
}else{
this.setData({
showSignInBtn:false
})
}
wx.getStorage({
key: 'userInfo',
success(res) {
that.setData({
userId: res.data.id
})
}
})
UserApi.projectDetail({
id: meetingInfo.situationId
}).then(res => {
this.setData({
form: res.result
})
}).catch(err => {
wx.showToast({
title: '加载失败',
icon: 'none',
duration: 2000
})
})
//
let {
meetingFiles,
meetingData,
meetingMinute
} = meetingInfo
// 获取参会人信息
this.queryPeronInfo(meetingInfo.situationId)
// this.queryFileInfo(meetingFiles)
// 获取会议资料文件
this.initFileList(meetingData).then(res => {
that.setData({
meetingDataList: res
})
})
// 会议通知文件meetingFiles
this.initFileList(meetingFiles).then(res => {
that.setData({
meetingFilesList: res
})
})
// 会议纪要文件
this.initFileList(meetingMinute).then(res => {
that.setData({
meetingJiyaoList: res
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})