Commit a2db2129 authored by 林文清's avatar 林文清

fix:学习考试模块 各种页面跳转返回错误

parent 822f205a
...@@ -153,7 +153,7 @@ var json = { ...@@ -153,7 +153,7 @@ var json = {
{ {
title: "服务规范", title: "服务规范",
desc: "为用户提供更好服务,自己赚更多钱", desc: "为用户提供更好服务,自己赚更多钱",
pic: process.uniEnv.qn_base_url + "fwgf-3x.png", pic: process.uniEnv.qn_base_url + "fwgf-3x-v2.png",
percent: 0, percent: 0,
status: "", status: "",
id: 173, id: 173,
...@@ -162,7 +162,7 @@ var json = { ...@@ -162,7 +162,7 @@ var json = {
{ {
title: "接单规范", title: "接单规范",
desc: "快速学习,使用APP 接单、抢单", desc: "快速学习,使用APP 接单、抢单",
pic: process.uniEnv.qn_base_url + "jdgf-3x.png", pic: process.uniEnv.qn_base_url + "jdgf-3x-v2.png",
percent: 0, percent: 0,
status: "", status: "",
id: 173, id: 173,
...@@ -171,7 +171,7 @@ var json = { ...@@ -171,7 +171,7 @@ var json = {
{ {
title: "从0-1学习充电桩安装服务", title: "从0-1学习充电桩安装服务",
desc: "让你全面了解充电桩市场及服务规范", desc: "让你全面了解充电桩市场及服务规范",
pic: process.uniEnv.qn_base_url + "cdz-3x.png", pic: process.uniEnv.qn_base_url + "cdz-3x-v2.png",
percent: 0, percent: 0,
status: "", status: "",
id: 173, id: 173,
...@@ -182,7 +182,7 @@ var json = { ...@@ -182,7 +182,7 @@ var json = {
{ {
title: "服务规范", title: "服务规范",
desc: "为用户提供更好服务,自己赚更多钱", desc: "为用户提供更好服务,自己赚更多钱",
pic: process.uniEnv.qn_base_url + "fwgf-3x.png", pic: process.uniEnv.qn_base_url + "fwgf-3x-v2.png",
percent: 0, percent: 0,
status: "", status: "",
id: 150, id: 150,
...@@ -191,7 +191,7 @@ var json = { ...@@ -191,7 +191,7 @@ var json = {
{ {
title: "接单规范", title: "接单规范",
desc: "快速学习,使用APP 接单、抢单", desc: "快速学习,使用APP 接单、抢单",
pic: process.uniEnv.qn_base_url + "jdgf-3x.png", pic: process.uniEnv.qn_base_url + "jdgf-3x-v2.png",
percent: 0, percent: 0,
status: "", status: "",
id: 149, id: 149,
...@@ -200,7 +200,7 @@ var json = { ...@@ -200,7 +200,7 @@ var json = {
{ {
title: "从0-1学习充电桩安装服务", title: "从0-1学习充电桩安装服务",
desc: "让你全面了解充电桩市场及服务规范", desc: "让你全面了解充电桩市场及服务规范",
pic: process.uniEnv.qn_base_url + "cdz-3x.png", pic: process.uniEnv.qn_base_url + "cdz-3x-v2.png",
percent: 0, percent: 0,
status: "", status: "",
id: 151, id: 151,
...@@ -211,7 +211,7 @@ var json = { ...@@ -211,7 +211,7 @@ var json = {
{ {
title: "服务规范", title: "服务规范",
desc: "为用户提供更好服务,自己赚更多钱", desc: "为用户提供更好服务,自己赚更多钱",
pic: process.uniEnv.qn_base_url + "fwgf-3x.png", pic: process.uniEnv.qn_base_url + "fwgf-3x-v2.png",
percent: 0, percent: 0,
status: "", status: "",
sectionId: "", sectionId: "",
...@@ -219,7 +219,7 @@ var json = { ...@@ -219,7 +219,7 @@ var json = {
{ {
title: "接单规范", title: "接单规范",
desc: "快速学习,使用APP 接单、抢单", desc: "快速学习,使用APP 接单、抢单",
pic: process.uniEnv.qn_base_url + "jdgf-3x.png", pic: process.uniEnv.qn_base_url + "jdgf-3x-v2.png",
percent: 0, percent: 0,
status: "", status: "",
sectionId: "", sectionId: "",
...@@ -227,7 +227,7 @@ var json = { ...@@ -227,7 +227,7 @@ var json = {
{ {
title: "从0-1学习充电桩安装服务", title: "从0-1学习充电桩安装服务",
desc: "让你全面了解充电桩市场及服务规范", desc: "让你全面了解充电桩市场及服务规范",
pic: process.uniEnv.qn_base_url + "cdz-3x.png", pic: process.uniEnv.qn_base_url + "cdz-3x-v2.png",
percent: 0, percent: 0,
status: "", status: "",
sectionId: "", sectionId: "",
...@@ -242,7 +242,7 @@ var examJson = { ...@@ -242,7 +242,7 @@ var examJson = {
desc: "通过本认证,是接单的必要条件", desc: "通过本认证,是接单的必要条件",
condition: "随机20题,及格20题", condition: "随机20题,及格20题",
status: "", status: "",
pic: process.uniEnv.qn_base_url + "fwgf-3x.png", pic: process.uniEnv.qn_base_url + "fwgf-e-3x.png",
id: 2, id: 2,
examId: "", examId: "",
examStatus: "", examStatus: "",
...@@ -425,6 +425,12 @@ export default { ...@@ -425,6 +425,12 @@ export default {
}, },
}, },
onShow: function (param) { onShow: function (param) {
try {
if (param.tabs) {
this.current = param.tabs;
this.swiperCurrent = param.tabs;
}
} catch (e) {}
if (this.current == 2 || this.current == 3) { if (this.current == 2 || this.current == 3) {
this.tabsChange(this.current); this.tabsChange(this.current);
} }
...@@ -588,8 +594,8 @@ export default { ...@@ -588,8 +594,8 @@ export default {
}, },
//tabs通知swiper切换 //tabs通知swiper切换
tabsChange(index) { tabsChange(index) {
this.swiperCurrent = index; this.swiperCurrent = Number(index);
switch (index) { switch (this.swiperCurrent) {
case 1: case 1:
this.loadNews(); this.loadNews();
break; break;
...@@ -705,25 +711,24 @@ export default { ...@@ -705,25 +711,24 @@ export default {
var examInfo = this.examList[index]; var examInfo = this.examList[index];
if (examInfo.examStatus == 0) { if (examInfo.examStatus == 0) {
wx.navigateTo({ wx.navigateTo({
// url: "/pages/learn/answer?examId=" + examInfo.id,
url: "/pages/learn/assessment?examId=" + examInfo.id, url: "/pages/learn/assessment?examId=" + examInfo.id,
}); });
} else if (examInfo.examStatus == 1) { } else if (examInfo.examStatus == 1) {
let url = '';
if (examInfo.status == "已通过") { if (examInfo.status == "已通过") {
wx.navigateTo({ url = "/pages/learn/exam-pass?userExamId=" +
url: examInfo.examId +
"/pages/learn/exam-pass?userExamId=" + "&examId=" +
examInfo.examId, examInfo.id;
});
} else { } else {
wx.navigateTo({ url = "/pages/learn/result?userExamId=" +
url:
"/pages/learn/result?userExamId=" +
examInfo.examId + examInfo.examId +
"&examId=" + "&examId=" +
examInfo.id, examInfo.id
});
} }
wx.navigateTo({
url: url,
});
} else if (examInfo.examStatus == 2) { } else if (examInfo.examStatus == 2) {
wx.navigateTo({ wx.navigateTo({
url: "/pages/learn/assessment?examId=" + examInfo.id, url: "/pages/learn/assessment?examId=" + examInfo.id,
......
...@@ -136,25 +136,22 @@ export default { ...@@ -136,25 +136,22 @@ export default {
toSubmit() { toSubmit() {
//判断是否通过,通过去成功页,失败去失败页 //判断是否通过,通过去成功页,失败去失败页
let examInfo = this.examInfo; let examInfo = this.examInfo;
let examId = this.examId;
let status = examInfo.examLevelResult == "已通过"; let status = examInfo.examLevelResult == "已通过";
let url = '';
if (status) { if (status) {
wx.navigateTo({ url = "/pages/learn/exam-pass?userExamId=" +
url:
"/pages/learn/exam-pass?userExamId=" +
this.userExamId + this.userExamId +
"&examId=" + "&examId=" +
examId, this.examId;
});
} else { } else {
wx.navigateTo({ url = "/pages/learn/result?userExamId=" +
url:
"/pages/learn/result?userExamId=" +
this.userExamId + this.userExamId +
"&examId=" + "&examId=" +
examId, this.examId
});
} }
wx.redirectTo({
url: url,
});
}, },
contentFilter(txt) { contentFilter(txt) {
if (!txt) { if (!txt) {
...@@ -172,7 +169,12 @@ export default { ...@@ -172,7 +169,12 @@ export default {
this.getUserExamInfo(); this.getUserExamInfo();
}, },
gotoLogin() {
uni.navigateTo({
url: "/pages/login/wxlogin",
});
return;
},
//获取考试信息 //获取考试信息
getUserExamInfo: function () { getUserExamInfo: function () {
uni.showLoading({ uni.showLoading({
...@@ -201,10 +203,12 @@ export default { ...@@ -201,10 +203,12 @@ export default {
return; return;
} }
if (res.data.code == 401 || res.data.code == 403) { if (res.data.code == 401 || res.data.code == 403) {
uni.navigateTo({ //提示 提交结果失败 请再次提交
url: "/pages/login/wxlogin", uni.showToast({
icon: "none",
title: "获取考试结果失败,请再次尝试提交",
}); });
return; return
} }
if (res.data.code == 200) { if (res.data.code == 200) {
//examStatus 用户考试状态 0考试中 1考试完成 2未参与 //examStatus 用户考试状态 0考试中 1考试完成 2未参与
...@@ -264,10 +268,8 @@ export default { ...@@ -264,10 +268,8 @@ export default {
success: (res) => { success: (res) => {
uni.hideLoading(); uni.hideLoading();
if (res.statusCode == 401) { if (res.statusCode == 401) {
uni.navigateTo({ this.gotoLogin();
url: "/pages/login/wxlogin", return
});
return;
} }
if (res.data.code == 200) { if (res.data.code == 200) {
...@@ -347,11 +349,16 @@ export default { ...@@ -347,11 +349,16 @@ export default {
success: (res) => { success: (res) => {
uni.hideLoading(); uni.hideLoading();
if (res.statusCode == 401) { if (res.statusCode == 401) {
uni.navigateTo({ this.gotoLogin()
url: "/pages/login/wxlogin",
});
return; return;
} }
if(res.statusCode == 403){
uni.showToast({
icon: "none",
title: "获取考试结果失败,请再次尝试提交",
});
return
}
if (res.data.code == 200) { if (res.data.code == 200) {
that.currentItem = res.data.data; that.currentItem = res.data.data;
console.log(that.currentItem); console.log(that.currentItem);
...@@ -496,55 +503,6 @@ export default { ...@@ -496,55 +503,6 @@ export default {
this.handleAnswer(); this.handleAnswer();
//this.getNext() //this.getNext()
}, },
//上传考试结果
postResult: function () {
uni.showLoading({
title: "请稍候",
});
let that = this;
uni.request({
url:
ucenterApiUrl +
"/v1/settled/update-settled-exam-score" +
"?access-token=" +
that.vuex_token,
method: "POST",
data: {
score: this.examScore || 0,
},
success: (res) => {
uni.hideLoading();
if (res.statusCode == 401) {
uni.navigateTo({
url: "/pages/login/wxlogin",
});
return;
}
if (res.statusCode == 200) {
// uni.navigateTo({
// url: '/pages/settle/prompt'
// })
} else {
uni.showToast({
icon: "none",
title: "上传考试结果失败",
});
}
},
fail: (e) => {
uni.hideLoading();
uni.showToast({
icon: "none",
title: "上传考试结果失败",
});
},
});
},
//所选答案 //所选答案
handleAnswer: function () { handleAnswer: function () {
/* /*
......
...@@ -31,7 +31,7 @@ export default { ...@@ -31,7 +31,7 @@ export default {
data() { data() {
return { return {
text: "", text: "",
examId: 2, examId: null,
result: null, result: null,
is_pass: false, is_pass: false,
score: 0, score: 0,
...@@ -39,54 +39,44 @@ export default { ...@@ -39,54 +39,44 @@ export default {
}; };
}, },
onLoad(a) { onLoad(a) {
this.examId = a.examId;
this.userExamId = a.userExamId; this.userExamId = a.userExamId;
console.log("userExamId是", this.userExamId); console.log("userExamId是", this.userExamId);
this.nextClick(); this.getCourseResult();
},
onUnload() {
this.toIndex()
}, },
// onUnload() {
// wx.reLaunch({
// url: "./index",
// });
// },
methods: { methods: {
//考试结果 //考试结果
nextClick: function () { getCourseResult: function () {
console.log("wwwwwwwwww"); this.$u.api
uni.request({ .getExamResult(this.examId)
url: .then((res) => {
process.uniEnv.systemUrl.apiUrl + if (res.code != 200) {
"/wxh-worker-rest/rest/exam" + console.log("getUserExamInfo 200 err");
"/serviceRule/next/" + uni.showToast({
this.vuex_token + icon: "none",
"?userExamId=" + title: "获取考试结果失败",
this.userExamId, });
}
method: "POST", this.result = res.data;
header: { this.text = res.data.examLevelResult;
"Content-Type": "application/x-www-form-urlencoded",
},
success: (res) => {
this.result = res.data.data;
this.text = res.data.data.examLevelResult;
this.score = this.result.examScore; this.score = this.result.examScore;
this.is_pass = this.result.result == '通过'; })
console.log("标识符55", this.result); .catch((err) => {
}, console.log("getUserExamInfo err" + err);
uni.hideLoading();
uni.showToast({
icon: "none",
title: "获取考试信息失败",
}); });
},
//再次考试
getAgain: function () {
wx.navigateTo({
url: "/pages/learn/assessment",
}); });
}, },
//下次再考跳转到学习主界面页面 //下次再考跳转到学习主界面页面
toIndex: function () { toIndex: function () {
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组 uni.switchTab({
let length = routes.length url: '/pages/index/learn'
uni.navigateBack({
delta: length - 1
}); });
}, },
}, },
......
...@@ -46,52 +46,50 @@ export default { ...@@ -46,52 +46,50 @@ export default {
this.userExamId = a.userExamId; this.userExamId = a.userExamId;
this.examId = a.examId; this.examId = a.examId;
console.log("userExamId是", this.userExamId); console.log("userExamId是", this.userExamId);
this.nextClick(); this.getCourseResult();
},
onUnload() {
this.toIndex()
}, },
// onUnload() {
// wx.reLaunch({
// url: "./index",
// });
// },
methods: { methods: {
//考试结果 //考试结果
nextClick: function () { getCourseResult: function () {
console.log("wwwwwwwwww"); this.$u.api
uni.request({ .getExamResult(this.examId)
url: .then((res) => {
process.uniEnv.systemUrl.apiUrl + if (res.code != 200) {
"/wxh-worker-rest/rest/exam" + console.log("getUserExamInfo 200 err");
"/serviceRule/next/" + uni.showToast({
this.vuex_token + icon: "none",
"?userExamId=" + title: "获取考试结果失败",
this.userExamId, });
}
method: "POST", this.result = res.data;
header: { this.text = res.data.examLevelResult;
"Content-Type": "application/x-www-form-urlencoded",
},
success: (res) => {
this.result = res.data.data;
this.text = res.data.data.examLevelResult;
this.score = this.result.examScore; this.score = this.result.examScore;
console.log("标识符55", this.result); })
}, .catch((err) => {
console.log("getUserExamInfo err" + err);
uni.hideLoading();
uni.showToast({
icon: "none",
title: "获取考试信息失败",
});
}); });
}, },
//再次考试 //再次考试
getAgain: function () { getAgain: function () {
let examId = this.examId; let examId = this.examId;
wx.navigateTo({ let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
console.log(routes.length);
uni.navigateTo({
url: "/pages/learn/assessment?examId=" + examId, url: "/pages/learn/assessment?examId=" + examId,
}); });
}, },
//下次再考跳转到学习主界面页面 //下次再考跳转到学习主界面页面
toIndex: function () { toIndex: function () {
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组 uni.switchTab({
let length = routes.length url: '/pages/index/learn'
uni.navigateBack({
delta: length - 1
}); });
}, },
}, },
......
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