提交 0e4967b2 编写于 作者: yi.li's avatar yi.li

Merge branch 'dev-question-bank-0916' of...

Merge branch 'dev-question-bank-0916' of 192.168.110.53:com.pica.cloud.education.frontend/pica-professional-exam into dev-question-bank-0916
<template> <template>
<div class="no-question-wrapper"> <div class="no-question-wrapper">
<img v-if="dataType == 1" src="../../images/question/no-error.png" alt=""> <img v-if="commitKind == 1" src="../../images/question/no-error.png" alt="">
<img v-else-if="dataType == 2" src="../../images/question/no-collect.png" alt=""> <img v-else-if="commitKind == 2" src="../../images/question/no-collect.png" alt="">
<img v-else src="../../images/question/no-collect.png" alt=""> <img v-else src="../../images/question/no-collect.png" alt="">
<span>{{dataType == 1 ? "您答错的题目会自动记录在这里哦!" : dataType == 2 ? "您收藏的题目会自动记录在这里哦!" : "现在没有题目哦!"}}</span> <span>{{commitKind == 1 ? "您答错的题目会自动记录在这里哦!" : commitKind == 2 ? "您收藏的题目会自动记录在这里哦!" : "现在没有题目哦!"}}</span>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
props: { props: {
dataType: { // 答题来源 1:错题集 2:收藏 3:题库 commitKind: { // 答题来源 1:错题集 2:收藏 3:题库
type: Number | String, type: Number | String,
default: 1 default: 1
} }
......
...@@ -17,9 +17,7 @@ ...@@ -17,9 +17,7 @@
v-for="(item, index) in currentQuestion.options" v-for="(item, index) in currentQuestion.options"
:key="index" :key="index"
> >
<span v-if="!item.isSelected" class="option">{{getOrderVac(index)}}.</span> <span class="option">{{getOrderVac(index)}}.</span>
<img v-if="item.isSelected && item.isCorrect" src="../../images/question/correct.png" alt />
<img v-if="item.isSelected && !item.isCorrect" src="../../images/question/error.png" alt />
<span class="content">{{item.text}}</span> <span class="content">{{item.text}}</span>
</div> </div>
</article> </article>
...@@ -29,15 +27,22 @@ ...@@ -29,15 +27,22 @@
<span class="type" :class="{'multi': currentQuestion.typeId == 2}"> <span class="type" :class="{'multi': currentQuestion.typeId == 2}">
<span>{{currentQuestion.typeId == 1 ? "单选题" : "多选题"}}</span> <span>{{currentQuestion.typeId == 1 ? "单选题" : "多选题"}}</span>
</span> </span>
<span class="content">{{currentQuestion.question}}</span> <span class="content" v-html="currentQuestion.question"></span>
<img src="https://files.yunqueyi.com/image/png/protal/project/20200702161856970.png" /> <!-- <img src="https://files.yunqueyi.com/image/png/protal/project/20200702161856970.png" /> -->
</article> </article>
<article class="select-wrapper"> <article class="select-wrapper">
<div class="item" v-for="(item, index) in currentQuestion.options" :key="index" @click="selectOption(index)"> <div class="item" v-for="(item, index) in currentQuestion.options" :key="index" @click="selectOption(index)">
<span v-if="!item.isSelected" class="option border">{{getOrderVac(index)}}</span> <span v-if="!item.isSelected" class="option border">{{getOrderVac(index)}}</span>
<span v-if="item.isSelected && !currentQuestion.commitFlag" class="option bg">{{getOrderVac(index)}}</span>
<template v-else>
<img v-if="item.isSelected && item.isCorrect" src="../../images/question/correct.png" alt /> <img v-if="item.isSelected && item.isCorrect" src="../../images/question/correct.png" alt />
<img v-if="item.isSelected && !item.isCorrect" src="../../images/question/error.png" alt /> <img v-if="item.isSelected && !item.isCorrect" src="../../images/question/error.png" alt />
<span </template>
<span v-if="!currentQuestion.commitFlag"
class="content"
:class="{'select': item.isSelected}"
>{{currentQuestion.unionType == 2 ? getOrderVac(index) : item.text}}</span>
<span v-else
class="content" class="content"
:class="{'select': item.isSelected && item.isCorrect, 'error': item.isSelected && !item.isCorrect}" :class="{'select': item.isSelected && item.isCorrect, 'error': item.isSelected && !item.isCorrect}"
>{{currentQuestion.unionType == 2 ? getOrderVac(index) : item.text}}</span> >{{currentQuestion.unionType == 2 ? getOrderVac(index) : item.text}}</span>
...@@ -56,11 +61,11 @@ ...@@ -56,11 +61,11 @@
<span class="content">查看病理,了解病史</span> <span class="content">查看病理,了解病史</span>
</div>--> </div>-->
</article> </article>
<article class="c-btn-wrapper" v-show="currentQuestion.typeId == 2"> <article class="c-btn-wrapper" v-show="currentQuestion.typeId == 2 && !currentQuestion.commitFlag" @click="commitAnswer">
<van-button size="large" round color="#449284">确 认</van-button> <van-button size="large" round color="#449284">确 认</van-button>
</article> </article>
<article class="answer-wrapper" v-show="currentQuestion.isAnalyzed || currentQuestion.myAnswer"> <article class="answer-wrapper" v-show="currentQuestion.isAnalyzed || currentQuestion.commitFlag">
<span class="content">正确答案:D</span> <span class="content">正确答案:{{currentQuestion.answer}}</span>
</article> </article>
<article class="analysis-wrapper" v-show="currentQuestion.isAnalyzed"> <article class="analysis-wrapper" v-show="currentQuestion.isAnalyzed">
<span class="title">解析</span> <span class="title">解析</span>
...@@ -71,22 +76,8 @@ ...@@ -71,22 +76,8 @@
<script> <script>
import commonSpliteLine from "@/components/common/common-splite-line"; import commonSpliteLine from "@/components/common/common-splite-line";
import { mapGetters, mapActions } from "vuex"; import { mapGetters, mapActions } from "vuex";
let orderVac = [ import { getOrderText } from "@/utils";
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N"
];
export default { export default {
components: { components: {
commonSpliteLine commonSpliteLine
...@@ -101,7 +92,6 @@ export default { ...@@ -101,7 +92,6 @@ export default {
...mapGetters([ ...mapGetters([
"questionList", "questionList",
"currentQuestion", "currentQuestion",
"currentQuestionIndex",
]) ])
}, },
data() { data() {
...@@ -115,29 +105,38 @@ export default { ...@@ -115,29 +105,38 @@ export default {
}, },
methods: { methods: {
getOrderVac(index) { getOrderVac(index) {
return orderVac[index]; return getOrderText(index);
}, },
// 选择选项 // 选择选项
selectOption(index) { selectOption(index) {
if(this.currentQuestion.commitFlag) return;
// 只记录当前选项,不提交答案 // 只记录当前选项,不提交答案
this.currentQuestion.options[index].selected = true; this.currentQuestion.options[index].isSelected = true;
if(this.currentQuestion.typeId == 2) {
// 重新设置答案(myAnswer) // 重新设置答案(myAnswer)
if(this.currentQuestion.typeId == 2) {
let myAnswer = ""; let myAnswer = "";
this.currentQuestion.options.forEach( (item, index) => { this.currentQuestion.options.forEach( (item, index) => {
if(item.selected) { if(item.isSelected) {
myAnswer += this.getOrderVac(index); myAnswer += this.getOrderVac(index);
} }
}) })
myAnswer = myAnswer.split('').join(','); myAnswer = myAnswer.split('').join(',');
this.currentQuestion.myAnswer = myAnswer; this.currentQuestion.myAnswer = myAnswer;
} else { } else {
// 单选题直接设置commitFlag
if(this.currentQuestion.options[index].isCorrect) {
this.currentQuestion.commitFlag = 1;
} else {
this.currentQuestion.commitFlag = 2;
}
this.currentQuestion.myAnswer = this.getOrderVac(index); this.currentQuestion.myAnswer = this.getOrderVac(index);
this.commit(); this.commitAnswer();
} }
this.$forceUpdate();
console.log("in commit", this.currentQuestion.myAnswer); console.log("in commit", this.currentQuestion.myAnswer);
}, },
commit() { commitAnswer() {
let params = { let params = {
commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库 commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库
directoryId: 0, // 题库ID directoryId: 0, // 题库ID
...@@ -147,7 +146,8 @@ export default { ...@@ -147,7 +146,8 @@ export default {
resultId: 1, // 刷题库轮次ID,刷收藏和错题集时为0 resultId: 1, // 刷题库轮次ID,刷收藏和错题集时为0
rightFlag: 1, // 答题对错:1对 2错 rightFlag: 1, // 答题对错:1对 2错
titleId: 1, // 题目ID titleId: 1, // 题目ID
} };
this.currentQuestion.commitFlag = 1;
} }
} }
}; };
...@@ -186,15 +186,18 @@ export default { ...@@ -186,15 +186,18 @@ export default {
background: #e6a23c; background: #e6a23c;
} }
} }
.content { .content {
font-size: 16px; font-size: 16px;
font-weight: 700; font-weight: 700;
color: #333333; color: #333333;
// & > img {
// margin-top: 15px !important;
// width: 100% !important;
// }
} }
& > img { img {
margin-top: 15px; margin-top: 15px !important;
width: 100%; width: 100% !important;
} }
} }
.select-wrapper { .select-wrapper {
...@@ -218,6 +221,11 @@ export default { ...@@ -218,6 +221,11 @@ export default {
border: 1px solid #c7c8c9; border: 1px solid #c7c8c9;
border-radius: 50%; border-radius: 50%;
} }
&.bg {
color: #fff;
background: #449284;
border-radius: 50%;
}
} }
& > img { & > img {
width: 18px; width: 18px;
......
...@@ -10,25 +10,43 @@ ...@@ -10,25 +10,43 @@
<span class="text">收藏</span> <span class="text">收藏</span>
</article> </article>
<article class="right"> <article class="right">
<span class="pre" :class="{'disabled': currentQuestionIndex == 0}" @click="previous">上一题</span> <span class="pre" :class="{'disabled': currentQuestion.titleNo == 1}" @click="previous">上一题</span>
<span class="next" @click="next">下一题</span> <span class="next" :class="{'disabled': currentQuestion.titleNo == totalCount}" @click="next">下一题</span>
</article> </article>
</section> </section>
</template> </template>
<script> <script>
import { Toast } from "vant"; import { Toast } from "vant";
import { mapGetters, mapActions } from "vuex"; import { mapGetters, mapActions } from "vuex";
import { findQuestionIndexNo } from "@/utils";
export default { export default {
props: {}, props: {},
data() { data() {
return {}; return {
queryParams: {
// commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库
// directoryId: 0, // 题库ID,获取错题集或收藏时传0
// pageFlag: 0, // 翻页标记:0往前翻页 1往后翻页
// pageSize: 10, // 每页大小
// secondSubjectId: 0, // 二级学科分类ID:用于判断学科下目录免费题数
// titleNo: 0, // 起始或结束题目序号,首次进入页面时传0,系统自动定位到上次做的题
commitKind: 3, // 答题来源 1:错题集 2:收藏 3:题库
directoryId: 1748, // 题库ID,获取错题集或收藏时传0
pageFlag: 0, // 翻页标记:0往前翻页 1往后翻页
pageSize: 5, // 每页大小
secondSubjectId: 106, // 二级学科分类ID:用于判断学科下目录免费题数
titleNo: 0, // 起始或结束题目ID,首次进入页面时传0,系统自动定位到上次做的题
}
};
}, },
computed: { computed: {
...mapGetters([ ...mapGetters([
"dataType", "commitKind",
"questionList", "questionList",
"currentQuestion", "currentQuestion",
"currentQuestionIndex",
"totalCount", "totalCount",
"userInfo" "userInfo"
]) ])
...@@ -37,33 +55,38 @@ export default { ...@@ -37,33 +55,38 @@ export default {
// 上一页 // 有可能要触发上分页(前端的个数只有一条) // 上一页 // 有可能要触发上分页(前端的个数只有一条)
// TODO // TODO
previous() { previous() {
if (this.currentQuestion.order == 1) { // debugger
if (this.currentQuestion.titleNo == 1) {
Toast("已是第一题"); Toast("已是第一题");
} else { } else {
let preIndex = this.currentQuestionIndex - 1; let cIndex = findQuestionIndexNo(this.questionList, "titleNo", this.currentQuestion.titleNo);
this.$store.commit("SET_CURRENT_QUESTION_INDEX", preIndex);
this.$store.commit( this.$store.commit(
"SET_CURRENT_QUESTION", "SET_CURRENT_QUESTION",
this.questionList[preIndex] || { answerList: [] } this.questionList[cIndex - 1] || { answerList: [] }
); );
if(cIndex == 1 && this.currentQuestion.titleNo > 2) {
this.$emit("pageQuestion", 0, this.questionList[0].titleNo);
}
} }
}, },
// 下一页 // 有可能要触发下分页(后面的个数只有一条) // 下一页 // 有可能要触发下分页(后面的个数只有一条)
// TODO // TODO
next() { next() {
if (this.currentQuestion.order == this.totalCount) { // if (this.currentQuestion.titleNo == this.totalCount) {
Toast("已是最后一题"); if (this.currentQuestion.titleNo == this.questionList.length) {
// Toast("已是最后一题");
this.$emit("statistics");
} else { } else {
if (this.currentQuestion.order >= this.questionList.length) { let cIndex = findQuestionIndexNo(this.questionList, 'titleNo', this.currentQuestion.titleNo);
return;
}
let nextIndex = this.currentQuestionIndex + 1;
this.$store.commit("SET_CURRENT_QUESTION_INDEX", nextIndex);
this.$store.commit( this.$store.commit(
"SET_CURRENT_QUESTION", "SET_CURRENT_QUESTION",
this.questionList[nextIndex] || { answerList: [] } this.questionList[cIndex + 1] || { answerList: [] }
); );
if((cIndex == this.questionList.length - 2) && (this.questionList.length < this.totalCount)) {
this.$emit("pageQuestion", 1, this.questionList[this.questionList.length - 1].titleNo);
}
} }
}, },
...@@ -83,16 +106,17 @@ export default { ...@@ -83,16 +106,17 @@ export default {
favor(currentQuestion) { favor(currentQuestion) {
let favorFlag = currentQuestion.favorFlag; let favorFlag = currentQuestion.favorFlag;
let param = { let param = {
dataType: this.dataType, dataType: 2,
directoryId: currentQuestion.directoryId, directoryId: currentQuestion.directoryId,
examTitleId: currentQuestion.examTitleId, examTitleId: currentQuestion.titleId,
operateType: favorFlag == 1 ? 2 : 1, // 操作类型:1:收藏 2:取消收藏 operateType: favorFlag == 1 ? 2 : 1, // 操作类型:1:收藏 2:取消收藏
paperId: currentQuestion.paperId, paperId: currentQuestion.paperId,
paperIndex: currentQuestion.paperIndex, paperIndex: currentQuestion.paperIndex,
token: this.userInfo.userToken || this.token, token: this.userInfo.userToken || this.token || '998E10CD98ED4BCF91A28223270FE8CE',
setEntry: true setEntry: true
// userId: 0 // userId: 0
}; };
this.currentQuestion.favorFlag = this.currentQuestion.favorFlag == 0 ? 1 : 0;
this.POST("onlineexam/collectExamTitle", param).then(res => { this.POST("onlineexam/collectExamTitle", param).then(res => {
if (res.code == "000000") { if (res.code == "000000") {
if(res.data) { if(res.data) {
......
...@@ -8,11 +8,12 @@ const getters = { ...@@ -8,11 +8,12 @@ const getters = {
organizationInfo: state => state.coop.organizationInfo, organizationInfo: state => state.coop.organizationInfo,
logged: state => !!(state.user.token && state.user.info.id), logged: state => !!(state.user.token && state.user.info.id),
// 刷题相关 // 刷题相关
commonConfig: state => state.question.commonConfig,
titleConfig: state => state.question.titleConfig,
questionList: state => state.question.questionList, questionList: state => state.question.questionList,
currentQuestion: state => state.question.currentQuestion, currentQuestion: state => state.question.currentQuestion,
currentQuestionIndex: state => state.question.currentQuestionIndex, commitKind: state => state.question.titleConfig.commitKind,
dataType: state => state.question.dataType, freeFlag: state => state.question.titleConfig.freeFlag,
freeFlag: state => state.question.freeFlag, totalCount: state => state.question.titleConfig.totalCount,
totalCount: state => state.question.totalCount,
} }
export default getters export default getters
// import fetch from '@/utils/fetch';
// import { getBaseUrl } from '@/utils/index'
// import { setCookie, getCookie, delCookie } from '@/utils/index';
// import { envConfig } from '@/utils/env-config';
import { findQuestionIndexNo } from "@/utils";
const question = {
state: {
currentTitle: "题库",
questionList: [],
currentQuestion: {
isAnalyzed: false,
options: [ // 从options加工出来
{
isCorrect: false,
isSelected: true,
text: "进行分析评估",
},
{
isCorrect: false,
isSelected: false,
text: "进行分析评估",
},
{
isCorrect: true,
isSelected: true,
text: "进行分析评估",
},
{
isCorrect: false,
isSelected: false,
text: "进行分析评估",
},
],
titleId: 1,
titleNo: 1, // 题序,从1开始
typeId: 1, // 题目类型ID 1-单选,2-多选,3-判断
unionId: "", // 联合类型题目,分组唯一标识
unionType: 1, // 0普通题型 1-共用题干; 2-共用选项
unionQuestion: "", // 共用题干
question: '题干内容<img src="https://files.yunqueyi.com/image/png/protal/project/20200702161856970.png" />', // 题干内容
config: "", // 选项
answer: "", // 正确答案
intro: "", // 题目解析
score: 0, // 题目分值
myAnswer: "", // 我的答案
commitFlag: 0, // 0还未做 1做对了 2做错了
favorFlag: 0, // 0未收藏 1已收藏
pictureFlag: "", // 0没有图 1有图
questionStreamType: "", // 题干内流媒体类型:0-文本,1-图片,2-视频,3-音频
directoryId: 0, // 题库ID
paperId: "", // 试卷ID
paperIndex: "", // 试卷索引
},
commonConfig: {
// 0: 免费; 1: 收费; 没有绑卡且是收费题库(bindStatus == 0 && freeFlag == 1)可以走免费体验流程
freeFlag: 0,
directoryId: "",
secondSubjectId: 0,
cardType: 3,
goodsType: 3,
commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库
},
titleConfig: {
bindStatus: 0, // 绑卡状态:0未绑卡 1已绑卡
commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库
currentTitleNo: 0, // 定位答题题目id
resultId: 0, // 刷题库轮次ID
totalCount: 0, // 题目总数
}
},
mutations: {
SET_COMMON_CONIFG: (state, payload) => {
state.commonConfig = payload;
},
SET_TITLE_CONIFG: (state, payload) => {
state.titleConfig = payload;
},
SET_COMMIT_KIND: (state, payload) => {
state.titleConfig.commitKind = payload;
},
SET_FREE_FLAG: (state, payload) => {
state.titleConfig.freeFlag = payload;
},
SET_TOTAL_COUNT: (state, payload) => {
state.titleConfig.totalCount = payload;
},
SET_QUESTION_LIST: (state, payload) => {
state.questionList = payload;
},
SET_CURRENT_QUESTION: (state, payload) => {
state.currentQuestion = payload;
},
},
actions: {
// 处理返回的数据
handlerQuestionList({ commit, state }, rezultData) {
// debugger
let questionList = rezultData.practiseTitleModelList;
let handlerList = [], question, option, optionList = [], myAnswer = "", answer = "";
questionList.forEach( (item, index) => {
question = JSON.parse(JSON.stringify(item));
question.isAnalyzed = false;
option = {};
optionList = [];
question.options.forEach( (text, i) => {
option.isCorrect = false;
option.isSelected = false;
option.text = text;
optionList.push(JSON.parse(JSON.stringify(option)));
});
question.options = optionList;
console.log('handlerList', index);
handlerList.push(question);
});
console.log('in handlerList', handlerList);
let cIndex = findQuestionIndexNo(handlerList, 'titleNo', rezultData.currentTitleNo || 1);
commit("SET_CURRENT_QUESTION", handlerList[cIndex]);
commit("SET_QUESTION_LIST", handlerList);
let titleConfig = {
bindStatus: rezultData.bindStatus, // 绑卡状态:0未绑卡 1已绑卡
commitKind: rezultData.commitKind, // 答题来源 1:错题集 2:收藏 3:题库
currentTitleNo: rezultData.currentTitleNo, // 定位答题题目id
resultId: rezultData.resultId, // 刷题库轮次ID
totalCount: rezultData.totalCount, // 题目总数
}
commit("SET_TITLE_CONIFG", titleConfig);
},
},
}
export default question;
此差异已折叠。
此差异已折叠。
...@@ -11,13 +11,12 @@ const service = axios.create({ ...@@ -11,13 +11,12 @@ const service = axios.create({
// request拦截器 // request拦截器
service.interceptors.request.use(config => { service.interceptors.request.use(config => {
// debugger
if (config.data && config.data.setEntry) { if (config.data && config.data.setEntry) {
config.headers['sysCode'] = config.data.sysCode || 10 config.headers['sysCode'] = config.data.sysCode || 10
if(config.data.token){ if (config.data.token) {
config.headers['token'] = config.data.token || '47993ED00ECB46CE8D31ECF3AE34B4AA' config.headers['token'] = config.data.token || '998E10CD98ED4BCF91A28223270FE8CE'
if( process.env.BUILD_ENV == "development" ){ // 本地开发环境 if (process.env.BUILD_ENV == "development") { // 本地开发环境
config.headers['token'] = config.data.token || '47993ED00ECB46CE8D31ECF3AE34B4AA'; config.headers['token'] = config.data.token || '998E10CD98ED4BCF91A28223270FE8CE';
} }
} }
delete config.data.setEntry; delete config.data.setEntry;
......
/** /**
* Created by Anndy Yang on 19/02/28. * Created by Anndy Yang on 19/02/28.
*/ */
let orderVac = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S"
];
import { envConfig } from '@/utils/env-config' import { envConfig } from '@/utils/env-config'
const { BUILD_ENV } = process.env; const { BUILD_ENV } = process.env;
// 获取SC服务器域名地址 // 获取SC服务器域名地址
export function getBaseUrl(url) { export function getBaseUrl(url) {
return getConfigByEnvType('baseUrl') + url return getConfigByEnvType('baseUrl') + url
...@@ -251,7 +272,7 @@ export const getCookie = key => { ...@@ -251,7 +272,7 @@ export const getCookie = key => {
export function debounce(fn, wait = 50) { export function debounce(fn, wait = 50) {
let timer; let timer;
return function() { return function () {
if (timer) clearTimeout(timer) if (timer) clearTimeout(timer)
timer = setTimeout(() => { timer = setTimeout(() => {
fn.apply(this, arguments); fn.apply(this, arguments);
...@@ -275,3 +296,15 @@ export function querystring(query) { ...@@ -275,3 +296,15 @@ export function querystring(query) {
return result; return result;
} }
export function getOrderText(index) {
return orderVac[index];
}
export function findQuestionIndexNo(oList, key, keyValue) {
let index = oList.findIndex( item => {
return item[key] == keyValue;
});
return index;
}
...@@ -110,8 +110,10 @@ module.exports = { ...@@ -110,8 +110,10 @@ module.exports = {
// 通用GET请求 // 通用GET请求
GET(api, para, callback, str) { GET(api, para, callback, str) {
// debugger // debugger
let token = para.token || this.token || this.$store.state.user.token || ''; let token = para.token || this.token || this.$store.state.user.token || '998E10CD98ED4BCF91A28223270FE8CE';
para.token = token; para.token = token;
delete para.token;
delete para.setEntry;
let url = api + this.getUrlPara(para) let url = api + this.getUrlPara(para)
return fetch({ return fetch({
url: getBaseUrl(url), url: getBaseUrl(url),
......
<template> <template>
<section class="question-detail-wrapper" :style="{'position': needFixed ? 'fixed': 'static'}"> <section class="question-detail-wrapper" :style="{'position': needFixed ? 'fixed': 'static'}">
<question-header :title="currentTitle" :order="currentQuestion.order" :total="totalCount"></question-header> <question-header :title="currentTitle" :order="currentQuestion.titleNo" :total="titleConfig.totalCount"></question-header>
<article class="body"> <article class="body">
<question-content v-show="questionList.length"></question-content> <question-content v-show="questionList.length"></question-content>
<no-content v-show="!questionList.length" :listType="dataType"></no-content> <no-content v-show="!questionList.length" :listType="commitKind"></no-content>
</article> </article>
<!-- <free-tips ></free-tips> --> <!-- <free-tips ></free-tips> -->
<question-footer></question-footer> <question-footer @statistics="statistics" @pageQuestion="pageQuestion"></question-footer>
<ExperienceDialog :showDialog="experienceDialog" @activeCard="activeCard" @buyCard="buyCard" @close="experienceDialog = false"></ExperienceDialog> <ExperienceDialog :showDialog="experienceDialog" @activeCard="activeCard" @buyCard="buyCard" @close="experienceDialog = false"></ExperienceDialog>
<!-- 去激活 --> <!-- 去激活 -->
...@@ -41,6 +41,8 @@ import CourseDialog from "@/components/course/course-dialog"; ...@@ -41,6 +41,8 @@ import CourseDialog from "@/components/course/course-dialog";
import ChangeCard from "@/components/cme/change-card"; import ChangeCard from "@/components/cme/change-card";
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import { Toast } from "vant";
import { findQuestionIndexNo } from "@/utils";
let titleArray = ["", "", "免费体验", "错题集", "收藏夹"]; let titleArray = ["", "", "免费体验", "错题集", "收藏夹"];
export default { export default {
...@@ -61,7 +63,7 @@ export default { ...@@ -61,7 +63,7 @@ export default {
cardType: 3, cardType: 3,
goodsType: 3, goodsType: 3,
currentTitle: "试题集", currentTitle: "试题集",
dataType: 1, // 答题来源 1:错题集 2:收藏 3:题库 commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库
experienceDialog: false, // 体验结束弹框 experienceDialog: false, // 体验结束弹框
showChangeCard: false, //是否展示激活弹框, showChangeCard: false, //是否展示激活弹框,
changeCardErrorMsg: "", changeCardErrorMsg: "",
...@@ -78,40 +80,42 @@ export default { ...@@ -78,40 +80,42 @@ export default {
id: 0 id: 0
}, },
queryParams: { queryParams: {
commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库 commitKind: 3, // 答题来源 1:错题集 2:收藏 3:题库
directoryId: 0, // 题库ID,获取错题集或收藏时传0 directoryId: 1748, // 题库ID,获取错题集或收藏时传0
pageFlag: 0, // 翻页标记:0往前翻页 1往后翻页 pageFlag: 0, // 翻页标记:0往前翻页 1往后翻页
pageSize: 10, // 每页大小 pageSize: 5, // 每页大小
secondSubjectId: 0, // 二级学科分类ID:用于判断学科下目录免费题数 secondSubjectId: 106, // 二级学科分类ID:用于判断学科下目录免费题数
titleNo: 0, // 起始或结束题目ID,首次进入页面时传0,系统自动定位到上次做的题 titleNo: 0, // 起始或结束题目ID,首次进入页面时传0,系统自动定位到上次做的题
} }
} }
}, },
computed: { computed: {
...mapGetters(['questionList', 'currentQuestion', 'currentQuestionIndex', 'totalCount']), ...mapGetters(['questionList', 'currentQuestion', 'totalCount', 'titleConfig']),
needFixed() { needFixed() {
return this.experienceDialog || this.showChangeCard || this.showBindCardTips; return this.experienceDialog || this.showChangeCard || this.showBindCardTips;
}, },
}, },
created() { created() {
let _this = this; let _this = this;
this.directoryId = this.$route.query.directoryId || 1; this.directoryId = this.$route.query.directoryId || 1; // 题库ID,获取错题集或收藏时传0
this.commitKind = this.$route.query.commitKind || 1; this.secondSubjectId = this.$route.query.secondSubjectId || 1; // 学科id
this.cardType = this.$route.query.cardType || 3; this.cardType = this.$route.query.cardType || 3; // 卡类型
this.goodsType = this.$route.query.goodsType || 3; this.goodsType = this.$route.query.goodsType || 3; // 商品类型
this.dataType = this.$route.query.dataType || 1; this.commitKind = this.$route.query.commitKind || 1; // 答题来源 1:错题集 2:收藏 3:题库
this.freeFlag = this.$route.query.freeFlag || 0; // 0: 免费; 1: 收费; this.freeFlag = this.$route.query.freeFlag || 0; // 0: 免费; 1: 收费;
this.currentTitle = this.$route.query.currentTitle || this.currentTitle; this.currentTitle = this.$route.query.currentTitle || this.currentTitle; // 顶部导航文案
this.init(); this.init();
window.__getUserInfoForQD = function(param) { window.__getUserInfoForQD = function(param) {
_this.token = param.userToken; _this.token = param.userToken;
_this.setUserInfo(param); _this.setUserInfo(param);
_this.getQuestionList(); this.getPractiseTitles();
// _this.checkToken(); // _this.checkToken();
}; };
if(__isWeb) { if(__isWeb) {
_this.getQuestionList(); this.getPractiseTitles();
} else { } else {
_this.getUserInfo(); _this.getUserInfo();
} }
...@@ -130,14 +134,43 @@ export default { ...@@ -130,14 +134,43 @@ export default {
}, },
methods: { methods: {
...mapActions(["setUserInfo", "getQuestionList"]), ...mapActions(["setUserInfo", "handlerQuestionList"]),
init() { init() {
if(this.dataType >= 2 && this.dataType <= 4) { if(this.commitKind >= 2 && this.commitKind <= 4) {
this.currentTitle = titleArray[this.dataType]; this.currentTitle = titleArray[this.commitKind];
} }
this.$store.commit('SET_COMMON_CONIFG', {
// 0: 免费; 1: 收费; 没有绑卡且是收费题库(bindStatus == 0 && freeFlag == 1)可以走免费体验流程
freeFlag: this.freeFlag,
directoryId: this.directoryId,
secondSubjectId: this.secondSubjectId,
cardType: this.cardType,
goodsType: this.goodsType,
commitKind: this.commitKind, // 答题来源 1:错题集 2:收藏 3:题库
});
this.getUserInfo();
// this.getPractiseTitles();
// this.preJumper(); // this.preJumper();
}, },
// 开始翻页
pageQuestion(pageFlag, titleNo) {
this.queryParams.pageFlag = pageFlag;
this.queryParams.titleNo = titleNo;
this.getPractiseTitles();
},
// 统计当前信息
statistics() {
let correctNum = 0, errNum = 0, rate = 0;
this.questionList.forEach( item => {
if(item.commitKind) {
}
});
this.experienceDialog = true;
},
//获取用户信息 //获取用户信息
getUserInfo() { getUserInfo() {
rocNative.getUserInfo({ rocNative.getUserInfo({
...@@ -228,14 +261,42 @@ export default { ...@@ -228,14 +261,42 @@ export default {
}, },
// 分页获取题目(前、后翻页) // 分页获取题目(前、后翻页)
getPractiseTitles(params) { getPractiseTitles() {
let param = { this.GET(`portal/titleTest/practise/titles`, this.queryParams).then(({ data }) => {
...params, this.currentTitleNo = data.currentTitleNo;
setEntry: true this.handlerQuestionList(data);
}; // this.handlerPractiseData(data.practiseTitleModelList);
this.GET(`portal/titleTest/practise/titles`, param).then(({ data }) => { console.log(data);
});
},
// 将序号转成字母
getOrderVac(index) {
return getOrderText(index);
},
// 处理返回的数据,并存储到store中
handlerPractiseData(questionList) {
let handlerList = [], question, option, optionList = [], myAnswer = "", answer = "";
questionList.forEach( (item, index) => {
question = JSON.parse(JSON.stringify(item));
question.isAnalyzed = false;
option = {};
optionList = [];
question.options.forEach( (text, i) => {
option.isCorrect = false;
option.isSelected = false;
option.text = text;
optionList.push(JSON.parse(JSON.stringify(option)));
});
question.options = optionList;
console.log('handlerList', index);
handlerList.push(question);
}); });
console.log('in handlerList', handlerList);
let cIndex = findQuestionIndexNo(handlerList, 'titleNo', this.currentTitleNo);
this.$store.commit("SET_CURRENT_QUESTION", handlerList[cIndex]);
this.$store.commit("SET_QUESTION_LIST", handlerList);
}, },
// 激活Action 返回值:0绑定失败,1绑定成功 // 激活Action 返回值:0绑定失败,1绑定成功
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册