享飞-小程序
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.
 
 
 

226 lines
7.2 KiB

<script setup>
import { reactive, ref } from 'vue';
import Taro from "@tarojs/taro";
import { storeToRefs } from "pinia";
import { useFlightStore } from "../../stores";
const { getFlightList } = useFlightStore();
const { flightList, flightExtra, flightQueries } = storeToRefs(useFlightStore());
const state = reactive({
msg: '错误提示',
type: 'warn',
show: false,
cover: true,
center: true,
});
function openToast(type = 'warn', msg = '错误提示') {
state.msg = msg;
state.type = type;
state.show = true;
}
const loading = ref(false);
const isRefreshing = ref(false);
function onRefresh() {
isRefreshing.value = true;
flightQueries.value.pageNum = 1;
getFlightList().then(() => {
Taro.stopPullDownRefresh();
}).catch(({ msg }) => {
if (msg) openToast('warn', msg);
}).finally(() => {
isRefreshing.value = false;
});
}
function onLoadMore() {
if (loading.value) return;
if (flightList.value.length >= flightExtra.value.total) return;
loading.value = true;
flightQueries.value.pageNum += 1;
getFlightList().catch(({ msg }) => {
if (msg) openToast('warn', msg);
}).finally(() => {
loading.value = false;
});
}
function onNavTo(id) {
Taro.navigateTo({
url: `/pages/flightMap/index?id=${id}`,
});
}
Taro.usePullDownRefresh(() => {
onRefresh();
});
Taro.useReachBottom(() => {
onLoadMore();
});
Taro.useDidShow(() => {
getFlightList().catch(({ msg }) => {
if (msg) openToast('warn', msg);
});
});
</script>
<template>
<div :class="s.root">
<div class="list">
<div class="item" v-for="item in flightList" :key="item.id" :class="{ 'is-pass': item.isPass }">
<div class="title">
<span>{{ item.studentName || '-' }}</span>
<nut-button size="mini" type="info" @click="onNavTo(item.id)">回放</nut-button>
</div>
<div class="info">
<div class="info-row">
<span>班级:{{ item.className || '-' }}</span>
<span>无人机:{{ item.droneName || '-' }}</span>
</div>
<div class="info-row">
<span>教师:{{ item.teacherName || '-' }}</span>
</div>
<div class="info-row">
<span>场地:{{ item.airfieldName || '-' }}</span>
</div>
<div class="info-row">
<span>开始时间:{{ item.startTime || '-' }}</span>
</div>
<div class="info-row">
<span><nut-tag :type="item.isPass ? 'success' : 'danger'">{{ item.isPass ? '通过' : '未通过' }}</nut-tag></span>
<span>失败次数:{{ item.failTimes || 0 }}</span>
</div>
</div>
</div>
<nut-empty v-if="!loading && !flightList.length" description="暂无数据" />
<nut-infiniteloading
v-if="flightList.length"
load-txt="加载中..."
load-more-txt="没有更多了"
:has-more="flightList.length < flightExtra.total"
@load-more="onLoadMore"
/>
</div>
</div>
<nut-toast :msg="state.msg" v-model:visible="state.show" :type="state.type" :cover="state.cover" :duration="2000" />
</template>
<style lang="less" module="s">
page {
height: 100%;
padding: 20px 0;
box-sizing: border-box;
background-color: #eaeaea;
overflow: hidden;
}
.root {
height: 100%;
display: flex;
flex-direction: column;
:global {
.list {
flex: 1;
overflow: auto;
padding: 0 20px;
.item {
background-color: white;
border-radius: 16px;
padding: 28px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
cursor: pointer;
position: relative;
overflow: hidden;
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 6px;
height: 100%;
background-color: #4CAF50;
opacity: 0.8;
}
&:not(.is-pass)::before {
background-color: #FF5252;
}
&:hover {
transform: translateY(-4px);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
&:active {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}
& + .item {
margin-top: 28px;
}
.title {
font-size: 38px;
font-weight: 600;
margin-bottom: 24px;
display: flex;
justify-content: space-between;
align-items: center;
color: #2c3e50;
:global(.nut-button) {
font-size: 28px;
padding: 10px 24px;
border-radius: 8px;
background: rgba(74, 144, 226, 0.12);
color: #4a90e2;
border: none;
font-weight: 500;
transition: all 0.2s ease;
&:active {
transform: scale(0.96);
opacity: 0.9;
}
}
}
.info {
color: #666;
font-size: 28px;
line-height: 1.6;
.info-row {
display: flex;
justify-content: space-between;
margin-bottom: 16px;
padding-right: 12px;
&:last-child {
margin-bottom: 0;
}
span {
color: #34495e;
&:first-child {
color: #7f8c8d;
}
}
}
}
}
}
}
}
</style>