提交 1f317554 编写于 作者: 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
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<article class="content"> <article class="content">
<img class="img-tips" src="../../images/question/note.png" alt=""> <img class="img-tips" src="../../images/question/note.png" alt="">
<p class="tips">您已完成本次免费练习体验</p> <p class="tips">您已完成本次免费练习体验</p>
<p class="status"><span class="cm rn">{{rightNum}}</span>题,错<span class="cm en">{{errorNum}}</span>题,正确率<span class="cm rate">{{rate}}%</span></p> <p class="status"><span class="cm rn">{{statisConfig.rightNum}}</span>题,错<span class="cm en">{{statisConfig.errorNum}}</span>题,正确率<span class="cm rate">{{statisConfig.rate}}%</span></p>
<p class="guide-tips">想体验完整题目,请先激活或购买题库</p> <p class="guide-tips">想体验完整题目,请先激活或购买题库</p>
<div class="btn-wrapper"> <div class="btn-wrapper">
<span class="plain" @click="activeCard">去激活</span> <span class="plain" @click="activeCard">去激活</span>
...@@ -20,22 +20,32 @@ ...@@ -20,22 +20,32 @@
<script> <script>
export default { export default {
props: { props: {
statisConfig: {
type: Object,
default: () => {
return {
rightNum: 0,
errorNum: 0,
rate: 0
}
}
},
showDialog: { showDialog: {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
rightNum: { // rightNum: {
type: Number | String, // type: Number | String,
default: 0, // default: 0,
}, // },
errorNum: { // errorNum: {
type: Number | String, // type: Number | String,
default: 0, // default: 0,
}, // },
rate: { // rate: {
type: Number | String, // type: Number | String,
default: 0, // default: 0,
} // }
}, },
methods: { methods: {
......
<template> <template>
<section class="qeustion-content-wrapper"> <section class="qeustion-content-wrapper">
<article class="public-title" v-show="currentQuestion.unionType"> <article class="public-title" v-show="currentQuestion.unionType">
<p class="text" v-show="currentQuestion.unionType == 1"> <p class="text" v-show="currentQuestion.unionType == 1">{{currentQuestion.unionQuestion}}</p>
{{currentQuestion.unionQuestion}}
</p>
<article <article
class="select-wrapper" class="select-wrapper"
style="padding: 10px 15px 20px;" style="padding: 10px 15px 20px;"
v-show="currentQuestion.unionType == 2" v-show="currentQuestion.unionType == 2"
> >
<div <div class="item" v-for="(item, index) in currentQuestion.options" :key="index">
class="item"
v-for="(item, index) in currentQuestion.options"
:key="index"
>
<span class="option">{{getOrderVac(index)}}.</span> <span class="option">{{getOrderVac(index)}}.</span>
<span class="content">{{item.text}}</span> <span class="content">{{item.text}}</span>
</div> </div>
...@@ -22,24 +16,37 @@ ...@@ -22,24 +16,37 @@
</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 != 2 ? "单选题" : "多选题"}}</span> <span>{{currentQuestion.typeId == 1 ? "单选题" : 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" /> -->
</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
<span v-if="!item.isSelected && !((item.isSelected && !currentQuestion.commitFlag) || (!item.isSelected && currentQuestion.commitFlag && item.isCorrect))" class="option border">{{getOrderVac(index)}}</span> class="item"
<span v-if="(item.isSelected && !currentQuestion.commitFlag) || (!item.isSelected && currentQuestion.commitFlag && item.isCorrect)" class="option bg">{{getOrderVac(index)}}</span> v-for="(item, index) in currentQuestion.options"
:key="index"
@click="selectOption(index)"
>
<span
v-if="!item.isSelected && !((item.isSelected && !currentQuestion.commitFlag) || (!item.isSelected && currentQuestion.commitFlag && item.isCorrect))"
class="option border"
>{{getOrderVac(index)}}</span>
<span
v-else-if="(item.isSelected && !currentQuestion.commitFlag) || (!item.isSelected && currentQuestion.commitFlag && item.isCorrect)"
class="option bg"
>{{getOrderVac(index)}}</span>
<template v-else> <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 />
</template> </template>
<span v-if="!currentQuestion.commitFlag" <span
v-if="!currentQuestion.commitFlag"
class="content" class="content"
:class="{'select': item.isSelected}" :class="{'select': item.isSelected}"
>{{currentQuestion.unionType == 2 ? getOrderVac(index) : item.text}}</span> >{{currentQuestion.unionType == 2 ? getOrderVac(index) : item.text}}</span>
<span v-else <span
v-else
class="content" class="content"
:class="{'select': item.isCorrect, 'error': item.isSelected && !item.isCorrect}" :class="{'select': item.isCorrect, 'error': item.isSelected && !item.isCorrect}"
>{{currentQuestion.unionType == 2 ? getOrderVac(index) : item.text}}</span> >{{currentQuestion.unionType == 2 ? getOrderVac(index) : item.text}}</span>
...@@ -58,7 +65,11 @@ ...@@ -58,7 +65,11 @@
<span class="content">查看病理,了解病史</span> <span class="content">查看病理,了解病史</span>
</div>--> </div>-->
</article> </article>
<article class="c-btn-wrapper" v-show="currentQuestion.typeId == 2 && !currentQuestion.commitFlag" @click="commitAnswer"> <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"> <article class="answer-wrapper" v-show="currentQuestion.isAnalyzed">
...@@ -90,17 +101,12 @@ export default { ...@@ -90,17 +101,12 @@ export default {
"questionList", "questionList",
"currentQuestion", "currentQuestion",
"commonConfig", "commonConfig",
"titleConfig" "titleConfig",
"userInfo"
]) ])
}, },
data() { data() {
return { return {};
analysisContent: `商户支付的订单号由商户自定义生成,仅支持使用字 母、数字、中划线-、下划线_、竖线|、
星号*这些英文 半角字符的组合,请勿使用汉字或全角等特殊字符。微 信支付要求商户订单号保持唯一性
(建议根据当前系统 时间加随机序列来生成订单号)。重新发起一笔支付要 使用原订单号,避免重复支付;
已支付过或已调用关 单、撤销(请见后文的API列表)的订单号不能重新发 起支付。
<img data-v-5f105ddf="" src="https://files.yunqueyi.com/image/png/protal/project/20200702161856970.png">`
};
}, },
methods: { methods: {
getOrderVac(index) { getOrderVac(index) {
...@@ -109,28 +115,30 @@ export default { ...@@ -109,28 +115,30 @@ export default {
// 选择选项 // 选择选项
selectOption(index) { selectOption(index) {
if(this.currentQuestion.commitFlag) return; if (this.currentQuestion.commitFlag) return;
// 只记录当前选项,不提交答案 // 只记录当前选项,不提交答案
this.currentQuestion.options[index].isSelected = true; this.currentQuestion.options[index].isSelected = true;
// 重新设置答案(myAnswer) // 重新设置答案(myAnswer)
if(this.currentQuestion.typeId == 2) { if (this.currentQuestion.typeId == 2) {
let myAnswer = ""; let myAnswer = "";
this.currentQuestion.options.forEach( (item, index) => { this.currentQuestion.options.forEach((item, index) => {
if(item.isSelected) { 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 // 单选题或者判断题直接设置commitFlag
if(this.currentQuestion.options[index].isCorrect) { if (this.currentQuestion.options[index].isCorrect) {
this.currentQuestion.commitFlag = 1; this.currentQuestion.commitFlag = 1;
} else { } else {
this.currentQuestion.commitFlag = 2; this.currentQuestion.commitFlag = 2;
} }
let myAnswer = this.getOrderVac(index); let myAnswer = this.getOrderVac(index);
let isAnalyzed = this.currentQuestion.commitFlag && myAnswer != this.currentQuestion.answer; let isAnalyzed =
this.currentQuestion.commitFlag &&
myAnswer != this.currentQuestion.answer;
this.currentQuestion.isAnalyzed = isAnalyzed; this.currentQuestion.isAnalyzed = isAnalyzed;
this.currentQuestion.myAnswer = this.getOrderVac(index); this.currentQuestion.myAnswer = this.getOrderVac(index);
this.commitAnswer(); this.commitAnswer();
...@@ -140,7 +148,8 @@ export default { ...@@ -140,7 +148,8 @@ export default {
}, },
// 提交答案 // 提交答案
commitAnswer(isMulti) { commitAnswer() {
this.checkTokenForNative( () => {
let params = { let params = {
commitKind: this.commonConfig.commitKind, // 答题来源 1:错题集 2:收藏 3:题库 commitKind: this.commonConfig.commitKind, // 答题来源 1:错题集 2:收藏 3:题库
directoryId: this.currentQuestion.directoryId, // 题库ID directoryId: this.currentQuestion.directoryId, // 题库ID
...@@ -151,29 +160,30 @@ export default { ...@@ -151,29 +160,30 @@ export default {
// rightFlag: 1, // 答题对错:1对 2错 // rightFlag: 1, // 答题对错:1对 2错
titleId: this.currentQuestion.titleId, // 题目ID titleId: this.currentQuestion.titleId, // 题目ID
titleNo: this.currentQuestion.titleNo, // 题目ID titleNo: this.currentQuestion.titleNo, // 题目ID
setEntry: true,
token: this.userInfo.userToken
}; };
// 计算是否答对了题目(只有多选题,才做相应处理) // 计算是否答对了题目(只有多选题,才做相应处理)
if(isMulti) { // if (this.currentQuestion.typeId == 2) {
let cList = this.currentQuestion, option = {}, isRight = true; let isRight = this.currentQuestion.myAnswer == this.currentQuestion.answer;
for(let i = 0; i < cList.length; i ++) { if (isRight) {
option = cList[i];
if(option.isCorrect && !option.isSelected) {
isRight = false;
return;
}
}
if(isRight) {
this.currentQuestion.commitFlag = 1; this.currentQuestion.commitFlag = 1;
} else { } else {
this.currentQuestion.commitFlag = 2; this.currentQuestion.commitFlag = 2;
this.currentQuestion.isAnalyzed = true;
} }
} // }
this.POST(`onlineexam/practise/commit`, params).then(({ data }) => { this.POST(`onlineexam/practise/commit`, params).then(({ data }) => {
// this.currentTitleNo = data.currentTitleNo; console.log('in commitAnswer res', data);
// this.handlerQuestionList(data); // if(data.resultType == 1) {
// this.handlerPractiseData(data.practiseTitleModelList); // this.currentQuestion.commitFlag = 1;
console.log("onlineexam/practise/commit", data); // } else {
// this.currentQuestion.commitFlag = 2;
// }
}).catch( error => {
this.currentQuestion.commitFlag = 0;
this.currentQuestion.isAnalyzed = false;
})
}); });
} }
} }
...@@ -199,7 +209,7 @@ export default { ...@@ -199,7 +209,7 @@ export default {
top: 3px; top: 3px;
left: 0; left: 0;
display: inline-block; display: inline-block;
width: 44px; width: 47px;
height: 18px; height: 18px;
line-height: 12px; line-height: 12px;
margin-right: 4px; margin-right: 4px;
...@@ -209,7 +219,7 @@ export default { ...@@ -209,7 +219,7 @@ export default {
& > span { & > span {
position: absolute; position: absolute;
top: 3px; top: 3px;
left: 4px; left: 4.5px;
color: #ffffff; color: #ffffff;
} }
&.multi { &.multi {
......
...@@ -25,21 +25,13 @@ export default { ...@@ -25,21 +25,13 @@ export default {
data() { data() {
return { return {
queryParams: { 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:题库 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, // 起始或结束题目序号,首次进入页面时传0,系统自动定位到上次做的题
} }
}; };
}, },
computed: { computed: {
...@@ -48,14 +40,14 @@ export default { ...@@ -48,14 +40,14 @@ export default {
"questionList", "questionList",
"currentQuestion", "currentQuestion",
"totalCount", "totalCount",
"userInfo" "userInfo",
"titleConfig",
"commonConfig",
]) ])
}, },
methods: { methods: {
// 上一页 // 有可能要触发上分页(前端的个数只有一条) // 上一页 // 有可能要触发上分页(前端的个数只有一条)
// TODO
previous() { previous() {
// debugger
if (this.currentQuestion.titleNo == 1) { if (this.currentQuestion.titleNo == 1) {
Toast("已是第一题"); Toast("已是第一题");
} else { } else {
...@@ -64,8 +56,8 @@ export default { ...@@ -64,8 +56,8 @@ export default {
"SET_CURRENT_QUESTION", "SET_CURRENT_QUESTION",
this.questionList[cIndex - 1] || { answerList: [] } this.questionList[cIndex - 1] || { answerList: [] }
); );
console.log(this.currentQuestion.isAnalyzed || (this.currentQuestion.commitFlag == 2)); console.log(cIndex == 1, this.currentQuestion.titleNo >= 2);
if(cIndex == 1 && this.currentQuestion.titleNo > 2) { if(cIndex == 1 && this.currentQuestion.titleNo >= 2) {
this.$emit("pageQuestion", 0, this.questionList[0].titleNo); this.$emit("pageQuestion", 0, this.questionList[0].titleNo);
} }
} }
...@@ -74,9 +66,9 @@ export default { ...@@ -74,9 +66,9 @@ export default {
// 下一页 // 有可能要触发下分页(后面的个数只有一条) // 下一页 // 有可能要触发下分页(后面的个数只有一条)
// TODO // TODO
next() { next() {
// if (this.currentQuestion.titleNo == this.totalCount) { if (this.currentQuestion.titleNo == this.totalCount
if (this.currentQuestion.titleNo == this.questionList.length) { // if (this.currentQuestion.titleNo == this.questionList.length
// Toast("已是最后一题"); || this.currentQuestion.titleNo == this.questionList[this.questionList.length - 1].titleNo) {
this.$emit("statistics"); this.$emit("statistics");
} else { } else {
let cIndex = findQuestionIndexNo(this.questionList, 'titleNo', this.currentQuestion.titleNo); let cIndex = findQuestionIndexNo(this.questionList, 'titleNo', this.currentQuestion.titleNo);
...@@ -95,6 +87,9 @@ export default { ...@@ -95,6 +87,9 @@ export default {
// 解析 // 解析
toggleAnalysis() { toggleAnalysis() {
this.currentQuestion.isAnalyzed = true; this.currentQuestion.isAnalyzed = true;
if(!this.currentQuestion.commitFlag) {
this.commitAnswer();
}
// this.$store.commit('SET_CURRENT_QUESTION', this.currentQuestion); // this.$store.commit('SET_CURRENT_QUESTION', this.currentQuestion);
}, },
...@@ -105,31 +100,70 @@ export default { ...@@ -105,31 +100,70 @@ export default {
}, },
// 收藏/取消收藏 // 收藏/取消收藏
favor(currentQuestion) { favor() {
let favorFlag = currentQuestion.favorFlag; let favorFlag = this.currentQuestion.favorFlag;
let param = { let param = {
dataType: 2, dataType: 2,
directoryId: currentQuestion.directoryId, directoryId: this.currentQuestion.directoryId,
examTitleId: currentQuestion.titleId, examTitleId: this.currentQuestion.titleId,
operateType: favorFlag == 1 ? 2 : 1, // 操作类型:1:收藏 2:取消收藏 operateType: favorFlag == 1 ? 2 : 1, // 操作类型:1:收藏 2:取消收藏
paperId: currentQuestion.paperId, paperId: this.currentQuestion.paperId,
paperIndex: currentQuestion.paperIndex, paperIndex: this.currentQuestion.paperIndex,
token: this.userInfo.userToken || this.token || '93521BDB92774134B2CC18633F2B6D3A', token: this.userInfo.userToken || this.token,
setEntry: true setEntry: true
// userId: 0
}; };
this.currentQuestion.favorFlag = this.currentQuestion.favorFlag == 0 ? 1 : 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) {
let cIndex = this.questionList.findIndex( item => { // let cIndex = this.questionList.findIndex( item => {
return item.titleNo = currentQuestion.titleNo; // return item.titleNo = this.currentQuestion.titleNo;
}); // });
this.questionList[cIndex].favorFlag = favorFlag == 0 ? 1 : 0; // this.questionList[cIndex].favorFlag = favorFlag == 0 ? 1 : 0;
this.currentQuestion.favorFlag = favorFlag == 0 ? 1 : 0; // this.currentQuestion.favorFlag = favorFlag == 0 ? 1 : 0;
} }
} }
}); });
},
// 提交答案
commitAnswer() {
this.checkTokenForNative( () => {
let params = {
commitKind: this.commonConfig.commitKind, // 答题来源 1:错题集 2:收藏 3:题库
directoryId: this.currentQuestion.directoryId, // 题库ID
myAnswer: this.currentQuestion.myAnswer, // 我的答案,单选时单个答案,如A;多选答案,按照顺序使用
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
setEntry: true,
token: this.userInfo.userToken,
};
// 计算是否答对了题目(只有多选题,才做相应处理)
// if (this.currentQuestion.typeId == 2) {
let isRight = this.currentQuestion.myAnswer == this.currentQuestion.answer;
if (isRight) {
this.currentQuestion.commitFlag = 1;
} else {
this.currentQuestion.commitFlag = 2;
}
this.currentQuestion.isAnalyzed = true;
// }
this.POST(`onlineexam/practise/commit`, params).then(({ data }) => {
console.log('in commitAnswer res', data);
// if(data.resultType == 1) {
// this.currentQuestion.commitFlag = 1;
// } else {
// this.currentQuestion.commitFlag = 0;
// }
}).catch( error => {
this.currentQuestion.commitFlag = 0;
this.currentQuestion.isAnalyzed = false;
})
});
} }
} }
}; };
......
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
<section class="question-header-wrapper"> <section class="question-header-wrapper">
<img @click="goBack" class="left" src="../../images/left-array-black.png" alt=""> <img @click="goBack" class="left" src="../../images/left-array-black.png" alt="">
<span class="center">{{title}}</span> <span class="center">{{title}}</span>
<div class="right"> <div class="right" >
<span v-show="total">
<span class="order">{{order}}</span><span class="total">/{{total}}</span> <span class="order">{{order}}</span><span class="total">/{{total}}</span>
</span>
</div> </div>
</section> </section>
</template> </template>
...@@ -16,11 +18,11 @@ export default { ...@@ -16,11 +18,11 @@ export default {
}, },
order: { order: {
type: Number | String, type: Number | String,
default: 1, default: 0,
}, },
total: { total: {
type: Number | String, type: Number | String,
default: 20, default: 0,
} }
}, },
methods: { methods: {
......
const coop = { const coop = {
state: { state: {
userInfo: {appVersion: '343'}, userInfo: {appVersion: "343", userToken: "EFC0A4A5EC4B49FBBBBCD1AD0E46515F"},
statusBarHeight: {}, statusBarHeight: {},
projectTabIndex: 1, projectTabIndex: 1,
jumpURLForI: "", //中华医学会一类跳转地址 jumpURLForI: "", //中华医学会一类跳转地址
......
...@@ -97,19 +97,21 @@ const question = { ...@@ -97,19 +97,21 @@ const question = {
// 处理返回的数据 // 处理返回的数据
handlerQuestionList({ commit, state }, rezultData) { handlerQuestionList({ commit, state }, rezultData) {
let questionList = rezultData.practiseTitleModelList || []; let questionList = rezultData.practiseTitleModelList || [];
let handlerList = [], question, option, optionList = [], myAnswer = "", answer = ""; let handlerList = [], question, option, optionList = [], myAnswer = "",
answer = "", questionContent = "";
questionList.forEach( (item, index) => { questionList.forEach((item, index) => {
myAnswer = item.myAnswer; myAnswer = item.myAnswer;
answer = item.answer; answer = item.answer;
question = JSON.parse(JSON.stringify(item)); question = JSON.parse(JSON.stringify(item));
question.question = question.question.replace(/<img/, '<img style="max-width:98%;"');
question.intro = question.intro.replace(/<img/, '<img style="max-width:98%;"');
let isAnalyzed = question.commitFlag && myAnswer != answer; let isAnalyzed = question.commitFlag && myAnswer != answer;
question.isAnalyzed = isAnalyzed; question.isAnalyzed = isAnalyzed;
option = {}; option = {};
optionList = []; optionList = [];
question.options.forEach( (text, i) => { question.options.forEach((text, i) => {
option.isCorrect = answer.indexOf(getOrderText(i)) != -1; option.isCorrect = answer.indexOf(getOrderText(i)) != -1;
if(myAnswer.indexOf(getOrderText(i)) != -1) { if (myAnswer.indexOf(getOrderText(i)) != -1) {
option.isSelected = true; option.isSelected = true;
} else { } else {
option.isSelected = false; option.isSelected = false;
...@@ -125,7 +127,7 @@ const question = { ...@@ -125,7 +127,7 @@ const question = {
let newList = concatArray(state.questionList, handlerList, 'titleNo'); let newList = concatArray(state.questionList, handlerList, 'titleNo');
commit("SET_QUESTION_LIST", newList); commit("SET_QUESTION_LIST", newList);
if(rezultData.isFirst) { if (rezultData.isFirst) {
let cIndex = findQuestionIndexNo(handlerList, 'titleNo', rezultData.currentTitleNo || 1); let cIndex = findQuestionIndexNo(handlerList, 'titleNo', rezultData.currentTitleNo || 1);
let titleConfig = { let titleConfig = {
bindStatus: rezultData.bindStatus, // 绑卡状态:0未绑卡 1已绑卡 bindStatus: rezultData.bindStatus, // 绑卡状态:0未绑卡 1已绑卡
...@@ -134,7 +136,7 @@ const question = { ...@@ -134,7 +136,7 @@ const question = {
resultId: rezultData.resultId, // 刷题库轮次ID resultId: rezultData.resultId, // 刷题库轮次ID
totalCount: rezultData.totalCount, // 题目总数 totalCount: rezultData.totalCount, // 题目总数
} }
commit("SET_CURRENT_QUESTION", newList[cIndex] || {titleNo: 1}); commit("SET_CURRENT_QUESTION", newList[cIndex] || { titleNo: 1 });
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 || '93521BDB92774134B2CC18633F2B6D3A' config.headers['token'] = config.data.token;
if (process.env.BUILD_ENV == "development") { // 本地开发环境 if (process.env.BUILD_ENV == "development") { // 本地开发环境
config.headers['token'] = config.data.token || '93521BDB92774134B2CC18633F2B6D3A'; config.headers['token'] = config.data.token;
} }
} }
delete config.data.setEntry; delete config.data.setEntry;
......
...@@ -303,7 +303,7 @@ export function getOrderText(index) { ...@@ -303,7 +303,7 @@ export function getOrderText(index) {
// 从数组中查找某个key对应值所在的位置(序号:0开始的) // 从数组中查找某个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;
}); });
return index; return index;
...@@ -311,22 +311,22 @@ export function findQuestionIndexNo(oList, key, keyValue) { ...@@ -311,22 +311,22 @@ export function findQuestionIndexNo(oList, key, keyValue) {
// 对两个数组中的元素进行排序 // 对两个数组中的元素进行排序
export function concatArray(firstArr = [], secondArr = [], key) { export function concatArray(firstArr = [], secondArr = [], key) {
if(firstArr.length == 0) return secondArr; if (firstArr.length == 0) return secondArr;
if(secondArr.length == 0) return []; if (secondArr.length == 0) return [];
let all = [], newArr = [], deleteIndex; let all = [], newArr = [], deleteIndex;
if(firstArr[0][key] == secondArr[0][key]) { if (firstArr[0][key] == secondArr[0][key]) {
return firstArr; return firstArr;
}else if(firstArr[0][key] < secondArr[0][key]) { } else if (firstArr[0][key] < secondArr[0][key]) {
all = firstArr.concat(secondArr); all = firstArr.concat(secondArr);
} else { } else {
all = secondArr.concat(firstArr); all = secondArr.concat(firstArr);
} }
// 从all中去重 // 从all中去重
for(let i = 0; i < all.length; i ++) { for (let i = 0; i < all.length; i++) {
deleteIndex = findQuestionIndexNo(all.slice(i + 1), key, all[i][key]); deleteIndex = findQuestionIndexNo(all.slice(i + 1), key, all[i][key]);
if(deleteIndex >= 0) { if (deleteIndex >= 0) {
all.splice(deleteIndex, 1); all.splice(deleteIndex, 1);
i --; i--;
} }
} }
console.log("in contactArray", all); console.log("in contactArray", all);
......
import fetch from '@/utils/fetch' import fetch from '@/utils/fetch'
import { getBaseUrl, getApiUrl } from '@/utils/index' import { getBaseUrl, getApiUrl } from '@/utils/index'
import store from '../store';
module.exports = { module.exports = {
data: function () { data: function () {
return { return {
token: null token: 'weewfwefw'
} }
}, },
created: function () { created: function () {
...@@ -110,7 +111,7 @@ module.exports = { ...@@ -110,7 +111,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 || '93521BDB92774134B2CC18633F2B6D3A'; let token = para.token || this.token || this.$store.state.user.token || this.$store.state.coop.userInfo.userToken;
para.token = token; para.token = token;
delete para.token; delete para.token;
delete para.setEntry; delete para.setEntry;
...@@ -148,7 +149,7 @@ module.exports = { ...@@ -148,7 +149,7 @@ module.exports = {
// 通用POST请求 // 通用POST请求
POST(api, para, callback) { POST(api, para, callback) {
let token = para.token || this.token || this.$store.state.user.token || '93521BDB92774134B2CC18633F2B6D3A'; let token = para.token || this.token || this.$store.state.user.token || this.$store.state.coop.userInfo.userToken;
para.token = token; para.token = token;
delete para.token; delete para.token;
delete para.setEntry; delete para.setEntry;
...@@ -162,7 +163,7 @@ module.exports = { ...@@ -162,7 +163,7 @@ module.exports = {
// 通用POST请求 // 通用POST请求
NEW_POST(api, para, callback) { NEW_POST(api, para, callback) {
// para.token = para.token || this.token || '00175A13D70D4234822D90AC3C74202C' // para.token = para.token || this.token || this.$store.state.coop.userInfo.userToken;
return fetch({ return fetch({
url: getBaseUrl(api), url: getBaseUrl(api),
method: 'post', method: 'post',
...@@ -172,7 +173,7 @@ module.exports = { ...@@ -172,7 +173,7 @@ module.exports = {
// 通用GET请求 // 通用GET请求
API_GET(api, para, callback) { API_GET(api, para, callback) {
para.token = para.token || this.token || '00175A13D70D4234822D90AC3C74202C' //'AF3DFCF2DD4B4115AC47ACA25D5420E9''F90DF48D3EFA49DFAE1267A67DBEFB18'//token para.token = para.token || this.token || this.$store.state.coop.userInfo.userToken; //'AF3DFCF2DD4B4115AC47ACA25D5420E9''F90DF48D3EFA49DFAE1267A67DBEFB18'//token
let url = api + this.getUrlPara(para) let url = api + this.getUrlPara(para)
return fetch({ return fetch({
url: getApiUrl(url), url: getApiUrl(url),
...@@ -183,7 +184,7 @@ module.exports = { ...@@ -183,7 +184,7 @@ module.exports = {
// 通用POST请求 // 通用POST请求
API_POST(api, para, callback) { API_POST(api, para, callback) {
para.token = para.token || this.token || '00175A13D70D4234822D90AC3C74202C' //'AF3DFCF2DD4B4115AC47ACA25D5420E9''F90DF48D3EFA49DFAE1267A67DBEFB18'//token para.token = para.token || this.token || this.$store.state.coop.userInfo.userToken; //'AF3DFCF2DD4B4115AC47ACA25D5420E9''F90DF48D3EFA49DFAE1267A67DBEFB18'//token
return fetch({ return fetch({
url: getApiUrl(api), url: getApiUrl(api),
method: 'post', method: 'post',
...@@ -222,7 +223,8 @@ module.exports = { ...@@ -222,7 +223,8 @@ module.exports = {
// 校验token,有效则调用回调函数,否则调起原生登陆页面 // 校验token,有效则调用回调函数,否则调起原生登陆页面
commonCheckToken(cb) { commonCheckToken(cb) {
let param = { let param = {
token: this.token, // token: this.token,
token: this.token || this.$store.state.user.token || this.$store.state.coop.userInfo.userToken,
setEntry: true setEntry: true
}; };
this.GET("campaign/admin/task/checkToken", param).then(res => { this.GET("campaign/admin/task/checkToken", param).then(res => {
...@@ -237,7 +239,7 @@ module.exports = { ...@@ -237,7 +239,7 @@ module.exports = {
// 校验token,有效则调用回调函数,否则使用调起原生登陆页面 // 校验token,有效则调用回调函数,否则使用调起原生登陆页面
checkTokenForNative(cb) { checkTokenForNative(cb) {
let param = { let param = {
token: this.token, token: this.token || this.$store.state.coop.userInfo.userToken,
setEntry: true setEntry: true
}; };
this.GET("campaign/admin/task/checkToken", param).then(res => { this.GET("campaign/admin/task/checkToken", param).then(res => {
......
...@@ -6,13 +6,14 @@ ...@@ -6,13 +6,14 @@
:total="titleConfig.totalCount" :total="titleConfig.totalCount"
></question-header> ></question-header>
<article class="body"> <article class="body">
<question-content v-show="questionList.length"></question-content> <question-content ref="questionContentRef" 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 v-show="questionList.length" @statistics="statistics" @pageQuestion="pageQuestion"></question-footer>
<ExperienceDialog <ExperienceDialog
:showDialog="experienceDialog" :showDialog="experienceDialog"
:statisConfig="statisConfig"
@activeCard="activeCard" @activeCard="activeCard"
@buyCard="buyCard" @buyCard="buyCard"
@close="experienceDialog = false" @close="experienceDialog = false"
...@@ -67,7 +68,8 @@ export default { ...@@ -67,7 +68,8 @@ export default {
}, },
data() { data() {
return { return {
// token: "", // mixns里有 token: "",
// token: "",
directoryId: "", directoryId: "",
cardType: 3, cardType: 3,
goodsType: 3, goodsType: 3,
...@@ -95,14 +97,21 @@ export default { ...@@ -95,14 +97,21 @@ export default {
titleNo: 0, // 起始或结束题目ID,首次进入页面时传0,系统自动定位到上次做的题 titleNo: 0, // 起始或结束题目ID,首次进入页面时传0,系统自动定位到上次做的题
pageFlag: 0, // 翻页标记:0往前翻页 1往后翻页 pageFlag: 0, // 翻页标记:0往前翻页 1往后翻页
pageSize: 5, // 每页大小 pageSize: 5, // 每页大小
},
statisConfig: {
rightNum: 0,
errorNum: 0,
rate: 0
} }
}; };
}, },
computed: { computed: {
...mapGetters([ ...mapGetters([
"userInfo",
"questionList", "questionList",
"currentQuestion", "currentQuestion",
"totalCount", "totalCount",
"commonConfig",
"titleConfig" "titleConfig"
]), ]),
needFixed() { needFixed() {
...@@ -127,27 +136,15 @@ export default { ...@@ -127,27 +136,15 @@ export default {
this.queryParams.directoryId = this.directoryId; this.queryParams.directoryId = this.directoryId;
this.queryParams.secondSubjectId = this.secondSubjectId; this.queryParams.secondSubjectId = this.secondSubjectId;
// queryParams: {
// commitKind: 3, // 答题来源 1:错题集 2:收藏 3:题库
// directoryId: 1748, // 题库ID,获取错题集或收藏时传0
// pageFlag: 0, // 翻页标记:0往前翻页 1往后翻页
// pageSize: 5, // 每页大小
// secondSubjectId: 106, // 二级学科分类ID:用于判断学科下目录免费题数
// titleNo: 0 // 起始或结束题目ID,首次进入页面时传0,系统自动定位到上次做的题
// }
window.__getUserInfoForQD = function(param) { window.__getUserInfoForQD = function(param) {
_this.token = param.userToken; _this.token = param.userToken;
_this.setUserInfo(param); _this.setUserInfo(param);
_this.getPractiseTitles(true); _this.init();
// _this.checkToken();
}; };
if (__isWeb) { if (__isWeb) {
_this.getPractiseTitles(true);
} else {
_this.init(); _this.init();
// _this.getUserInfo(); } else {
this.getUserInfo();
} }
window.__refresh = function() { window.__refresh = function() {
...@@ -165,9 +162,7 @@ export default { ...@@ -165,9 +162,7 @@ export default {
methods: { methods: {
...mapActions(["setUserInfo", "handlerQuestionList"]), ...mapActions(["setUserInfo", "handlerQuestionList"]),
init() { init() {
// 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,
...@@ -177,8 +172,7 @@ export default { ...@@ -177,8 +172,7 @@ export default {
goodsType: this.goodsType, goodsType: this.goodsType,
commitKind: this.commitKind // 答题来源 1:错题集 2:收藏 3:题库 commitKind: this.commitKind // 答题来源 1:错题集 2:收藏 3:题库
}); });
this.getUserInfo(); this.getPractiseTitles(true);
// this.getPractiseTitles();
// this.preJumper(); // this.preJumper();
}, },
...@@ -191,13 +185,34 @@ export default { ...@@ -191,13 +185,34 @@ export default {
// 统计当前信息 // 统计当前信息
statistics() { statistics() {
let correctNum = 0, // 如果是收费的题库(不是错题集或收载),并且没有绑定卡
errNum = 0, console.log(this.commonConfig.freeFlag, this.commitKind == 3, !this.titleConfig.bindStatus);
if(!(this.commonConfig.freeFlag == 1 && this.commitKind == 3 && !this.titleConfig.bindStatus)) {
Toast("已是最后一题");
return;
}
let rightNum = 0,
errorNum = 0,
rate = 0; rate = 0;
this.questionList.forEach(item => { this.questionList.forEach(item => {
if (item.commitKind) { if (item.commitFlag) {
if(item.myAnswer == item.answer) {
rightNum ++;
} else {
errorNum ++;
}
} }
}); });
console.log();
if((rightNum + errorNum) > 0) {
rate = (rightNum * 100 / (rightNum + errorNum)).toFixed(0);
this.statisConfig = {
rightNum,
errorNum,
rate
}
}
this.experienceDialog = true; this.experienceDialog = true;
}, },
...@@ -210,20 +225,21 @@ export default { ...@@ -210,20 +225,21 @@ export default {
// 打开激活弹框 // 打开激活弹框
activeCard() { activeCard() {
this.checkTokenForNative(() => {
this.experienceDialog = false; this.experienceDialog = false;
this.showChangeCard = true; this.showChangeCard = true;
});
}, },
buyCard() { buyCard() {
!__isWeb && this.confirm(); this.checkTokenForNative(() => {
this.confirm();
});
}, },
// 跳转到原生的购买页面 // 跳转到原生的购买页面
confirm() { confirm() {
// this.$sendBuriedData({
// component_tag: `882#88203`
// });
let appVersion = this.userInfo.appVersion || ""; let appVersion = this.userInfo.appVersion || "";
let appVersionNum = appVersion.split(".").join(""); let appVersionNum = appVersion.split(".").join("");
if (appVersionNum < 344) { if (appVersionNum < 344) {
...@@ -256,7 +272,6 @@ export default { ...@@ -256,7 +272,6 @@ export default {
seqNo: 1 seqNo: 1
} }
]; ];
this.$refs.tcPlayerRef && this.$refs.tcPlayerRef.pause();
rocNative.dispatchEventByModuleCode({ rocNative.dispatchEventByModuleCode({
modeCode: "M200", modeCode: "M200",
jsonString: paramList jsonString: paramList
...@@ -292,13 +307,16 @@ export default { ...@@ -292,13 +307,16 @@ export default {
// 分页获取题目(前、后翻页) // 分页获取题目(前、后翻页)
getPractiseTitles(isFirst) { getPractiseTitles(isFirst) {
if(isFirst) {
this.$store.commit("SET_QUESTION_LIST", []);
}
this.queryParams.token = this.userInfo.userToken || this.token;
this.queryParams.setEntry = true;
this.GET(`portal/titleTest/practise/titles`, this.queryParams).then( this.GET(`portal/titleTest/practise/titles`, this.queryParams).then(
({ data }) => { ({ data }) => {
this.currentTitleNo = data.currentTitleNo; this.currentTitleNo = data.currentTitleNo;
data.isFirst = isFirst; data.isFirst = isFirst;
this.handlerQuestionList(data); this.handlerQuestionList(data);
// this.handlerPractiseData(data.practiseTitleModelList);
console.log(data);
} }
); );
}, },
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册