examInfo.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view style="width: 80vh;margin: auto;padding-bottom: 25px;">
  3. <view style="text-align: center;margin: auto; padding-top: 80px;" v-if="exams.length!==1&&!enter">
  4. <h3 style="display: inline-block">{{ '考生号:' + user.username }}</h3>
  5. <h3 v-if="user.grade!==undefined&&user.grade!==null" style="display: inline-block;margin-left: 50px">
  6. {{ "年级:" + user.grade }}
  7. </h3>
  8. <h3 v-if="user.sex!==undefined&&user.sex!==null" style="display: inline-block;margin-left: 50px">
  9. {{ "性别:" + (user.sex === 1 ? "男" : "女") }}
  10. </h3>
  11. <h3 style="display: inline-block;margin-left: 50px">{{ "姓名:" + user.realname }}</h3>
  12. </view>
  13. <uni-section>
  14. <uni-card class="box-card" v-if="exams.length===0&&!enter">
  15. <uni-row>
  16. <uni-col :span="4">
  17. </uni-col>
  18. <uni-col :span="16">
  19. <h1>当前并无考试,请退出</h1>
  20. <br>
  21. </uni-col>
  22. </uni-row>
  23. </uni-card>
  24. <view v-if="!enter" v-for="o in exams" :key="o">
  25. <uni-card style="background-color:#f0fff3; " class="box-card" v-if="o.state==0&&exams.length>1">
  26. <uni-row class="allceter">
  27. <uni-col :span="12" style="font-size: 20px;">
  28. {{ '考试名称: '}}<strong>{{o.title }}</strong>
  29. </uni-col>
  30. <uni-col :span="6">
  31. <uni-tag :text="o. state_dictText" type="success" />
  32. </uni-col>
  33. <uni-col :span="6">
  34. <button v-if="o.tryCount<o.limitCount" type="primary" @click="enterExam(o.id)">进入考试</button>
  35. </uni-col>
  36. </uni-row>
  37. </uni-card>
  38. <uni-card style="background-color:#6a0001;" class="box-card" v-if="o.state==1&&exams.length>1">
  39. <uni-row class="allceter">
  40. <uni-col :span="12" style="font-size: 20px;">
  41. {{ '考试名称: '}}<strong>{{o.title }}</strong>
  42. </uni-col>
  43. <uni-col :span="6">
  44. <uni-tag text="不可用" type="warning" />
  45. </uni-col>
  46. <uni-col :span="6">
  47. <!-- <button type="primary" @click="enterExam(o.id)">进入考试</button> -->
  48. </uni-col>
  49. </uni-row>
  50. </uni-card>
  51. <uni-card style="background-color:#e6f7ff;" class="box-card" v-if="o.state==2&&exams.length>1">
  52. <uni-row class="allceter">
  53. <uni-col :span="12" style="font-size: 20px;">
  54. {{ '考试名称: '}}<strong>{{o.title }}</strong>
  55. </uni-col>
  56. <uni-col :span="4">
  57. <uni-tag text="未开始" type="primary" />
  58. </uni-col>
  59. <uni-col :span="6">
  60. <!-- <button type="primary" @click="enterExam(o.id)">进入考试</button> -->
  61. </uni-col>
  62. </uni-row>
  63. </uni-card>
  64. <uni-card style="background-color:#e3e3e3;" class="box-card" v-if="o.state==3&&exams.length>1">
  65. <uni-row class="allceter">
  66. <uni-col :span="12" style="font-size: 20px;">
  67. {{ '考试名称: '}}<strong>{{o.title }}</strong>
  68. </uni-col>
  69. <uni-col :span="6">
  70. <uni-tag text="已结束" type="default" />
  71. </uni-col>
  72. <uni-col :span="6">
  73. <!-- <button type="primary" @click="enterExam(o.id)">进入考试</button> -->
  74. </uni-col>
  75. </uni-row>
  76. </uni-card>
  77. </view>
  78. </uni-section>
  79. <uni-section v-if="exams.length===1||enter">
  80. <uni-card :is-shadow="false">
  81. <!-- <view style="padding-top: 30px;text-align: center;">
  82. <h1>考试须知</h1>
  83. </view> -->
  84. <view style="width: 100%;text-align: center;margin-bottom: 20px;padding-top:30px ;padding-bottom: 15px;">
  85. <h1>{{ exam.title }}</h1>
  86. </view>
  87. <l-divider color="#adadad">
  88. <strong>
  89. <h2>考生信息</h2>
  90. </strong>
  91. </l-divider>
  92. <view class="text" style="width: 100%;text-align: center;padding: 15px;">
  93. <view>
  94. <view class="userInfo">
  95. <view>当前考试:<strong>{{ exam.title }}</strong></view>
  96. </view>
  97. <view class="userInfo">
  98. <view>考生号:<strong>{{ user.username }}</strong></view>
  99. </view>
  100. <view class="userInfo" v-if="user.grade!==undefined&&user.grade!==null">
  101. <view>年 级:<strong>{{ user.grade }}</strong></view>
  102. </view>
  103. <view class="userInfo" v-if="user.sex!==undefined&&user.sex!==null">
  104. <view>性 别:<strong>{{ (user.sex === 1 ? "男" : "女") }}</strong></view>
  105. </view>
  106. <view class="userInfo">
  107. <view>姓 名:<strong>{{ user.realname }}</strong></view>
  108. </view>
  109. </view>
  110. </view>
  111. <l-divider color="#adadad">
  112. <strong>
  113. <h2>考试须知</h2>
  114. </strong>
  115. </l-divider>
  116. <view class="text">
  117. <view style="width: 70vh; margin: auto;font-size: 16px;">
  118. <rich-text :nodes="exam.message"></rich-text>
  119. </view>
  120. </view>
  121. <button type="primary" style="margin-top: 50px" @click="examStart(exam.id)">开始考试</button>
  122. <button v-if="exams.length>1&&enter" style="margin-top: 30px;" @click="enter=!enter">返回
  123. </button>
  124. </uni-card >
  125. </uni-section>
  126. </view>
  127. <view style="width: 80vh;margin: auto;padding-bottom: 30px;">
  128. <view style="text-align: center;width: 300px;margin: auto;">
  129. <button type="primary" @click="infoExit()" v-if="exams.length>1&&!enter">退出
  130. </button>
  131. </view>
  132. </view>
  133. <uni-popup ref="inputDialog" type="dialog">
  134. <uni-popup-dialog style="width: 50vh;" ref="inputClose" title="考生信息" >
  135. <view >
  136. <view style="text-align: center;"><strong>姓名:</strong><strong>{{ user.realname }}</strong></view>
  137. <view></view>
  138. <view style="text-align: center;"><strong>考号:</strong><strong>{{ user.username }}</strong></view>
  139. <view></view>
  140. </view>
  141. </uni-popup-dialog>
  142. </uni-popup>
  143. </template>
  144. <script>
  145. import {
  146. exit,
  147. request,
  148. getExamCreateExam,
  149. getExamOnlineExam,
  150. getExamQueryById,
  151. getExamListExamIn
  152. } from '../../examJs/examRequest';
  153. import {
  154. toExamStart,
  155. redirectTo,
  156. } from '../../examJs/examRoute.js'
  157. import screenfull from "screenfull";
  158. export default {
  159. name: 'examInfo',
  160. data() {
  161. return {
  162. isLoading: true,
  163. exams: [],
  164. enter: false,
  165. exam: {
  166. id: 1,
  167. message: ["点击开始考试后将自动进入考试,请遵守考场纪律诚信考试。", "考试试题,共3题。",
  168. "艺术类监测试卷分音乐和美术两个学科,其中音乐和美术各15分钟共计30分钟答卷时间,每一学科超时后将自动提交试卷。"
  169. ],
  170. Paper: []
  171. },
  172. user: {
  173. grade: "五年级"
  174. }
  175. }
  176. },
  177. mounted() {
  178. screenfull.request();
  179. redirectTo()
  180. this.user = JSON.parse(sessionStorage.getItem("user"))
  181. getExamOnlineExam({
  182. pageNo: 1,
  183. pageSize: 80
  184. }).then((data) => {
  185. this.exams = data.data.result.records
  186. if (this.exams.length === 1) {
  187. this.enterExam(0)
  188. }
  189. this.$refs.inputDialog.open()
  190. }).catch(xhr => {
  191. console.log(xhr);
  192. });
  193. },
  194. methods: {
  195. // 进入考试
  196. enterExam(index) {
  197. getExamQueryById({
  198. id: index
  199. }).then(data => {
  200. console.log(data)
  201. this.exam = data.data.result
  202. console.log(this.exam);
  203. if (this.exams.length === 1) {
  204. this.enterExam(0)
  205. }
  206. this.enter = !this.enter
  207. }).catch(xhr => {
  208. console.log(xhr);
  209. });
  210. },
  211. // 退出
  212. infoExit() {
  213. exit()
  214. },
  215. // 开始考试
  216. examStart(examId) {
  217. getExamListExamIn({
  218. 't': new Date().toString()
  219. }).then(dataList => {
  220. console.log(dataList);
  221. if (dataList.data.result === null) {
  222. getExamCreateExam({
  223. 'examId': examId,
  224. 't': new Date().toString()
  225. }).then(data => {
  226. console.log(data);
  227. sessionStorage.setItem("examId", data.data.result.id)
  228. toExamStart()
  229. })
  230. } else {
  231. sessionStorage.setItem("examId", dataList.data.result.id)
  232. toExamStart()
  233. }
  234. })
  235. }
  236. }
  237. }
  238. </script>
  239. <style scoped lang="scss">
  240. .text {
  241. padding-top: 15px;
  242. text-align: left;
  243. font-size: 14px;
  244. }
  245. .item {
  246. margin-bottom: 18px;
  247. }
  248. .clearfix:before,
  249. .clearfix:after {
  250. display: table;
  251. content: "";
  252. }
  253. .clearfix:after {
  254. clear: both
  255. }
  256. .box-card {
  257. margin: 20px auto auto;
  258. width: 100%;
  259. height: 70px;
  260. }
  261. .allceter {
  262. display: flex;
  263. align-items: center;
  264. height: 50px;
  265. }
  266. .userInfo {
  267. display: inline-block;
  268. width: 15vh;
  269. min-width: 150px;
  270. }
  271. </style>