提交 e01660d4 编写于 作者: guangjun.yang's avatar guangjun.yang

部分功能完善

bug修改
上级 68913c6e
<template>
<section class="qeustion-content-wrapper">
<article class="public-title" v-show="currentQuestion.unionType">
<p class="text" v-show="currentQuestion.unionType == 1">
{{currentQuestion.unionQuestion}}
</p>
<p class="text" v-show="currentQuestion.unionType == 1">{{currentQuestion.unionQuestion}}</p>
<article
class="select-wrapper"
style="padding: 10px 15px 20px;"
v-show="currentQuestion.unionType == 2"
>
<div
class="item"
v-for="(item, index) in currentQuestion.options"
:key="index"
>
<div class="item" v-for="(item, index) in currentQuestion.options" :key="index">
<span class="option">{{getOrderVac(index)}}.</span>
<span class="content">{{item.text}}</span>
</div>
......@@ -28,18 +22,31 @@
<!-- <img src="https://files.yunqueyi.com/image/png/protal/project/20200702161856970.png" /> -->
</article>
<article class="select-wrapper">
<div class="item" 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-if="(item.isSelected && !currentQuestion.commitFlag) || (!item.isSelected && currentQuestion.commitFlag && item.isCorrect)" class="option bg">{{getOrderVac(index)}}</span>
<div
class="item"
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-if="(item.isSelected && !currentQuestion.commitFlag) || (!item.isSelected && currentQuestion.commitFlag && item.isCorrect)"
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/error.png" alt />
</template>
<span v-if="!currentQuestion.commitFlag"
<span
v-if="!currentQuestion.commitFlag"
class="content"
:class="{'select': item.isSelected}"
>{{currentQuestion.unionType == 2 ? getOrderVac(index) : item.text}}</span>
<span v-else
<span
v-else
class="content"
:class="{'select': item.isCorrect, 'error': item.isSelected && !item.isCorrect}"
>{{currentQuestion.unionType == 2 ? getOrderVac(index) : item.text}}</span>
......@@ -58,7 +65,11 @@
<span class="content">查看病理,了解病史</span>
</div>-->
</article>
<article class="c-btn-wrapper" v-show="currentQuestion.typeId == 2 && !currentQuestion.commitFlag" @click="commitAnswer(true)">
<article
class="c-btn-wrapper"
v-show="currentQuestion.typeId == 2 && !currentQuestion.commitFlag"
@click="commitAnswer()"
>
<van-button size="large" round color="#449284">确 认</van-button>
</article>
<article class="answer-wrapper" v-show="currentQuestion.isAnalyzed">
......@@ -95,13 +106,7 @@ export default {
])
},
data() {
return {
analysisContent: `商户支付的订单号由商户自定义生成,仅支持使用字 母、数字、中划线-、下划线_、竖线|、
星号*这些英文 半角字符的组合,请勿使用汉字或全角等特殊字符。微 信支付要求商户订单号保持唯一性
(建议根据当前系统 时间加随机序列来生成订单号)。重新发起一笔支付要 使用原订单号,避免重复支付;
已支付过或已调用关 单、撤销(请见后文的API列表)的订单号不能重新发 起支付。
<img data-v-5f105ddf="" src="https://files.yunqueyi.com/image/png/protal/project/20200702161856970.png">`
};
return {};
},
methods: {
getOrderVac(index) {
......@@ -110,28 +115,30 @@ export default {
// 选择选项
selectOption(index) {
if(this.currentQuestion.commitFlag) return;
if (this.currentQuestion.commitFlag) return;
// 只记录当前选项,不提交答案
this.currentQuestion.options[index].isSelected = true;
// 重新设置答案(myAnswer)
if(this.currentQuestion.typeId == 2) {
if (this.currentQuestion.typeId == 2) {
let myAnswer = "";
this.currentQuestion.options.forEach( (item, index) => {
if(item.isSelected) {
this.currentQuestion.options.forEach((item, index) => {
if (item.isSelected) {
myAnswer += this.getOrderVac(index);
}
})
myAnswer = myAnswer.split('').join(',');
});
myAnswer = myAnswer.split("").join(",");
this.currentQuestion.myAnswer = myAnswer;
} else {
// 单选题或者判断题直接设置commitFlag
if(this.currentQuestion.options[index].isCorrect) {
if (this.currentQuestion.options[index].isCorrect) {
this.currentQuestion.commitFlag = 1;
} else {
this.currentQuestion.commitFlag = 2;
}
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.myAnswer = this.getOrderVac(index);
this.commitAnswer();
......@@ -141,8 +148,8 @@ export default {
},
// 提交答案
commitAnswer(isMulti) {
this.checkTokenForNative((isMulti) => {
commitAnswer() {
this.checkTokenForNative( () => {
let params = {
commitKind: this.commonConfig.commitKind, // 答题来源 1:错题集 2:收藏 3:题库
directoryId: this.currentQuestion.directoryId, // 题库ID
......@@ -154,33 +161,31 @@ export default {
titleId: this.currentQuestion.titleId, // 题目ID
titleNo: this.currentQuestion.titleNo, // 题目ID
setEntry: true,
token: this.userInfo.userToken,
token: this.userInfo.userToken
};
// 计算是否答对了题目(只有多选题,才做相应处理)
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) {
if (this.currentQuestion.typeId == 2) {
console.log('isMulti', isMulti);
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 }) => {
// this.currentTitleNo = data.currentTitleNo;
// this.handlerQuestionList(data);
// this.handlerPractiseData(data.practiseTitleModelList);
console.log("onlineexam/practise/commit", data);
});
console.log('in commitAnswer res', data);
if(data.resultType == 1) {
this.currentQuestion.commitFlag = 1;
} else {
this.currentQuestion.commitFlag = 2;
}
}).catch( error => {
this.currentQuestion.commitFlag = 0;
this.currentQuestion.isAnalyzed = false;
})
});
}
}
};
......@@ -205,7 +210,7 @@ export default {
top: 3px;
left: 0;
display: inline-block;
width: 44px;
width: 47px;
height: 18px;
line-height: 12px;
margin-right: 4px;
......@@ -215,7 +220,7 @@ export default {
& > span {
position: absolute;
top: 3px;
left: 4px;
left: 4.5px;
color: #ffffff;
}
&.multi {
......
......@@ -54,8 +54,8 @@ export default {
"SET_CURRENT_QUESTION",
this.questionList[cIndex - 1] || { answerList: [] }
);
console.log(cIndex == 1, this.currentQuestion.titleNo > 2);
if(cIndex == 1 && this.currentQuestion.titleNo > 2) {
console.log(cIndex == 1, this.currentQuestion.titleNo >= 2);
if(cIndex == 1 && this.currentQuestion.titleNo >= 2) {
this.$emit("pageQuestion", 0, this.questionList[0].titleNo);
}
}
......@@ -64,8 +64,8 @@ export default {
// 下一页 // 有可能要触发下分页(后面的个数只有一条)
// TODO
next() {
// if (this.currentQuestion.titleNo == this.totalCount) {
if (this.currentQuestion.titleNo == this.questionList.length
if (this.currentQuestion.titleNo == this.totalCount
// if (this.currentQuestion.titleNo == this.questionList.length
|| this.currentQuestion.titleNo == this.questionList[this.questionList.length - 1].titleNo) {
this.$emit("statistics");
} else {
......@@ -107,7 +107,7 @@ export default {
operateType: favorFlag == 1 ? 2 : 1, // 操作类型:1:收藏 2:取消收藏
paperId: currentQuestion.paperId,
paperIndex: currentQuestion.paperIndex,
token: this.userInfo.userToken || this.token || '93521BDB92774134B2CC18633F2B6D3A',
token: this.userInfo.userToken || this.token || 'EFC0A4A5EC4B49FBBBBCD1AD0E46515F',
setEntry: true
// userId: 0
};
......
......@@ -97,19 +97,21 @@ const question = {
// 处理返回的数据
handlerQuestionList({ commit, state }, rezultData) {
let questionList = rezultData.practiseTitleModelList || [];
let handlerList = [], question, option, optionList = [], myAnswer = "", answer = "";
questionList.forEach( (item, index) => {
let handlerList = [], question, option, optionList = [], myAnswer = "",
answer = "", questionContent = "";
questionList.forEach((item, index) => {
myAnswer = item.myAnswer;
answer = item.answer;
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;
question.isAnalyzed = isAnalyzed;
option = {};
optionList = [];
question.options.forEach( (text, i) => {
question.options.forEach((text, i) => {
option.isCorrect = answer.indexOf(getOrderText(i)) != -1;
if(myAnswer.indexOf(getOrderText(i)) != -1) {
if (myAnswer.indexOf(getOrderText(i)) != -1) {
option.isSelected = true;
} else {
option.isSelected = false;
......@@ -125,7 +127,7 @@ const question = {
let newList = concatArray(state.questionList, handlerList, 'titleNo');
commit("SET_QUESTION_LIST", newList);
if(rezultData.isFirst) {
if (rezultData.isFirst) {
let cIndex = findQuestionIndexNo(handlerList, 'titleNo', rezultData.currentTitleNo || 1);
let titleConfig = {
bindStatus: rezultData.bindStatus, // 绑卡状态:0未绑卡 1已绑卡
......@@ -134,7 +136,7 @@ const question = {
resultId: rezultData.resultId, // 刷题库轮次ID
totalCount: rezultData.totalCount, // 题目总数
}
commit("SET_CURRENT_QUESTION", newList[cIndex] || {titleNo: 1});
commit("SET_CURRENT_QUESTION", newList[cIndex] || { titleNo: 1 });
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 || '93521BDB92774134B2CC18633F2B6D3A'
config.headers['token'] = config.data.token || 'EFC0A4A5EC4B49FBBBBCD1AD0E46515F'
if (process.env.BUILD_ENV == "development") { // 本地开发环境
config.headers['token'] = config.data.token || '93521BDB92774134B2CC18633F2B6D3A';
config.headers['token'] = config.data.token || 'EFC0A4A5EC4B49FBBBBCD1AD0E46515F';
}
}
delete config.data.setEntry;
......
......@@ -303,7 +303,7 @@ export function getOrderText(index) {
// 从数组中查找某个key对应值所在的位置(序号:0开始的)
export function findQuestionIndexNo(oList, key, keyValue) {
let index = oList.findIndex( item => {
let index = oList.findIndex(item => {
return item[key] == keyValue;
});
return index;
......@@ -311,22 +311,22 @@ export function findQuestionIndexNo(oList, key, keyValue) {
// 对两个数组中的元素进行排序
export function concatArray(firstArr = [], secondArr = [], key) {
if(firstArr.length == 0) return secondArr;
if(secondArr.length == 0) return [];
if (firstArr.length == 0) return secondArr;
if (secondArr.length == 0) return [];
let all = [], newArr = [], deleteIndex;
if(firstArr[0][key] == secondArr[0][key]) {
if (firstArr[0][key] == secondArr[0][key]) {
return firstArr;
}else if(firstArr[0][key] < secondArr[0][key]) {
} 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 ++) {
for (let i = 0; i < all.length; i++) {
deleteIndex = findQuestionIndexNo(all.slice(i + 1), key, all[i][key]);
if(deleteIndex >= 0) {
if (deleteIndex >= 0) {
all.splice(deleteIndex, 1);
i --;
i--;
}
}
console.log("in contactArray", 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 || '93521BDB92774134B2CC18633F2B6D3A';
let token = para.token || this.token || this.$store.state.user.token || 'EFC0A4A5EC4B49FBBBBCD1AD0E46515F';
para.token = token;
delete para.token;
delete para.setEntry;
......@@ -148,7 +148,7 @@ module.exports = {
// 通用POST请求
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 || 'EFC0A4A5EC4B49FBBBBCD1AD0E46515F';
para.token = token;
delete para.token;
delete para.setEntry;
......
......@@ -68,7 +68,7 @@ export default {
},
data() {
return {
token: "",
token: "EFC0A4A5EC4B49FBBBBCD1AD0E46515F",
directoryId: "",
cardType: 3,
goodsType: 3,
......@@ -311,6 +311,8 @@ export default {
if(isFirst) {
this.$store.commit("SET_QUESTION_LIST", []);
}
this.queryParams.token = "EFC0A4A5EC4B49FBBBBCD1AD0E46515F";
this.queryParams.setEntry = true;
this.GET(`portal/titleTest/practise/titles`, this.queryParams).then(
({ data }) => {
this.currentTitleNo = data.currentTitleNo;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册