|
|
|
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,
|
|
|
|
timeJudge: false,//根据当前时间比较活动结束时间,判断活动是否已经结束,用以判断显示订单多多里面的志愿者
|
|
|
|
defaultGridId:"",//默认网格
|
|
|
|
actType: "",
|
|
|
|
pageIndex: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
curSize: 0, // 当前页码获取的活动条数
|
|
|
|
isPreviewImage: false //是否从图片预览返回
|
|
|
|
},
|
|
|
|
onLoad: function (options) {
|
|
|
|
console.log("当前时间" + getTimestamp())
|
|
|
|
this.setData({
|
|
|
|
id: options.id,
|
|
|
|
actCurrentState: options.actcurrentstate,
|
|
|
|
signupFlag: options.signupflag,
|
|
|
|
selectedTab: options.selectedTab,
|
|
|
|
actType: options.selectedTab==undefined?'':options.selectedTab=='tab0'?'0':options.selectedTab=='tab2'?'1':''
|
|
|
|
})
|
|
|
|
// this.getDetail();//活动详情
|
|
|
|
// this.clockList();//打卡列表
|
|
|
|
// if (this.data.actCurrentState == 2 || this.data.actCurrentState == 3 || this.data.actCurrentState == 4){
|
|
|
|
// this.clockList();//打卡列表
|
|
|
|
// }
|
|
|
|
// 获取默认网格
|
|
|
|
this.getDefaultGridInfo()
|
|
|
|
},
|
|
|
|
onReachBottom () {
|
|
|
|
if (this.data.curSize == this.data.pageSize) {
|
|
|
|
this.data.pageIndex++
|
|
|
|
this.clockList()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 获取详情信息
|
|
|
|
getDetail () {
|
|
|
|
// let id = this.data.id
|
|
|
|
const param = {
|
|
|
|
id: this.data.id,
|
|
|
|
actType: this.data.actType
|
|
|
|
}
|
|
|
|
api.detail(param).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),
|
|
|
|
timeJudge: getTimestamp() > res.data.actEndTime.substring(0, 16) ? true : false,
|
|
|
|
preloadVisible: false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//打卡列表
|
|
|
|
clockList () {
|
|
|
|
let param = {
|
|
|
|
actId: this.data.id,
|
|
|
|
pageIndex: this.data.pageIndex,
|
|
|
|
pageSize: this.data.pageSize
|
|
|
|
}
|
|
|
|
api.clockListV2(param).then(res => {
|
|
|
|
// console.log("打卡列表:" + JSON.stringify(res.data))
|
|
|
|
if (res.code === 0 && res.msg === "success") {
|
|
|
|
this.setData({
|
|
|
|
clockNum: res.data.clockNum,
|
|
|
|
clocks: this.data.clocks.concat(res.data.clocks),
|
|
|
|
curSize: res.data.clocks.length
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).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 () {
|
|
|
|
if (this.data.isPreviewImage) {
|
|
|
|
this.data.isPreviewImage = false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
pageIndex: 1,
|
|
|
|
clocks: []
|
|
|
|
})
|
|
|
|
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(() => {
|
|
|
|
wx.showToast({
|
|
|
|
title: "取消报名成功",
|
|
|
|
icon: "none",
|
|
|
|
duration: 2000
|
|
|
|
})
|
|
|
|
this.getDetail()
|
|
|
|
setTimeout(() => {
|
|
|
|
wx.navigateBack({
|
|
|
|
delta: 1
|
|
|
|
})
|
|
|
|
}, 2000)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
preViewImage (e) {
|
|
|
|
this.setData({
|
|
|
|
isPreviewImage: true
|
|
|
|
})
|
|
|
|
wx.previewImage({
|
|
|
|
urls: e.currentTarget.dataset.list,
|
|
|
|
current: e.currentTarget.dataset.src
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 获取默认网格
|
|
|
|
getDefaultGridInfo (){
|
|
|
|
let that = this
|
|
|
|
api.getDefaultGridInfo().then(res => {
|
|
|
|
if (res.code === 0 && res.msg === "success") {
|
|
|
|
that.setData({
|
|
|
|
defaultGridId:res.data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
return {
|
|
|
|
title: "活动详情",
|
|
|
|
path: `/pages/indexNew/indexNew?shareType=heartDetail&id=${this.data.id}&defaultGridId=${this.data.defaultGridId}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|