提交 d2bbcdbc 编写于 作者: 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
......@@ -25,7 +25,7 @@
</article>
<article class="title-wrapper">
<span class="type" :class="{'multi': currentQuestion.typeId == 2}">
<span>{{currentQuestion.typeId == 1 ? "单选题" : "多选题"}}</span>
<span>{{currentQuestion.typeId != 2 ? "单选题" : "多选题"}}</span>
</span>
<span class="content" v-html="currentQuestion.question"></span>
<!-- <img src="https://files.yunqueyi.com/image/png/protal/project/20200702161856970.png" /> -->
......@@ -92,6 +92,8 @@ export default {
...mapGetters([
"questionList",
"currentQuestion",
"commonConfig",
"titleConfig"
])
},
data() {
......@@ -124,7 +126,7 @@ export default {
myAnswer = myAnswer.split('').join(',');
this.currentQuestion.myAnswer = myAnswer;
} else {
// 单选题直接设置commitFlag
// 单选题或者判断题直接设置commitFlag
if(this.currentQuestion.options[index].isCorrect) {
this.currentQuestion.commitFlag = 1;
} else {
......@@ -136,18 +138,43 @@ export default {
this.$forceUpdate();
console.log("in commit", this.currentQuestion.myAnswer);
},
commitAnswer() {
// 提交答案
commitAnswer(isMulti) {
let params = {
commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库
directoryId: 0, // 题库ID
commitKind: this.commonConfig.commitKind, // 答题来源 1:错题集 2:收藏 3:题库
directoryId: this.currentQuestion.directoryId, // 题库ID
myAnswer: this.currentQuestion.myAnswer, // 我的答案,单选时单个答案,如A;多选答案,按照顺序使用
paperId: 1, // 试卷ID
paperIndex: 1, // 试卷索引(随机试卷的第n套)
resultId: 1, // 刷题库轮次ID,刷收藏和错题集时为0
rightFlag: 1, // 答题对错:1对 2错
titleId: 1, // 题目ID
paperId: this.currentQuestion.paperId, // 试卷ID
paperIndex: this.currentQuestion.paperIndex, // 试卷索引(随机试卷的第n套)
resultId: this.titleConfig.resultId, // 刷题库轮次ID,刷收藏和错题集时为0
// rightFlag: 1, // 答题对错:1对 2错
titleId: this.currentQuestion.titleId, // 题目ID
titleNo: this.currentQuestion.titleNo, // 题目ID
};
// 计算是否答对了题目(只有多选题,才做相应处理)
if(isMulti) {
let cList = this.currentQuestion, option = {}, isRight = true;
for(let i = 0; i < cList.length; i ++) {
option = cList[i];
if(option.isCorrect && !option.isSelected) {
isRight = false;
return;
}
}
if(isRight) {
this.currentQuestion.commitFlag = 1;
} else {
this.currentQuestion.commitFlag = 2;
}
}
this.POST(`onlineexam/practise/commit`, params).then(({ data }) => {
// this.currentTitleNo = data.currentTitleNo;
// this.handlerQuestionList(data);
// this.handlerPractiseData(data.practiseTitleModelList);
console.log("onlineexam/practise/commit", data);
});
}
}
};
......
......@@ -112,7 +112,7 @@ export default {
operateType: favorFlag == 1 ? 2 : 1, // 操作类型:1:收藏 2:取消收藏
paperId: currentQuestion.paperId,
paperIndex: currentQuestion.paperIndex,
token: this.userInfo.userToken || this.token || '998E10CD98ED4BCF91A28223270FE8CE',
token: this.userInfo.userToken || this.token || '93521BDB92774134B2CC18633F2B6D3A',
setEntry: true
// userId: 0
};
......
......@@ -97,7 +97,7 @@ const question = {
// async getQuestionList({ commit, state }, params) {
// // let param = {
// // ...params,
// // token: '998E10CD98ED4BCF91A28223270FE8CE',
// // token: '93521BDB92774134B2CC18633F2B6D3A',
// // setEntry: true
// // };
// // this.GET(`portal/titleTest/practise/titles`, param).then(({ data }) => {
......
......@@ -2,7 +2,7 @@
// import { getBaseUrl } from '@/utils/index'
// import { setCookie, getCookie, delCookie } from '@/utils/index';
// import { envConfig } from '@/utils/env-config';
import { findQuestionIndexNo, getOrderText } from "@/utils";
import { findQuestionIndexNo, getOrderText, concatArray } from "@/utils";
const question = {
state: {
......@@ -59,11 +59,11 @@ const question = {
secondSubjectId: 0,
cardType: 3,
goodsType: 3,
commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库
commitKind: 3, // 答题来源 1:错题集 2:收藏 3:题库
},
titleConfig: {
bindStatus: 0, // 绑卡状态:0未绑卡 1已绑卡
commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库
commitKind: 3, // 答题来源 1:错题集 2:收藏 3:题库
currentTitleNo: 0, // 定位答题题目id
resultId: 0, // 刷题库轮次ID
totalCount: 0, // 题目总数
......@@ -97,7 +97,7 @@ const question = {
// 处理返回的数据
handlerQuestionList({ commit, state }, rezultData) {
// debugger
let questionList = rezultData.practiseTitleModelList;
let questionList = rezultData.practiseTitleModelList || [];
let handlerList = [], question, option, optionList = [], myAnswer = "", answer = "";
questionList.forEach( (item, index) => {
......@@ -123,9 +123,7 @@ const 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 newList = concatArray(state.questionList, handlerList, 'titleNo');
let titleConfig = {
bindStatus: rezultData.bindStatus, // 绑卡状态:0未绑卡 1已绑卡
commitKind: rezultData.commitKind, // 答题来源 1:错题集 2:收藏 3:题库
......@@ -133,6 +131,8 @@ const question = {
resultId: rezultData.resultId, // 刷题库轮次ID
totalCount: rezultData.totalCount, // 题目总数
}
commit("SET_CURRENT_QUESTION", newList[cIndex] || {titleNo: 1});
commit("SET_QUESTION_LIST", newList);
commit("SET_TITLE_CONIFG", titleConfig);
},
......
......@@ -14,9 +14,9 @@ service.interceptors.request.use(config => {
if (config.data && config.data.setEntry) {
config.headers['sysCode'] = config.data.sysCode || 10
if (config.data.token) {
config.headers['token'] = config.data.token || '998E10CD98ED4BCF91A28223270FE8CE'
config.headers['token'] = config.data.token || '93521BDB92774134B2CC18633F2B6D3A'
if (process.env.BUILD_ENV == "development") { // 本地开发环境
config.headers['token'] = config.data.token || '998E10CD98ED4BCF91A28223270FE8CE';
config.headers['token'] = config.data.token || '93521BDB92774134B2CC18633F2B6D3A';
}
}
delete config.data.setEntry;
......
......@@ -301,6 +301,7 @@ export function getOrderText(index) {
return orderVac[index];
}
// 从数组中查找某个key对应值所在的位置(序号:0开始的)
export function findQuestionIndexNo(oList, key, keyValue) {
let index = oList.findIndex( item => {
return item[key] == keyValue;
......@@ -308,3 +309,28 @@ export function findQuestionIndexNo(oList, key, keyValue) {
return index;
}
// 对两个数组中的元素进行排序
export function concatArray(firstArr = [], secondArr = [], key) {
if(firstArr.length == 0) return secondArr;
if(secondArr.length == 0) return [];
let all = [], newArr = [], deleteIndex;
if(firstArr[0][key] == secondArr[0][key]) {
return firstArr;
}else if(firstArr[0][key] < secondArr[0][key]) {
all = firstArr.concat(secondArr);
} else {
all = secondArr.concat(firstArr);
}
// 从all中去重
for(let i = 0; i < all.length; i ++) {
deleteIndex = findQuestionIndexNo(all.slice(i + 1), key, all[i][key]);
if(deleteIndex >= 0) {
all.splice(deleteIndex, 1);
i --;
}
}
console.log("in contactArray", all);
return all;
}
......@@ -110,7 +110,7 @@ module.exports = {
// 通用GET请求
GET(api, para, callback, str) {
// debugger
let token = para.token || this.token || this.$store.state.user.token || '998E10CD98ED4BCF91A28223270FE8CE';
let token = para.token || this.token || this.$store.state.user.token || '93521BDB92774134B2CC18633F2B6D3A';
para.token = token;
delete para.token;
delete para.setEntry;
......@@ -148,8 +148,10 @@ module.exports = {
// 通用POST请求
POST(api, para, callback) {
let token = para.token || this.token || this.$store.state.user.token || '';
let token = para.token || this.token || this.$store.state.user.token || '93521BDB92774134B2CC18633F2B6D3A';
para.token = token;
delete para.token;
delete para.setEntry;
return fetch({
url: getBaseUrl(api),
method: 'post',
......
<template>
<section class="question-detail-wrapper" :style="{'position': needFixed ? 'fixed': 'static'}">
<question-header :title="currentTitle" :order="currentQuestion.titleNo" :total="titleConfig.totalCount"></question-header>
<question-header
:title="currentTitle"
:order="currentQuestion.titleNo"
:total="titleConfig.totalCount"
></question-header>
<article class="body">
<question-content v-show="questionList.length"></question-content>
<no-content v-show="!questionList.length" :listType="commitKind"></no-content>
</article>
<!-- <free-tips ></free-tips> -->
<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>
<!-- 去激活 -->
<ChangeCard
......@@ -40,11 +49,11 @@ import Loading from "@/components/common/common-loading";
import CourseDialog from "@/components/course/course-dialog";
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";
import { findQuestionIndexNo, contactArray } from "@/utils";
let titleArray = ["", "", "免费体验", "错题集", "收藏夹"];
let titleArray = ["", "错题集", "收藏夹", "收藏夹"];
export default {
components: {
QuestionHeader,
......@@ -54,7 +63,7 @@ export default {
ExperienceDialog,
Loading,
CourseDialog,
ChangeCard,
ChangeCard
},
data() {
return {
......@@ -85,15 +94,22 @@ export default {
pageFlag: 0, // 翻页标记:0往前翻页 1往后翻页
pageSize: 5, // 每页大小
secondSubjectId: 106, // 二级学科分类ID:用于判断学科下目录免费题数
titleNo: 0, // 起始或结束题目ID,首次进入页面时传0,系统自动定位到上次做的题
}
titleNo: 0 // 起始或结束题目ID,首次进入页面时传0,系统自动定位到上次做的题
}
};
},
computed: {
...mapGetters(['questionList', 'currentQuestion', 'totalCount', 'titleConfig']),
...mapGetters([
"questionList",
"currentQuestion",
"totalCount",
"titleConfig"
]),
needFixed() {
return this.experienceDialog || this.showChangeCard || this.showBindCardTips;
},
return (
this.experienceDialog || this.showChangeCard || this.showBindCardTips
);
}
},
created() {
let _this = this;
......@@ -101,12 +117,58 @@ export default {
this.secondSubjectId = this.$route.query.secondSubjectId || 1; // 学科id
this.cardType = this.$route.query.cardType || 3; // 卡类型
this.goodsType = this.$route.query.goodsType || 3; // 商品类型
this.commitKind = this.$route.query.commitKind || 1; // 答题来源 1:错题集 2:收藏 3:题库
this.commitKind = this.$route.query.commitKind || 3; // 答题来源 1:错题集 2:收藏 3:题库
this.freeFlag = this.$route.query.freeFlag || 0; // 0: 免费; 1: 收费;
this.currentTitle = this.$route.query.currentTitle || this.currentTitle; // 顶部导航文案
this.init();
let firstArr = [
{
titleNo: 1,
name: "11"
},
{
titleNo: 2,
name: "11"
},
{
titleNo: 3,
name: "11"
},
{
titleNo: 4,
name: "11"
},
{
titleNo: 5,
name: "11"
}
];
let secondArr = [
{
titleNo: 3,
name: "11"
},
{
titleNo: 4,
name: "11"
},
{
titleNo: 5,
name: "11"
},
{
titleNo: 6,
name: "11"
},
{
titleNo: 7,
name: "11"
}
];
window.__getUserInfoForQD = function(param) {
_this.token = param.userToken;
_this.setUserInfo(param);
......@@ -114,7 +176,7 @@ export default {
// _this.checkToken();
};
if(__isWeb) {
if (__isWeb) {
this.getPractiseTitles();
} else {
_this.getUserInfo();
......@@ -131,22 +193,21 @@ export default {
param.setEntry = true;
_this.getProvinceIdByPosition(param);
};
},
methods: {
...mapActions(["setUserInfo", "handlerQuestionList"]),
init() {
if(this.commitKind >= 2 && this.commitKind <= 4) {
if (this.commitKind >= 2 && this.commitKind <= 4) {
this.currentTitle = titleArray[this.commitKind];
}
this.$store.commit('SET_COMMON_CONIFG', {
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:题库
commitKind: this.commitKind // 答题来源 1:错题集 2:收藏 3:题库
});
this.getUserInfo();
// this.getPractiseTitles();
......@@ -162,10 +223,11 @@ export default {
// 统计当前信息
statistics() {
let correctNum = 0, errNum = 0, rate = 0;
this.questionList.forEach( item => {
if(item.commitKind) {
let correctNum = 0,
errNum = 0,
rate = 0;
this.questionList.forEach(item => {
if (item.commitKind) {
}
});
this.experienceDialog = true;
......@@ -185,7 +247,7 @@ export default {
},
buyCard() {
!__isWeb && this.confirm()
!__isWeb && this.confirm();
},
// 跳转到原生的购买页面
......@@ -201,9 +263,9 @@ export default {
return;
}
// 直接传入题库ID(directoryId)
// 直接传入学科ID(secondSubjectId)
let pageUrl = getWebPageUrl(
`/profexam/#/question-detail?id=${this.directoryId}&bankName=${this.bankName}&directoryId=${this.directoryId}`
`/profexam/#/question-bank?id=${this.secondSubjectId}&secondSubjectId=${this.secondSubjectId}`
);
let paramList = [
{
......@@ -247,7 +309,7 @@ export default {
// 处理提示信息框
handlerAction(type) {
if(type == 1) {
if (type == 1) {
// this.$sendBuriedData({
// component_tag: `882#88219`
// });
......@@ -256,18 +318,20 @@ export default {
// this.$sendBuriedData({
// component_tag: `882#88218`
// });
this.beforeChangeCardAction(this.cmeCardModels.cardKey, true)
this.beforeChangeCardAction(this.cmeCardModels.cardKey, true);
}
},
// 分页获取题目(前、后翻页)
getPractiseTitles() {
this.GET(`portal/titleTest/practise/titles`, this.queryParams).then(({ data }) => {
this.GET(`portal/titleTest/practise/titles`, this.queryParams).then(
({ data }) => {
this.currentTitleNo = data.currentTitleNo;
this.handlerQuestionList(data);
// this.handlerPractiseData(data.practiseTitleModelList);
console.log(data);
});
}
);
},
// 将序号转成字母
......@@ -277,24 +341,33 @@ export default {
// 处理返回的数据,并存储到store中
handlerPractiseData(questionList) {
let handlerList = [], question, option, optionList = [], myAnswer = "", answer = "";
questionList.forEach( (item, index) => {
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) => {
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);
console.log("handlerList", index);
handlerList.push(question);
});
console.log('in handlerList', handlerList);
let cIndex = findQuestionIndexNo(handlerList, 'titleNo', this.currentTitleNo);
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);
},
......@@ -315,10 +388,10 @@ export default {
this.POST("cme/projectCard/bind", param)
.then(res => {
isInTips && (_this.showBindCardTips = false);
console.log('in res', res, isInTips);
console.log("in res", res, isInTips);
if (res.code == "000000") {
if (!res.data) {
if(isInTips) {
if (isInTips) {
Toast(res.message);
} else {
_this.changeCardErrorMsg = "请输入正确的激活码";
......@@ -334,8 +407,8 @@ export default {
}
})
.catch(e => {
console.log('in catch', isInTips);
if(isInTips) {
console.log("in catch", isInTips);
if (isInTips) {
Toast("无效的激活码");
_this.showBindCardTips = false;
} else {
......@@ -349,7 +422,10 @@ export default {
let param = {
setEntry: true
};
this.GET(`cme/projectCard/queryNoUsedCard/${this.goodsType}/${this.cardType}`, param).then(({ data }) => {
this.GET(
`cme/projectCard/queryNoUsedCard/${this.goodsType}/${this.cardType}`,
param
).then(({ data }) => {
this.hasNoUsedCard = data.hasNoUsedCard;
if (data.hasNoUsedCard == 1) {
this.cmeCardModels = data.cmeCardModels[0] || {};
......@@ -389,14 +465,17 @@ export default {
let param = {
area: provinceId + "",
cardType: this.cardType || 3,
cardTypeList: [ this.cardType || 3],
goodsType: this.goodsType,
cardTypeList: [this.cardType || 3],
goodsType: this.goodsType
};
param.setEntry = true;
this.POST("trade/goods/cardList_v2", param).then(res => {
if (res.code == "000000") {
this.showLoading = false;
this.cardInfo = (res.data && res.data[0]) || { id: 0, name: "题库卡" };
this.cardInfo = (res.data && res.data[0]) || {
id: 0,
name: "题库卡"
};
this.subContent = `您已购买${this.cardInfo.goodsName}”,是否用此卡绑定并激活当前题库。题库卡激活码一旦使用,不可更改不可退回`;
}
});
......@@ -408,11 +487,9 @@ export default {
rocNative.getPositionData({
__funcName: "__getPositionData"
});
},
},
}
}
}
};
</script>
<style lang="less" scoped>
.question-detail-wrapper {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册