|
@@ -659,6 +659,19 @@
|
|
|
</template>
|
|
|
|
|
|
<view class="footer_btn">
|
|
|
+ <view
|
|
|
+ class="collect show"
|
|
|
+ @click="collect(collectList[bankIndex], bankIndex, bank)"
|
|
|
+ >
|
|
|
+ <view v-if="collectList[bankIndex]">
|
|
|
+ <image src="/static/icon/collected.png" mode=""></image>
|
|
|
+ <view>取消收藏</view>
|
|
|
+ </view>
|
|
|
+ <view v-if="!collectList[bankIndex]">
|
|
|
+ <image src="/static/icon/collect.png" mode=""></image>
|
|
|
+ <view>收藏</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
<view class="flex_center" @click="openFooterTab">
|
|
|
<view class="up-icon">
|
|
|
<image src="/static/up.png"></image>
|
|
@@ -709,7 +722,7 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- id: "",
|
|
|
+ examId: "",
|
|
|
current: 0,
|
|
|
questionList: [],
|
|
|
ast: ["A", "B", "C", "D", "E", "F", "G"],
|
|
@@ -721,13 +734,17 @@ export default {
|
|
|
goodsId: "",
|
|
|
explain: "",
|
|
|
orderGoodsId: "",
|
|
|
+ distinction: 1, // 1试卷归类,2题型归类
|
|
|
+ subjectType: 0, // 题目类型
|
|
|
};
|
|
|
},
|
|
|
onLoad(option) {
|
|
|
this.orderGoodsId = option.orderGoodsId || "";
|
|
|
- this.id = option.id;
|
|
|
- this.explain = option.explain;
|
|
|
-
|
|
|
+ const { examId, explain, type, distinction} = option
|
|
|
+ this.examId = examId
|
|
|
+ this.explain = explain
|
|
|
+ this.distinction = distinction
|
|
|
+ this.subjectType = type
|
|
|
let showDialog = uni.getStorageSync("showDialog");
|
|
|
|
|
|
if (showDialog) {
|
|
@@ -736,8 +753,11 @@ export default {
|
|
|
this.showDialog = true;
|
|
|
uni.setStorageSync("showDialog", "1");
|
|
|
}
|
|
|
-
|
|
|
+ if (this.distinction == 1) {
|
|
|
this.collectQuestionExamQuestionList();
|
|
|
+ } else {
|
|
|
+ this.goodsCollectList()
|
|
|
+ }
|
|
|
},
|
|
|
onUnload() {},
|
|
|
methods: {
|
|
@@ -750,10 +770,22 @@ export default {
|
|
|
collectQuestionExamQuestionList() {
|
|
|
this.$api
|
|
|
.collectQuestionExamQuestionList({
|
|
|
- examId: this.id,
|
|
|
+ examId: this.examId,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ this.analysteData(res.data.rows)
|
|
|
+ });
|
|
|
+ },
|
|
|
+ goodsCollectList() {
|
|
|
+ this.$api.goodsCollectList({
|
|
|
+ type: this.subjectType,
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- res.data.rows.forEach((item, index) => {
|
|
|
+ this.analysteData(res.data.rows)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ analysteData(rows) {
|
|
|
+ rows.forEach((item, index) => {
|
|
|
if (typeof item.jsonStr == "string") {
|
|
|
item.jsonStr = JSON.parse(item.jsonStr);
|
|
|
|
|
@@ -861,6 +893,12 @@ export default {
|
|
|
/<img/gi,
|
|
|
'<img style="max-width:100%;"'
|
|
|
));
|
|
|
+ if (this.distinction == 2) {
|
|
|
+ item.content && (item.content = item.content.replace(
|
|
|
+ /<img/gi,
|
|
|
+ '<img style="max-width:100%;"'
|
|
|
+ ));
|
|
|
+ }
|
|
|
if (this.explain) {
|
|
|
item.ques = item.ans;
|
|
|
}
|
|
@@ -887,8 +925,61 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- this.questionList = res.data.rows;
|
|
|
- });
|
|
|
+ this.questionList = rows;
|
|
|
+ // new Array(12).fill(true)
|
|
|
+ this.collectList = new Array(this.questionList.length).fill(true)
|
|
|
+ console.log('this.collectList', this.collectList)
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @param {Object} state
|
|
|
+ * @param {Object} index
|
|
|
+ * 收藏
|
|
|
+ */
|
|
|
+ collect(state, index, bank) {
|
|
|
+ console.log('0000', state, index, bank);
|
|
|
+ // return
|
|
|
+ if (!state) {
|
|
|
+ this.$api.collectQuestion({
|
|
|
+ examId: this.examId || bank.examId,
|
|
|
+ questionId: bank.questionId,
|
|
|
+ goodsId: bank.goodsId || "",
|
|
|
+ orderGoodsId: bank.orderGoodsId,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ this.$set(this.collectList, index, true);
|
|
|
+ uni.showToast({
|
|
|
+ title: "收藏成功",
|
|
|
+ duration: 2000,
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: "收藏失败",
|
|
|
+ duration: 2000,
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$api.deleteCollectQuestion(bank.collectQuestionId).then((res) => {
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ this.$set(this.collectList, index, false)
|
|
|
+ uni.showToast({
|
|
|
+ title: "取消收藏成功",
|
|
|
+ duration: 2000,
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: "取消收藏失败",
|
|
|
+ duration: 2000,
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return;
|
|
|
},
|
|
|
/**
|
|
|
* @param {Object} e单选点击
|