home.uvue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <cl-page>
  3. <img src="/static/home/2.png" alt="" class="w-full h-full object-cover">
  4. <!-- 精灵图动画 -->
  5. <cl-image src="/static/home/3.gif" mode="heightFix" class="!absolute bottom-0 left-0 !w-[44vh] !h-[55vh] z-[1]" />
  6. <!-- <view class="sprite-animation"></view> -->
  7. <view>
  8. </view>
  9. <cl-button @tap="handleLogin" class="!absolute top-10 left-10 z-[1]">登录</cl-button>
  10. <!-- 顶部右侧光标签 -->
  11. <view class="light-tag" @tap="visible = true">
  12. <image class="light-icon" :src="catalog?.fileList?.[0]?.url"></image>
  13. <text class="light-text">{{ catalog?.name }}</text>
  14. <cl-icon name="arrow-left-right-line" color="primary"></cl-icon>
  15. </view>
  16. <view class="boxs">
  17. <scroll-view class="scroll-view_H" direction="horizontal" :scroll-left="120" :show-scrollbar="false">
  18. <view class="scroll-view-item_H bg-[white]" v-for="course in catalog?.courseList || []" :key="course.id">
  19. <cl-image :src="course?.fileList?.[0]?.url" mode="heightFix"
  20. class="!w-full !h-[26vh] mb-[2px] rounded-xl"></cl-image>
  21. <text class="text-[16px] font-bold">{{
  22. course.mainTitle }}</text>
  23. <text class="text-[14px] text-[#666]">{{
  24. course.assistantTitle }}</text>
  25. <view>
  26. <Progress :progress="30" />
  27. </view>
  28. </view>
  29. </scroll-view>
  30. </view>
  31. <cl-popup v-model="visible" :show-header="false" direction="center" :size="500">
  32. <view class="p-4">
  33. <cl-row :gutter="0">
  34. <cl-col :span="6" v-for="item in dataList" :key="item.id" :pt="{
  35. className: '!p-2'
  36. }" @tap="handleSelect(item)">
  37. <view class="select-item" :class="{ selected: item.id === catalog?.id }">
  38. <image :src="item?.fileList?.[0]?.url" class="w-[30rpx] h-[30rpx] mb-[2px]"></image>
  39. <text>{{ item.name }}</text>
  40. </view>
  41. </cl-col>
  42. </cl-row>
  43. </view>
  44. </cl-popup>
  45. </cl-page>
  46. </template>
  47. <script lang="ts" setup>
  48. import { ref, onMounted } from 'vue'
  49. import { fetchSubjectConfigInfo } from '@/api/subject/info'
  50. import type { SubjectCatalogResult } from '@/api/subject/catalog'
  51. import Progress from './components/progress.uvue'
  52. function handleLogin() {
  53. uni.navigateTo({
  54. url: '/pages/user/login'
  55. })
  56. }
  57. const visible = ref<boolean>(false)
  58. const dataList = ref<SubjectCatalogResult[]>([])
  59. const catalog = ref<SubjectCatalogResult>()
  60. async function getDataList() {
  61. const res = await fetchSubjectConfigInfo({ id: '69afc7e048070409048c06b6' })
  62. dataList.value = res.catalogList || []
  63. catalog.value = res?.catalogList?.[0]
  64. }
  65. onMounted(() => {
  66. getDataList()
  67. })
  68. function handleSelect(item: SubjectCatalogResult) {
  69. catalog.value = item
  70. visible.value = false
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. .boxs {
  75. @apply w-[100vw] h-[50vh] absolute top-1/2 left-[50vh] z-[1];
  76. transform: translateY(-50%);
  77. }
  78. .scroll-view_H {
  79. width: 100%;
  80. flex-direction: row;
  81. }
  82. .scroll-view-item_H {
  83. @apply w-[40vh] h-[50vh] mr-[20px] rounded-2xl border-[5px] border-[#1D4BD9] border-solid border-b-[10px] p-1 flex items-center;
  84. }
  85. .light-tag {
  86. @apply absolute top-5 right-5 z-[1] flex flex-row items-center bg-white px-3 py-2 font-bold rounded-full shadow-md;
  87. .light-icon {
  88. width: 20px;
  89. height: 20px;
  90. margin-right: 3px;
  91. }
  92. .light-text {
  93. font-size: 16px;
  94. width: 70px;
  95. }
  96. }
  97. .select-item {
  98. @apply flex items-center justify-center rounded-xl border-[3px] border-[#1D4BD9] border-solid border-b-[5px] px-4 py-2 font-bold;
  99. }
  100. .selected {
  101. @apply border-green-500;
  102. }
  103. .sprite-animation {
  104. @apply absolute bottom-0 left-0 w-[42vh] h-[60vh] z-[1] bg-[url('https://oss.xiaoxiongcode.com/static/home/sprite.png')] bg-no-repeat;
  105. background-size: 1460% 1000%;
  106. background-position: 0 0;
  107. animation: sprite-animation 3s steps(13) infinite;
  108. }
  109. @keyframes sprite-animation {
  110. from {
  111. background-position: 0 0;
  112. }
  113. to {
  114. background-position: calc(-42vh * 13) 0;
  115. }
  116. }
  117. </style>