|
|
|
const api = require('../../../../utils/api')
|
|
|
|
import {
|
|
|
|
getTimestamp
|
|
|
|
} from '../../../../utils/common'
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
detail: {},
|
|
|
|
actCurrentState: 0, //活动当前状态(0-报名中,1-已报满,2-未开始,3-进行中,4-已结束)
|
|
|
|
actStartTime: '',
|
|
|
|
actEndTime: '',
|
|
|
|
signupEndTime: '',
|
|
|
|
signupFlag: 0, //用户报名状态(0-未报名,1已报名)
|
|
|
|
clocks: [], //打卡列表
|
|
|
|
clockNum: 0, //打卡人次
|
|
|
|
actContent: '', //富文本
|
|
|
|
actNewsContent:'',//新闻稿
|
|
|
|
dialogTitle: '',
|
|
|
|
dialogContent: '',
|
|
|
|
dialogConfirmText: '',
|
|
|
|
dialogCancelText: '',
|
|
|
|
uservolunteerflag: '',
|
|
|
|
cancelSignupVisible: false,
|
|
|
|
cancelSignupTipValue: '',
|
|
|
|
cancelSignupTipVisible: false,
|
|
|
|
selectedTab:'',//用来判断详情是否显示志愿者打卡
|
|
|
|
preloadVisible: true,
|
|
|
|
},
|
|
|
|
onLoad: function(options) {
|
|
|
|
this.setData({
|
|
|
|
id: options.id,
|
|
|
|
actCurrentState: options.actcurrentstate,
|
|
|
|
signupFlag: options.signupflag,
|
|
|
|
selectedTab:options.selectedTab,
|
|
|
|
})
|
|
|
|
// this.getDetail();//活动详情
|
|
|
|
// this.clockList();//打卡列表
|
|
|
|
// if (this.data.actCurrentState == 2 || this.data.actCurrentState == 3 || this.data.actCurrentState == 4){
|
|
|
|
// this.clockList();//打卡列表
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
// 获取详情信息
|
|
|
|
getDetail() {
|
|
|
|
let id = this.data.id
|
|
|
|
api.detail(id).then(res => {
|
|
|
|
if (res.code === 0 && res.msg === 'success') {
|
|
|
|
this.setData({
|
|
|
|
detail: res.data,
|
|
|
|
actContent: res.data.actContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto"'),
|
|
|
|
actNewsContent:res.data.actNewsContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto"'),
|
|
|
|
actStartTime: res.data.actStartTime.substring(0, 16),
|
|
|
|
actEndTime: res.data.actEndTime.substring(0, 16),
|
|
|
|
signupEndTime: res.data.signupEndTime.substring(0, 16),
|
|
|
|
preloadVisible:false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//打卡列表
|
|
|
|
clockList() {
|
|
|
|
let id = this.data.id
|
|
|
|
api.clockList(id).then(res => {
|
|
|
|
// console.log("打卡列表:" + JSON.stringify(res.data))
|
|
|
|
if (res.code === 0 && res.msg === 'success') {
|
|
|
|
this.setData({
|
|
|
|
clockNum: res.data.clockNum,
|
|
|
|
clocks: res.data.clocks
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
goClockIn(e) { //前往打卡页面
|
|
|
|
const id = e.currentTarget.dataset.id
|
|
|
|
const currentUserStatus = e.currentTarget.dataset.currentuserstatus;//4 我要打卡 5 更新打卡
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `../clockIn/clockIn?id=${id}¤tUserStatus=${currentUserStatus}`
|
|
|
|
})
|
|
|
|
},
|
|
|
|
goVolunteer(e) { //我要报名 用户认证志愿者标识(0-未认证,1-已认证)
|
|
|
|
// 0-待审核 提醒用户志愿者身份认证审核中,不能报名也不用去认证
|
|
|
|
// 1 - 认证通过 直接报名
|
|
|
|
// 2 - 待认证 提示用户去认证
|
|
|
|
// 3 - 黑名单 提示用户已被拉入黑名单,不能报名
|
|
|
|
const uservolunteerflag = e.currentTarget.dataset.uservolunteerflag
|
|
|
|
this.setData({
|
|
|
|
uservolunteerflag: uservolunteerflag
|
|
|
|
})
|
|
|
|
if (uservolunteerflag == 0) {
|
|
|
|
// this.setData({
|
|
|
|
// dialogVisible: !this.data.dialogVisible,
|
|
|
|
// dialogTitle: '正在审核',
|
|
|
|
// dialogContent: ['志愿者身份审核中'],
|
|
|
|
// dialogConfirmText: '确定',
|
|
|
|
// dialogCancelText: ''
|
|
|
|
// })
|
|
|
|
this.setData({
|
|
|
|
dialogVisible: !this.data.dialogVisible,
|
|
|
|
dialogTitle: '报名提醒',
|
|
|
|
dialogContent: ['报名时间截止之前可取消', `缺席活动扣除${this.data.detail.punishmentPoints}积分,是否确定报名`],
|
|
|
|
dialogConfirmText: '是',
|
|
|
|
dialogCancelText: '否'
|
|
|
|
})
|
|
|
|
} else if (uservolunteerflag == 1) {
|
|
|
|
this.setData({
|
|
|
|
dialogVisible: !this.data.dialogVisible,
|
|
|
|
dialogTitle: '报名提醒',
|
|
|
|
dialogContent: ['报名时间截止之前可取消', `缺席活动扣除${this.data.detail.punishmentPoints}积分,是否确定报名`],
|
|
|
|
dialogConfirmText: '是',
|
|
|
|
dialogCancelText: '否'
|
|
|
|
})
|
|
|
|
|
|
|
|
} else if (uservolunteerflag == 2) {
|
|
|
|
this.setData({
|
|
|
|
dialogVisible: !this.data.dialogVisible,
|
|
|
|
dialogTitle: '志愿者认证',
|
|
|
|
dialogContent: ['是否认证志愿者,完成报名'],
|
|
|
|
dialogConfirmText: '是',
|
|
|
|
dialogCancelText: '否'
|
|
|
|
})
|
|
|
|
} else if (uservolunteerflag == 3) {
|
|
|
|
this.setData({
|
|
|
|
dialogVisible: !this.data.dialogVisible,
|
|
|
|
dialogTitle: '已被拉入黑名单',
|
|
|
|
dialogContent: ['您已被拉入黑名单,不能报名'],
|
|
|
|
dialogConfirmText: '确定',
|
|
|
|
dialogCancelText: ''
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
//已报满
|
|
|
|
signUpFull() {
|
|
|
|
this.setData({
|
|
|
|
dialogVisible: !this.data.dialogVisible,
|
|
|
|
dialogTitle: '已报满',
|
|
|
|
dialogContent: ['活动名额报名已满', '快去“招募令”中参加其他活动吧'],
|
|
|
|
dialogConfirmText: '确定',
|
|
|
|
dialogCancelText: ''
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 取消报名
|
|
|
|
prompt() {
|
|
|
|
const now = getTimestamp()
|
|
|
|
if (now > this.data.detail.signupEndTime) {
|
|
|
|
this.setData({
|
|
|
|
cancelSignupVisible: !this.data.cancelSignupVisible,
|
|
|
|
cancelSignupTipValue: `报名时间已结束,取消活动将扣除${this.data.detail.punishmentPoints}积分`,
|
|
|
|
cancelSignupTipVisible: true
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
cancelSignupVisible: !this.data.cancelSignupVisible,
|
|
|
|
cancelSignupTipVisible: false,
|
|
|
|
cancelSignupTipValue: ''
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onShow: function() {
|
|
|
|
this.getDetail(); //活动详情
|
|
|
|
this.clockList(); //打卡列表
|
|
|
|
// if (this.data.actCurrentState == 2 || this.data.actCurrentState == 3 || this.data.actCurrentState == 4) {
|
|
|
|
// this.clockList();//打卡列表
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
// 弹框确认
|
|
|
|
confirmDialog() {
|
|
|
|
console.log('::::::' + this.data.uservolunteerflag.length)
|
|
|
|
if (this.data.uservolunteerflag.length > 0) {
|
|
|
|
if (this.data.uservolunteerflag == 0 || this.data.uservolunteerflag == 1) {
|
|
|
|
let id = this.data.id
|
|
|
|
api.signup(id).then(res => {
|
|
|
|
if (res.code == 0) {
|
|
|
|
this.setData({
|
|
|
|
dialogVisible: !this.data.dialogVisible,
|
|
|
|
dialogTitle: '报名成功',
|
|
|
|
dialogContent: ['正在审核中', '请耐心等待消息通知!'],
|
|
|
|
dialogConfirmText: '确定',
|
|
|
|
dialogCancelText: '',
|
|
|
|
uservolunteerflag: ''
|
|
|
|
})
|
|
|
|
this.getDetail()
|
|
|
|
} else { //点击我要报名,刚好已经报满,此时弹出已报满的提示框,点击确定后,我要报名按钮变成已报满按钮(置灰)
|
|
|
|
this.getDetail()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else if (this.data.uservolunteerflag == 2) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/subpages/heart/pages/volunteer/volunteer'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log('报名成功以后不进行操作')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
cancelSignupCallback(e) {
|
|
|
|
let id = this.data.id
|
|
|
|
let reason = e.detail.data
|
|
|
|
api.cancelsignup(id, reason).then(res => {
|
|
|
|
wx.showToast({
|
|
|
|
title: '取消报名成功',
|
|
|
|
icon: 'none',
|
|
|
|
duration: 2000
|
|
|
|
})
|
|
|
|
this.getDetail()
|
|
|
|
setTimeout(() => {
|
|
|
|
wx.navigateBack({
|
|
|
|
delta: 1
|
|
|
|
})
|
|
|
|
}, 2000)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
preViewImage(e) {
|
|
|
|
wx.previewImage({
|
|
|
|
urls: e.currentTarget.dataset.list,
|
|
|
|
current: e.currentTarget.dataset.src
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|