|
|
@@ -6,7 +6,7 @@
|
|
|
<ie-navbar title="收藏夹" />
|
|
|
</template>
|
|
|
<view v-for="item in list" :key="item.id">
|
|
|
- <question-book-item :data="item" @correct="handleCorrect" @cancelCollect="handleCancelCollect" />
|
|
|
+ <question-book-item :data="item" @correct="handleCorrect" @toggleCollect="handleToggleCollect" />
|
|
|
</view>
|
|
|
</z-paging>
|
|
|
<question-correct-popup ref="questionCorrectPopupRef" />
|
|
|
@@ -24,7 +24,7 @@ import useQuestionBook from '@/composables/useQuestionBook';
|
|
|
const list = ref<Study.FavoriteQuestionVO[]>([]);
|
|
|
const paging = ref<ZPagingInstance>();
|
|
|
const questionCorrectPopupRef = ref();
|
|
|
-const { cancelCollect, isOptionCorrect, isOptionSelected } = useQuestionBook();
|
|
|
+const { isOptionCorrect, isOptionSelected, cancelCollect, collect, } = useQuestionBook();
|
|
|
|
|
|
const transfomeToQuestionBookVO = (list: Study.FavoriteQuestion[]): Study.FavoriteQuestionVO[] => {
|
|
|
const orders = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
|
|
|
@@ -48,7 +48,7 @@ const transfomeToQuestionBookVO = (list: Study.FavoriteQuestion[]): Study.Favori
|
|
|
title: item.title,
|
|
|
options: options,
|
|
|
answers: [], // 收藏下没有答案
|
|
|
- answer: decodeHtmlEntities(item.answer1 || ''),
|
|
|
+ answer: decodeHtmlEntities(item.answer2 || ''),
|
|
|
qtype: item.qtpye,
|
|
|
typeId: item.typeId,
|
|
|
parse: decodeHtmlEntities(item.parse || ''),
|
|
|
@@ -68,19 +68,27 @@ const handleQuery = (page: number, size: number) => {
|
|
|
option.isIncorrect = !option.isCorrect && option.isSelected;
|
|
|
});
|
|
|
});
|
|
|
- console.log(data)
|
|
|
paging.value?.completeByTotal(data, res.total);
|
|
|
});
|
|
|
};
|
|
|
const handleCorrect = (question: Study.FavoriteQuestionVO) => {
|
|
|
questionCorrectPopupRef.value.open(question.id);
|
|
|
}
|
|
|
-const handleCancelCollect = (question: Study.FavoriteQuestionVO) => {
|
|
|
- cancelCollect(question.id).then(res => {
|
|
|
- if (res) {
|
|
|
- paging.value?.refresh();
|
|
|
- }
|
|
|
- });
|
|
|
+const handleToggleCollect = (question: Study.FavoriteQuestionVO) => {
|
|
|
+ if (question.collect) {
|
|
|
+ cancelCollect(question.id).then(res => {
|
|
|
+ if (res) {
|
|
|
+ paging.value?.refresh();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ collect(question.id).then(res => {
|
|
|
+ if (res) {
|
|
|
+ paging.value?.refresh();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
</script>
|
|
|
|