index.uvue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <script lang="ts" setup>
  2. import Loading from '@/components/loading.uvue'
  3. import Back from '@/components/back.uvue'
  4. import { ref, onMounted } from 'vue'
  5. import { querySubjectInfo, querySubjectInfoNoLogin, querySubjectUnit } from '@/services/subject/info'
  6. import type { SubjectInfoResult } from '@/services/subject/info'
  7. import { router, debounce, user, dict } from "@/.cool";
  8. const isLoading = ref(true)
  9. const dataList = ref<any[]>([])
  10. const unitType = ref('course_unit')
  11. const visible = ref(false)
  12. const unitTypeMap = dict.getLabelByValueMapByType('subject_unit_type')
  13. console.log(unitTypeMap);
  14. async function getDataList() {
  15. const res = await querySubjectUnit({
  16. subjectId: '69c49329091547710d451f9d',
  17. unitType: unitType.value,
  18. })
  19. dataList.value = res || []
  20. }
  21. onMounted(async () => {
  22. try {
  23. await getDataList()
  24. isLoading.value = false
  25. } catch (err) {
  26. console.log(err);
  27. isLoading.value = false
  28. }
  29. })
  30. function handleDetail(item: any) {
  31. if (user.token === 'Basic ZW5kOmVuZA==') {
  32. router.push({
  33. path: "/pages/user/login",
  34. });
  35. return
  36. }
  37. router.push({
  38. path: "/pages/practice/detail",
  39. query: {
  40. num: item.sortNum,
  41. unitType: unitType.value,
  42. }
  43. });
  44. }
  45. async function handleSelect(val: any) {
  46. unitType.value = val
  47. visible.value = false
  48. await getDataList()
  49. }
  50. </script>
  51. <template>
  52. <Loading v-show="isLoading" />
  53. <cl-page v-show="!isLoading">
  54. <view class="video-fullscreen_title">
  55. <Back />
  56. <view class="text-[20px] font-bold text-white">
  57. 单元练习
  58. </view>
  59. </view>
  60. <image mode="aspectFill" src="https://oss.xiaoxiongcode.com/static/home/2.jpg" alt=""
  61. class="w-full h-full object-cover" />
  62. <view class="light-tag" @tap="visible = true">
  63. <text class="light-text text-[#000]">{{ unitTypeMap[unitType] }}</text>
  64. <cl-icon name="arrow-left-right-line" color="primary"></cl-icon>
  65. </view>
  66. <!-- 顶部右侧光标签 -->
  67. <view class="boxs">
  68. <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false" ref="cardsScrollView">
  69. <view class="scroll-view-item_H bg-[white]" v-for="course in dataList || []" :key="course.id"
  70. @tap="handleDetail(course)">
  71. <cl-image :src="course?.unitPicPath" mode="heightFix"
  72. class="!w-full !h-[30vh] mb-[10px] rounded-xl"></cl-image>
  73. <text class="text-[4vh] font-bold text-[#000]">{{ course.sortNum }} 、{{
  74. course.name }}</text>
  75. </view>
  76. </scroll-view>
  77. </view>
  78. <cl-popup v-model="visible" :show-header="false" direction="center" :size="600">
  79. <view class="p-4">
  80. <cl-row :gutter="0">
  81. <cl-col :span="8" v-for="(label, value) in unitTypeMap || []" :key="value" :pt="{
  82. className: '!p-2'
  83. }" @tap="handleSelect(value)">
  84. <view class="select-item" :class="{ selected: value == unitType }">
  85. <text class="text-[#000]">{{ label }}</text>
  86. </view>
  87. </cl-col>
  88. </cl-row>
  89. </view>
  90. </cl-popup>
  91. </cl-page>
  92. </template>
  93. <style lang="scss" scoped>
  94. .boxs {
  95. @apply w-[calc(100vw-100px)] h-[50vh] absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[1];
  96. }
  97. .video-fullscreen_title {
  98. @apply absolute top-3 left-0 pl-[80px] w-[100vw] z-10 flex items-center justify-between flex-row;
  99. color: #fff;
  100. }
  101. .scroll-view_H {
  102. width: 100%;
  103. height: 100%;
  104. flex-direction: row;
  105. }
  106. .scroll-view-item_H {
  107. @apply w-[50vh] h-[50vh] mr-[20px] rounded-2xl border-[5px] border-[#1D4BD9] border-solid border-b-[10px] p-1 flex items-center relative;
  108. }
  109. .light-tag {
  110. @apply absolute top-3 left-1/2 z-[111] flex flex-row items-center bg-white px-3 py-2 font-bold rounded-full shadow-md;
  111. transform: translateX(-50%);
  112. .light-icon {
  113. width: 20px;
  114. height: 20px;
  115. margin-right: 3px;
  116. }
  117. .light-text {
  118. font-size: 16px;
  119. min-width: 100px;
  120. padding-right: 5px;
  121. }
  122. }
  123. .select-item {
  124. @apply flex items-center justify-center rounded-xl border-[3px] border-[#1D4BD9] border-solid border-b-[5px] px-4 py-2 font-bold;
  125. }
  126. .selected {
  127. @apply border-green-500;
  128. }
  129. .footer {
  130. @apply absolute bottom-2 right-5 z-[1] flex flex-row items-center justify-center gap-4;
  131. }
  132. .text-stroke-custom {
  133. color: white;
  134. text-shadow:
  135. /* 左上角投影 */
  136. -1px -1px 0 #1D4BD9,
  137. /* 右上角投影 */
  138. 1px -1px 0 #1D4BD9,
  139. /* 左下角投影 */
  140. -1px 1px 0 #1D4BD9,
  141. /* 右下角投影 */
  142. 1px 1px 0 #1D4BD9;
  143. }
  144. </style>