123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- <template>
- <Container
- title="学习本"
- bgColor="#f8f8f8"
- :scrollStyle="{
- padding: 0,
- }"
- headerColor="#fff"
- >
- <div class="top">
- <div
- class="item col left"
- :class="currentIndex === 0 && 'select'"
- @click="currentIndex = 0"
- >
- <span>
- <span class="primary">{{ info.answer_total }}</span
- >/{{ info.topic_total }}
- </span>
- <span
- >正确率<span class="primary">{{ info.accuracy }}</span></span
- >
- </div>
- <div
- class="item"
- :class="currentIndex === 1 && 'select'"
- @click="currentIndex = 1"
- >
- 考试记录(<span class="primary">{{ info.real_paper_total }}</span
- >)
- </div>
- <div
- class="item right"
- :class="currentIndex === 2 && 'select'"
- @click="currentIndex = 2"
- >
- 题目收藏(<span class="primary">{{ info.favorite_total }}</span
- >)
- </div>
- </div>
- <div class="tab">
- <scroll-view class="scroll" scroll-x>
- <div class="box">
- <div
- v-for="(item, index) in info.chapter_infos"
- class="item"
- :class="{
- select: item.id === currentTab,
- }"
- :key="item.id"
- @click="
- () => {
- currentTab = item.id;
- }
- "
- >
- {{ item.name }}
- </div>
- </div>
- </scroll-view>
- <div class="select-line" v-if="currentIndex === 0">
- <div class="item" :class="{ select: isRight }" @click="isRight = 1">
- 答案正确({{ rightTotal }})
- </div>
- <div class="item" :class="{ select: !isRight }" @click="isRight = 0">
- 答案错误({{ errorTotal }})
- </div>
- </div>
- </div>
- <div class="context">
- <template v-if="currentIndex === 0 && dataList.length">
- <QuestionsItem :data="dataList" :isRight="isRight" />
- </template>
- <template v-else-if="currentIndex === 1 && examList.length">
- <div class="card" v-for="item in examList" :key="item.catalogue_id">
- <div class="card-header">
- <span class="title">{{ item.year }}年真题</span>
- <span class="exam-count">已考试{{ item.exam_count }}次</span>
- </div>
- <div class="card-body">
- <span>最低分:{{ item.min_score }}分</span>
- <span>最高分:{{ item.max_score }}分</span>
- </div>
- <div class="footer">
- <div class="c-primary" @click="toHistory(item)">再考一次</div>
- </div>
- </div>
- </template>
- <template v-else-if="currentIndex === 2 && favoriteList.length">
- <QuestionsItem
- :data="favoriteList"
- :isRight="isRight"
- :onClick="toFavorite"
- />
- </template>
- <Empty v-else text="暂无数据"></Empty>
- </div>
- </Container>
- </template>
- <script setup>
- import Container from "@/components/Container/Container.vue";
- import Empty from "@/components/Empty/Empty.vue";
- import { ref, watch } from "vue";
- import { onShow } from "@dcloudio/uni-app";
- import { request } from "../../utils/request";
- import QuestionsItem from "../../components/Topic/QuestionsItem.vue";
- import { router } from "../../utils/router";
- const currentIndex = ref(0);
- const currentTab = ref(0);
- const isRight = ref(1);
- const info = ref({});
- const rightTotal = ref(0);
- const errorTotal = ref(0);
- const dataList = ref([]);
- const examList = ref([]);
- const favoriteList = ref([]);
- const toHistory = (item) => {
- router.push({
- path: "/pages/real/history",
- query: {
- id: item.catalogue_id,
- },
- });
- };
- const requestTopic = (is_correct, onSucess) => {
- request(
- "api/question_bank/question_reception/study_book/get_answer_topic_record",
- {
- chapter_id: currentTab.value,
- is_correct,
- }
- ).then((res) => {
- if (onSucess) {
- onSucess(res.data.data);
- return;
- }
- if (is_correct) {
- rightTotal.value = res.data.total;
- dataList.value = res.data.data;
- } else {
- errorTotal.value = res.data.total;
- }
- });
- };
- const requestExamList = () => {
- request("api/question_bank/question_reception/real_topic/get_exam_record", {
- chapter_id: currentTab.value,
- }).then((res) => {
- examList.value = res.data;
- });
- };
- const requestFavo = () => {
- request(
- "api/question_bank/question_reception/favorite/get_user_favorite_list",
- {
- chapter_id: currentTab.value,
- }
- ).then((res) => {
- favoriteList.value = res.data.data;
- });
- };
- const toFavorite = (item) => {
- console.log(item);
- };
- watch(currentIndex, () => {
- switch (currentIndex.value) {
- case 1:
- requestExamList();
- break;
- case 2:
- requestFavo();
- break;
- default:
- break;
- }
- });
- watch(currentTab, () => {
- switch (currentIndex.value) {
- case 0:
- isRight.value = 1;
- requestTopic(isRight.value);
- requestTopic(Number(!isRight.value));
- break;
- case 1:
- requestExamList();
- break;
- case 2:
- requestFavo();
- break;
- default:
- break;
- }
- });
- watch(isRight, () => {
- dataList.value = [];
- requestTopic(isRight.value, (data) => {
- dataList.value = data;
- });
- });
- onShow(() => {
- request(
- "api/question_bank/question_reception/study_book/get_study_record_title"
- ).then((res) => {
- info.value = res.data;
- currentTab.value = res.data.chapter_infos[0].id;
- });
- });
- // 示例数据
- </script>
- <style scoped lang="scss">
- @import "@/uni.scss";
- .primary {
- color: $primary;
- }
- .top {
- margin: 24rpx 32rpx 0;
- display: grid;
- grid-template-columns: repeat(3, 1fr);
- .item {
- border: 1px solid $primary;
- display: flex;
- align-items: center;
- justify-content: center;
- height: 113rpx;
- background-color: #fff;
- font-weight: 500;
- font-size: 24rpx;
- color: #333333;
- }
- .item.col {
- flex-direction: column;
- gap: 12rpx;
- }
- .item.left {
- border-top-left-radius: 24rpx;
- }
- .item.right {
- border-top-right-radius: 24rpx;
- }
- .select {
- border-color: #fff;
- }
- }
- .tab {
- background-color: #fff;
- .select-line {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- .item {
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 28rpx;
- border-bottom: 1px solid #fff;
- font-weight: 500;
- font-size: 32rpx;
- }
- .item.select {
- color: $primary;
- border-color: $primary;
- }
- }
- }
- .scroll {
- white-space: nowrap;
- font-weight: 500;
- font-size: 32rpx;
- color: #333333;
- .box {
- padding: 30rpx;
- }
- .item {
- display: inline-flex;
- padding: 8rpx 36rpx;
- }
- .item.select {
- border-radius: 200rpx;
- background-color: $primary;
- color: #fff;
- }
- }
- .context {
- padding: 20rpx 32rpx;
- display: flex;
- flex-direction: column;
- gap: 16rpx;
- .card {
- border-radius: 16rpx;
- padding: 16rpx;
- background-color: #fff;
- display: flex;
- flex-direction: column;
- .question-header {
- display: flex;
- justify-content: space-between;
- margin-bottom: 12rpx;
- color: #999;
- .question-type {
- font-weight: 500;
- font-size: 32rpx;
- color: #999999;
- border-radius: 8rpx 8rpx 8rpx 8rpx;
- border: 1rpx solid #dddddd;
- padding: 0 10rpx;
- }
- .question-date {
- color: #999;
- font-size: 24rpx;
- }
- }
- .question-text {
- font-size: 28rpx;
- color: #333;
- margin-bottom: 16rpx;
- }
- .options {
- margin-top: 8rpx;
- .option {
- display: flex;
- align-items: center;
- margin-bottom: 12rpx;
- gap: 14rpx;
- .option-select {
- width: 51rpx;
- height: 51rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- border: 1rpx solid #dddddd;
- border-radius: 50%;
- }
- }
- }
- .footer {
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .card-header {
- display: flex;
- justify-content: space-between;
- margin-bottom: 12rpx;
- .title {
- font-weight: bold;
- font-size: 28rpx;
- color: #333;
- }
- .exam-count {
- color: #999;
- font-size: 24rpx;
- }
- }
- .card-body {
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-weight: 500;
- font-size: 28rpx;
- color: #000000;
- }
- }
- }
- .c-primary {
- padding: 2rpx 10rpx;
- border-radius: 4rpx;
- border: 1rpx solid $primary;
- color: $primary;
- font-size: 24rpx;
- }
- .c-error {
- padding: 2rpx 10rpx;
- border-radius: 4rpx;
- border: 1rpx solid $error;
- color: $error;
- font-size: 24rpx;
- }
- </style>
|