diff --git a/.nuxt/components.d.ts b/.nuxt/components.d.ts index 3f0b56b..5cc791c 100644 --- a/.nuxt/components.d.ts +++ b/.nuxt/components.d.ts @@ -37,16 +37,16 @@ declare module 'vue' { 'PlayerAudio': typeof import("../components/Player/Audio.vue")['default'], 'PlayerLive': typeof import("../components/Player/Live.vue")['default'], 'PlayerVideo': typeof import("../components/Player/Video.vue")['default'], - 'UiImage': typeof import("../components/Ui/Image.vue")['default'], - 'UiMenu': typeof import("../components/Ui/Menu.vue")['default'], - 'UiMenuItem': typeof import("../components/Ui/MenuItem.vue")['default'], - 'UiTab': typeof import("../components/Ui/Tab.vue")['default'], - 'UiTabItem': typeof import("../components/Ui/TabItem.vue")['default'], 'UserBuyList': typeof import("../components/User/BuyList.vue")['default'], 'UserCouponList': typeof import("../components/User/CouponList.vue")['default'], 'UserFavaList': typeof import("../components/User/FavaList.vue")['default'], 'UserHistoryList': typeof import("../components/User/HistoryList.vue")['default'], 'UserTestList': typeof import("../components/User/TestList.vue")['default'], + 'UiImage': typeof import("../components/Ui/Image.vue")['default'], + 'UiMenu': typeof import("../components/Ui/Menu.vue")['default'], + 'UiMenuItem': typeof import("../components/Ui/MenuItem.vue")['default'], + 'UiTab': typeof import("../components/Ui/Tab.vue")['default'], + 'UiTabItem': typeof import("../components/Ui/TabItem.vue")['default'], 'UiCardBody': typeof import("../components/Ui/Card/Body.vue")['default'], 'UiCardFooter': typeof import("../components/Ui/Card/Footer.vue")['default'], 'UiCardHeader': typeof import("../components/Ui/Card/Header.vue")['default'], @@ -94,16 +94,16 @@ declare module 'vue' { 'LazyPlayerAudio': typeof import("../components/Player/Audio.vue")['default'], 'LazyPlayerLive': typeof import("../components/Player/Live.vue")['default'], 'LazyPlayerVideo': typeof import("../components/Player/Video.vue")['default'], - 'LazyUiImage': typeof import("../components/Ui/Image.vue")['default'], - 'LazyUiMenu': typeof import("../components/Ui/Menu.vue")['default'], - 'LazyUiMenuItem': typeof import("../components/Ui/MenuItem.vue")['default'], - 'LazyUiTab': typeof import("../components/Ui/Tab.vue")['default'], - 'LazyUiTabItem': typeof import("../components/Ui/TabItem.vue")['default'], 'LazyUserBuyList': typeof import("../components/User/BuyList.vue")['default'], 'LazyUserCouponList': typeof import("../components/User/CouponList.vue")['default'], 'LazyUserFavaList': typeof import("../components/User/FavaList.vue")['default'], 'LazyUserHistoryList': typeof import("../components/User/HistoryList.vue")['default'], 'LazyUserTestList': typeof import("../components/User/TestList.vue")['default'], + 'LazyUiImage': typeof import("../components/Ui/Image.vue")['default'], + 'LazyUiMenu': typeof import("../components/Ui/Menu.vue")['default'], + 'LazyUiMenuItem': typeof import("../components/Ui/MenuItem.vue")['default'], + 'LazyUiTab': typeof import("../components/Ui/Tab.vue")['default'], + 'LazyUiTabItem': typeof import("../components/Ui/TabItem.vue")['default'], 'LazyUiCardBody': typeof import("../components/Ui/Card/Body.vue")['default'], 'LazyUiCardFooter': typeof import("../components/Ui/Card/Footer.vue")['default'], 'LazyUiCardHeader': typeof import("../components/Ui/Card/Header.vue")['default'], @@ -153,16 +153,16 @@ export const LoadingSkeleton: typeof import("../components/Loading/Skeleton.vue" export const PlayerAudio: typeof import("../components/Player/Audio.vue")['default'] export const PlayerLive: typeof import("../components/Player/Live.vue")['default'] export const PlayerVideo: typeof import("../components/Player/Video.vue")['default'] -export const UiImage: typeof import("../components/Ui/Image.vue")['default'] -export const UiMenu: typeof import("../components/Ui/Menu.vue")['default'] -export const UiMenuItem: typeof import("../components/Ui/MenuItem.vue")['default'] -export const UiTab: typeof import("../components/Ui/Tab.vue")['default'] -export const UiTabItem: typeof import("../components/Ui/TabItem.vue")['default'] export const UserBuyList: typeof import("../components/User/BuyList.vue")['default'] export const UserCouponList: typeof import("../components/User/CouponList.vue")['default'] export const UserFavaList: typeof import("../components/User/FavaList.vue")['default'] export const UserHistoryList: typeof import("../components/User/HistoryList.vue")['default'] export const UserTestList: typeof import("../components/User/TestList.vue")['default'] +export const UiImage: typeof import("../components/Ui/Image.vue")['default'] +export const UiMenu: typeof import("../components/Ui/Menu.vue")['default'] +export const UiMenuItem: typeof import("../components/Ui/MenuItem.vue")['default'] +export const UiTab: typeof import("../components/Ui/Tab.vue")['default'] +export const UiTabItem: typeof import("../components/Ui/TabItem.vue")['default'] export const UiCardBody: typeof import("../components/Ui/Card/Body.vue")['default'] export const UiCardFooter: typeof import("../components/Ui/Card/Footer.vue")['default'] export const UiCardHeader: typeof import("../components/Ui/Card/Header.vue")['default'] @@ -210,16 +210,16 @@ export const LazyLoadingSkeleton: typeof import("../components/Loading/Skeleton. export const LazyPlayerAudio: typeof import("../components/Player/Audio.vue")['default'] export const LazyPlayerLive: typeof import("../components/Player/Live.vue")['default'] export const LazyPlayerVideo: typeof import("../components/Player/Video.vue")['default'] -export const LazyUiImage: typeof import("../components/Ui/Image.vue")['default'] -export const LazyUiMenu: typeof import("../components/Ui/Menu.vue")['default'] -export const LazyUiMenuItem: typeof import("../components/Ui/MenuItem.vue")['default'] -export const LazyUiTab: typeof import("../components/Ui/Tab.vue")['default'] -export const LazyUiTabItem: typeof import("../components/Ui/TabItem.vue")['default'] export const LazyUserBuyList: typeof import("../components/User/BuyList.vue")['default'] export const LazyUserCouponList: typeof import("../components/User/CouponList.vue")['default'] export const LazyUserFavaList: typeof import("../components/User/FavaList.vue")['default'] export const LazyUserHistoryList: typeof import("../components/User/HistoryList.vue")['default'] export const LazyUserTestList: typeof import("../components/User/TestList.vue")['default'] +export const LazyUiImage: typeof import("../components/Ui/Image.vue")['default'] +export const LazyUiMenu: typeof import("../components/Ui/Menu.vue")['default'] +export const LazyUiMenuItem: typeof import("../components/Ui/MenuItem.vue")['default'] +export const LazyUiTab: typeof import("../components/Ui/Tab.vue")['default'] +export const LazyUiTabItem: typeof import("../components/Ui/TabItem.vue")['default'] export const LazyUiCardBody: typeof import("../components/Ui/Card/Body.vue")['default'] export const LazyUiCardFooter: typeof import("../components/Ui/Card/Footer.vue")['default'] export const LazyUiCardHeader: typeof import("../components/Ui/Card/Header.vue")['default'] diff --git a/.nuxt/imports.d.ts b/.nuxt/imports.d.ts index d3a45a0..bfc7a5b 100644 --- a/.nuxt/imports.d.ts +++ b/.nuxt/imports.d.ts @@ -2,15 +2,16 @@ export { useHead, useMeta } from '#head'; export { isVue2, isVue3 } from 'vue-demi'; export { useAsyncData, useLazyAsyncData, refreshNuxtData, defineNuxtComponent, useNuxtApp, defineNuxtPlugin, useRuntimeConfig, useState, useFetch, useLazyFetch, useCookie, useRequestHeaders, useRequestEvent, useRouter, useRoute, useActiveRoute, defineNuxtRouteMiddleware, navigateTo, abortNavigation, addRouteMiddleware, throwError, clearError, useError, defineNuxtLink } from '#app'; export { withCtx, withDirectives, withKeys, withMemo, withModifiers, withScopeId, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onServerPrefetch, onUnmounted, onUpdated, computed, customRef, isProxy, isReactive, isReadonly, isRef, markRaw, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, watch, watchEffect, isShallow, effect, effectScope, getCurrentScope, onScopeDispose, defineComponent, defineAsyncComponent, resolveComponent, getCurrentInstance, h, inject, nextTick, provide, useAttrs, useCssModule, useCssVars, useSlots, useTransitionState } from 'vue'; -export { useUser, useRefreshUserInfo, useLogout, useHasAuth, useHandleSupportPost } from 'E:/WebProject/nuxt3-edu/composables/useAuth'; +export { usePostSupportApi, useDeletePostApi } from 'E:/WebProject/nuxt3-edu/apis/bbs'; export { fetchConfig, useHttp, useHttpGet, useHttpPost } from 'E:/WebProject/nuxt3-edu/composables/useHttp'; +export { useUser, useRefreshUserInfo, useLogout, useHasAuth, useHandleSupportPost } from 'E:/WebProject/nuxt3-edu/composables/useAuth'; export { usePage } from 'E:/WebProject/nuxt3-edu/composables/usePage'; export { useQueryToString, useEnterEvent, useTimeStatus } from 'E:/WebProject/nuxt3-edu/composables/useUtil'; -export { usePostSupportApi, useDeletePostApi } from 'E:/WebProject/nuxt3-edu/apis/bbs'; export { useSearchListApi, useCouponListApi, useListApi, useReadDetailApi } from 'E:/WebProject/nuxt3-edu/apis/common'; +export { usecourseListApi, useReadCourseApi, useHotCourseListApi, useLearnApi } from 'E:/WebProject/nuxt3-edu/apis/course'; export { useBookMenusApi, useBookDetailApi } from 'E:/WebProject/nuxt3-edu/apis/book'; +export { useSubmitTestApi, useReadTestPaperApi } from 'E:/WebProject/nuxt3-edu/apis/test'; export { useGetGoodsInfoApi, useGetUseableUserCouponApi, useCreateOrderApi, useWxpayApi, useGetWxpayStatusApi, useGetGroupWorkListApi } from 'E:/WebProject/nuxt3-edu/apis/order'; -export { usecourseListApi, useReadCourseApi, useHotCourseListApi, useLearnApi } from 'E:/WebProject/nuxt3-edu/apis/course'; export { useIndexDataApi, useGroupDataApi } from 'E:/WebProject/nuxt3-edu/apis/index'; export { useLoginApi, useGetinfoApi, useRegApi, useLogoutApi, useGetCaptchaApi, useBindPhoneApi, useForgetApi, useUserHistoryApi, useOrderListApi, useUserTestApi, useMypostListApi, useUserCouponApi, useMyFavaListApi, useUncollectApi, useUpdateUserInfoApi, useUploadConfig, useUpdatePasswordApi, useCollectApi, useReceiveUserCouponApi } from 'E:/WebProject/nuxt3-edu/apis/user'; export { definePageMeta } from 'E:/WebProject/nuxt3-edu/node_modules/nuxt/dist/pages/runtime/composables'; diff --git a/.nuxt/types/auto-imports.d.ts b/.nuxt/types/auto-imports.d.ts index 8d81f80..528fb6d 100644 --- a/.nuxt/types/auto-imports.d.ts +++ b/.nuxt/types/auto-imports.d.ts @@ -109,6 +109,7 @@ declare global { const useQueryToString: typeof import('../../composables/useUtil')['useQueryToString'] const useReadCourseApi: typeof import('../../apis/course')['useReadCourseApi'] const useReadDetailApi: typeof import('../../apis/common')['useReadDetailApi'] + const useReadTestPaperApi: typeof import('../../apis/test')['useReadTestPaperApi'] const useReceiveUserCouponApi: typeof import('../../apis/user')['useReceiveUserCouponApi'] const useRefreshUserInfo: typeof import('../../composables/useAuth')['useRefreshUserInfo'] const useRegApi: typeof import('../../apis/user')['useRegApi'] @@ -120,6 +121,7 @@ declare global { const useSearchListApi: typeof import('../../apis/common')['useSearchListApi'] const useSlots: typeof import('vue')['useSlots'] const useState: typeof import('../../node_modules/nuxt/dist/app')['useState'] + const useSubmitTestApi: typeof import('../../apis/test')['useSubmitTestApi'] const useTimeStatus: typeof import('../../composables/useUtil')['useTimeStatus'] const useTransitionState: typeof import('vue')['useTransitionState'] const useUncollectApi: typeof import('../../apis/user')['useUncollectApi'] @@ -253,6 +255,7 @@ declare module '@vue/runtime-core' { readonly useQueryToString: UnwrapRef readonly useReadCourseApi: UnwrapRef readonly useReadDetailApi: UnwrapRef + readonly useReadTestPaperApi: UnwrapRef readonly useReceiveUserCouponApi: UnwrapRef readonly useRefreshUserInfo: UnwrapRef readonly useRegApi: UnwrapRef @@ -264,6 +267,7 @@ declare module '@vue/runtime-core' { readonly useSearchListApi: UnwrapRef readonly useSlots: UnwrapRef readonly useState: UnwrapRef + readonly useSubmitTestApi: UnwrapRef readonly useTimeStatus: UnwrapRef readonly useTransitionState: UnwrapRef readonly useUncollectApi: UnwrapRef diff --git a/apis/test.js b/apis/test.js new file mode 100644 index 0000000..81a17e9 --- /dev/null +++ b/apis/test.js @@ -0,0 +1,11 @@ +//交卷 /pc/user_test/save +export function useSubmitTestApi(body) { + return useHttpPost("SubmitTest", "user_test/save", { + body, + }); +} + +//开始考试 /pc/testpaper/read?id=12 +export function useReadTestPaperApi(id) { + return useHttpPost("ReadTestPaper", "/testpaper/read?id="+id); + } \ No newline at end of file diff --git a/pages/paper_test/[id].vue b/pages/paper_test/[id].vue index f5d71d4..119c912 100644 --- a/pages/paper_test/[id].vue +++ b/pages/paper_test/[id].vue @@ -36,7 +36,7 @@
- 交 卷 + 交 卷
@@ -54,81 +54,11 @@ import { createDiscreteApi } from "naive-ui" -const data = ref({ - "id": 12, - "title": "测试试卷111", - "total_score": 100, - "pass_score": 60, - "expire": 60, - "testpaper_questions": [ - { - "id": 42, - "score": 25, - "question_id": 73, - "title": "说说你的看法", - "remark": "问题解析", - "type": "answer", - "user_value": [ - "" - ] - }, - { - "id": 43, - "score": 25, - "question_id": 72, - "title": "请问我年龄多大", - "remark": "问题解析", - "type": "completion", - "user_value": [ - "", - ] - }, - { - "id": 44, - "score": 0, - "question_id": 71, - "title": "请问我是男生还是女生", - "remark": "问题解析", - "type": "trueOrfalse", - "options": [ - "正确", - "错误" - ], - "user_value": -1 - }, - { - "id": 45, - "score": 25, - "question_id": 70, - "title": "

你的名字叫什么

", - "remark": "问题解析", - "type": "checkbox", - "options": [ - "张三", - "李四", - "王五", - "王五哈" - ], - "user_value": [] - }, - { - "id": 46, - "score": 25, - "question_id": 65, - "title": "你的名字叫什么", - "remark": "问题解析", - "type": "checkbox", - "options": [ - "张三", - "李四", - "王五", - "王五哈" - ], - "user_value": [] - } - ], - "user_test_id": 7 -}) +const route = useRoute() + +let { data } = useReadDetailApi(route.params.id) + + // 题目列表 const testpaper_questions = computed(() => { @@ -194,4 +124,35 @@ onBeforeRouteLeave((to, from, next) => { }) + +//交卷 +const loading = ref(false) +async function submit() { + const { message } = createDiscreteApi(["message"]) + let l = (testpaper_questions.value.fliter(v => !v.isTest)).length + if (l > 0) { + return message.warning("还有题目没完成,请检查~") + } + loading.value = true + const { + data: submitData, + error: submitError, + } = await useSubmitTestApi({ + user_test_id: data.user_test_id, + value: testpaper_questions.value.map(o => o.value) + }) + loading.value = false + + if(submitError.value) return + + //跳转前先把disabled_PageBack设置为false + disabled_PageBack.value = false; + message.success("交卷成功(^-^)V") + navigateTo(`/paper/1`,{ + replace:true + }) +} + +//自动交卷 +