examInfo.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. } from '../../examJs/examRoute.js'
  165. import screenfull from "screenfull";
  166. export default {
  167. name: 'examInfo',
  168. data() {
  169. return {
  170. isLoading: true,
  171. exams: [],
  172. enter: false,
  173. exam: {
  174. id: 1,
  175. message: ["点击开始考试后将自动进入考试,请遵守考场纪律诚信考试。", "考试试题,共3题。",
  176. "艺术类监测试卷分音乐和美术两个学科,其中音乐和美术各15分钟共计30分钟答卷时间,每一学科超时后将自动提交试卷。"
  177. ],
  178. Paper: []
  179. },
  180. user: {
  181. grade: "五年级"
  182. },
  183. msgType: 'success',
  184. messageText: '这是一条成功提示',
  185. }
  186. },
  187. mounted() {
  188. screenfull.request();
  189. redirectTo()
  190. this.user = JSON.parse(sessionStorage.getItem("user"))
  191. getExamOnlineExam({
  192. pageNo: 1,
  193. pageSize: 80
  194. }).then((data) => {
  195. this.exams = data.data.result.records
  196. if (this.exams.length === 1) {
  197. this.enterExam(0)
  198. }
  199. this.$refs.inputDialog.open()
  200. }).catch(xhr => {
  201. console.log(xhr);
  202. });
  203. },
  204. methods: {
  205. // 进入考试
  206. enterExam(index) {
  207. getExamQueryById({
  208. id: index
  209. }).then(data => {
  210. console.log(data)
  211. this.exam = data.data.result
  212. console.log(this.exam);
  213. if (this.exams.length === 1) {
  214. this.enterExam(0)
  215. }
  216. this.enter = !this.enter
  217. }).catch(xhr => {
  218. console.log(xhr);
  219. });
  220. },
  221. messageToggle(type, message) {
  222. this.msgType = type
  223. this.messageText = message
  224. this.$refs.message.open()
  225. },
  226. // 退出
  227. infoExit() {
  228. screenfull.exit()
  229. exit()
  230. },
  231. // 开始考试
  232. examStart(examId) {
  233. getExamListExamIn({
  234. 't': new Date().toString()
  235. }).then(dataList => {
  236. console.log(dataList);
  237. if (dataList.data.result === null) {
  238. getExamCreateExam({
  239. 'examId': examId,
  240. 't': new Date().toString()
  241. }).then(data => {
  242. console.log(data);
  243. sessionStorage.setItem("examId", data.data.result.id)
  244. toExamStart()
  245. })
  246. } else {
  247. this.messageToggle('warn',"你有正在进行中的考试,正在跳转......")
  248. sessionStorage.setItem("examId", dataList.data.result.id)
  249. setTimeout(()=>{
  250. toExamStart()
  251. },2000)
  252. }
  253. })
  254. }
  255. }
  256. }
  257. </script>
  258. <style scoped lang="scss">
  259. .text {
  260. padding-top: 15px;
  261. text-align: left;
  262. font-size: 14px;
  263. }
  264. .item {
  265. margin-bottom: 18px;
  266. }
  267. .clearfix:before,
  268. .clearfix:after {
  269. display: table;
  270. content: "";
  271. }
  272. .clearfix:after {
  273. clear: both
  274. }
  275. .box-card {
  276. margin: 20px auto auto;
  277. width: 100%;
  278. height: 70px;
  279. }
  280. .allceter {
  281. display: flex;
  282. align-items: center;
  283. height: 50px;
  284. }
  285. .userInfo {
  286. display: inline-block;
  287. width: 15vh;
  288. min-width: 150px;
  289. }
  290. </style>