幼教产品B2B生态平台小程序端
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.

384 lines
9.9 KiB

12 months ago
<template>
<view class="wrap">
<view class="banner">
<image class="pic" :src="form.coverUrl" mode="widthFix"></image>
</view>
<view class="info">
<view class="line">
<view class="label">活动名称</view>
<view class="val">{{ form.name }}</view>
</view>
<view class="line">
<view class="label">状态</view>
11 months ago
<view class="val">{{ statusList[comStatus] }}</view>
12 months ago
</view>
11 months ago
<view v-if="form.whetherToShowApplicants === '1'" class="line">
12 months ago
<view class="label">人数限制</view>
<view class="val">{{ form.quantityLimit }}</view>
</view>
<view class="line items-start">
<view class="label">举办时间</view>
11 months ago
<view class="val">{{ form.startTime + ' ~ ' + form.endTime }}</view>
12 months ago
</view>
<view class="line">
<view class="label">活动地点</view>
<view class="val">{{ form.reportingPlace }}</view>
</view>
<view class="line">
<view class="label">主办方</view>
<view class="val">{{ form.sponsor }}</view>
</view>
<view v-if="form.whetherToShowApplicants === '1'" class="line">
<view class="label">已报名人员</view>
<view class="val">({{ form.applicantNum }}/{{ form.quantityLimit }})</view>
</view>
</view>
<ul class="tab">
<li :class="{active: curTab === 0}" @click="tabChange(0)">活动详情</li>
11 months ago
<!-- <li :class="{active: curTab === 1}" @click="tabChange(1)">活动通知</li> -->
12 months ago
<li v-if="form.whetherToShowApplicants === '1'" :class="{active: curTab === 2}" @click="tabChange(2)">已报名人员({{ form.applicantNum }}/{{ form.quantityLimit }})</li>
</ul>
<view v-if="!curTab" class="detail">
<mp-html :content="form.description"/>
</view>
11 months ago
<view v-else-if="curTab === 2" class="list">
12 months ago
<view v-for="(item, i) in list" :key="i" class="item" @click="toDetail(item)">
<view class="top">
11 months ago
<image class="avatar" :src="item.userAvatars || Common.avatar"></image>
12 months ago
<view class="name">{{ item.username }}</view>
</view>
</view>
</view>
<view class="btns">
11 months ago
<button class="share" open-type="share">分享</button>
11 months ago
<view :class="['btn sign', {signed, disabled: comStatus !== 1}]" @click="presign">{{ stopSign ? '已截止报名' : comStatus === 1 ? (signed ? '取消报名' : '立刻报名') : statusList[comStatus] }}</view>
12 months ago
</view>
<uni-popup ref="popup" type="dialog">
<uni-popup-dialog mode="input" placeholder="请输入4位数邀请码" :duration="2000" :before-close="true" @close="closePopup" @confirm="codeSubmit"></uni-popup-dialog>
</uni-popup>
</view>
</template>
<script>
11 months ago
import { getCompetition, individualEventRegistration, queryRegistrationByCondition, cancelRegistration } from '@/apis/modules/activity.js'
12 months ago
import Util from '@/libs/util'
11 months ago
import Common from '@/config/common'
12 months ago
export default {
data() {
return {
11 months ago
Common,
12 months ago
id: '',
11 months ago
statusList: ['待开始', '进行中', '已截止报名', '已结束'],
11 months ago
comStatus: 0,
signed: 0,
11 months ago
stopSign: 0,
12 months ago
curTab: 0,
reachBottom: 0, // 是否是上拉加载。0->否,1->是,-1->加载完所有数据
status: 'more', // 上拉加载状态 more|loading|noMore
list: [],
page: 1,
pageSize: 5,
total: 0,
form: {
11 months ago
startTime: '',
endTime: '',
12 months ago
quantityLimit: '',
playStartTime: '',
playEndTime: '',
reportingPlace: '',
sponsor: '',
},
shopCartTotal: 0,
types: [],
mpStyle: {
p: 'font-size: 25rpx !important;font-family: Microsoft Yahei !important;font-weight: 400 !important;color: #333 !important;',
span: 'font-size: 25rpx !important;font-family: Microsoft Yahei !important;font-weight: 400 !important;color: #333 !important;'
},
timer: null,
now: '',
invitationCode: '',
11 months ago
submiting: false,
12 months ago
}
},
// 下拉刷新
onPullDownRefresh() {
this.initList()
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1500)
},
// 上拉加载
onReachBottom() {
if (this.reachBottom >= 0) {
this.reachBottom = 1
this.status = 'loading'
11 months ago
this.getRegList()
12 months ago
}
},
onShow() {
const pages = getCurrentPages()
const { options } = pages[pages.length - 1]
11 months ago
this.stopSign = 0
12 months ago
this.id = options.id
this.getInfo()
},
methods: {
// 获取详情
getInfo() {
uni.showLoading({
title: '加载中'
})
getCompetition(this.id).then(async (res) => {
const data = res.competition
11 months ago
data.startTime = data.playStartTime.substr(5, 11).split('-').join('/')
data.endTime = data.playEndTime.substr(5, 11).split('-').join('/')
12 months ago
this.form = data
this.now = await Util.getNow()
this.statusInterval()
11 months ago
clearInterval(this.timer)
12 months ago
this.timer = setInterval(() => {
this.now = new Date(this.now.setSeconds(this.now.getSeconds() + 1))
this.statusInterval()
}, 1000)
uni.hideLoading()
}).catch(e => {
uni.hideLoading()
})
},
async statusInterval () {
const data = this.form
if (data.signUpStartTime && data.signUpEndTime) {
this.handleStatus()
}
},
// 定时处理时间及状态
handleStatus () {
const data = this.form
11 months ago
let status = 0
11 months ago
let signed = 0 // 是否已经报了名
12 months ago
const signUpStartTime = new Date(data.signUpStartTime) // 报名开始时间
const signUpEndTime = new Date(data.signUpEndTime) // 报名结束时间
11 months ago
const playStartTime = new Date(data.playStartTime) // 活动结束时间
const playEndTime = new Date(data.playEndTime) // 活动结束时间
12 months ago
const { now } = this
// 报名中(whetherToSignUp 是否已报名 1已报名,0未报名)
11 months ago
if (now < signUpStartTime) {
11 months ago
// 待开始
11 months ago
status = 0
} else if (now > signUpStartTime && now < signUpEndTime) {
11 months ago
// 报名中
11 months ago
status = 1
11 months ago
if (data.competitionRegistration) signed = 1
11 months ago
} else if (now > signUpEndTime && now < playEndTime) {
11 months ago
// 已截止报名
this.stopSign = 1
11 months ago
} else if (now > playEndTime) {
11 months ago
// 已结束
status = 2
12 months ago
}
11 months ago
this.comStatus = status
this.signed = signed
12 months ago
},
// 已报名人员
getRegList() {
uni.showLoading({
title: '加载中'
})
queryRegistrationByCondition({
competitionId: this.id,
pageNum: this.page,
pageSize: this.pageSize,
11 months ago
querySource: 1,
12 months ago
}).then(async ({ data }) => {
this.list = this.reachBottom > 0 ? [...this.list, ...data.records] : data.records
this.page++ // 每次获取了数据后page+1
const noMore = this.list.length === data.total // 是否加载完所有数据
this.status = noMore ? 'noMore' : 'more' // 加载完了则设置为noMore
this.reachBottom = noMore ? -1 : 0 // 加载完了则设置为-1
uni.hideLoading()
}).catch(e => {
uni.hideLoading()
})
},
initList() {
this.page = 1
this.reachBottom = 0
this.getRegList()
},
// tab切换
tabChange(id) {
id === 2 && this.initList()
this.curTab = id
},
// 报名前的判断
async presign() {
11 months ago
if (this.comStatus !== 1) return false
11 months ago
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
}
}
})
12 months ago
},
// 报名
async sign() {
const res = await individualEventRegistration({
competitionId: this.form.id,
registrationInvitationCode: this.invitationCode
})
this.getInfo()
this.$util.sucMsg('报名成功!')
this.closePopup()
},
// 关闭邀请码弹框
closePopup() {
this.$refs.popup.close()
},
// 邀请码确定
codeSubmit(value) {
if (!value || value.length !== 4) return this.$util.errMsg('请输入4位数邀请码!')
this.invitationCode = value
this.sign()
},
}
}
</script>
<style scoped lang="scss">
.wrap {
padding-bottom: 140rpx;
}
.banner {
.pic {
width: 100%;
11 months ago
max-height: 500rpx;
12 months ago
}
}
.info {
position: relative;
padding: 20rpx;
margin: -150rpx 30rpx 0;
background-color: #fff;
border-radius: 8px;
.line {
display: flex;
align-items: center;
margin: 20rpx 0;
}
.items-start {
align-items: flex-start;
}
.label {
min-width: 180rpx;
font-size: 28rpx;
11 months ago
text-align: right;
12 months ago
}
.val {
font-size: 28rpx;
font-weight: 600;
color: #333;
}
}
.detail {
padding: 34rpx 32rpx;
margin: 20rpx;
border-radius: 20px;
background-color: #fff;
}
.list {
margin: 0 30rpx;
.item {
padding: 30rpx;
margin: 10rpx 0;
background-color: #fff;
border-radius: 8px;
}
.top {
display: flex;
align-items: center;
}
.avatar {
width: 60rpx;
height: 60rpx;
margin-right: 20rpx;
border-radius: 50%;
}
.name {
font-size: 30rpx;
font-weight: 600;
}
.meta {
margin: 10rpx 0;
font-size: 26rpx;
}
}
.btns {
position: fixed;
bottom: 0;
display: flex;
justify-content: center;
width: 100%;
padding: 20rpx 0;
background-color: #fff;
.btn {
width: 200rpx;
padding: 16rpx 0;
font-size: 28rpx;
color: #fff;
text-align: center;
}
.share {
11 months ago
width: 200rpx;
margin: 0;
font-size: 28rpx;
color: #fff;
text-align: center;
12 months ago
background-color: #75b4ff;
11 months ago
border-radius: 0;
12 months ago
border-top-left-radius: 40rpx;
border-bottom-left-radius: 40rpx;
11 months ago
border: 0;
12 months ago
}
.sign {
background-color: $uni-primary;
border-top-right-radius: 40rpx;
border-bottom-right-radius: 40rpx;
11 months ago
&.signed {
background-color: #ff7b32;
}
12 months ago
&.disabled {
background-color: #d7d7d7;
}
}
}
</style>