flat: 暂存

This commit is contained in:
史典卓
2025-05-13 11:10:38 +08:00
parent 582e432e6a
commit fd74b7d4df
109 changed files with 8644 additions and 5205 deletions

View File

@@ -0,0 +1,161 @@
<template>
<div class="countdown-wrapper" style="width: 100%">
<template v-if="isNotStarted">
<view class="fl_box fl_nowarp fl_justbet" style="width: 100%">
<view class="fl_box">
<span class="colon">距离开始还剩</span>
<div class="time-block">{{ days }}</div>
<span class="colon"></span>
</view>
<view style="color: #ff881a">待开始</view>
</view>
</template>
<template v-else-if="isEnd">
<view class="fl_box fl_nowarp fl_justbet" style="width: 100%">
<view class="fl_box">
<span class="colon hui">距离结束还剩</span>
<div class="time-block huibg">00</div>
<span class="colon hui">:</span>
<div class="time-block huibg">00</div>
<span class="colon hui">:</span>
<div class="time-block huibg">00</div>
</view>
<view class="hui">已结束</view>
</view>
</template>
<template v-else>
<template v-if="showDays">
<view class="fl_box fl_nowarp fl_justbet" style="width: 100%">
<view class="fl_box">
<span class="colon">距离结束还剩</span>
<div class="time-block">{{ days }}</div>
<span class="colon"></span>
</view>
<view style="color: #18a14f">进行中</view>
</view>
</template>
<template v-else>
<view class="fl_box fl_nowarp fl_justbet" style="width: 100%">
<view class="fl_box">
<span class="colon">距离结束还剩</span>
<div class="time-block">{{ hours }}</div>
<span class="colon">:</span>
<div class="time-block">{{ minutes }}</div>
<span class="colon">:</span>
<div class="time-block">{{ seconds }}</div>
</view>
<view style="color: #18a14f">进行中</view>
</view>
</template>
</template>
</div>
</template>
<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue';
const props = defineProps({
startTime: { type: [String, Number, Date], required: true },
endTime: { type: [String, Number, Date], required: true },
interval: { type: Number, default: 1000 },
});
const now = ref(Date.now());
let timer = null;
const startTimestamp = computed(() => new Date(props.startTime).getTime());
const endTimestamp = computed(() => new Date(props.endTime).getTime());
const isEnd = computed(() => now.value >= endTimestamp.value);
const isNotStarted = computed(() => now.value < startTimestamp.value);
const targetTimestamp = computed(() => {
if (isNotStarted.value) return startTimestamp.value;
if (!isEnd.value) return endTimestamp.value;
return now.value;
});
const remainingMs = computed(() => Math.max(0, targetTimestamp.value - now.value));
const secondsTotal = computed(() => Math.floor(remainingMs.value / 1000));
const showDays = computed(() => secondsTotal.value >= 86400);
const days = computed(() => Math.ceil(secondsTotal.value / 86400));
const hours = computed(() => {
const h = Math.floor(secondsTotal.value / 3600) % 24;
return h.toString().padStart(2, '0');
});
const minutes = computed(() => {
const m = Math.floor((secondsTotal.value % 3600) / 60);
return m.toString().padStart(2, '0');
});
const seconds = computed(() => {
const s = secondsTotal.value % 60;
return s.toString().padStart(2, '0');
});
const startTimer = () => {
timer = setInterval(() => {
now.value = Date.now();
}, props.interval);
};
const stopTimer = () => {
if (timer) {
clearInterval(timer);
timer = null;
}
};
onMounted(() => {
startTimer();
});
onUnmounted(() => {
stopTimer();
});
</script>
<style scoped>
.countdown-wrapper {
display: flex;
align-items: center;
}
.time-block {
text-align: center;
font-weight: 500;
font-size: 28rpx;
color: #ffffff;
height: 44rpx;
line-height: 44rpx;
padding: 0 14rpx;
background: #256bfa;
border-radius: 8rpx 8rpx 8rpx 8rpx;
margin: 0 10rpx;
}
.colon {
font-family: PingFang SC, PingFang SC;
font-weight: 400;
font-size: 28rpx;
color: #256bfa;
}
.day-text {
font-size: 18px;
color: #333;
}
.hui {
color: #b6b6b6;
}
.huibg {
background-color: #b6b6b6;
}
.lan {
color: #256bfa;
}
</style>

View File

@@ -0,0 +1,193 @@
<template>
<view class="reser-content">
<view class="content-top">
<view
class="top-item"
:class="{ active: ranItem.value === item.value }"
v-for="(item, index) in ranOptions"
:key="index"
@click="chnageRanOption(item)"
>
{{ item.label }}
</view>
</view>
<view class="main">
<scroll-view scroll-y>
<view v-if="pageState.list.length">
<view class="card" v-for="(item, index) in pageState.list" :key="index">
<view @click="navTo('/packageA/pages/exhibitors/exhibitors?jobFairId=' + item.jobFairId)">
<view class="card-row">
<Countdown startTime="item.startTime" :endTime="item.endTime" />
</view>
<view class="card-Title">{{ item.name }}</view>
<view class="card-row">
<view class="rowleft">{{ item.location }}</view>
<view class="rowright">
<convert-distance
:alat="item.latitude"
:along="item.longitude"
:blat="latitudeVal"
:blong="longitudeVal"
></convert-distance>
</view>
</view>
</view>
<view class="footer" v-if="isTimePassed(item.startTime)">
<view class="card_cancel" @click="updateCancel(item)">取消预约</view>
</view>
</view>
</view>
<empty v-else pdTop="200"></empty>
</scroll-view>
</view>
</view>
</template>
<script setup>
import { reactive, inject, watch, ref, onMounted, onBeforeUnmount } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
const { $api, navTo, debounce, customSystem } = inject('globalFunction');
import Countdown from './component/countdown.vue';
import { storeToRefs } from 'pinia';
import useLocationStore from '@/stores/useLocationStore';
import useUserStore from '@/stores/useUserStore';
const { userInfo } = storeToRefs(useUserStore());
const { longitudeVal, latitudeVal } = storeToRefs(useLocationStore());
const pageState = reactive({
page: 0,
list: [],
total: 0,
maxPage: 1,
pageSize: 10,
search: {},
lastDate: '',
});
const ranItem = ref({});
const ranOptions = ref([
{ label: '全部', value: 0 },
{ label: '待开始', value: 1 },
{ label: '进行中', value: 2 },
{ label: '已结束', value: 3 },
]);
function isTimePassed(timeStr) {
const targetTime = new Date(timeStr.replace(/-/g, '/')).getTime(); // 兼容格式
const now = Date.now();
return now < targetTime;
}
onLoad(() => {
ranItem.value = ranOptions.value[0];
getList();
});
function chnageRanOption(item) {
ranItem.value = item;
getList();
}
function updateCancel(item) {
const fairId = item.jobFairId;
$api.createRequest(`/app/fair/collection/${fairId}`, {}, 'DELETE').then((resData) => {
getList('refresh');
$api.msg('取消预约成功');
});
}
function getList(type = 'add', loading = true) {
if (type === 'refresh') {
pageState.page = 0;
pageState.maxPage = 1;
}
if (type === 'add' && pageState.page < pageState.maxPage) {
pageState.page += 1;
}
let params = {
current: pageState.page,
pageSize: pageState.pageSize,
type: ranItem.value.value,
};
$api.createRequest('/app/user/collection/fair', params).then((resData) => {
const { rows, total } = resData;
if (type === 'add') {
const str = pageState.pageSize * (pageState.page - 1);
const end = pageState.list.length;
const reslist = rows;
pageState.list.splice(str, end, ...reslist);
} else {
pageState.list = rows;
}
// pageState.list = resData.rows;
pageState.total = resData.total;
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
});
}
</script>
<style lang="stylus" scoped>
.reser-content{
width: 100%;
height: calc(100vh - var(--window-top) - var(--status-bar-height) - var(--window-bottom));
display: flex;
flex-direction: column;
.content-top{
display: flex
padding: 28rpx
.top-item{
font-weight: 400;
font-size: 32rpx;
margin-right: 48rpx
color: #666D7F;
}
.active{
font-weight: 500;
font-size: 32rpx;
color: #000000;
}
}
.main{
flex: 1
overflow: hidden
background: #F4F4F4
padding: 28rpx
.card{
padding: 30rpx
background: #FFFFFF;
box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0,0,0,0.04);
border-radius: 20rpx 20rpx 20rpx 20rpx;
color: #495264
margin-bottom: 28rpx
.card-row{
display: flex
justify-content: space-between
.rowleft{
display: flex
align-items: center
}
}
.card-Title{
font-weight: 500;
font-size: 32rpx;
line-height: 70rpx
color: #333333;
}
.footer{
display: flex
align-items: center
justify-content: flex-end
}
.card_cancel{
width: 228rpx;
height: 80rpx;
line-height: 80rpx;
text-align: center;
border-radius: 12rpx 12rpx 12rpx 12rpx;
border: 2rpx solid #E8EAEE;
margin-top: 32rpx
}
}
}
}
</style>