锦水居民端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

405 lines
13 KiB

const api = require("../../../../utils/api")
5 years ago
import {
getTimestamp
} from "../../../../utils/common"
5 years ago
Page({
data: {
detail: {},
actCurrentState: 0, //活动当前状态(0-报名中,1-已报满,2-未开始,3-进行中,4-已结束)
actStartTime: "",
actEndTime: "",
signupEndTime: "",
5 years ago
signupFlag: 0, //用户报名状态(0-未报名,1已报名)
clocks: [], //打卡列表
clockNum: 0, //打卡人次
actContent: "", //富文本
actNewsContent: "",//新闻稿
dialogTitle: "",
dialogContent: "",
dialogConfirmText: "",
dialogCancelText: "",
uservolunteerflag: "",
5 years ago
cancelSignupVisible: false,
cancelSignupTipValue: "",
5 years ago
cancelSignupTipVisible: false,
selectedTab: "",//用来判断详情是否显示志愿者打卡
5 years ago
preloadVisible: true,
5 years ago
timeJudge: false,//根据当前时间比较活动结束时间,判断活动是否已经结束,用以判断显示订单多多里面的志愿者
defaultGridId:"",//默认网格
4 years ago
actType: "",
pageIndex: 1,
pageSize: 10,
curSize: 0, // 当前页码获取的活动条数
isPreviewImage: false, //是否从图片预览返回
showPeriodDialog: false, // 是否显示选择时间段对话框
dialogTips: '',
sponsor: '', // 主办方
periodList: [], // 时间段
actPeriodId: [], //
cancelPeriodList: [], // 取消报名的时间段
textareaValue: '', // 取消原因
5 years ago
},
5 years ago
onLoad: function (options) {
console.log("当前时间" + getTimestamp())
5 years ago
this.setData({
id: options.id,
actCurrentState: options.actcurrentstate,
5 years ago
signupFlag: options.signupflag,
5 years ago
selectedTab: options.selectedTab,
actType: options.selectedTab==undefined?'':options.selectedTab=='tab0'?'0':options.selectedTab=='tab2'?'1':''
5 years ago
})
// this.getDetail();//活动详情
// this.clockList();//打卡列表
// if (this.data.actCurrentState == 2 || this.data.actCurrentState == 3 || this.data.actCurrentState == 4){
// this.clockList();//打卡列表
// }
5 years ago
// 获取默认网格
this.getDefaultGridInfo()
5 years ago
},
4 years ago
onReachBottom () {
if (this.data.curSize == this.data.pageSize) {
this.data.pageIndex++
this.clockList()
}
},
5 years ago
// 获取详情信息
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") {
5 years ago
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\""),
5 years ago
actStartTime: res.data.actStartTime.substring(0, 16),
actEndTime: res.data.actEndTime.substring(0, 16),
signupEndTime: res.data.signupEndTime.substring(0, 16),
5 years ago
timeJudge: getTimestamp() > res.data.actEndTime.substring(0, 16) ? true : false,
preloadVisible: false,
sponsor: res.data.sponsor
5 years ago
})
}
}).catch(err => {
console.log(err)
})
},
//打卡列表
clockList () {
4 years ago
let param = {
actId: this.data.id,
pageIndex: this.data.pageIndex,
pageSize: this.data.pageSize
}
api.clockListV2(param).then(res => {
5 years ago
// console.log("打卡列表:" + JSON.stringify(res.data))
if (res.code === 0 && res.msg === "success") {
5 years ago
this.setData({
clockNum: res.data.clockNum,
4 years ago
clocks: this.data.clocks.concat(res.data.clocks),
curSize: res.data.clocks.length
5 years ago
})
}
}).catch(err => {
console.log(err)
})
},
goClockIn (e) { //前往打卡页面
5 years ago
const id = e.currentTarget.dataset.id
5 years ago
const currentUserStatus = e.currentTarget.dataset.currentuserstatus;//4 我要打卡 5 更新打卡
5 years ago
wx.navigateTo({
5 years ago
url: `../clockIn/clockIn?id=${id}&currentUserStatus=${currentUserStatus}`
5 years ago
})
},
goVolunteer (e) {
//我要报名 用户认证志愿者标识(0-未认证,1-已认证)
5 years ago
// 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.getActPeriods()
5 years ago
this.setData({
// dialogVisible: this.data.periodList.length == 0 ? true : false,
showPeriodDialog: !this.data.showPeriodDialog,
dialogTips: `报名时间截止之前可取消,缺席活动扣除${this.data.detail.punishmentPoints}积分,是否确定报名`,
dialogTitle: "报名提醒",
dialogContent: ["报名时间截止之前可取消", `缺席活动扣除${this.data.detail.punishmentPoints}积分,是否确定报名`],
dialogConfirmText: "是",
dialogCancelText: "否"
5 years ago
})
} else if (uservolunteerflag == 1) {
// 获取活动时间段
this.getActPeriods()
5 years ago
this.setData({
// dialogVisible: this.data.periodList.length == 0 ? true : false,
showPeriodDialog: !this.data.showPeriodDialog,
dialogTips: `报名时间截止之前可取消,缺席活动扣除${this.data.detail.punishmentPoints}积分,是否确定报名`,
dialogTitle: "报名提醒",
dialogContent: ["报名时间截止之前可取消", `缺席活动扣除${this.data.detail.punishmentPoints}积分,是否确定报名`],
dialogConfirmText: "是",
dialogCancelText: "否"
5 years ago
})
} else if (uservolunteerflag == 2) {
this.setData({
dialogVisible: !this.data.dialogVisible,
dialogTitle: "志愿者认证",
dialogContent: ["是否认证志愿者,完成报名"],
dialogConfirmText: "是",
dialogCancelText: "否"
5 years ago
})
} else if (uservolunteerflag == 3) {
this.setData({
dialogVisible: !this.data.dialogVisible,
dialogTitle: "已被拉入黑名单",
dialogContent: ["您已被拉入黑名单,不能报名"],
dialogConfirmText: "确定",
dialogCancelText: ""
5 years ago
})
}
},
//已报满
signUpFull () {
5 years ago
this.setData({
dialogVisible: !this.data.dialogVisible,
dialogTitle: "已报满",
dialogContent: ["活动名额报名已满", "快去“招募令”中参加其他活动吧"],
dialogConfirmText: "确定",
dialogCancelText: ""
5 years ago
})
},
// 取消报名
prompt () {
this.getSignInActPeriods()
5 years ago
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: ""
5 years ago
})
}
},
5 years ago
onShow: function () {
4 years ago
if (this.data.isPreviewImage) {
this.data.isPreviewImage = false
return
}
this.setData({
pageIndex: 1,
clocks: []
})
5 years ago
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)
5 years ago
if (this.data.uservolunteerflag.length > 0) {
if (this.data.uservolunteerflag == 0 || this.data.uservolunteerflag == 1) {
let param = {
actId: this.data.id,
actPeriodId: this.data.actPeriodId
}
api.signup(param).then(res => {
5 years ago
if (res.code == 0) {
this.setData({
dialogVisible: !this.data.dialogVisible,
dialogTitle: "报名成功",
dialogContent: ["正在审核中", "请耐心等待消息通知!"],
dialogConfirmText: "确定",
dialogCancelText: "",
uservolunteerflag: ""
5 years ago
})
this.getDetail()
} else { //点击我要报名,刚好已经报满,此时弹出已报满的提示框,点击确定后,我要报名按钮变成已报满按钮(置灰)
this.getDetail()
}
})
} else if (this.data.uservolunteerflag == 2) {
wx.navigateTo({
url: "/subpages/heart/pages/volunteer/volunteer"
5 years ago
})
}
} else {
console.log("报名成功以后不进行操作")
5 years ago
}
},
cancelSignupCallback (e) {
5 years ago
let id = this.data.id
let actPeriodId = this.data.actPeriodId
let reason = this.data.textareaValue
console.log(this.data.actPeriodId)
if (actPeriodId.length == 0) {
wx.showToast({
title: "请选择取消的时间段",
icon: "none",
duration: 2000
})
return
}
api.cancelsignup(id, reason, actPeriodId).then(() => {
5 years ago
wx.showToast({
title: "取消报名成功",
icon: "none",
5 years ago
duration: 2000
})
this.getDetail()
setTimeout(() => {
wx.navigateBack({
delta: 1
})
}, 2000)
})
},
preViewImage (e) {
4 years ago
this.setData({
isPreviewImage: true
})
5 years ago
wx.previewImage({
urls: e.currentTarget.dataset.list,
current: e.currentTarget.dataset.src
})
5 years ago
},
5 years ago
// 获取默认网格
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)
})
},
5 years ago
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
return {
title: "活动详情",
5 years ago
path: `/pages/indexNew/indexNew?shareType=heartDetail&id=${this.data.id}&defaultGridId=${this.data.defaultGridId}`
5 years ago
}
},
checkboxChange (e) {
console.log(e.detail.value)
// let actPeriodId = []
// if (e.detail.value.length > 0) {
// e.detail.value.forEach(item => {
// let ob = {
// id: item
// }
// actPeriodId.push(ob)
// })
// }
this.setData({
actPeriodId: e.detail.value
})
},
onCancelPeriod () {
this.setData({
showPeriodDialog: false,
actPeriodId: []
})
},
onConfirmPeriod () {
console.log("::::::" + this.data.uservolunteerflag.length)
if (this.data.uservolunteerflag.length > 0) {
if (this.data.uservolunteerflag == 0 || this.data.uservolunteerflag == 1) {
let param = {
actId: this.data.id,
actPeriodId: this.data.actPeriodId
}
api.signup(param).then(res => {
if (res.code == 0) {
this.setData({
showPeriodDialog: !this.data.showPeriodDialog,
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("报名成功以后不进行操作")
}
},
getActPeriods () {
this.setData({
periodList: [],
actPeriodId: [],
})
api.getActPeriods(this.data.id).then(res => {
console.log(res.data)
this.setData({
periodList: res.data
})
})
},
textareaInput (e) {
this.setData({
textareaValue: e.detail.value
})
},
closeCancelDialog () {
this.setData({
cancelPeriodList: [],
actPeriodId: [],
textareaValue: '',
cancelSignupVisible: !this.data.cancelSignupVisible,
cancelSignupTipValue: ""
})
},
getSignInActPeriods () {
this.setData({
cancelPeriodList: [],
actPeriodId: [],
})
api.getSignInActPeriods(this.data.id).then(res => {
console.log(res.data)
this.setData({
cancelPeriodList: res.data
})
}).catch(err => {})
5 years ago
}
})