Commit 0628aaca authored by 林文清's avatar 林文清

fix:学习考试下一题403错误,跳页错误

parent 840bea4b
...@@ -674,7 +674,7 @@ export default { ...@@ -674,7 +674,7 @@ export default {
} }
if (res.data.examStatus == 1) { if (res.data.examStatus == 1) {
that.examList[i].isComplete = that.examList[i].isComplete =
this.examList[i].status == "通过"; this.examList[i].status == "已通过";
that.examScore = res.data.examScore; that.examScore = res.data.examScore;
return; return;
} }
......
<template> <template>
<view class="backView"> <view class="backView">
<Examine :index="3"> <Examine :index="3">
<view class="bottom-padding" v-if="currentItem"> <view class="bottom-padding">
<view class="title-view"> <view class="title-view">
<view :class="['title-text', {'radio': currentItem.question ? currentItem.question.answerType == 1 : true}]"> <view :class="['title-text', {'radio': currentItem.question ? currentItem.question.answerType == 1 : true}]">
<text>{{ titleText[Math.max(0, currentItem.question ? currentItem.question.answerType - 1 : 0)] }}</text> <text>{{ titleText[Math.max(0, currentItem.question ? currentItem.question.answerType - 1 : 0)] }}</text>
...@@ -70,7 +70,13 @@ export default { ...@@ -70,7 +70,13 @@ export default {
userAnswerIds: "", userAnswerIds: "",
isStart: true, isStart: true,
currentNumber: 1, currentNumber: 1,
currentItem: null, currentItem: {
question: {
answerType: 1,
content: ""
},
answerList: {}
},
isSelect: false, isSelect: false,
timeDefine: { timeDefine: {
"time-id-2": 1800, "time-id-2": 1800,
...@@ -89,6 +95,7 @@ export default { ...@@ -89,6 +95,7 @@ export default {
timer: null, timer: null,
isComplete: false, // 是否已经考试完成判定 isComplete: false, // 是否已经考试完成判定
examInfo: null, examInfo: null,
isLoadQuestion: true
}; };
}, },
computed: { computed: {
...@@ -107,11 +114,15 @@ export default { ...@@ -107,11 +114,15 @@ export default {
}, },
onLoad(e) { onLoad(e) {
this.examId = e.examId; this.examId = e.examId;
this.applyExam(); this.userExamId = e.userExamId;
this.getNext();
// this.applyExam();
// this.getUserExamInfo(); // this.getUserExamInfo();
}, },
onUnload() { onUnload() {
clearTimeout(this.timer); clearTimeout(this.timer);
let key = 'exma-' + this.examId;
uni.setStorageSync(key, this.endTime);
}, },
methods: { methods: {
formatTimeToMini(timestamp) { formatTimeToMini(timestamp) {
...@@ -335,11 +346,6 @@ export default { ...@@ -335,11 +346,6 @@ export default {
(this.userAnswerIds || "9999") + (this.userAnswerIds || "9999") +
",", // 9999超时自动下一题 ",", // 9999超时自动下一题
method: "POST", method: "POST",
data: {
// userExamId:this.userExamId,
// questionId:this.currentItem.question.id,
// userAnswerIds:this.userAnswerIds,
},
header: { header: {
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
}, },
...@@ -359,6 +365,20 @@ export default { ...@@ -359,6 +365,20 @@ export default {
if (res.data.code == 200) { if (res.data.code == 200) {
that.currentItem = res.data.data; that.currentItem = res.data.data;
that.progress = res.data.data.progress; that.progress = res.data.data.progress;
if(this.isLoadQuestion){
this.isLoadQuestion = false;
if(!res.data.data.isQuestion){
this.applyExam()
return
}
let key = 'exma-' + this.examId;
let limitTime = uni.getStorageSync(key);
console.log(limitTime);
// let limitTime = this.getLimitTime(that.progress);
// console.log(limitTime);
this.endTime = parseInt(limitTime);
this.currentTime = parseInt(limitTime * 1000);
}
if (res.data.data.isQuestion) { if (res.data.data.isQuestion) {
let str = res.data.data.question.content; let str = res.data.data.question.content;
var wz = str.indexOf("."); var wz = str.indexOf(".");
...@@ -397,7 +417,12 @@ export default { ...@@ -397,7 +417,12 @@ export default {
}, },
}); });
}, },
getLimitTime(progress){
let arr = progress.split('/');
let how = arr[0].replace(/[^0-9]/ig,"");
let total = arr[1].replace(/[^0-9]/ig,"");
return (total - how + 1) * this.currentTime;
},
handleData: function () { handleData: function () {
this.currentItem.answerList.forEach((item, index) => { this.currentItem.answerList.forEach((item, index) => {
item.isSelect = false; item.isSelect = false;
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
这是一场严肃的考试,请认真查看 规则,预祝您顺利通过考试! 这是一场严肃的考试,请认真查看 规则,预祝您顺利通过考试!
</view> </view>
<view class="text"> <view class="text">
<text class="left">考试科目:</text><text style="color: #007aff">{{ desc.title }}</text> <text class="left">考试科目:</text><text style="color: #007aff">{{ title }}</text>
</view> </view>
<view class="text"> <view class="text">
<text class="left">合格条件:</text><text>{{ desc.score }}</text> <text class="left">合格条件:</text><text>{{ score }}</text>
</view> </view>
<view class="text"> <view class="text">
<text class="left">考试时间:</text><text>{{ desc.time }}</text> <text class="left">考试时间:</text><text>{{ time }}</text>
</view> </view>
<view class="text"> <view class="text">
<text class="left">题目来源:</text><text>{{ ruleDisc }}</text> <text class="left">题目来源:</text><text>{{ ruleDisc }}</text>
...@@ -24,122 +24,46 @@ ...@@ -24,122 +24,46 @@
</template> </template>
<script> <script>
let condition = {
dev: {
"id-2": {
score: "60分",
time: "30分钟",
number: "20",
title: "服务规范",
},
"id-3": {
score: "30分",
time: "15分钟",
number: "10",
title: "服务规范",
},
"id-4": {
score: "15分",
time: "6分钟",
number: "4",
title: "交付规范",
},
},
test: {
"id-2": {
score: "60分",
time: "30分钟",
number: "20",
title: "服务规范",
},
"id-3": {
score: "30分",
time: "15分钟",
number: "10",
title: "服务规范",
},
"id-4": {
score: "15分",
time: "6分钟",
number: "4",
title: "交付规范",
},
},
prod: {
"id-2": {
score: "60分",
time: "30分钟",
number: "20",
title: "服务规范",
},
"id-3": {
score: "30分",
time: "15分钟",
number: "10",
title: "服务规范",
},
"id-4": {
score: "15分",
time: "6分钟",
number: "4",
title: "交付规范",
},
},
};
let env = process.uniEnv.node_env;
let desc = condition[env];
export default { export default {
data() { data() {
return { return {
desc: null, title: "",
score: "",
time: "",
ruleDisc: "",
examId: null, examId: null,
exam: null, exam: null,
userExamId: null, userExamId: null
ruleDisc: "",
}; };
}, },
onLoad(param) { onLoad(param) {
this.examId = param.examId; this.examId = param.examId;
this.desc = desc["id-" + this.examId];
this.getExamResult(); this.getExamResult();
// this.getUserExamInfo(); // this.getUserExamInfo();
}, },
onUnload() {
uni.switchTab({
url: '/pages/index/learn'
});
},
methods: { methods: {
//申请考试获取userExamId //申请考试获取userExamId
getUserExamId: function () { getUserExamId: function () {
let examId = this.examId; let examId = this.examId;
let userExamId = this.userExamId;
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
let length = routes.length
if(length > 8){
uni.showToast({
icon: "none",
title: "打开页面过多,请返回后再操作",
});
return;
}
console.log(length);
wx.navigateTo({ wx.navigateTo({
url: "/pages/learn/answer?examId=" + examId, url: "/pages/learn/answer?examId=" + examId + "&userExamId=" + userExamId,
});
},
getUserExamInfo() {
uni.request({
url:
process.uniEnv.systemUrl.apiUrl +
"/wxh-worker-rest/rest/exam/serviceRule/" +
this.vuex_token +
"?examId=" +
this.examId,
method: "POST",
header: {
"Content-Type": "application/x-www-from-urlencoded",
},
success: (res) => {
uni.hideLoading();
if (res.data.code == 200) {
if (res.data.data.userExamId) {
this.userExamId = res.data.data.userExamId;
}
}
},
}); });
setTimeout(() => {
wx.navigateTo({
url: "/pages/learn/answer?userExamId=" + this.userExamId,
});
}, 1000);
}, },
getExamResult() { getExamResult() {
uni.request({ uni.request({
...@@ -158,10 +82,12 @@ export default { ...@@ -158,10 +82,12 @@ export default {
if (res.data.code == 200) { if (res.data.code == 200) {
if (res.data.data.ruleDisc) { if (res.data.data.ruleDisc) {
var str = res.data.data.ruleDisc; var str = res.data.data.ruleDisc;
this.userExamId = res.data.data.id;
let strArr = str.split("(")[0].split(","); let strArr = str.split("(")[0].split(",");
this.desc.title = strArr[0]; this.title = strArr[0];
this.desc.score = strArr[1]; this.score = strArr[1];
this.desc.time = strArr[2]; this.time = strArr[2];
this.ruleDisc = strArr[3]; this.ruleDisc = strArr[3];
} }
} }
......
...@@ -77,7 +77,6 @@ export default { ...@@ -77,7 +77,6 @@ export default {
//再次考试 //再次考试
getAgain: function () { getAgain: function () {
let examId = this.examId; let examId = this.examId;
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
uni.navigateTo({ uni.navigateTo({
url: "/pages/learn/assessment?examId=" + examId, url: "/pages/learn/assessment?examId=" + examId,
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment