examInfo.vue 8.9 KB

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