examInfo.vue 8.7 KB

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