初步完成页面
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<view class="qr-status">
|
||||
<!-- 加载中状态 -->
|
||||
<view v-if="status === 'loading'" class="status-loading">
|
||||
<view class="status-icon">
|
||||
<view class="loading-spinner"></view>
|
||||
</view>
|
||||
<text>生成中...</text>
|
||||
</view>
|
||||
|
||||
<!-- 签到成功状态 -->
|
||||
<view v-else-if="status === 'scanned'" class="status-success">
|
||||
<view class="status-icon">
|
||||
<uni-icons type="checkmarkcircle" size="40rpx" color="#2ECC71"></uni-icons>
|
||||
</view>
|
||||
<text>签到成功!</text>
|
||||
</view>
|
||||
|
||||
<!-- 错误状态(支持自定义文案) -->
|
||||
<view v-else-if="status === 'error'" class="status-error">
|
||||
<view class="status-icon">
|
||||
<uni-icons type="closecircle" size="40rpx" color="#E74C3C"></uni-icons>
|
||||
</view>
|
||||
<text>{{ errorText || '签到失败,请重试' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { defineProps } from 'vue';
|
||||
|
||||
// 扩展Props,支持自定义错误文案
|
||||
const props = defineProps({
|
||||
status: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: ''
|
||||
},
|
||||
// 自定义错误文本(可选)
|
||||
errorText: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ''
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 保留原样式,新增加载中样式 */
|
||||
.qr-status {
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.status-loading,
|
||||
.status-waiting,
|
||||
.status-success,
|
||||
.status-error {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 16rpx;
|
||||
font-size: 29rpx;
|
||||
}
|
||||
|
||||
.status-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* 加载中样式 */
|
||||
.status-loading {
|
||||
color: #FF6B35;
|
||||
}
|
||||
.loading-spinner {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
border: 4rpx solid #E9EDF2;
|
||||
border-top-color: #FF6B35;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
.status-success {
|
||||
color: #2ECC71;
|
||||
}
|
||||
|
||||
.status-error {
|
||||
color: #E74C3C;
|
||||
}
|
||||
|
||||
|
||||
/* 旋转动画 */
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
</style>
|
||||
@@ -2,6 +2,7 @@
|
||||
<view class="tab-bar">
|
||||
<view
|
||||
v-for="(tab, index) in tabs"
|
||||
<<<<<<< HEAD
|
||||
:key="tab.path"
|
||||
:class="['tab-item', { active: currentIndex === index }]"
|
||||
hover-class="tab-item--hover"
|
||||
@@ -12,12 +13,22 @@
|
||||
mode="aspectFit"
|
||||
class="tab-icon"
|
||||
/>
|
||||
=======
|
||||
:key="index"
|
||||
:class="['tab-item', { active: currentActive === index }]"
|
||||
@click="switchTab(index)"
|
||||
>
|
||||
<!-- 导航栏图标 -->
|
||||
<image :src="currentActive === index ? tab.iconActive : tab.icon" mode="aspectFit" class="tab-icon" />
|
||||
<!-- 导航栏标签文字 -->
|
||||
>>>>>>> 8cf3c9ccee0d9274f647f0126b50dc1e79178809
|
||||
<text class="tab-label">{{ tab.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
<<<<<<< HEAD
|
||||
import { computed, ref } from 'vue'
|
||||
import {
|
||||
PAGE,
|
||||
@@ -36,9 +47,29 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const tapping = ref(false)
|
||||
=======
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
// 当前激活的导航栏索引(从外部传入)
|
||||
const props = defineProps({
|
||||
activeTab: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
|
||||
// 当前激活状态
|
||||
const currentActive = ref(props.activeTab)
|
||||
|
||||
// 监听外部传入的激活状态变化
|
||||
watch(() => props.activeTab, (newVal) => {
|
||||
currentActive.value = newVal
|
||||
})
|
||||
>>>>>>> 8cf3c9ccee0d9274f647f0126b50dc1e79178809
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
path: PAGE.INDEX,
|
||||
icon: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/home.png',
|
||||
iconActive: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/active/home.png',
|
||||
@@ -82,6 +113,58 @@ function onTabTap(index) {
|
||||
setTimeout(() => {
|
||||
tapping.value = false
|
||||
}, 350)
|
||||
=======
|
||||
icon: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/home.png',
|
||||
iconActive: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/active/home.png',
|
||||
label: '首页',
|
||||
path: '/pages/index/index'
|
||||
},
|
||||
{
|
||||
icon: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/course.png',
|
||||
iconActive: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/active/course.png',
|
||||
label: '课程',
|
||||
path: '/pages/groupCourse/list'
|
||||
},
|
||||
{
|
||||
icon: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/train.png',
|
||||
iconActive: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/active/train.png',
|
||||
label: '训练',
|
||||
path: '/pages/train/index'
|
||||
},
|
||||
{
|
||||
icon: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/discover.png',
|
||||
iconActive: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/active/discover.png',
|
||||
label: '发现',
|
||||
path: '/pages/discover/index'
|
||||
},
|
||||
{
|
||||
icon: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/profile.png',
|
||||
iconActive: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/tabBar/active/profile.png',
|
||||
label: '我的',
|
||||
path: '/pages/profile/index'
|
||||
}
|
||||
]
|
||||
|
||||
// 切换标签页
|
||||
const switchTab = (index) => {
|
||||
currentActive.value = index
|
||||
const tab = tabs[index]
|
||||
|
||||
// 获取当前页面路径
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
const currentPath = '/' + currentPage.route
|
||||
|
||||
// 如果点击的是当前页面,不跳转
|
||||
if (currentPath === tab.path) {
|
||||
return
|
||||
}
|
||||
|
||||
// 跳转对应页面
|
||||
uni.redirectTo({
|
||||
url: tab.path
|
||||
})
|
||||
>>>>>>> 8cf3c9ccee0d9274f647f0126b50dc1e79178809
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -100,7 +183,11 @@ function onTabTap(index) {
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.06);
|
||||
border-radius: 32rpx 32rpx 0 0;
|
||||
<<<<<<< HEAD
|
||||
z-index: 999;
|
||||
=======
|
||||
z-index: 100;
|
||||
>>>>>>> 8cf3c9ccee0d9274f647f0126b50dc1e79178809
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
|
||||
@@ -0,0 +1,487 @@
|
||||
<template>
|
||||
<!-- 团课卡片容器 -->
|
||||
<view class="course-card" @click="goDetail">
|
||||
<!-- 卡片顶部图片区域 -->
|
||||
<view class="card-top">
|
||||
<!-- 图片骨架屏 -->
|
||||
<view v-if="!imageLoaded" class="skeleton skeleton-image"></view>
|
||||
<!-- 课程封面图片 -->
|
||||
<image
|
||||
:src="course.coverImage"
|
||||
mode="aspectFill"
|
||||
class="cover-image"
|
||||
:class="{ hidden: !imageLoaded }"
|
||||
@load="imageLoaded = true"
|
||||
@error="imageLoaded = true"
|
||||
/>
|
||||
<!-- 课程状态标签 -->
|
||||
<view :class="['status-tag', statusClass]">
|
||||
{{ statusText }}
|
||||
</view>
|
||||
<!-- 剩余名额标签 -->
|
||||
<view class="spots-tag" v-if="course.currentMembers < course.maxMembers">
|
||||
<span class="iconfont_courseCard icon-renwu-ren"></span>
|
||||
<text>{{ course.maxMembers - course.currentMembers }}个名额</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 卡片内容区域 -->
|
||||
<view class="card-content">
|
||||
<!-- 课程名称 -->
|
||||
<view class="course-name-wrapper">
|
||||
<text class="course-name">{{ course.courseName }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 课程信息 -->
|
||||
<view class="course-info">
|
||||
<!-- 上课时间 -->
|
||||
<view class="info-item">
|
||||
<span class="iconfont_courseCard icon-shijian "></span>
|
||||
<text class="info-text">{{ formatTime(course.startTime) }}</text>
|
||||
</view>
|
||||
<!-- 上课地点 -->
|
||||
<view class="info-item">
|
||||
<span class="iconfont_courseCard icon-didian"></span>
|
||||
<text class="info-text">{{ course.location }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 课程时长 -->
|
||||
<view class="course-duration">
|
||||
<uni-icons type="time" size="14" color="#8A99B4" />
|
||||
<text>{{ formatDuration(course.startTime, course.endTime) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 卡片底部操作区域 -->
|
||||
<view class="card-footer">
|
||||
<!-- 价格信息 -->
|
||||
<view class="price-info">
|
||||
<!-- 免费课程 -->
|
||||
<view v-if="course.storedValueAmount === 0 && course.pointCardAmount === 0" class="price-free">
|
||||
<text class="free-text">免费</text>
|
||||
</view>
|
||||
<!-- 支持多种支付方式 -->
|
||||
<view v-else-if="course.storedValueAmount > 0 && course.pointCardAmount > 0" class="price-multi">
|
||||
<view class="price-item stored-value">
|
||||
<text class="currency">¥</text>
|
||||
<text class="amount">{{ course.storedValueAmount }}</text>
|
||||
<text class="label">储值卡</text>
|
||||
</view>
|
||||
<view class="price-divider"></view>
|
||||
<view class="price-item point-card">
|
||||
<uni-icons type="shop" size="14" color="#FF6B35" />
|
||||
<text class="amount">{{ course.pointCardAmount }}次</text>
|
||||
<text class="label">次卡</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 仅储值卡支付 -->
|
||||
<view v-else-if="course.storedValueAmount > 0" class="price-single">
|
||||
<text class="price">
|
||||
<text class="currency">¥</text>{{ course.storedValueAmount }}
|
||||
</text>
|
||||
<text class="pay-label">储值卡</text>
|
||||
</view>
|
||||
<!-- 仅次卡支付 -->
|
||||
<view v-else-if="course.pointCardAmount > 0" class="price-single">
|
||||
<text class="price points">
|
||||
<uni-icons type="shop" size="14" color="#FF6B35" />
|
||||
<text>{{ course.pointCardAmount }}次</text>
|
||||
</text>
|
||||
<text class="pay-label">次卡</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 预约按钮 -->
|
||||
<view :class="['booking-btn', { disabled: !canBook }]" @click.stop="handleBooking">
|
||||
<text>{{ canBook ? '立即预约' : (course.currentMembers >= course.maxMembers ? '已满员' : '已结束') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
|
||||
// 图片加载状态
|
||||
const imageLoaded = ref(false)
|
||||
|
||||
const props = defineProps({
|
||||
course: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['booking', 'detail'])
|
||||
|
||||
const statusText = computed(() => {
|
||||
const status = props.course.status
|
||||
if (status === '0') return '进行中'
|
||||
if (status === '1') return '已取消'
|
||||
if (status === '2') return '已结束'
|
||||
return '未知'
|
||||
})
|
||||
|
||||
const statusClass = computed(() => {
|
||||
const status = props.course.status
|
||||
if (status === '0') return 'active'
|
||||
if (status === '1') return 'canceled'
|
||||
if (status === '2') return 'ended'
|
||||
return ''
|
||||
})
|
||||
|
||||
const canBook = computed(() => {
|
||||
const status = props.course.status
|
||||
const isFull = props.course.currentMembers >= props.course.maxMembers
|
||||
return status === '0' && !isFull
|
||||
})
|
||||
|
||||
const formatTime = (dateStr) => {
|
||||
if (!dateStr) return ''
|
||||
const date = new Date(dateStr)
|
||||
const month = date.getMonth() + 1
|
||||
const day = date.getDate()
|
||||
const weekDays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
|
||||
const weekDay = weekDays[date.getDay()]
|
||||
const hours = date.getHours().toString().padStart(2, '0')
|
||||
const minutes = date.getMinutes().toString().padStart(2, '0')
|
||||
return `${month}月${day}日 ${weekDay} ${hours}:${minutes}`
|
||||
}
|
||||
|
||||
const formatDuration = (startStr, endStr) => {
|
||||
if (!startStr || !endStr) return ''
|
||||
const start = new Date(startStr)
|
||||
const end = new Date(endStr)
|
||||
const minutes = Math.floor((end.getTime() - start.getTime()) / 60000)
|
||||
return `${minutes}分钟`
|
||||
}
|
||||
|
||||
const goDetail = () => {
|
||||
emit('detail', props.course.id)
|
||||
}
|
||||
|
||||
const handleBooking = () => {
|
||||
if (canBook.value) {
|
||||
emit('booking', props.course)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@import "@/common/style/iconfont_courseCard.css";
|
||||
|
||||
/* 团课卡片容器 */
|
||||
.course-card {
|
||||
background: #ffffff;
|
||||
border-radius: 28rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.04);
|
||||
margin-bottom: 28rpx;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
}
|
||||
|
||||
/* 卡片顶部图片区域 */
|
||||
.card-top {
|
||||
position: relative;
|
||||
height: 320rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 课程封面图片 */
|
||||
.cover-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transition: opacity 0.3s ease;
|
||||
|
||||
&.hidden {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
/* 骨架屏基础样式 */
|
||||
.skeleton {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: linear-gradient(90deg, #f6f7f8 0%, #e0e0e0 20%, #f6f7f8 40%, #f6f7f8 100%);
|
||||
background-size: 100% 100%;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
border-radius: inherit;
|
||||
}
|
||||
|
||||
/* 骨架屏动画 */
|
||||
@keyframes skeleton-loading {
|
||||
0% {
|
||||
background-position: 100% 0;
|
||||
}
|
||||
100% {
|
||||
background-position: -100% 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* 图片骨架屏 */
|
||||
.skeleton-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* 课程状态标签 */
|
||||
.status-tag {
|
||||
position: absolute;
|
||||
top: 24rpx;
|
||||
left: 24rpx;
|
||||
padding: 10rpx 24rpx;
|
||||
border-radius: 24rpx;
|
||||
font-size: 22rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
backdrop-filter: blur(8rpx);
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
|
||||
|
||||
&.active {
|
||||
background: linear-gradient(135deg, #10B981 0%, #059669 100%);
|
||||
}
|
||||
|
||||
&.canceled {
|
||||
background: linear-gradient(135deg, #9CA3AF 0%, #6B7280 100%);
|
||||
}
|
||||
|
||||
&.ended {
|
||||
background: linear-gradient(135deg, #D1D5DB 0%, #9CA3AF 100%);
|
||||
}
|
||||
}
|
||||
|
||||
/* 剩余名额标签 */
|
||||
.spots-tag {
|
||||
position: absolute;
|
||||
top: 24rpx;
|
||||
right: 24rpx;
|
||||
padding: 10rpx 20rpx;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
backdrop-filter: blur(8rpx);
|
||||
border-radius: 24rpx;
|
||||
font-size: 22rpx;
|
||||
color: #ffffff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
/* 卡片内容区域 */
|
||||
.card-content {
|
||||
padding: 28rpx 32rpx;
|
||||
}
|
||||
|
||||
/* 课程名称容器 */
|
||||
.course-name-wrapper {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
/* 课程名称 */
|
||||
.course-name {
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
color: #1F2937;
|
||||
display: block;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.5rpx;
|
||||
}
|
||||
|
||||
/* 课程信息容器 */
|
||||
.course-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
/* 信息项 */
|
||||
.info-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
padding: 12rpx 16rpx;
|
||||
background: linear-gradient(135deg, #F9FAFB 0%, #F3F4F6 100%);
|
||||
border-radius: 16rpx;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:active {
|
||||
background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
|
||||
}
|
||||
}
|
||||
|
||||
/* 信息图标 */
|
||||
.info-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* 图标字体垂直居中 */
|
||||
.iconfont_courseCard {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* 信息文字 */
|
||||
.info-text {
|
||||
font-size: 26rpx;
|
||||
color: #4B5563;
|
||||
line-height: 1.5;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 课程时长 */
|
||||
.course-duration {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
padding: 10rpx 20rpx;
|
||||
background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
color: #3B82F6;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* 卡片底部区域 */
|
||||
.card-footer {
|
||||
padding: 24rpx 32rpx 28rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-top: 1rpx solid #F3F4F6;
|
||||
margin-top: 4rpx;
|
||||
}
|
||||
|
||||
/* 价格信息 */
|
||||
.price-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.price {
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
color: #FF6B35;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 4rpx;
|
||||
|
||||
.currency {
|
||||
font-size: 24rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&.points {
|
||||
color: #FF6B35;
|
||||
gap: 6rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 免费课程样式 */
|
||||
.price-free {
|
||||
.free-text {
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
color: #10B981;
|
||||
}
|
||||
}
|
||||
|
||||
/* 多种支付方式样式 */
|
||||
.price-multi {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
|
||||
.price-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6rpx;
|
||||
|
||||
.currency {
|
||||
font-size: 20rpx;
|
||||
font-weight: 600;
|
||||
color: #FF6B35;
|
||||
}
|
||||
|
||||
.amount {
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
color: #FF6B35;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 20rpx;
|
||||
color: #6B7280;
|
||||
margin-left: 4rpx;
|
||||
}
|
||||
|
||||
&.stored-value {
|
||||
.currency, .amount {
|
||||
color: #FF6B35;
|
||||
}
|
||||
}
|
||||
|
||||
&.point-card {
|
||||
.amount {
|
||||
color: #FF6B35;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.price-divider {
|
||||
width: 2rpx;
|
||||
height: 32rpx;
|
||||
background: #E5E7EB;
|
||||
}
|
||||
}
|
||||
|
||||
/* 单一支付方式样式 */
|
||||
.price-single {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8rpx;
|
||||
|
||||
.pay-label {
|
||||
font-size: 20rpx;
|
||||
color: #6B7280;
|
||||
padding: 4rpx 12rpx;
|
||||
background: #F3F4F6;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
/* 预约按钮 */
|
||||
.booking-btn {
|
||||
padding: 18rpx 48rpx;
|
||||
background: linear-gradient(135deg, #FF6B35 0%, #FF8C5A 100%);
|
||||
border-radius: 44rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
box-shadow: 0 8rpx 20rpx rgba(255, 107, 53, 0.25);
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
letter-spacing: 1rpx;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.95);
|
||||
box-shadow: 0 4rpx 12rpx rgba(255, 107, 53, 0.2);
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
|
||||
color: #9CA3AF;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,202 @@
|
||||
<template>
|
||||
<view class="filter-section">
|
||||
<!-- 时间区间筛选 -->
|
||||
<view class="filter-item" @click="handleTimePick">
|
||||
<uni-icons type="calendar" size="18" color="#5E6F8D" class="filter-icon" />
|
||||
<text class="filter-text">{{ timeRangeText || '选择时间' }}</text>
|
||||
<uni-icons type="right" size="20" color="#A0AEC0" class="filter-arrow" />
|
||||
</view>
|
||||
|
||||
<!-- 排序方式 -->
|
||||
<picker
|
||||
mode="selector"
|
||||
:range="sortOptions"
|
||||
range-key="label"
|
||||
:value="sortIndex"
|
||||
@change="onSortChange"
|
||||
>
|
||||
<view class="filter-item">
|
||||
<uni-icons type="list" size="18" color="#5E6F8D" class="filter-icon" />
|
||||
<text class="filter-text">{{ sortOptions[sortIndex].label }}</text>
|
||||
<uni-icons type="right" size="20" color="#A0AEC0" class="filter-arrow" />
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
timeRangeText: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
sortOptions: {
|
||||
type: Array,
|
||||
default: () => [
|
||||
{ label: '默认排序', value: 'default' },
|
||||
{ label: '价格从低到高', value: 'priceAsc' },
|
||||
{ label: '价格从高到低', value: 'priceDesc' },
|
||||
{ label: '剩余名额最多', value: 'spotsDesc' },
|
||||
{ label: '仅次数卡', value: 'pointCardOnly' },
|
||||
{ label: '仅储值卡', value: 'storedValueOnly' },
|
||||
{ label: '两种支付', value: 'bothPayment' }
|
||||
]
|
||||
},
|
||||
sortIndex: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:sortIndex', 'timePick'])
|
||||
|
||||
const localSortIndex = ref(props.sortIndex)
|
||||
|
||||
watch(() => props.sortIndex, (val) => {
|
||||
localSortIndex.value = val
|
||||
})
|
||||
|
||||
const onSortChange = (e) => {
|
||||
localSortIndex.value = e.detail.value
|
||||
console.log('[FilterSection] 排序方式变更:', {
|
||||
index: localSortIndex.value,
|
||||
value: props.sortOptions[localSortIndex.value]
|
||||
})
|
||||
emit('update:sortIndex', localSortIndex.value)
|
||||
}
|
||||
|
||||
const handleTimePick = () => {
|
||||
console.log('[FilterSection] 触发时间选择器')
|
||||
emit('timePick')
|
||||
}
|
||||
|
||||
const getFilterParams = () => {
|
||||
const params = {
|
||||
sortType: props.sortOptions[localSortIndex.value].value,
|
||||
timeRangeText: props.timeRangeText
|
||||
}
|
||||
console.log('[FilterSection] 获取筛选参数:', params)
|
||||
return params
|
||||
}
|
||||
|
||||
const getSortType = () => {
|
||||
return props.sortOptions[localSortIndex.value].value
|
||||
}
|
||||
|
||||
const comparePrice = (a, b, ascending = true) => {
|
||||
const getEffectivePrice = (item) => {
|
||||
if (item.storedValueAmount > 0 && item.pointCardAmount > 0) {
|
||||
return Math.min(item.storedValueAmount, item.pointCardAmount * 50)
|
||||
} else if (item.storedValueAmount > 0) {
|
||||
return item.storedValueAmount
|
||||
} else if (item.pointCardAmount > 0) {
|
||||
return item.pointCardAmount * 50
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
const priceA = getEffectivePrice(a)
|
||||
const priceB = getEffectivePrice(b)
|
||||
|
||||
return ascending ? priceA - priceB : priceB - priceA
|
||||
}
|
||||
|
||||
const compareByPaymentType = (a, b, sortType) => {
|
||||
const getPaymentType = (item) => {
|
||||
const hasPointCard = item.pointCardAmount > 0
|
||||
const hasStoredValue = item.storedValueAmount > 0
|
||||
|
||||
if (hasPointCard && !hasStoredValue) return 1
|
||||
if (!hasPointCard && hasStoredValue) return 2
|
||||
if (hasPointCard && hasStoredValue) return 3
|
||||
return 0
|
||||
}
|
||||
|
||||
const typeA = getPaymentType(a)
|
||||
const typeB = getPaymentType(b)
|
||||
|
||||
switch (sortType) {
|
||||
case 'pointCardOnly':
|
||||
if (typeA === 1 && typeB !== 1) return -1
|
||||
if (typeA !== 1 && typeB === 1) return 1
|
||||
return 0
|
||||
case 'storedValueOnly':
|
||||
if (typeA === 2 && typeB !== 2) return -1
|
||||
if (typeA !== 2 && typeB === 2) return 1
|
||||
return 0
|
||||
case 'bothPayment':
|
||||
if (typeA === 3 && typeB !== 3) return -1
|
||||
if (typeA !== 3 && typeB === 3) return 1
|
||||
return 0
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
const sortCourses = (courses) => {
|
||||
const sortType = getSortType()
|
||||
if (!courses || !Array.isArray(courses)) return []
|
||||
|
||||
const sorted = [...courses]
|
||||
|
||||
switch (sortType) {
|
||||
case 'priceAsc':
|
||||
sorted.sort((a, b) => comparePrice(a, b, true))
|
||||
break
|
||||
case 'priceDesc':
|
||||
sorted.sort((a, b) => comparePrice(a, b, false))
|
||||
break
|
||||
case 'spotsDesc':
|
||||
sorted.sort((a, b) => (b.maxMembers - b.currentMembers) - (a.maxMembers - a.currentMembers))
|
||||
break
|
||||
case 'pointCardOnly':
|
||||
case 'storedValueOnly':
|
||||
case 'bothPayment':
|
||||
sorted.sort((a, b) => compareByPaymentType(a, b, sortType))
|
||||
break
|
||||
default:
|
||||
sorted.sort((a, b) => new Date(a.startTime) - new Date(b.startTime))
|
||||
}
|
||||
|
||||
return sorted
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
getFilterParams,
|
||||
getSortType,
|
||||
sortCourses
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.filter-section {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
|
||||
.filter-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
background: #F5F7FA;
|
||||
border-radius: 16rpx;
|
||||
font-size: 26rpx;
|
||||
color: #5E6F8D;
|
||||
|
||||
.filter-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.filter-arrow {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,165 @@
|
||||
<template>
|
||||
<view class="search-bar-wrapper">
|
||||
<!-- 搜索框 -->
|
||||
<view class="search-bar">
|
||||
<view class="search-input-wrapper">
|
||||
<uni-icons type="search" size="20" color="#A0AEC0" class="search-icon" />
|
||||
<input
|
||||
class="search-input"
|
||||
v-model="keyword"
|
||||
placeholder="搜索课程名称"
|
||||
placeholder-class="input-placeholder"
|
||||
@confirm="handleSearch"
|
||||
/>
|
||||
<uni-icons
|
||||
v-if="keyword"
|
||||
type="closeempty"
|
||||
size="16"
|
||||
color="#A0AEC0"
|
||||
class="clear-icon"
|
||||
@click="clearSearch"
|
||||
/>
|
||||
</view>
|
||||
<view class="search-btn" @click="handleSearch">搜索</view>
|
||||
</view>
|
||||
|
||||
<!-- 热门关键词 -->
|
||||
<view class="hot-keywords">
|
||||
<text class="hot-label">热门搜索:</text>
|
||||
<view
|
||||
v-for="(kw, index) in hotKeywords"
|
||||
:key="index"
|
||||
:class="['hot-tag', { active: keyword === kw }]"
|
||||
@click="selectKeyword(kw)"
|
||||
>
|
||||
{{ kw }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
hotKeywords: {
|
||||
type: Array,
|
||||
default: () => ['燃脂', '瑜伽', '单车', '普拉提', '高强度']
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'search'])
|
||||
|
||||
const keyword = ref(props.modelValue)
|
||||
|
||||
watch(() => props.modelValue, (val) => {
|
||||
keyword.value = val
|
||||
})
|
||||
|
||||
const handleSearch = () => {
|
||||
console.log('[SearchBar] 搜索参数:', { keyword: keyword.value })
|
||||
emit('update:modelValue', keyword.value)
|
||||
emit('search', { keyword: keyword.value })
|
||||
}
|
||||
|
||||
const clearSearch = () => {
|
||||
keyword.value = ''
|
||||
emit('update:modelValue', '')
|
||||
console.log('[SearchBar] 已清除搜索关键词')
|
||||
}
|
||||
|
||||
const selectKeyword = (kw) => {
|
||||
keyword.value = kw
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
const getSearchParams = () => {
|
||||
console.log('[SearchBar] 获取搜索参数:', { keyword: keyword.value })
|
||||
return { keyword: keyword.value }
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
getSearchParams,
|
||||
clearSearch
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* 搜索框 */
|
||||
.search-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.search-input-wrapper {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #F5F7FA;
|
||||
border-radius: 44rpx;
|
||||
padding: 0 24rpx;
|
||||
height: 72rpx;
|
||||
|
||||
.search-icon {
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #1a202c;
|
||||
}
|
||||
|
||||
.input-placeholder {
|
||||
color: #A0AEC0;
|
||||
}
|
||||
|
||||
.clear-icon {
|
||||
padding: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
padding: 0 32rpx;
|
||||
height: 72rpx;
|
||||
line-height: 72rpx;
|
||||
background: linear-gradient(135deg, #FF6B35 0%, #FF8C5A 100%);
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
border-radius: 44rpx;
|
||||
}
|
||||
}
|
||||
|
||||
/* 热门关键词 */
|
||||
.hot-keywords {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
|
||||
.hot-label {
|
||||
font-size: 26rpx;
|
||||
color: #8A99B4;
|
||||
}
|
||||
|
||||
.hot-tag {
|
||||
padding: 8rpx 20rpx;
|
||||
background: #F5F7FA;
|
||||
color: #5E6F8D;
|
||||
font-size: 24rpx;
|
||||
border-radius: 28rpx;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&.active {
|
||||
background: linear-gradient(135deg, #FF6B35 0%, #FF8C5A 100%);
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,191 @@
|
||||
<template>
|
||||
<view class="time-period-selector">
|
||||
<view class="sort-header">
|
||||
<uni-icons type="calendar" size="16" color="#FF6B35" class="sort-icon" />
|
||||
<text class="sort-label">上课时段</text>
|
||||
</view>
|
||||
<view class="slider-wrapper">
|
||||
<view
|
||||
v-for="(option, index) in timePeriodOptions"
|
||||
:key="index"
|
||||
:class="['slider-item', { active: currentIndex === index }]"
|
||||
@click="handlePeriodChange(index)"
|
||||
>
|
||||
<span class="iconfont_time_select" v-bind:class="getPeriodIcon(option.value)"></span>
|
||||
|
||||
<text :class="['slider-text', { active: currentIndex === index }]">
|
||||
{{ option.label.split(' ')[0] }}
|
||||
</text>
|
||||
</view>
|
||||
<!-- 滑动指示器 -->
|
||||
<view
|
||||
class="slider-indicator"
|
||||
:style="{ left: `calc(8rpx + ${currentIndex} * (100% - 16rpx) / 4)` }"
|
||||
></view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
timePeriodOptions: {
|
||||
type: Array,
|
||||
default: () => [
|
||||
{ label: '全部', value: 'all' },
|
||||
{ label: '早上 (6-12 点)', value: 'morning', startHour: 6, endHour: 12 },
|
||||
{ label: '下午 (12-18 点)', value: 'afternoon', startHour: 12, endHour: 18 },
|
||||
{ label: '晚上 (18-24 点)', value: 'evening', startHour: 18, endHour: 24 }
|
||||
]
|
||||
},
|
||||
modelValue: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'change'])
|
||||
|
||||
const currentIndex = ref(props.modelValue)
|
||||
|
||||
watch(() => props.modelValue, (val) => {
|
||||
currentIndex.value = val
|
||||
})
|
||||
|
||||
const getPeriodIcon = (value) => {
|
||||
const iconMap = {
|
||||
'all': 'icon-gengduo ',
|
||||
'morning': 'icon-zaochen',
|
||||
'afternoon': 'icon-xiawucha ',
|
||||
'evening': 'icon-yewan '
|
||||
}
|
||||
return iconMap[value] || iconMap[all]
|
||||
}
|
||||
|
||||
const handlePeriodChange = (index) => {
|
||||
currentIndex.value = index
|
||||
const option = props.timePeriodOptions[index]
|
||||
console.log('[TimePeriodSelector] 时间段变更:', {
|
||||
index,
|
||||
value: option.value,
|
||||
label: option.label
|
||||
})
|
||||
emit('update:modelValue', index)
|
||||
emit('change', option)
|
||||
}
|
||||
|
||||
const getTimePeriodParams = () => {
|
||||
const option = props.timePeriodOptions[currentIndex.value]
|
||||
const params = {
|
||||
index: currentIndex.value,
|
||||
value: option.value,
|
||||
label: option.label,
|
||||
startHour: option.startHour,
|
||||
endHour: option.endHour
|
||||
}
|
||||
console.log('[TimePeriodSelector] 获取时间段参数:', params)
|
||||
return params
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
getTimePeriodParams,
|
||||
getPeriodIcon
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@import "@/common/style/iconfont_time_select.css";
|
||||
|
||||
.time-period-selector {
|
||||
padding: 24rpx;
|
||||
background: linear-gradient(135deg, #F5F7FA 0%, #E9EDF2 100%);
|
||||
border-radius: 20rpx;
|
||||
box-shadow: inset 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
|
||||
|
||||
.sort-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.sort-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sort-label {
|
||||
font-size: 28rpx;
|
||||
color: #1a202c;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.slider-wrapper {
|
||||
position: relative;
|
||||
display: flex;
|
||||
background: #ffffff;
|
||||
border-radius: 16rpx;
|
||||
padding: 8rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
|
||||
overflow: hidden;
|
||||
|
||||
.slider-item {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8rpx;
|
||||
padding: 20rpx 0;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
.slider-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.slider-text {
|
||||
font-size: 24rpx;
|
||||
color: #8A99B4;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&.active {
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
.slider-icon {
|
||||
color: #ffffff !important;
|
||||
}
|
||||
|
||||
.slider-text {
|
||||
color: #ffffff !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 滑动指示器 */
|
||||
.slider-indicator {
|
||||
position: absolute;
|
||||
top: 8rpx;
|
||||
left: 8rpx;
|
||||
width: calc((100% - 16rpx) / 4);
|
||||
height: calc(100% - 16rpx);
|
||||
background: linear-gradient(135deg, #FF6B35 0%, #FF8C5A 100%);
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(255, 107, 53, 0.4);
|
||||
transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,728 @@
|
||||
<template>
|
||||
<view>
|
||||
<!-- 时间范围选择弹窗 -->
|
||||
<Transition name="modal">
|
||||
<view v-if="visible" class="time-range-modal">
|
||||
<view class="modal-mask" @click="handleClose"></view>
|
||||
<view class="modal-content">
|
||||
<view class="modal-header">
|
||||
<text class="modal-title">选择时间范围</text>
|
||||
<view class="header-actions">
|
||||
<text class="modal-clear" @click="handleClear">清空</text>
|
||||
<text class="modal-close" @click="handleClose">×</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="modal-body">
|
||||
<!-- 开始日期 -->
|
||||
<view class="date-item">
|
||||
<text class="date-label">开始日期</text>
|
||||
<view class="date-value" @click="toggleStartPicker">
|
||||
<text>{{ localStartDate || '请选择' }}</text>
|
||||
<text class="date-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 结束日期 -->
|
||||
<view class="date-item">
|
||||
<text class="date-label">结束日期</text>
|
||||
<view class="date-value" @click="toggleEndPicker">
|
||||
<text>{{ localEndDate || '请选择' }}</text>
|
||||
<text class="date-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 快捷选择 -->
|
||||
<view class="quick-select">
|
||||
<text class="quick-label">快捷选择</text>
|
||||
<view class="quick-btns">
|
||||
<view
|
||||
v-for="item in quickOptions"
|
||||
:key="item.value"
|
||||
class="quick-btn"
|
||||
:class="{ active: quickSelected === item.value }"
|
||||
@click="applyQuickOption(item.value)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="modal-footer">
|
||||
<view class="btn btn-cancel" @click="handleClose">取消</view>
|
||||
<view class="btn btn-confirm" @click="handleConfirm">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 日期选择器弹窗 -->
|
||||
<Transition name="date-picker">
|
||||
<view v-if="showDatePicker" class="date-picker-modal">
|
||||
<view class="date-mask" @click="showDatePicker = false"></view>
|
||||
<view class="date-picker-content">
|
||||
<view class="date-header">
|
||||
<text class="date-prev" @click="prevMonth">‹</text>
|
||||
<text class="date-title">{{ currentYear }}年{{ currentMonth }}月</text>
|
||||
<text class="date-next" @click="nextMonth">›</text>
|
||||
</view>
|
||||
<view class="date-weekdays">
|
||||
<text v-for="day in weekdays" :key="day">{{ day }}</text>
|
||||
</view>
|
||||
<view class="date-days">
|
||||
<view
|
||||
v-for="(day, index) in calendarDays"
|
||||
:key="index"
|
||||
class="date-day"
|
||||
:class="{
|
||||
'other-month': !day.currentMonth,
|
||||
'today': day.isToday,
|
||||
'selected': day.date === selectedDate,
|
||||
'disabled': day.disabled
|
||||
}"
|
||||
@click="selectDate(day)"
|
||||
>
|
||||
{{ day.day }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</Transition>
|
||||
</view>
|
||||
</Transition>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, computed, onMounted } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
startDate: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
endDate: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:visible', 'update:startDate', 'update:endDate', 'confirm', 'cancel'])
|
||||
|
||||
const localStartDate = ref(props.startDate)
|
||||
const localEndDate = ref(props.endDate)
|
||||
const showDatePicker = ref(false)
|
||||
const pickerType = ref('start') // 'start' | 'end'
|
||||
const currentYear = ref(2024)
|
||||
const currentMonth = ref(1)
|
||||
const selectedDate = ref('')
|
||||
const quickSelected = ref('')
|
||||
|
||||
const weekdays = ['日', '一', '二', '三', '四', '五', '六']
|
||||
|
||||
const quickOptions = [
|
||||
{ label: '近7天', value: '7d' },
|
||||
{ label: '近30天', value: '30d' },
|
||||
{ label: '本月', value: 'month' },
|
||||
{ label: '上月', value: 'lastMonth' }
|
||||
]
|
||||
|
||||
// 监听 props 变化
|
||||
watch(() => props.startDate, (val) => {
|
||||
localStartDate.value = val
|
||||
})
|
||||
|
||||
watch(() => props.endDate, (val) => {
|
||||
localEndDate.value = val
|
||||
})
|
||||
|
||||
watch(() => props.visible, (val) => {
|
||||
if (val) {
|
||||
// 弹窗打开时设置当前日期
|
||||
const now = new Date()
|
||||
currentYear.value = now.getFullYear()
|
||||
currentMonth.value = now.getMonth() + 1
|
||||
}
|
||||
})
|
||||
|
||||
// 计算时间范围文本
|
||||
const timeRangeText = computed(() => {
|
||||
if (localStartDate.value && localEndDate.value) {
|
||||
return `${localStartDate.value} 至 ${localEndDate.value}`
|
||||
} else if (localStartDate.value) {
|
||||
return `${localStartDate.value} 起`
|
||||
} else if (localEndDate.value) {
|
||||
return `至 ${localEndDate.value}`
|
||||
}
|
||||
return ''
|
||||
})
|
||||
|
||||
// 生成日历日期
|
||||
const calendarDays = computed(() => {
|
||||
const days = []
|
||||
const firstDay = new Date(currentYear.value, currentMonth.value - 1, 1)
|
||||
const lastDay = new Date(currentYear.value, currentMonth.value, 0)
|
||||
const startDay = firstDay.getDay()
|
||||
const totalDays = lastDay.getDate()
|
||||
|
||||
// 上个月的天数
|
||||
const prevMonthLastDay = new Date(currentYear.value, currentMonth.value - 1, 0).getDate()
|
||||
for (let i = startDay - 1; i >= 0; i--) {
|
||||
days.push({
|
||||
day: prevMonthLastDay - i,
|
||||
date: formatDate(currentYear.value, currentMonth.value - 1, prevMonthLastDay - i),
|
||||
currentMonth: false,
|
||||
isToday: false,
|
||||
disabled: true
|
||||
})
|
||||
}
|
||||
|
||||
// 本月的天数
|
||||
const today = new Date()
|
||||
for (let i = 1; i <= totalDays; i++) {
|
||||
const dateStr = formatDate(currentYear.value, currentMonth.value, i)
|
||||
days.push({
|
||||
day: i,
|
||||
date: dateStr,
|
||||
currentMonth: true,
|
||||
isToday: isToday(currentYear.value, currentMonth.value, i),
|
||||
disabled: isFuture(currentYear.value, currentMonth.value, i)
|
||||
})
|
||||
}
|
||||
|
||||
// 下个月的天数
|
||||
const remaining = 42 - days.length
|
||||
for (let i = 1; i <= remaining; i++) {
|
||||
days.push({
|
||||
day: i,
|
||||
date: formatDate(currentYear.value, currentMonth.value + 1, i),
|
||||
currentMonth: false,
|
||||
isToday: false,
|
||||
disabled: true
|
||||
})
|
||||
}
|
||||
|
||||
return days
|
||||
})
|
||||
|
||||
// 格式化日期
|
||||
function formatDate(year, month, day) {
|
||||
const m = month.toString().padStart(2, '0')
|
||||
const d = day.toString().padStart(2, '0')
|
||||
return `${year}-${m}-${d}`
|
||||
}
|
||||
|
||||
// 判断是否是今天
|
||||
function isToday(year, month, day) {
|
||||
const today = new Date()
|
||||
return year === today.getFullYear() &&
|
||||
month === today.getMonth() + 1 &&
|
||||
day === today.getDate()
|
||||
}
|
||||
|
||||
// 判断是否是未来日期
|
||||
function isFuture(year, month, day) {
|
||||
const today = new Date()
|
||||
today.setHours(0, 0, 0, 0)
|
||||
const date = new Date(year, month - 1, day)
|
||||
return date > today
|
||||
}
|
||||
|
||||
// 切换日期选择器
|
||||
const toggleStartPicker = () => {
|
||||
pickerType.value = 'start'
|
||||
selectedDate.value = localStartDate.value
|
||||
showDatePicker.value = true
|
||||
}
|
||||
|
||||
const toggleEndPicker = () => {
|
||||
pickerType.value = 'end'
|
||||
selectedDate.value = localEndDate.value
|
||||
showDatePicker.value = true
|
||||
}
|
||||
|
||||
// 月份切换
|
||||
const prevMonth = () => {
|
||||
if (currentMonth.value === 1) {
|
||||
currentYear.value--
|
||||
currentMonth.value = 12
|
||||
} else {
|
||||
currentMonth.value--
|
||||
}
|
||||
}
|
||||
|
||||
const nextMonth = () => {
|
||||
if (currentMonth.value === 12) {
|
||||
currentYear.value++
|
||||
currentMonth.value = 1
|
||||
} else {
|
||||
currentMonth.value++
|
||||
}
|
||||
}
|
||||
|
||||
// 选择日期
|
||||
const selectDate = (day) => {
|
||||
if (day.disabled) return
|
||||
selectedDate.value = day.date
|
||||
if (pickerType.value === 'start') {
|
||||
localStartDate.value = day.date
|
||||
emit('update:startDate', day.date)
|
||||
} else {
|
||||
localEndDate.value = day.date
|
||||
emit('update:endDate', day.date)
|
||||
}
|
||||
showDatePicker.value = false
|
||||
console.log(`[TimeRangePicker] ${pickerType.value === 'start' ? '开始' : '结束'}日期变更:`, day.date)
|
||||
}
|
||||
|
||||
// 应用快捷选项
|
||||
const applyQuickOption = (value) => {
|
||||
quickSelected.value = value
|
||||
const today = new Date()
|
||||
let startDate, endDate
|
||||
|
||||
switch (value) {
|
||||
case '7d':
|
||||
startDate = new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000)
|
||||
endDate = today
|
||||
break
|
||||
case '30d':
|
||||
startDate = new Date(today.getTime() - 30 * 24 * 60 * 60 * 1000)
|
||||
endDate = today
|
||||
break
|
||||
case 'month':
|
||||
startDate = new Date(today.getFullYear(), today.getMonth(), 1)
|
||||
endDate = today
|
||||
break
|
||||
case 'lastMonth':
|
||||
startDate = new Date(today.getFullYear(), today.getMonth() - 1, 1)
|
||||
endDate = new Date(today.getFullYear(), today.getMonth(), 0)
|
||||
break
|
||||
}
|
||||
|
||||
localStartDate.value = formatDate(startDate.getFullYear(), startDate.getMonth() + 1, startDate.getDate())
|
||||
localEndDate.value = formatDate(endDate.getFullYear(), endDate.getMonth() + 1, endDate.getDate())
|
||||
emit('update:startDate', localStartDate.value)
|
||||
emit('update:endDate', localEndDate.value)
|
||||
console.log('[TimeRangePicker] 快捷选择:', value, { start: localStartDate.value, end: localEndDate.value })
|
||||
}
|
||||
|
||||
// 清空选择
|
||||
const handleClear = () => {
|
||||
localStartDate.value = ''
|
||||
localEndDate.value = ''
|
||||
quickSelected.value = ''
|
||||
emit('update:startDate', '')
|
||||
emit('update:endDate', '')
|
||||
console.log('[TimeRangePicker] 已清空时间选择')
|
||||
}
|
||||
|
||||
// 关闭弹窗
|
||||
const handleClose = () => {
|
||||
console.log('[TimeRangePicker] 关闭时间选择器')
|
||||
emit('update:visible', false)
|
||||
emit('cancel')
|
||||
}
|
||||
|
||||
// 确认选择
|
||||
const handleConfirm = () => {
|
||||
console.log('[TimeRangePicker] 确认时间范围:', {
|
||||
startDate: localStartDate.value,
|
||||
endDate: localEndDate.value,
|
||||
timeRangeText: timeRangeText.value
|
||||
})
|
||||
emit('update:visible', false)
|
||||
emit('confirm', {
|
||||
startDate: localStartDate.value,
|
||||
endDate: localEndDate.value,
|
||||
timeRangeText: timeRangeText.value
|
||||
})
|
||||
}
|
||||
|
||||
// 获取参数
|
||||
const getTimeRangeParams = () => {
|
||||
const params = {
|
||||
startDate: localStartDate.value,
|
||||
endDate: localEndDate.value,
|
||||
timeRangeText: timeRangeText.value
|
||||
}
|
||||
console.log('[TimeRangePicker] 获取时间范围参数:', params)
|
||||
return params
|
||||
}
|
||||
|
||||
// 重置日期
|
||||
const resetDate = () => {
|
||||
localStartDate.value = ''
|
||||
localEndDate.value = ''
|
||||
quickSelected.value = ''
|
||||
emit('update:startDate', '')
|
||||
emit('update:endDate', '')
|
||||
console.log('[TimeRangePicker] 已重置日期')
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
getTimeRangeParams,
|
||||
resetDate,
|
||||
timeRangeText
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.time-range-modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.modal-mask {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
position: relative;
|
||||
width: 640rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 24rpx;
|
||||
overflow: hidden;
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 32rpx;
|
||||
border-bottom: 1rpx solid #E9EDF2;
|
||||
|
||||
.modal-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #1a202c;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
.modal-clear {
|
||||
font-size: 28rpx;
|
||||
color: #8A99B4;
|
||||
padding: 8rpx 16rpx;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
font-size: 48rpx;
|
||||
color: #8A99B4;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 32rpx;
|
||||
|
||||
.date-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 24rpx 0;
|
||||
border-bottom: 1rpx solid #F0F2F5;
|
||||
|
||||
&:last-of-type {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.date-label {
|
||||
font-size: 28rpx;
|
||||
color: #6B7280;
|
||||
}
|
||||
|
||||
.date-value {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
|
||||
text {
|
||||
font-size: 28rpx;
|
||||
color: #1a202c;
|
||||
}
|
||||
|
||||
.date-arrow {
|
||||
font-size: 32rpx;
|
||||
color: #C4C9D4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.quick-select {
|
||||
margin-top: 24rpx;
|
||||
|
||||
.quick-label {
|
||||
font-size: 26rpx;
|
||||
color: #9CA3AF;
|
||||
margin-bottom: 16rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.quick-btns {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
|
||||
.quick-btn {
|
||||
padding: 16rpx 28rpx;
|
||||
background: #F5F7FA;
|
||||
border-radius: 32rpx;
|
||||
font-size: 26rpx;
|
||||
color: #6B7280;
|
||||
|
||||
&.active {
|
||||
background: #FF6B35;
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
display: flex;
|
||||
border-top: 1rpx solid #E9EDF2;
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
padding: 32rpx;
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
|
||||
&.btn-cancel {
|
||||
color: #6B7280;
|
||||
border-right: 1rpx solid #E9EDF2;
|
||||
}
|
||||
|
||||
&.btn-confirm {
|
||||
color: #FF6B35;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.date-picker-modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1001;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
|
||||
.date-mask {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
.date-picker-content {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
background: #ffffff;
|
||||
border-radius: 32rpx 32rpx 0 0;
|
||||
transform: translateY(0);
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
.date-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 32rpx;
|
||||
|
||||
.date-prev, .date-next {
|
||||
font-size: 40rpx;
|
||||
color: #1a202c;
|
||||
width: 64rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.date-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #1a202c;
|
||||
}
|
||||
}
|
||||
|
||||
.date-weekdays {
|
||||
display: flex;
|
||||
padding: 0 24rpx;
|
||||
|
||||
text {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
color: #9CA3AF;
|
||||
padding: 16rpx 0;
|
||||
}
|
||||
}
|
||||
|
||||
.date-days {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: 16rpx 24rpx 32rpx;
|
||||
|
||||
.date-day {
|
||||
width: calc(100% / 7);
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 28rpx;
|
||||
color: #1a202c;
|
||||
border-radius: 50%;
|
||||
|
||||
&.other-month {
|
||||
color: #D1D5DB;
|
||||
}
|
||||
|
||||
&.today {
|
||||
background: #F5F7FA;
|
||||
color: #FF6B35;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background: #FF6B35;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
color: #E5E7EB;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 居中弹窗进入动画 */
|
||||
.modal-enter-active {
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.modal-enter-active .modal-mask {
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-enter-active .modal-content {
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.modal-enter-from .modal-mask {
|
||||
background: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.modal-enter-from .modal-content {
|
||||
opacity: 0;
|
||||
transform: scale(0.9);
|
||||
}
|
||||
|
||||
/* 居中弹窗退出动画 */
|
||||
.modal-leave-active {
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.modal-leave-active .modal-mask {
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-leave-active .modal-content {
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.modal-leave-to .modal-mask {
|
||||
background: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.modal-leave-to .modal-content {
|
||||
opacity: 0;
|
||||
transform: scale(0.9);
|
||||
}
|
||||
|
||||
@keyframes modalIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: scale(0.9);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideUp {
|
||||
from {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 日期选择器进入动画 */
|
||||
.date-picker-enter-active {
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.date-picker-enter-active .date-mask {
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
.date-picker-enter-active .date-picker-content {
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.date-picker-enter-from .date-mask {
|
||||
background: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.date-picker-enter-from .date-picker-content {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
/* 日期选择器退出动画 */
|
||||
.date-picker-leave-active {
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.date-picker-leave-active .date-mask {
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
.date-picker-leave-active .date-picker-content {
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.date-picker-leave-to .date-mask {
|
||||
background: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.date-picker-leave-to .date-picker-content {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
</style>
|
||||
@@ -6,6 +6,7 @@
|
||||
v-for="(item, index) in entries"
|
||||
:key="index"
|
||||
class="entry-item"
|
||||
@tap="QEClick(item.path)"
|
||||
>
|
||||
<!-- 入口图标容器 -->
|
||||
<view :class="['entry-icon', { accent: item.accent }]">
|
||||
@@ -21,37 +22,44 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
const QEClick = () => {
|
||||
uni.navigateTo({
|
||||
url:"/pages/checkIn/checkIn"
|
||||
})
|
||||
}
|
||||
// 快捷入口数据列表
|
||||
const entries = [
|
||||
{
|
||||
icon: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/icons/course.png',
|
||||
title: '找课程',
|
||||
desc: '精品课程',
|
||||
accent: false ,
|
||||
accent: false
|
||||
},
|
||||
{
|
||||
icon: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/icons/plan.png',
|
||||
title: '训练计划',
|
||||
desc: '个性定制',
|
||||
accent: true ,
|
||||
accent: true
|
||||
},
|
||||
{
|
||||
icon: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/icons/data.png',
|
||||
title: '健身数据',
|
||||
desc: '记录分析',
|
||||
accent: false ,
|
||||
accent: false
|
||||
},
|
||||
{
|
||||
icon: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/icons/message.png',
|
||||
title: '消息',
|
||||
desc: '通知消息',
|
||||
accent: true,
|
||||
accent: true
|
||||
},
|
||||
{
|
||||
icon: 'https://gymfuture.oss-cn-chengdu.aliyuncs.com/static/icons/checkIn.png',
|
||||
title: '签到',
|
||||
desc: '打卡签到',
|
||||
accent: false,
|
||||
path: "/pages/checkIn/checkIn"
|
||||
}
|
||||
]
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user