|
@@ -15,6 +15,7 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
async mounted() {
|
|
|
+ this.heartbeatErrorNum = 0;
|
|
|
this.getRemainTimeFromServer();
|
|
|
this.first = true;
|
|
|
this.remainTime += 60 * 1000; //补偿心跳
|
|
@@ -38,10 +39,27 @@ export default {
|
|
|
methods: {
|
|
|
...mapMutations(["setShouldSubmitPaper"]),
|
|
|
async getRemainTimeFromServer() {
|
|
|
- const res = await this.$http.get(
|
|
|
- "/api/ecs_oe_student/examControl/examHeartbeat"
|
|
|
- );
|
|
|
- this.remainTime = res.data;
|
|
|
+ try {
|
|
|
+ const res = await this.$http.get(
|
|
|
+ "/api/ecs_oe_student/examControl/examHeartbeat"
|
|
|
+ );
|
|
|
+ this.remainTime = res.data;
|
|
|
+ this.heartbeatErrorNum = 0;
|
|
|
+ } catch (e) {
|
|
|
+ this.heartbeatErrorNum++;
|
|
|
+ if (this.heartbeatErrorNum === 5) {
|
|
|
+ // 心跳异常5次则退出考试
|
|
|
+ this.$Modal.error({
|
|
|
+ title: "网络连接异常",
|
|
|
+ content: "退出考试",
|
|
|
+ onOk: () => {
|
|
|
+ this.$router.push("/login/" + localStorage.getItem("domain"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.getRemainTimeFromServer();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
computed: {
|