1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<template>
<view class="content">
<u-navbar back-icon-color="#FFFFFF" :background="background" title-color="#fff" :border-bottom="false"></u-navbar>
<view class="title">考试规则</view>
<view class="test">
<view class="slogan">
这是一场严肃的考试,请认真查看 规则,预祝您顺利通过考试!
</view>
<view class="text">
<text class="left">考试科目:</text><text style="color: #007aff">{{ title }}</text>
</view>
<view class="text">
<text class="left">合格条件:</text><text>{{ score }}</text>
</view>
<view class="text">
<text class="left">考试时间:</text><text>{{ time }}</text>
</view>
<view class="text">
<text class="left">题目来源:</text><text>{{ ruleDisc }}</text>
</view>
<button @click="getUserExamId()">开始考试</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: "",
score: "",
time: "",
ruleDisc: "",
examId: null,
exam: null,
userExamId: null
};
},
onLoad(param) {
getApp().trackPage('学习开始考试页')
this.examId = param.examId;
// this.getUserExamInfo();
},
onShow() {
this.getExamResult();
},
onUnload() {
uni.switchTab({
url: '/pages/index/learn'
});
},
methods: {
//申请考试获取userExamId
getUserExamId: function () {
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({
url: "/pages/learn/answer?examId=" + examId + "&userExamId=" + userExamId,
});
},
getExamResult() {
let examId = this.examId;
this.$u.api.getExamResult(examId)
.then((res) => {
uni.hideLoading();
if (res.code == 200) {
if (res.data.ruleDisc) {
var str = res.data.ruleDisc;
this.userExamId = res.data.id;
let strArr = str.split("(")[0].split(",");
this.title = strArr[0];
this.score = strArr[1];
this.time = strArr[2];
this.ruleDisc = strArr[3];
}
}
})
.catch((err) => {
uni.hideLoading();
uni.showToast({
icon: "none",
title: "获取考试信息失败",
});
});
},
},
};
</script>
<style>
.content {
width: 750rpx;
height: 100vh;
overflow: auto;
background-color: #f4f5f7;
background-image: linear-gradient(to top, #f4f5f7 0%, #2272ff 50%);
background-size: 750rpx 600rpx;
background-repeat: no-repeat;
}
.title {
padding: 30rpx 30rpx 46rpx;
line-height: 40rpx;
font-size: 40rpx;
color: #fff;
}
.test {
margin: 0 30rpx;
overflow: hidden;
border-radius: 12rpx;
padding-bottom: 60rpx;
background-image: url(../../static/photo/examination.png);
background-repeat: no-repeat;
background-size: 66%;
background-color: #fff;
background-position: right bottom;
min-height: 800rpx;
}
.slogan {
font-size: 40rpx;
font-weight: bold;
color: #333333;
line-height: 68rpx;
padding: 50rpx 58rpx 46rpx 30rpx;
}
.left {
margin-right: 8rpx;
margin-left: 30rpx;
color: #666666;
font-size: 28rpx;
}
.text {
margin: 30rpx 0;
}
button {
width: 600rpx;
height: 104rpx;
background: #2272ff;
font-size: 32rpx;
font-weight: 600;
color: #ffffff;
margin-top: 237rpx;
border-radius: 26px;
line-height: 104rpx;
}
</style>