import OHeader from '@/components/m-header'; import OSticky from '@/components/m-sticky'; import OEmpty from '@/components/m-empty'; import dayjs from 'dayjs'; import { DatePicker, Popup, List, Image, CellGroup, Cell } from 'vant'; import OFullRefresh from '@/components/m-full-refresh'; import DetailItem from './modals/detail-item'; import { defineComponent, onMounted, reactive, ref, nextTick } from 'vue'; import { useRoute } from 'vue-router'; import styles from './exercis-detail.module.less'; import request from '@/helpers/request'; import iconStudent from '@common/images/icon-student.png'; import iconData from './images/icon-data.png'; import { useRect } from '@vant/use'; import { formatterDatePicker } from '@/helpers/utils'; import { useEventListener, useWindowScroll } from '@vueuse/core'; import { state as baseState } from '@/state'; import iconClock from './images/icon-clock.png'; import iconDays from './images/icon-days.png'; export default defineComponent({ name: 'exercis-detail', setup() { const route = useRoute(); const state = reactive({ showPopoverTime: false, currentDate: [dayjs().format('YYYY'), dayjs().format('MM')], isClick: false, background: 'transparent', practiceMonthName: route.query.practiceMonthName ? route.query.practiceMonthName : dayjs().format('YYYY') + '年' + dayjs().format('MM') + '月' }); const forms = reactive({ practiceMonth: route.query.practiceMonth ? route.query.practiceMonth : state.currentDate[0] + '' + state.currentDate[1], page: 1, rows: 20 }); const refreshing = ref(false); const loading = ref(false); const finished = ref(false); const showContact = ref(false); const infoDetail = ref({} as any); const list = ref([]); const getList = async () => { if (state.isClick) { return; } state.isClick = true; if (refreshing.value) { list.value = []; forms.page = 1; refreshing.value = false; } try { const res = await request.post(`/edu-app/musicPracticeRecord/page`, { data: { ...forms, feature: 'EVALUATION' } }); if (list.value.length > 0 && res.data.current === 1) { return; } list.value = list.value.concat(res.data.rows || []); forms.page = res.data.current + 1; showContact.value = list.value.length > 0; loading.value = false; finished.value = res.data.current >= res.data.pages; } catch { showContact.value = false; finished.value = true; } state.isClick = false; }; const getDetail = async () => { try { const res = await request.get(`/edu-app/student/detail`, { params: { id: baseState.user.data?.id } }); infoDetail.value = { ...res.data }; } catch (e: any) {} }; const topWrap = ref(); const topWrapHeight = ref(0); onMounted(async () => { useEventListener(document, 'scroll', () => { const { y } = useWindowScroll(); if (y.value > 52) { state.background = '#fff'; // state.color = '#323333'; } else { state.background = 'transparent'; // state.color = '#fff'; } }); await getList(); await getDetail(); nextTick(() => { const { height } = useRect(topWrap.value); topWrapHeight.value = height; }); }); const checkTimer = (val: any) => { forms.practiceMonth = val.selectedValues[0] + val.selectedValues[1]; state.practiceMonthName = val.selectedValues[0] + '年' + val.selectedValues[1] + '月'; state.showPopoverTime = false; refreshing.value = true; getList(); }; const onRefresh = () => { finished.value = false; // 重新加载数据 // 将 loading 设置为 true,表示处于加载状态 loading.value = true; getList(); }; return () => ( <>
{infoDetail.value.nickname}
{infoDetail.value.practiceDays ? infoDetail.value.practiceDays : 0} {/* 天 */}
练习天数(天)
{infoDetail.value.practiceTimes ? Math.floor(infoDetail.value.practiceTimes / 60) : 0} {/* 分钟 */}
练习时长(分钟)