examInfo.vue 10 KB

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