408249787@qq.com 1 неделя назад
Родитель
Сommit
0f569eb24c
3 измененных файлов с 23 добавлено и 12 удалено
  1. 15 1
      pages/index/components/physics.uvue
  2. 5 11
      pages/practice/index.uvue
  3. 3 0
      services/subject/info.ts

+ 15 - 1
pages/index/components/physics.uvue

@@ -7,6 +7,20 @@ const visible = ref(false)
 function handleView(url) {
   router.push({ path: url })
 }
+function handleViewPractice() {
+  if (user.token == 'Basic ZW5kOmVuZA==') {
+    uni.showToast({
+      title: '请先登录',
+      icon: 'none'
+    })
+    router.push({
+      path: "/pages/user/login",
+    });
+    return
+  }
+  router.push({ path: '/pages/practice/index' })
+}
+
 function openPopup() {
   visible.value = true
 }
@@ -23,7 +37,7 @@ function openPopup() {
     </view>
     <view class=" box">
       <image class=" w-full  h-[15vw]" mode="heightFix" src="https://oss.xiaoxiongcode.com/static/home/761.png"
-        lazy-load @tap="handleView('/pages/practice/index')" />
+        lazy-load @tap="handleViewPractice" />
       <image class=" w-full h-[15vw]" mode="heightFix" src="https://oss.xiaoxiongcode.com/static/home/762.png" lazy-load
         @tap="handleView('/pages/test/index')" />
     </view>

+ 5 - 11
pages/practice/index.uvue

@@ -2,7 +2,7 @@
 import Loading from '@/components/loading.uvue'
 import Back from '@/components/back.uvue'
 import { ref, onMounted } from 'vue'
-import { querySubjectInfo, querySubjectInfoNoLogin } from '@/services/subject/info'
+import { querySubjectInfo, querySubjectInfoNoLogin, querySubjectUnit } from '@/services/subject/info'
 import type { SubjectInfoResult } from '@/services/subject/info'
 import { router, debounce, user } from "@/.cool";
 
@@ -10,15 +10,8 @@ const isLoading = ref(true)
 const dataList = ref<any[]>([])
 
 async function getDataList() {
-  const filePath = 'https://oss.xiaoxiongcode.com/physics-unit-practice/unit-pic.txt'
-  uni.request({
-    url: filePath,
-    method: 'GET',
-    success: (res) => {
-      dataList.value = res.data as any[]
-      console.log(dataList.value)
-    }
-  })
+  const res = await querySubjectUnit()
+  dataList.value = res || []
 }
 onMounted(async () => {
   try {
@@ -61,7 +54,8 @@ function handleDetail(item: any) {
       <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false" ref="cardsScrollView">
         <view class="scroll-view-item_H bg-[white]" v-for="course in dataList || []" :key="course.id"
           @tap="handleDetail(course)">
-          <cl-image :src="course?.ossPath" mode="heightFix" class="!w-full !h-[30vh] mb-[10px] rounded-xl"></cl-image>
+          <cl-image :src="course?.unitPicPath" mode="heightFix"
+            class="!w-full !h-[30vh] mb-[10px] rounded-xl"></cl-image>
           <text class="text-[4vh] font-bold">{{ course.sortNum }} 、{{
             course.name }}</text>
         </view>

+ 3 - 0
services/subject/info.ts

@@ -58,3 +58,6 @@ export function querySubjectInfo(parameter: any) {
 export function querySubjectInfoNoLogin(parameter: any) {
     return useGet(`/subject/info/no/login`, parameter) as Promise<SubjectInfoResult[]>
 }
+export function querySubjectUnit() {
+    return useGet(`/subject/unit`) as Promise<any[]>
+}