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