فهرست منبع

feat: 修复bug

huangziyang 1 هفته پیش
والد
کامیت
1f951897b5
7فایلهای تغییر یافته به همراه124 افزوده شده و 34 حذف شده
  1. 7 3
      components/Container/Container.vue
  2. 1 1
      components/Tree/Tree.vue
  3. 19 2
      pages/challenge/index.vue
  4. 3 1
      pages/challenge/registration.vue
  5. 53 10
      pages/learn/index.vue
  6. 16 4
      pages/real/history.vue
  7. 25 13
      utils/request.js

+ 7 - 3
components/Container/Container.vue

@@ -76,17 +76,16 @@ const props = defineProps({
   themeColor: {
     type: String,
     default: "#333",
-  }
+  },
 });
 
-const emit = defineEmits(["onSafeAreaChange", "onScroll"]);
+const emit = defineEmits(["onSafeAreaChange", "onScroll", "scrolltolower"]);
 
 const onBack = async () => {
   if (props.onBack) {
     const res = await props.onBack();
     if (!res) return;
     if (typeof res === "string") {
-      
       router.reLaunch(normalizeParams(res));
       return;
     }
@@ -168,6 +167,10 @@ watchEffect(() => {
   emit("onSafeAreaChange", safeArea.value);
 });
 
+const onScrolltolower = (e) => {
+  emit('scrolltolower', e)
+};
+
 const onScroll = debounce((e) => {
   emit("onScroll", e);
 }, 100);
@@ -210,6 +213,7 @@ defineExpose({
       :scroll-y="scrollY"
       :scroll-top="scrollTop"
       @scroll="onScroll"
+      @scrolltolower="onScrolltolower"
       :class="['scroll-view', scrollX ? 'topic-scroll' : '']"
       :style="{
         height: `calc(${

+ 1 - 1
components/Tree/Tree.vue

@@ -76,7 +76,7 @@ const emit = defineEmits(["onChnage", "onClickButton"]);
           <view
             @click="emit('onClickButton', items)"
             class="comment success"
-            v-if="items[keys.process] === 3"
+            v-if="items[keys.process] === 3 || items[keys.process] === 4"
             >已学习</view
           >
         </view>

+ 19 - 2
pages/challenge/index.vue

@@ -34,7 +34,7 @@ onShow(async () => {
   let res = {
     data: false,
   };
-  
+
   isPay.value = a === "" ? true : a;
   if (a === "") {
     isPay.value = true;
@@ -72,6 +72,23 @@ const toRule = () => {
 };
 
 const toAdd = async () => {
+  const isLogin = uni.getStorageSync("userLogin");
+  console.log(isLogin);
+
+  if (!isLogin) {
+    uni.showModal({
+      title: "请登录",
+      success(res) {
+        if (res.confirm) {
+          // 用户点击确定按钮
+          router.push({
+            url: "/pages/login/index",
+          });
+        }
+      },
+    });
+    return;
+  }
   router.push({
     url: !isPay.value
       ? "/pages/challenge/registration"
@@ -88,7 +105,7 @@ const toAdd = async () => {
 .bg {
   width: 100%;
   height: 1824rpx;
-  background: url("https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/Mta1ISg62sk0DW7GfkD2qGxwa0uQ2p4NH4gUC5op.png");
+  background: url("https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/mrFDMhG0TOSn9DcVQupf8b6w2UgGGhq6LhdfaZWn.png");
   background-size: cover;
   padding: 32rpx;
   box-sizing: border-box;

+ 3 - 1
pages/challenge/registration.vue

@@ -142,7 +142,9 @@ const onSubmit = async () => {
           uni.setStorageSync("pages/challenge/index", null);
         },
         fail(err) {
-          console.log(err);
+          router.push({
+            url: "/pages/success/error",
+          })
         },
         complete() {
           loading.value = false;

+ 53 - 10
pages/learn/index.vue

@@ -7,6 +7,7 @@
     }"
     :showBack="false"
     headerColor="#fff"
+    @scrolltolower="scrolltolower"
   >
     <div class="top">
       <div
@@ -118,6 +119,16 @@ const errorTotal = ref(0);
 const dataList = ref([]);
 const examList = ref([]);
 const favoriteList = ref([]);
+const pageParams = ref({
+  limit: 10,
+  page_num: 1,
+});
+const initPage = () => {
+  pageParams.value = {
+    limit: 10,
+    page_num: 1,
+  };
+};
 
 const toHistory = (item) => {
   router.push({
@@ -128,24 +139,40 @@ const toHistory = (item) => {
   });
 };
 
-const requestTopic = (is_correct, onSucess) => {
+const scrolltolower = (e) => {
+  pageParams.value.page_num += 1;
+  requestTopic(isRight.value);
+};
+
+const requestTopic = (is_correct) => {
+  const t = isRight.value ? rightTotal.value : errorTotal.value;
+  if (t < pageParams.value.limit * (pageParams.value.page_num - 1)) {
+    return;
+  }
   request(
     "api/question_bank/question_reception/study_book/get_answer_topic_record",
     {
       chapter_id: currentTab.value,
       is_correct,
+      showToast: false,
+      ...pageParams.value,
     }
   ).then((res) => {
-    if (onSucess) {
-      onSucess(res.data.data);
-      return;
+    let da = [];
+    if (pageParams.value.page_num !== 1) {
+      console.log(pageParams.value);
+
+      da = dataList.value;
     }
+    da.push(...res.data.data);
     if (is_correct) {
       rightTotal.value = res.data.total;
-      dataList.value = res.data.data;
     } else {
       errorTotal.value = res.data.total;
     }
+    if (isRight.value === is_correct) {
+      dataList.value = da;
+    }
   });
 };
 const requestExamList = () => {
@@ -156,13 +183,24 @@ const requestExamList = () => {
   });
 };
 const requestFavo = () => {
+  if (
+    info.value.favorite_total <
+    pageParams.value.limit * (pageParams.value.page_num - 1)
+  )
+    return;
   request(
     "api/question_bank/question_reception/favorite/get_user_favorite_list",
     {
       chapter_id: currentTab.value,
+      ...pageParams.value,
     }
   ).then((res) => {
-    favoriteList.value = res.data.data;
+    let da = [];
+    if (pageParams.value.page_num !== 1) {
+      da = favoriteList.value;
+    }
+    da.push(...res.data.data);
+    favoriteList.value = da;
   });
 };
 const toFavorite = () => {
@@ -175,6 +213,7 @@ const toFavorite = () => {
   });
 };
 watch([currentIndex, show], () => {
+  initPage();
   switch (currentIndex.value) {
     case 1:
       requestExamList();
@@ -187,6 +226,7 @@ watch([currentIndex, show], () => {
   }
 });
 watch([currentTab, show], () => {
+  initPage();
   switch (currentIndex.value) {
     case 0:
       isRight.value = 1;
@@ -204,10 +244,8 @@ watch([currentTab, show], () => {
   }
 });
 watch([isRight, show], () => {
-  dataList.value = [];
-  requestTopic(isRight.value, (data) => {
-    dataList.value = data;
-  });
+  initPage();
+  requestTopic(isRight.value);
 });
 onShow(() => {
   show.value = true;
@@ -221,6 +259,11 @@ onShow(() => {
 
 onHide(() => {
   show.value = false;
+  info.value = {};
+  dataList.value = [];
+  examList.value = [];
+  favoriteList.value = [];
+  initPage();
 });
 // 示例数据
 </script>

+ 16 - 4
pages/real/history.vue

@@ -12,15 +12,15 @@
     </view>
     <view class="exam-info">
       <view class="item">
-        <view class="score">100分</view>
+        <view class="score">{{t.total_score}}分</view>
         <view class="title">总分</view>
       </view>
       <view class="item">
-        <view class="score">100题</view>
+        <view class="score">{{t.topic_num}}题</view>
         <view class="title">题量</view>
       </view>
       <view class="item">
-        <view class="score">150分钟</view>
+        <view class="score">{{t.exam_time}}分钟</view>
         <view class="title">时长</view>
       </view>
     </view>
@@ -45,7 +45,7 @@
         >
           <view>{{ util.timestampToString_day(item.begin_time) }}</view>
           <view>{{ item.use_time }}分钟</view>
-          <view>{{ item.complete }}/100题</view>
+          <view>{{ item.complete }}/{{ item.total_real_topic }}题</view>
           <view class="score"
             >{{ item.score }}分<uni-icons type="right"
           /></view>
@@ -70,6 +70,11 @@ const userInfo = ref({
   userpic: "https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/uni@2x.png",
   username: "Hi, 这里是历史题库",
 });
+const t = ref({
+  total_score: 0,
+  topic_num: 0,
+  total_score: 0,
+})
 const list = ref([]);
 const onClick = (data = {}) => {
   router.push({
@@ -88,6 +93,13 @@ onShow(async () => {
       catalogue_id: getRoute().params.id, // 考试id
     }
   );
+  const r = await request(
+    "api/question_bank/question_reception/real_topic/get_real_paper_info",
+    {
+      catalogue_id: getRoute().params.id, // 考试id
+    }
+  );
+  t.value = r.data
   list.value = res.data;
   userInfo.value = uni.getStorageSync("userInfo");
 });

+ 25 - 13
utils/request.js

@@ -31,6 +31,7 @@ port = "wap";
 // #endif
 // domain = "https://openwork.dfwy.tech/";
 // 发送网络请求的函数
+let modal = null;
 export const request = (url, d = {}, method = "GET") => {
   let { showToast = true, ...data } = d;
   // 获取登录标识
@@ -42,8 +43,8 @@ export const request = (url, d = {}, method = "GET") => {
   if (shopId) data = Object.assign({ shop_id: shopId }, data);
   if (app_id) data = Object.assign({ app_id: app_id }, data);
   // 封装
-  return new Promise((resolve, reject) => {
-    uni.request({
+  return new Promise(async (resolve, reject) => {
+    await uni.request({
       url: domain + url,
       method: method,
       data: data,
@@ -55,17 +56,28 @@ export const request = (url, d = {}, method = "GET") => {
           // 清空用户信息
           uni.setStorageSync("userInfo", null);
           // 前去登录
-          uni.showModal({
-            title: "请登录",
-            success(res) {
-              if (res.confirm) {
-                // 用户点击确定按钮
-                router.push({
-                  url: "/pages/login/index",
-                });
-              }
-            },
-          });
+
+          if (!modal) {
+            modal = true;
+
+            uni.showModal({
+              title: "请登录",
+              success(res) {
+                if (res.confirm) {
+                  // 用户点击确定按钮
+                  router.push({
+                    url: "/pages/login/index",
+                  });
+                }
+              },
+              complete() {
+                setTimeout(() => {
+                  modal = false;
+                }, 1000);
+              },
+            });
+          }
+
           reject("请登录");
           return;
         }