|
|
|
@ -55,7 +55,7 @@ |
|
|
|
|
|
|
|
|
|
<view class="btns"> |
|
|
|
|
<view class="btn share">分享</view> |
|
|
|
|
<view :class="['btn sign', {disabled: !form.signing}]" @click="presign">立刻报名</view> |
|
|
|
|
<view :class="['btn sign', {signed: form.signed, disabled: !form.signing}]" @click="presign">{{ form.signed ? '取消报名' : '立刻报名' }}</view> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
<uni-popup ref="popup" type="dialog"> |
|
|
|
@ -65,7 +65,7 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { getCompetition, individualEventRegistration, queryRegistrationByCondition } from '@/apis/modules/activity.js' |
|
|
|
|
import { getCompetition, individualEventRegistration, queryRegistrationByCondition, cancelRegistration } from '@/apis/modules/activity.js' |
|
|
|
|
import Util from '@/libs/util' |
|
|
|
|
import Common from '@/config/common' |
|
|
|
|
export default { |
|
|
|
@ -96,6 +96,7 @@ |
|
|
|
|
timer: null, |
|
|
|
|
now: '', |
|
|
|
|
invitationCode: '', |
|
|
|
|
submiting: false, |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 下拉刷新 |
|
|
|
@ -110,7 +111,7 @@ |
|
|
|
|
if (this.reachBottom >= 0) { |
|
|
|
|
this.reachBottom = 1 |
|
|
|
|
this.status = 'loading' |
|
|
|
|
this.getList() |
|
|
|
|
this.getRegList() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onShow() { |
|
|
|
@ -131,6 +132,7 @@ |
|
|
|
|
|
|
|
|
|
this.now = await Util.getNow() |
|
|
|
|
this.statusInterval() |
|
|
|
|
clearInterval(this.timer) |
|
|
|
|
this.timer = setInterval(() => { |
|
|
|
|
this.now = new Date(this.now.setSeconds(this.now.getSeconds() + 1)) |
|
|
|
|
this.statusInterval() |
|
|
|
@ -149,15 +151,18 @@ |
|
|
|
|
// 定时处理时间及状态 |
|
|
|
|
handleStatus () { |
|
|
|
|
const data = this.form |
|
|
|
|
let signing = 0 |
|
|
|
|
let signing = 0 // 当前处于报名时间内 |
|
|
|
|
let signed = 0 // 是否已经报了名 |
|
|
|
|
const signUpStartTime = new Date(data.signUpStartTime) // 报名开始时间 |
|
|
|
|
const signUpEndTime = new Date(data.signUpEndTime) // 报名结束时间 |
|
|
|
|
const { now } = this |
|
|
|
|
// 报名中(whetherToSignUp 是否已报名 1已报名,0未报名) |
|
|
|
|
if (!data.competitionRegistration && now > signUpStartTime && now < signUpEndTime) { |
|
|
|
|
if (now > signUpStartTime && now < signUpEndTime) { |
|
|
|
|
signing = 1 |
|
|
|
|
if (data.competitionRegistration) signed = 1 |
|
|
|
|
} |
|
|
|
|
this.$set(this.form, 'signing', signing) |
|
|
|
|
this.$set(this.form, 'signed', signed) |
|
|
|
|
}, |
|
|
|
|
// 已报名人员 |
|
|
|
|
getRegList() { |
|
|
|
@ -191,11 +196,35 @@ |
|
|
|
|
}, |
|
|
|
|
// 报名前的判断 |
|
|
|
|
async presign() { |
|
|
|
|
if (this.form.competitionRegistration) return this.$util.errMsg('你已经报名过该活动!') |
|
|
|
|
if (!this.form.signing) return this.$util.errMsg('现在不在报名时间!') |
|
|
|
|
if (this.form.competitionRegistration) { // 取消报名 |
|
|
|
|
this.cancelSign() |
|
|
|
|
} else { // 报名 |
|
|
|
|
this.invitationCode = '' |
|
|
|
|
// 需要输入验证码就弹出邀请码弹框,否则直接报名 |
|
|
|
|
this.form.isNeedCode ? this.$refs.popup.open() : this.sign() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 取消报名 |
|
|
|
|
cancelSign() { |
|
|
|
|
if (this.submiting) return false |
|
|
|
|
this.submiting = true |
|
|
|
|
const that = this |
|
|
|
|
uni.showModal({ |
|
|
|
|
title: '提示', |
|
|
|
|
content: '确定要取消报名吗?', |
|
|
|
|
success(res) { |
|
|
|
|
if (res.confirm) { |
|
|
|
|
cancelRegistration(that.form.id).then(res => { |
|
|
|
|
that.$util.sucMsg('取消报名成功') |
|
|
|
|
that.getInfo() |
|
|
|
|
that.submiting = false |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
} else { |
|
|
|
|
that.submiting = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 报名 |
|
|
|
|
async sign() { |
|
|
|
@ -312,6 +341,9 @@ |
|
|
|
|
background-color: $uni-primary; |
|
|
|
|
border-top-right-radius: 40rpx; |
|
|
|
|
border-bottom-right-radius: 40rpx; |
|
|
|
|
&.signed { |
|
|
|
|
background-color: #ff7b32; |
|
|
|
|
} |
|
|
|
|
&.disabled { |
|
|
|
|
background-color: #d7d7d7; |
|
|
|
|
} |
|
|
|
|