355 lines
9.1 KiB
JavaScript
355 lines
9.1 KiB
JavaScript
import UserApi from '../../assets/js/http/userApi'
|
|
import MeetingApi from '../../assets/js/http/meetingApi'
|
|
import {
|
|
isLogin
|
|
} from '../../assets/js/common'
|
|
|
|
// pages/home/home.js
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
date: '',
|
|
selectArr: [],
|
|
titleList: [
|
|
'会议通知',
|
|
'文件通知',
|
|
'邮寄通知',
|
|
'催款通知',
|
|
],
|
|
index: 0,
|
|
list: [], // 消息列表
|
|
searchParams: {
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
titile: '', // 提醒类型 3:会议 6:文件 7:邮寄 8:催款
|
|
startTime: '', // 开始日期
|
|
endTime: '' // 结束日期
|
|
},
|
|
content: '', // 消息内容
|
|
showModal: false, // 是否显示弹窗
|
|
clickItem: null,
|
|
signUpBool: false // 是否跳转可报名
|
|
},
|
|
showDialogBtn: function (e) {
|
|
let content = e.currentTarget.dataset.message.msgContent
|
|
// 是否可跳转报名
|
|
const templateCode = e.currentTarget.dataset.message.templateCode
|
|
if (templateCode === 'QY_1_HYTZ_WORK_GROUP_CREATE' || templateCode === "QY_13_HYTZ_FBW_CREATE") {
|
|
this.setData({
|
|
signUpBool: true
|
|
})
|
|
} else {
|
|
|
|
this.setData({
|
|
signUpBool: false
|
|
})
|
|
}
|
|
const that = this
|
|
that.setData({
|
|
showModal: true,
|
|
content: content,
|
|
clickItem: e
|
|
})
|
|
console.log(this.data.clickItem);
|
|
},
|
|
/**
|
|
* 弹出框蒙层截断touchmove事件
|
|
*/
|
|
preventTouchMove: function () {},
|
|
/**
|
|
* 隐藏模态对话框
|
|
*/
|
|
hideModal: function () {
|
|
const that = this
|
|
this.messageDetail(this.data.clickItem)
|
|
this.loadData()
|
|
that.setData({
|
|
showModal: false,
|
|
content: '',
|
|
clickItem: null
|
|
});
|
|
|
|
},
|
|
loadData() {
|
|
wx.showToast({
|
|
title: '加载中...',
|
|
icon: 'loading'
|
|
})
|
|
UserApi.messageList(this.data.searchParams).then(res => {
|
|
if (res.success) {
|
|
// 搜索时,把原数据清空,重新筛选
|
|
if (this.data.searchParams.pageNo === 1) {
|
|
this.setData({
|
|
list: []
|
|
})
|
|
}
|
|
const reg = new RegExp("<p>", "g")
|
|
const reg1 = new RegExp("</p>", "g")
|
|
const reg2 = new RegExp("<span>", "g")
|
|
const reg3 = new RegExp("</span>", "g")
|
|
if (res.result.records && res.result.records.length) {
|
|
res.result.records.forEach(item => {
|
|
item.msgContent = item.msgContent.replace(reg, "")
|
|
item.msgContent = item.msgContent.replace(reg1, "")
|
|
item.msgContent = item.msgContent.replace(reg2, "")
|
|
item.msgContent = item.msgContent.replace(reg3, "")
|
|
})
|
|
this.setData({
|
|
list: [...this.data.list, ...res.result.records]
|
|
})
|
|
}
|
|
}
|
|
}).catch(err => {
|
|
wx.showToast({
|
|
title: '登录后查看消息通知!',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
})
|
|
},
|
|
// 点击首页的五个选项跳转页面
|
|
clickSelect(e) {
|
|
let index = e.currentTarget.dataset.index
|
|
let url = ''
|
|
if (this.data.selectArr[index].val === '0') { // 来款项目
|
|
url = '../project/project?type=project'
|
|
} else if (this.data.selectArr[index].val === '1') { // 工作组
|
|
// url = '../work/work'
|
|
url = '../project/project?type=work'
|
|
} else if (this.data.selectArr[index].val === '2') { // 分标委
|
|
url = '../committee/committee'
|
|
} else if (this.data.selectArr[index].val === '3') { // 会议活动
|
|
url = '../meeting/meeting'
|
|
} else if (this.data.selectArr[index].val === '4') { // 资料网员
|
|
// url = '../data/data'
|
|
url = '../project/project?type=ziliao'
|
|
} else if (this.data.selectArr[index].val === '6') { // 标协会员
|
|
url = '../standardRouter/standardRouter'
|
|
} else if (this.data.selectArr[index].val === '5') { // 合同
|
|
url = '../mineContract/mineContract'
|
|
}
|
|
isLogin( () => {
|
|
wx.navigateTo({
|
|
url,
|
|
})
|
|
})
|
|
|
|
},
|
|
// 会议去报名,切换已读状态
|
|
messageDetail(e) {
|
|
const readFlag = e.currentTarget.dataset.message.readFlag
|
|
|
|
if (readFlag == 0) { // 标记已读
|
|
UserApi.messageStatus({
|
|
anntId: e.currentTarget.dataset.message.anntId
|
|
}).then(res => {
|
|
this.loadData()
|
|
wx.showToast({
|
|
title: '已读成功',
|
|
icon: 'none'
|
|
})
|
|
})
|
|
}
|
|
|
|
},
|
|
// 去报名
|
|
goSignUpPage() {
|
|
const templateCode = this.data.clickItem.currentTarget.dataset.message.templateCode
|
|
const meetingId = JSON.parse(this.data.clickItem.currentTarget.dataset.message.busId).id
|
|
if (templateCode == 'QY_1_HYTZ_WORK_GROUP_CREATE' || templateCode == "QY_13_HYTZ_FBW_CREATE") { // 去报名页
|
|
// 需要调用会议详情的接口 判断该会议是否还在报名时间内 并跳转不同的页面或者操作
|
|
MeetingApi.meetingDetail({
|
|
id: meetingId
|
|
}).then(res => {
|
|
if (res.success) {
|
|
let flag = this.judgeCurrentTime(res.result.registerDeadline)
|
|
if (flag) {
|
|
// 超过报名时间了
|
|
wx.navigateTo({
|
|
// 这里传入的是会议id
|
|
url: `../cannotSignUp/cannotSignUp`,
|
|
success: () => {
|
|
this.hideModal()
|
|
}
|
|
})
|
|
} else {
|
|
// 从消息报名的参会单位不可更改
|
|
wx.setStorage({
|
|
key: 'companyDisabled',
|
|
data: true
|
|
})
|
|
wx.navigateTo({
|
|
// 这里传入的是会议id
|
|
url: `../signUpPage/signUpPage?meetingId=${meetingId}&type=indexMsg`,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
}
|
|
},
|
|
// 判断当前时间与会议报名截止时间
|
|
judgeCurrentTime(time) {
|
|
let date = new Date();
|
|
let compareTime = new Date(time)
|
|
if (date.getTime() > compareTime.getTime()) {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
},
|
|
// 类型选中
|
|
bindTitleChange(e) {
|
|
this.data.searchParams.pageNo = 1
|
|
if (e.detail.value == 0) {
|
|
this.setData({
|
|
"searchParams.titile": 3,
|
|
})
|
|
} else if (e.detail.value == 1) {
|
|
this.setData({
|
|
"searchParams.titile": 6,
|
|
})
|
|
} else if (e.detail.value == 2) {
|
|
this.setData({
|
|
"searchParams.titile": 7,
|
|
})
|
|
} else {
|
|
this.setData({
|
|
"searchParams.titile": 8,
|
|
})
|
|
}
|
|
this.loadData()
|
|
},
|
|
// 日期选中
|
|
bindDateChange: function (e) {
|
|
this.data.searchParams.pageNo = 1
|
|
this.setData({
|
|
"searchParams.startTime": e.detail.value,
|
|
"searchParams.endTime": e.detail.value
|
|
})
|
|
this.loadData()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
const that = this
|
|
let menuArrStand = [{
|
|
path: '../../assets/images/gongzuozu-new.png',
|
|
text: '工作组',
|
|
val: '1',
|
|
},
|
|
{
|
|
path: '../../assets/images/fenbiaowei-new.png',
|
|
text: '分标委',
|
|
val: '2',
|
|
},
|
|
{
|
|
path: '../../assets/images/ziliao-new.png',
|
|
text: '资料网员',
|
|
val: '4',
|
|
},
|
|
{
|
|
path: '../../assets/images/standard.png',
|
|
text: '标协会员',
|
|
val: '6',
|
|
},
|
|
{
|
|
path: '../../assets/images/laikuan-new.png',
|
|
val: '0',
|
|
text: '项目'
|
|
},
|
|
{
|
|
path: '../../assets/images/huiyi-new.png',
|
|
text: '会议',
|
|
val: '3',
|
|
},
|
|
{
|
|
path: '../../assets/images/new-contract.png',
|
|
text: '合同',
|
|
val: '5',
|
|
},
|
|
]
|
|
|
|
let menuArr = [{
|
|
path: '../../assets/images/gongzuozu-new.png',
|
|
text: '工作组',
|
|
val: '1',
|
|
},
|
|
{
|
|
path: '../../assets/images/fenbiaowei-new.png',
|
|
text: '分标委',
|
|
val: '2',
|
|
},
|
|
{
|
|
path: '../../assets/images/ziliao-new.png',
|
|
text: '资料网员',
|
|
val: '4',
|
|
},
|
|
{
|
|
path: '../../assets/images/laikuan-new.png',
|
|
text: '项目',
|
|
val: '0',
|
|
},
|
|
|
|
{
|
|
path: '../../assets/images/huiyi-new.png',
|
|
text: '会议',
|
|
val: '3',
|
|
},
|
|
{
|
|
path: '../../assets/images/new-contract.png',
|
|
text: '合同',
|
|
val: '5',
|
|
},
|
|
]
|
|
let searchParams = {
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
titile: '', // 提醒类型 3:会议 6:文件 7:邮寄 8:催款
|
|
startTime: '', // 开始日期
|
|
endTime: '' // 结束日期
|
|
}
|
|
this.setData({
|
|
list: [],
|
|
searchParams
|
|
})
|
|
this.loadData()
|
|
// 默认不显示标协会员的菜单
|
|
wx.getStorage({
|
|
key: 'userInfo',
|
|
success(res) {
|
|
console.log(res);
|
|
if (res.data.companyRole === '1') {
|
|
// 说明不是会员系统的企业
|
|
that.setData({
|
|
'selectArr': menuArr
|
|
})
|
|
} else {
|
|
// 是会员的企业
|
|
that.setData({
|
|
'selectArr': menuArrStand
|
|
})
|
|
}
|
|
|
|
},
|
|
fail() {
|
|
// this.data.selectArr = []
|
|
that.setData({
|
|
'selectArr': menuArr
|
|
})
|
|
}
|
|
})
|
|
},
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.data.searchParams.pageNo++
|
|
this.loadData()
|
|
}
|
|
}) |