schedule-card.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <script setup lang="ts">
  2. import SectionHeading from '@/components/section-heading.vue'
  3. import { scheduleCardBg } from '../../../core/libs/pngs'
  4. import { group } from 'radash'
  5. import dayjs from 'dayjs'
  6. import ImageEvo from '@/components/image-evo.vue'
  7. import { useRouter } from '../../../core/utils/router'
  8. const props = withDefaults(
  9. defineProps<{
  10. customClass?: string
  11. items?: {
  12. createTime: any
  13. updateTime: any
  14. creator: any
  15. updater: any
  16. deleted: any
  17. id: any
  18. studyId: number
  19. travelDate: any
  20. travelTime: number
  21. title: string
  22. travelDesc: string
  23. clockExplainDesc: string
  24. clockExplainUrl: string
  25. }[]
  26. }>(),
  27. {
  28. items: () => [],
  29. },
  30. )
  31. const router = useRouter()
  32. const data = ref()
  33. const imgDisplayed = ref(false)
  34. const schedules = computed(() =>
  35. group(props.items, (it) => dayjs(it?.travelTime).format('YYYY-MM-DD')),
  36. )
  37. const currentSchedule = computed(() => schedules.value[dayjs().format('YYYY-MM-DD')])
  38. const pull = () => {
  39. data.value = currentSchedule.value.slice(0, 3)
  40. }
  41. const push = () => {
  42. data.value = currentSchedule.value.slice(0, 2)
  43. }
  44. const handleClick = async () => {
  45. router.push('/pages/home/schedule/index')
  46. }
  47. const handleImgDisplayed = () => {
  48. setTimeout(() => (imgDisplayed.value = true), 300)
  49. }
  50. onMounted(() => {
  51. push()
  52. })
  53. </script>
  54. <template>
  55. <view class="flex flex-col items-center aspect-[1.28/1]" :class="[customClass]">
  56. <SectionHeading title="我的游学日程" custom-class="w-full"></SectionHeading>
  57. <div
  58. class="w-full my-3.5 text-[#acacac] text-sm font-normal font-['PingFang_SC'] leading-normal"
  59. >
  60. <!-- 6月26日 第二天 -->
  61. {{ dayjs().format('M月D日') }}
  62. 第{{ Object.keys(schedules).findIndex((it) => it === dayjs().format('YYYY-MM-DD')) + 1 }}天
  63. </div>
  64. <div
  65. class="w-80 bg-gradient-to-r from-[#141414] to-[#4b4949] rounded-tl-2xl rounded-tr-2xl p-6 box-border"
  66. >
  67. <template v-for="(it, index) in data" :key="index">
  68. <view class="relative mb-4">
  69. <view class="flex items-center">
  70. <div class="w-2 h-2 left-0 top-0 rounded-full border-2 border-solid border-white"></div>
  71. <div
  72. class="w-12 ml-3.5 text-white text-base font-normal font-['PingFang_SC'] leading-normal"
  73. >
  74. <!-- 9:00 -->
  75. {{ dayjs(it?.travelTime).format('HH:mm') }}
  76. </div>
  77. <div class="text-white text-base font-normal font-['PingFang_SC'] leading-normal">
  78. <!-- 早稻田大学课程 -->
  79. {{ it?.title }}
  80. </div>
  81. </view>
  82. <div class="ml-6.5 text-white/40 text-sm font-normal font-['PingFang_SC'] leading-normal">
  83. <!-- 学习灯光设计师课程 -->
  84. {{ it?.travelDesc }}
  85. </div>
  86. <div
  87. v-if="index !== data?.length - 1"
  88. class="absolute left-1.25 top-6 bottom--4 border border-dashed border-gray bg-gray-500"
  89. ></div>
  90. </view>
  91. </template>
  92. </div>
  93. <view class="w-full relative bottom-7 mb--9">
  94. <div class="aspect-[2.55/1]">
  95. <ImageEvo :src="scheduleCardBg" @displayed="handleImgDisplayed"></ImageEvo>
  96. </div>
  97. <view
  98. class="absolute bottom-0 left-0 right-0 px-3.5 py-7 flex flex-col items-center"
  99. v-show="imgDisplayed"
  100. >
  101. <wd-icon
  102. custom-class="relative bottom-6"
  103. :name="data?.length > 2 ? 'arrow-up' : 'arrow-down'"
  104. size="22px"
  105. color="#4f4f4f"
  106. @click="data?.length > 2 ? push() : pull()"
  107. ></wd-icon>
  108. <view class="w-full duration-800">
  109. <wd-button block size="large" custom-class="rd!" @click="handleClick">
  110. 查看全部行程
  111. </wd-button>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. </template>