锦水居民端小程序
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.

249 lines
8.3 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:"",//默认网格
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,
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
},
// 获取详情信息
getDetail () {
5 years ago
let id = this.data.id
api.detail(id).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,
5 years ago
preloadVisible: false
5 years ago
})
}
}).catch(err => {
console.log(err)
})
},
//打卡列表
clockList () {
5 years ago
let id = this.data.id
api.clockList(id).then(res => {
// console.log("打卡列表:" + JSON.stringify(res.data))
if (res.code === 0 && res.msg === "success") {
5 years ago
this.setData({
clockNum: res.data.clockNum,
clocks: res.data.clocks
})
}
}).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.setData({
dialogVisible: !this.data.dialogVisible,
dialogTitle: "报名提醒",
dialogContent: ["报名时间截止之前可取消", `缺席活动扣除${this.data.detail.punishmentPoints}积分,是否确定报名`],
dialogConfirmText: "是",
dialogCancelText: "否"
5 years ago
})
} else if (uservolunteerflag == 1) {
this.setData({
dialogVisible: !this.data.dialogVisible,
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 () {
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 () {
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 id = this.data.id
api.signup(id).then(res => {
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 reason = e.detail.data
api.cancelsignup(id, reason).then(() => {
5 years ago
wx.showToast({
title: "取消报名成功",
icon: "none",
5 years ago
duration: 2000
})
this.getDetail()
setTimeout(() => {
wx.navigateBack({
delta: 1
})
}, 2000)
})
},
preViewImage (e) {
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
}
5 years ago
}
})