index.uvue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <script lang="ts" setup>
  2. import { user } from '@/.cool'
  3. import { ref, onMounted, computed } from 'vue'
  4. import { fetchSubjectConfigInfo } from '@/services/subject/info'
  5. import type { SubjectCatalogResult } from '@/services/subject/catalog'
  6. import Progress from '../catalog/components/progress.uvue'
  7. import Back from '@/components/back.uvue'
  8. import Lock from '@/components/lock.uvue'
  9. import Loading from '@/components/loading.uvue'
  10. import { config } from '@/config'
  11. import { router } from "@/.cool";
  12. import { dict } from '@/.cool/store'
  13. const isLoading = ref(true)
  14. const visible = ref<boolean>(false)
  15. const dataList = ref<SubjectCatalogResult[]>([])
  16. const catalog = ref<SubjectCatalogResult>()
  17. const record = ref<any>()
  18. async function getDataList() {
  19. const id = dict.getValueByLabelMapByType('index_subject_id')['语文']
  20. const res = await fetchSubjectConfigInfo({ id })
  21. record.value = res
  22. dataList.value = res.catalogList || []
  23. catalog.value = res?.catalogList?.[0]
  24. }
  25. const userInfo = computed(() => user.info.value?.userInfo)
  26. onMounted(async () => {
  27. try {
  28. await getDataList()
  29. isLoading.value = false
  30. } catch (err) {
  31. console.log(err);
  32. isLoading.value = false
  33. }
  34. })
  35. function handleSelect(item: SubjectCatalogResult) {
  36. catalog.value = item
  37. visible.value = false
  38. }
  39. function handleDetail(item: SubjectCatalogResult) {
  40. if (!item.payFlag && !item.trialPlay) {
  41. uni.showToast({
  42. title: '请先购买',
  43. icon: 'none'
  44. })
  45. return
  46. }
  47. router.push({
  48. path: "/pages/english/detail",
  49. query: {
  50. id: item.id,
  51. }
  52. });
  53. }
  54. </script>
  55. <template>
  56. <Loading v-show="isLoading" />
  57. <cl-page v-show="!isLoading">
  58. <Back />
  59. <image mode="aspectFill" src="https://oss.xiaoxiongcode.com/static/语文/图层 4.png" alt="" class="w-full h-full object-cover" />
  60. <!-- 精灵图动画 -->
  61. <cl-image src="https://oss.xiaoxiongcode.com/static/home/3.gif" mode="heightFix"
  62. class="!absolute bottom-0 left-0 !w-[44vh] !h-[55vh] z-[1]" />
  63. <view>
  64. </view>
  65. <!-- 顶部右侧光标签 -->
  66. <view class="light-tag" @tap="visible = true">
  67. <image class="light-icon" v-if="catalog?.fileList?.[0]?.url" :src="config.baseUrl + catalog?.fileList?.[0]?.url">
  68. </image>
  69. <text class="light-text">{{ catalog?.name }}</text>
  70. <cl-icon name="arrow-left-right-line" color="primary"></cl-icon>
  71. </view>
  72. <view class="boxs">
  73. <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false">
  74. <view class="scroll-view-item_H bg-[white]" v-for="course in catalog?.courseList || []" :key="course.id"
  75. @tap="handleDetail(course)">
  76. <cl-image :src="config.baseUrl + course?.fileList?.[0]?.url" mode="heightFix"
  77. class="!w-full !h-[26vh] mb-[2px] rounded-xl"></cl-image>
  78. <text class="text-[16px] font-bold">{{
  79. course.mainTitle }}</text>
  80. <text class="text-[14px] text-[#666]">{{
  81. course.assistantTitle }}</text>
  82. <!-- <view>
  83. <Progress :progress="30" />
  84. </view> -->
  85. <Lock v-if="userInfo?.memberLevel === 'default'" :record="course" type="vip"/>
  86. </view>
  87. </scroll-view>
  88. </view>
  89. <!-- <view class="footer">
  90. <view>
  91. <cl-image src="https://oss.xiaoxiongcode.com/static/home/4.png" mode="heightFix"
  92. class=" !h-[40px] mb-[2px] rounded-xl"></cl-image>
  93. <text class="text-[14px] text-white font-bold text-stroke-custom">虚拟实验</text>
  94. </view>
  95. <view>
  96. <cl-image src="https://oss.xiaoxiongcode.com/static/home/5.png" mode="heightFix"
  97. class=" !h-[40px] mb-[2px] rounded-xl"></cl-image>
  98. <text class="text-[14px] text-white font-bold text-stroke-custom">我的收获</text>
  99. </view>
  100. <view>
  101. <cl-image src="https://oss.xiaoxiongcode.com/static/home/6.png" mode="heightFix"
  102. class=" !h-[40px] mb-[2px] rounded-xl"></cl-image>
  103. <text class="text-[14px] text-white font-bold text-stroke-custom">学习报告</text>
  104. </view>
  105. </view> -->
  106. <cl-popup v-model="visible" :show-header="false" direction="center" :size="600">
  107. <view class="p-4">
  108. <cl-row :gutter="0">
  109. <cl-col :span="6" v-for="item in dataList || []" :key="item.id" :pt="{
  110. className: '!p-2'
  111. }" @tap="handleSelect(item)">
  112. <view class="select-item" :class="{ selected: item.id === catalog?.id }">
  113. <image :src="config.baseUrl + item?.fileList?.[0]?.url" class="w-[30rpx] h-[30rpx] mb-[2px]"></image>
  114. <text>{{ item.name }}</text>
  115. </view>
  116. </cl-col>
  117. </cl-row>
  118. </view>
  119. </cl-popup>
  120. </cl-page>
  121. </template>
  122. <style lang="scss" scoped>
  123. .boxs {
  124. @apply w-[100vw] h-[50vh] absolute top-1/2 left-[50vh] z-[1];
  125. transform: translateY(-50%);
  126. }
  127. .scroll-view_H {
  128. width: 100%;
  129. height: 100%;
  130. flex-direction: row;
  131. }
  132. .scroll-view-item_H {
  133. @apply w-[40vh] h-[50vh] mr-[20px] rounded-2xl border-[5px] border-[#1D4BD9] border-solid border-b-[10px] p-1 flex items-center justify-between pb-[20px];
  134. }
  135. .light-tag {
  136. @apply absolute top-3 left-1/2 z-[1] flex flex-row items-center bg-white px-3 py-2 font-bold rounded-full shadow-md;
  137. transform: translateX(-50%);
  138. .light-icon {
  139. width: 20px;
  140. height: 20px;
  141. margin-right: 3px;
  142. }
  143. .light-text {
  144. font-size: 16px;
  145. min-width: 100px;
  146. padding-right: 5px;
  147. }
  148. }
  149. .select-item {
  150. @apply flex items-center justify-center rounded-xl border-[3px] border-[#1D4BD9] border-solid border-b-[5px] px-4 py-2 font-bold;
  151. }
  152. .selected {
  153. @apply border-green-500;
  154. }
  155. .footer {
  156. @apply absolute bottom-2 right-5 z-[1] flex flex-row items-center justify-center gap-4;
  157. }
  158. .text-stroke-custom {
  159. color: white;
  160. text-shadow:
  161. /* 左上角投影 */
  162. -1px -1px 0 #1D4BD9,
  163. /* 右上角投影 */
  164. 1px -1px 0 #1D4BD9,
  165. /* 左下角投影 */
  166. -1px 1px 0 #1D4BD9,
  167. /* 右下角投影 */
  168. 1px 1px 0 #1D4BD9;
  169. }
  170. </style>