123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- <script setup>
- import Questions from "./QuestionsItemSelect.vue";
- import uvParse from "@/uni_modules/uv-parse/components/uv-parse/uv-parse.vue";
- import { ref, watchEffect } from "vue";
- const dataList = ref([]);
- const props = defineProps({
- data: {
- type: Array,
- default: () => [],
- },
- isRight: {
- type: Boolean,
- default: true,
- },
- onClick: {
- type: Function,
- },
- });
- const TopicMapList = ["A", "B", "C", "D", "E"];
- watchEffect(() => {
- dataList.value = props.data.map((item, ind) => {
- let questions = [];
- const ans = item.correct_answer.split(",");
- const ansList = [];
- for (let i = 0; i < item.question_count; i++) {
- const current = TopicMapList[i];
- if (ans.includes(current)) {
- ansList.push({
- label: current,
- value: i,
- });
- }
- const v =
- item[`select_${current.toLowerCase()}`].replace(/<br\s*\/?>/g, "") ||
- "";
- questions.push({
- label: v,
- value: current,
- checked: false,
- index: i,
- });
- }
- return {
- ...item,
- questions, // 题目
- ansList, // 正确答案
- selectAns: !item.user_answer ? [] : item.user_answer.split(","), // 选择的答案
- isRight: !!item.is_correct, // 是否正确
- isImage: item.title.includes("<img"),
- ind,
- };
- });
- console.log(dataList.value);
- });
- const handleClick = (item) => {
- if (props.onClick) {
- props.onClick(item);
- return;
- }
- console.log(item);
- };
- </script>
- <template>
- <!-- 问题内容 -->
- <view
- class="topic-content"
- v-for="(item, parindex) in dataList"
- :key="parindex"
- v-if="dataList.length"
- >
- <uvParse
- v-if="item.isImage"
- :content="item.title"
- class="question-text"
- ></uvParse>
- <rich-text v-else :nodes="item.title" class="question-text"></rich-text>
- <uvParse
- :content="item.questions_ex"
- v-if="item.style === 6 && item.isImage"
- class="question-text"
- ></uvParse>
- <rich-text
- v-else
- :nodes="item.questions_ex"
- class="question-text"
- :style="{
- lineHeight: 2,
- }"
- ></rich-text>
- <questions
- v-if="item.style !== 6"
- v-for="(question, index) in item.questions"
- :key="index"
- :answerList="item.ansList"
- :index="index"
- :styleCount="item.style"
- :question="question"
- :showResult="item.showResult"
- :parindex="parindex"
- />
- <view class="other" v-else>
- <questions
- v-for="(question, index) in item.questions"
- :key="index"
- :answerList="item.ansList"
- :index="index"
- :styleCount="item.style"
- :question="question"
- :showResult="item.showResult"
- :parindex="parindex"
- />
- </view>
- <div class="footer">
- <view v-if="isRight" class="c-primary" @click="handleClick(item)">{{
- onClick ? "答题" : "查看"
- }}</view>
- <view v-else class="c-error" @click="handleClick(item)">重做</view>
- </div>
- </view>
- </template>
- <style lang="scss" scoped>
- @import "@/uni.scss";
- .other {
- display: flex;
- gap: 12px;
- margin-top: 20rpx;
- }
- .footer {
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .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;
- }
- .content {
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 28rpx;
- color: #333333;
- display: flex;
- flex-direction: column;
- gap: 24rpx;
- padding: 0 30rpx;
- .ques-type {
- display: flex;
- gap: 16rpx;
- flex-direction: column;
- }
- }
- .grid {
- display: grid;
- grid-template-columns: repeat(5, 1fr);
- gap: 12px;
- }
- .bottom-modal {
- display: flex;
- flex-direction: column;
- gap: 20rpx;
- // padding: 20rpx;
- }
- .title {
- display: flex;
- justify-content: center;
- align-items: center;
- position: relative;
- .closeempty {
- position: absolute;
- right: 0;
- }
- }
- .parsing-text {
- height: 381rpx;
- white-space: normal;
- }
- .answer-content {
- display: flex;
- flex-direction: column;
- gap: 45rpx;
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 32rpx;
- color: #666666;
- }
- .topic-container {
- width: 100vw;
- overflow: hidden;
- position: relative;
- }
- .topic-item {
- display: flex;
- flex-direction: column;
- gap: 12px;
- position: relative;
- box-sizing: border-box;
- }
- .topic-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .topic-header-left {
- display: flex;
- gap: 8px;
- align-items: center;
- }
- .item {
- width: 72rpx;
- height: 72rpx;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- border: 1rpx solid #dddddd;
- &.success {
- border-color: $primary;
- color: $primary;
- }
- }
- .topic-type {
- border: 1px solid $uni-primary;
- padding: 0 8px;
- border-radius: 6px;
- color: $uni-primary;
- font-weight: 600;
- font-size: 14px;
- }
- .topic-count {
- color: #333;
- font-size: 14px;
- }
- .topic-content {
- display: flex;
- flex-direction: column;
- gap: 8px;
- background-color: #fff;
- margin-top: 16rpx;
- padding: 24rpx;
- border-radius: 16rpx;
- }
- .question-text {
- font-weight: bold;
- font-size: 14px;
- white-space: normal;
- }
- .answer-section {
- border-radius: 16rpx;
- border: 1px solid #ddd;
- padding: 24rpx;
- display: flex;
- flex-direction: column;
- gap: 32rpx;
- }
- .answer-row {
- font-size: 14px;
- display: flex;
- align-items: center;
- gap: 12px;
- }
- .answer-item {
- display: flex;
- gap: 8px;
- align-items: center;
- padding-right: 12px;
- }
- .tip {
- margin-left: auto;
- }
- .border-r-primary {
- border-right: 2px solid $uni-primary;
- }
- .answer-text {
- color: $uni-primary;
- }
- .button-group {
- display: flex;
- gap: 8px;
- position: sticky;
- bottom: 0;
- margin-top: auto;
- }
- .prev-btn {
- flex: 1;
- background-color: $uni-primary-light;
- color: $uni-primary;
- }
- .next-btn {
- flex: 1;
- background-color: $uni-primary;
- color: #fff;
- }
- .star-icon {
- display: flex;
- flex-direction: column;
- align-items: center;
- font-weight: 500;
- font-size: 20rpx;
- color: #000000;
- }
- </style>
|