Files
income_payments_applet/pages/projectDetail/projectDetail.js
T
2021-10-21 09:08:31 +08:00

171 lines
3.8 KiB
JavaScript

import UserApi from '../../assets/js/http/userApi'
import {
previewFile,
initFileList
} from '../../assets/js/preview'
import MeetingApi from '../../assets/js/http/meetingApi'
Page({
/**
* 页面的初始数据
*/
data: {
form: {},
id: '', // 在工作组id,项目id
workingGroupId: '', //工作组id
showMeeting: false, // 会议信息的显隐
projectFileList: [], // 项目资料文件
notifyFileList: [], // 通知文件
meetingList: [] // 会议文件
},
// 预览
preview(e) {
const fileObj = e.currentTarget.dataset.file
previewFile(fileObj.id, fileObj.name)
},
// 获取更多会议信息数据
goMoreMeeting() {
wx.navigateTo({
url: `../meeting/meeting?workingGroupId=${this.data.workingGroupId}`,
})
},
// 会议详情
meetingDetail(e) {
const meetingInfo = JSON.stringify(e.currentTarget.dataset.meetinginfo)
wx.navigateTo({
url: `../meetingDetailSigned/meetingDetailSigned?meetingInfo=${meetingInfo}`,
})
},
// 查看物流
lookProgress(e){
console.log(e)
let num = e.currentTarget.dataset.progress.postNo
wx.navigateTo({
url: `plugin://kdPlugin/index?num=${num}&appName=来款测试demo`,
})
},
// 跳转合同详情
contractDetail(){
console.log(this.data.form)
if(this.data.form.contractId) { // 关联了合同才能去合同详情
wx.navigateTo({
url: `../contractDetail/contractDetail?id=${this.data.form.contractId}`,
})
}else{
wx.showToast({
title: '未关联合同',
icon: 'none'
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.data.id = options.id
this.data.workingGroupId = options.workingGroupId
if (options.type == 'work') { // 工作组项目有会议详情
this.setData({
showMeeting: true
})
MeetingApi.meetingList({
workingGroupProjectId: this.data.id
}).then(res => {
console.log(res)
if (res.success) {
if (res.result.records && res.result.records.length <= 2) {
this.setData({
meetingList: res.result.records
})
} else if (res.result.records && res.result.records.length > 2) {
this.setData({
meetingList: res.result.records.slice(0, 2)
})
}
}
}).catch(err => {
wx.showToast({
title: '加载失败',
icon: 'none',
duration: 2000
})
})
}
UserApi.projectDetail({
id: this.data.id
}).then(res => {
this.setData({
form: res.result
})
// 获取项目资料文件list
if (this.data.form) {
initFileList(this.data.form.files).then(res => {
this.setData({
projectFileList: res
})
})
// 获取通知文件list
initFileList(this.data.form.chargeNoticeId).then(res => {
this.setData({
notifyFileList: res
})
})
}
}).catch(err => {
wx.showToast({
title: '加载失败',
icon: 'none',
duration: 2000
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})