幼教产品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.

272 lines
6.2 KiB

11 months ago
<template>
<view class="page">
<ul class="tab-wrap">
<scroll-view scroll-x :scroll-left="scrollLeft" class="tab tab-scroll">
10 months ago
<li v-for="(tab, i) in tabs" :key="i" :class="{active: curTab === tab.id}" @click="tabChange(tab.id)">{{ tab.name }}</li>
11 months ago
</scroll-view>
</ul>
10 months ago
<view v-if="list.length && curTab === 1" class="list">
11 months ago
<view v-for="(item, i) in list" :key="i" class="item">
<view class="texts">
11 months ago
<view class="name">{{ item.competitionName }}</view>
10 months ago
<view class="meta">{{ item.status === 1 ? '未生效 |' : '' }} 有效期 {{ item.playEndTime.substr(0, 16) }}</view>
11 months ago
</view>
10 months ago
<view :class="['use', {ing: item.status}]" @click.stop="use(item)">{{ item.status === 1 ? '电子入场券' : '使用' }}</view>
11 months ago
</view>
</view>
10 months ago
<empty v-else text="暂无数据"></empty>
11 months ago
<uni-popup ref="popup" type="dialog">
<view class="sign-popup">
<uni-icons class="close" type="closeempty" size="16" color="#4876f9" @click="closePopup"></uni-icons>
<view class="activity-name">{{ curRow.competitionName }}</view>
<view class="title">签到二维码</view>
<image class="qrcode" src="http://124.71.79.122/images/miniProgram/qrcode.png"></image>
<view v-if="curRow.playStartTime" class="date">有效期限{{ curRow.playStartTime.substr(0, 16) + ' ~ ' + curRow.playEndTime.substr(0, 16) }}</view>
<view class="userName">{{ info.hrUserInfo.userName }}</view>
<view class="phone">{{ info.hrUserInfo.phone }}</view>
<view v-if="info.organizationInfoList && info.organizationInfoList.length" class="org-name">{{ info.organizationInfoList[0].organizationName }}</view>
</view>
</uni-popup>
11 months ago
</view>
</template>
<script>
import { postLoginActivity } from '@/apis/modules/activity.js'
11 months ago
import { viewUserDetails } from '@/apis/modules/user.js'
11 months ago
import Util from '@/libs/util'
export default {
data() {
return {
teamId: uni.getStorageSync('teamId') || '',
11 months ago
openId: uni.getStorageSync('openId'),
11 months ago
reachBottom: 0, // 是否是上拉加载。0->否,1->是,-1->加载完所有数据
status: 'more', // 上拉加载状态 more|loading|noMore
keyword: '',
list: [],
page: 1,
pageSize: 5,
total: 0,
curTab: 1,
curItem: null,
submiting: false,
tabs: [
{
id: 1,
name: '活动券票'
},
{
id: 2,
name: '品牌福利'
},
{
id: 3,
name: '会员福利'
},
],
scrollLeft: 0,
timer: null,
now: '',
11 months ago
curRow: {},
info: {},
11 months ago
}
},
// 下拉刷新
onPullDownRefresh() {
this.initList()
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1500)
},
// 上拉加载
onReachBottom() {
if (this.reachBottom >= 0) {
this.reachBottom = 1
this.status = 'loading'
this.getList()
}
},
onShow() {
this.keyword = ''
this.initList()
11 months ago
this.getInfo()
11 months ago
},
methods: {
getList() {
postLoginActivity({
pageNum: this.page,
pageSize: this.pageSize,
listType: 1,
keyWord: this.keyword,
platformSource: ''
}).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
this.now = await Util.getNow()
this.statusInterval()
uni.hideLoading()
this.timer = setInterval(() => {
this.now = new Date(this.now.setSeconds(this.now.getSeconds() + 1))
this.statusInterval()
}, 1000)
}).catch(e => {})
},
async statusInterval () {
this.list.map(item => {
if (item.signUpStartTime && item.signUpEndTime) {
this.handleStatus(item)
}
})
},
// 定时处理时间及状态
handleStatus (item) {
10 months ago
let status = 0
11 months ago
const playStartTime = new Date(item.playStartTime) // 报名开始时间
const playEndTime = new Date(item.playEndTime) // 报名结束时间
const { now } = this
10 months ago
if (now < playStartTime) { // 未生效
status = 1
} else if (now < playEndTime) { // 生效期中
status = 2
11 months ago
}
10 months ago
this.$set(item, 'status', status)
11 months ago
},
initList() {
this.page = 1
this.reachBottom = 0
this.getList()
},
11 months ago
// 获取组织名字
async getInfo() {
const { result } = await viewUserDetails({
openId: this.openId
})
this.info = result
11 months ago
},
// tab切换
10 months ago
tabChange(id) {
this.curTab = id
11 months ago
this.initList()
},
11 months ago
// 展示电子券
use(row) {
10 months ago
if (row.status) {
11 months ago
this.curRow = row
this.$refs.popup.open()
}
},
// 关闭弹框
closePopup() {
this.$refs.popup.close()
},
11 months ago
}
}
</script>
<style scoped lang="scss">
.page {
padding: 20rpx;
}
.tab-wrap {
display: flex;
.tab-scroll {
width: calc(100% - 100rpx);
white-space: nowrap;
li {
display: inline-block;
}
}
}
.list {
.item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx;
margin-bottom: 28rpx;
background-color: #fff;
overflow: hidden;
border-radius: 8px;
}
.name {
font-size: 30rpx;
font-weight: 600;
color: #333;
}
.meta {
11 months ago
margin-top: 20rpx;
11 months ago
font-size: 24rpx;
color: #999;
}
.use {
padding: 8rpx 28rpx;
11 months ago
margin-left: 20rpx;
11 months ago
font-size: 28rpx;
color: #fff;
11 months ago
white-space: nowrap;
11 months ago
background-color: #afafaf;
border-radius: 4px;
}
.ing {
font-size: 28rpx;
background-color: $uni-primary;
}
}
11 months ago
.sign-popup {
position: relative;
width: 80vw;
10 months ago
padding: 40rpx 0;
11 months ago
text-align: center;
box-sizing: border-box;
background-color: #fff;
border-radius: 8px;
.close {
position: absolute;
top: 20rpx;
right: 20rpx;
}
.activity-name {
11 months ago
padding: 0 10rpx;
11 months ago
font-size: 36rpx;
color: $uni-primary;
}
.title {
padding: 20rpx 0;
11 months ago
margin: 40rpx 0 20rpx;
11 months ago
font-size: 32rpx;
color: #fff;
background-color: $uni-primary;
}
.qrcode {
width: 200rpx;
height: 200rpx;
}
.date {
margin: 20rpx;
font-size: 24rpx;
color: #8c8c8c;
}
.userName {
font-size: 30rpx;
color: #333;
}
.phone {
margin: 20rpx;
font-size: 24rpx;
color: #6f6f6f;
}
.org-name {
font-size: 24rpx;
color: #333;
}
}
11 months ago
</style>