123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <template>
- <view class="container">
- <image class="banner" :src="info.image" mode="scaleToFill"></image>
- <uni-section :title="info.topic" titleFontSize="18" type="line">
- <uni-list>
- <uni-list-item :show-extra-icon="true" :extra-icon="extraIcon[0]" title="报名时间" :rightText="`${info.regStartTime}至${info.regEndTime}`"></uni-list-item>
- <uni-list-item :show-extra-icon="true" :extra-icon="extraIcon[0]" title="活动时间" :rightText="`${info.startTime}至${info.endTime}`"></uni-list-item>
- <uni-list-item v-if="info.regMaxCount < 999" :show-extra-icon="true" :extra-icon="extraIcon[1]" title="招募人数" :rightText="info.regMaxCount || '不限' + '人'"></uni-list-item>
- <uni-list-item :show-extra-icon="true" :extra-icon="extraIcon[1]" title="负责人" :rightText="info.sponsorName"></uni-list-item>
- <uni-list-item :show-extra-icon="true" :extra-icon="extraIcon[2]" title="联系电话" :rightText="info.sponsorPhone"></uni-list-item>
- </uni-list>
- </uni-section>
- <uni-section title="活动详情" titleFontSize="18" type="line">
- <rich-text image-menu-prevent="true" :nodes="info.description" class="content"></rich-text>
- </uni-section>
- <uni-goods-nav class="goodNav" :fill="true" :options="options" :buttonGroup="buttonGroup" @buttonClick="buttonClick" />
- </view>
- </template>
- <script>
- import request from '../../api/activity.js';
- import { BASE_URL } from '../../env.js';
- export default {
- onLoad: function (option) {
- this.activityId = option.activityId;
- },
- data() {
- return {
- activityId: '',
- info: null,
- options: [],
- extraIcon: [
- {
- color: '#c60814',
- size: '22',
- type: 'calendar'
- },
- {
- color: '#c60814',
- size: '22',
- type: 'person-filled'
- },
- {
- color: '#c60814',
- size: '22',
- type: 'phone'
- }
- ],
- buttonGroup: [
- {
- text: '报名活动',
- backgroundColor: '#ff0000',
- color: '#fff'
- },
- {
- text: '获取积分',
- backgroundColor: '#ffa200',
- color: '#fff'
- }
- ],
- statusInfo: true,
- pointNeedPoint: false
- }
- },
- mounted() {
- this.query();
- },
- methods: {
- async query() {
- const res = await request.getdetails({ activityId: this.activityId });
- const statusInfo = await request.getstatus({ activityId: this.activityId });
- res.data.image = BASE_URL.fileUrl + res.data.image;
- this.info = res.data;
- this.statusInfo = statusInfo.status;
- this.pointNeedPoint = false;
- const newDateTime = new Date().getTime();
- const endTime = Date.parse(res.data.regEndTime);
- const startTime = Date.parse(res.data.regStartTime);
- const startActiveTime = Date.parse(res.data.startTime);
- const endActiveTime = Date.parse(res.data.endTime);
- // 报名按钮状态设置
- if (!statusInfo.status && newDateTime > startTime && newDateTime < endTime) {
- this.buttonGroup[0].backgroundColor = '#ff0000';
- this.buttonGroup[0].text = '报名活动';
- delete this.buttonGroup[0].status
- delete this.buttonGroup[0].disable
- this.buttonGroup[1].disable = true;
- this.buttonGroup[1].backgroundColor = '#999';
- }
- if (statusInfo.status && newDateTime > startTime && newDateTime < endTime) {
- this.buttonGroup[0].backgroundColor = '#ffa200';
- this.buttonGroup[0].text = '取消报名';
- this.buttonGroup[0].status = true;
- delete this.buttonGroup[1].disable;
- this.buttonGroup[1].backgroundColor = '#ffa200';
- }
- if (newDateTime < startTime) {
- this.buttonGroup[0].backgroundColor = '#999';
- this.buttonGroup[0].text = '报名未开始';
- this.buttonGroup[0].disable = true;
- }
- if (newDateTime > endTime) {
- this.buttonGroup[0].backgroundColor = '#999';
- this.buttonGroup[0].text = '报名已结束';
- this.buttonGroup[0].disable = true;
- }
- // 活动状态及积分获取按钮状态
- if (res.data.status == 3) {
- this.buttonGroup[1].text = '活动已结束';
- this.buttonGroup[1].backgroundColor = '#999';
- this.buttonGroup[1].disable = true;
- this.buttonGroup[0].backgroundColor = '#999';
- this.buttonGroup[0].text = '报名已结束';
- this.buttonGroup[0].disable = true;
- }
- if(res.data.status == 0) {
- if(newDateTime < startActiveTime){
- this.buttonGroup[1].text = '活动未开始';
- this.buttonGroup[1].backgroundColor = '#999';
- this.buttonGroup[1].disable = true;
- }
- // if(newDateTime > endActiveTime){
- // this.buttonGroup[1].text = '活动已结束';
- // this.buttonGroup[1].backgroundColor = '#999';
- // this.buttonGroup[1].disable = true;
- // }
- if(statusInfo.status && newDateTime > startActiveTime){
- if(res.data.pointHowTo == '1'){
- this.buttonGroup[1].text = '获取积分';
- this.pointNeedPoint = true;
- }else{
- this.buttonGroup[1].text = '签到';
- }
-
- this.buttonGroup[1].backgroundColor = '#ffa200';
- delete this.buttonGroup[1].disable;
- }
- if (!statusInfo.status && newDateTime < endActiveTime && newDateTime > startActiveTime){
- this.buttonGroup[1].text = '活动进行中';
- this.buttonGroup[1].backgroundColor = '#999';
- this.buttonGroup[1].disable = true;
- }
- }
- },
- buttonClick(e) {
- if (e.index == 0){
- if (e.content.disable) return;
- if (e.content.status) {
- this.offReport();
- return;
- };
- this.report();
- } else {
- if (e.content.disable) return;
-
- console.log(e.content)
- if(this.pointNeedPoint)
- this.submitPhoto();
- else
- this.submitSignIn();
- }
- },
- async report() {
- const res = await request.report({ activityId: this.activityId });
- if (res.code == 200) {
- wx.showToast({
- title: '报名成功'
- })
- this.query();
- }
- },
- async offReport() {
- const res = await request.offReport({ activityId: this.activityId });
- if (res.code == 200) {
- wx.showToast({
- title: '取消报名成功'
- })
- this.query();
- }
- },
- async submitPhoto() {
- uni.navigateTo({ url: `/pages/activity/uploadFiel?activityId=${this.activityId}` })
- },
- async submitSignIn(){
- const res = await request.signIn({ activityId: this.activityId });
- if (res.code == 200) {
- wx.showToast({
- title: '签到成功'
- })
- this.query();
- }
- }
- }
- }
- </script>
- <style>
- .container {
- position: relative;
- padding-bottom: 12vw;
- background-color: #fff;
- }
- .banner {
- width: 100%;
- height: 50vw;
- }
- .content {
- display: block;
- width: 90%;
- margin: 10px auto;
- }
- .goodNav {
- width: 100%;
- height: 12vw;
- position: fixed;
- left: 0;
- bottom: 0;
- }
- </style>
|