You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

570 lines
12 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="content" id="brushQuestions">
  3. <view class="row row1">
  4. <view class="userInfoBox">
  5. <view class="examNo">
  6. <view class="h3">洛阳学车</view>
  7. <view class="card">第0{{ randomNumber }}号台</view>
  8. <view class="back" @click="goBack">
  9. <u-icon name="arrow-left" size="16"></u-icon>
  10. </view>
  11. </view>
  12. <view class="user">
  13. <view class="card">
  14. <view class="h3">考生信息</view>
  15. <view class="avatar">
  16. <image src="@/static/images/avatarbg.png" mode=""></image>
  17. </view>
  18. <view class="txt">用户{{ phone }}</view>
  19. <!-- <view class="txt">性别</view> -->
  20. <view class="txt">类型{{ usecarStore.carInfo.carTypeName}}</view>
  21. <view class="txt">科目科目{{ usecarStore.carInfo.stepType==1?'一': '四'}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="examConBox">
  26. <view class="leftBox">
  27. <view class="h3">考试题目</view>
  28. <view class="questionTxt">
  29. <view class="txt">{{currentIndex+1}}.{{ questionBank.title }}</view>
  30. <view class="txt" v-for="(item,index) in questionBank.optionArr">
  31. <view class="text"><text >{{item.key}}</text> {{item.text}}</view>
  32. </view>
  33. </view>
  34. <view class="answer flex-b">
  35. <view class="lab">您的答案{{ curOption.answer }}</view>
  36. <view class="rightSelect flex">
  37. <view class="lab">选项</view>
  38. <view class="optio flex" v-for="(item,index) in questionBank.optionArr" >
  39. <view class="optionItem" :class="{ active: curOption.answer.includes(item.key)}" @click="chooseOption(item)">{{item.key}}</view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="rightBox">
  45. <!-- 右边盒子 -->
  46. <table style="width: 100%;height: 100%;">
  47. <tr>
  48. <th class="blueItem br">题目</th>
  49. <th v-for="(item,index) in 10" class="blueItem br">{{index+1}}</th>
  50. </tr>
  51. <tr v-for="(item,index) in 10">
  52. <td class="blueItem bb">{{index+1}}</td>
  53. <td v-for="(item2,index2) in 10" class="ansItem">{{ item2 }}</td>
  54. </tr>
  55. </table>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="row row2">
  60. <view class="timeBox">
  61. <view class="h3">考试时间</view>
  62. <view class="time">1510</view>
  63. </view>
  64. <view class="leftTpsBox">
  65. <view class="card">
  66. <view class="h3">操作提示</view>
  67. <view class="txt">本题为单选题请在备选答案中选择一个你认为正确的答案</view>
  68. </view>
  69. </view>
  70. <view class="rightBtnBox">
  71. <view class="btn hui">上一题</view>
  72. <view class="btn hui">下一题</view>
  73. <view class="btn" @click="$goPage('/pages/exercises/examResults/examResults')">交卷</view>
  74. </view>
  75. </view>
  76. <view class="picBox">
  77. <view class="h3">考题图片</view>
  78. <view class="imgBox">
  79. <image :src="questionBank.img" v-if="questionBank.img" @click="previewImg" mode="aspectFit"></image>
  80. </view>
  81. <u-popup :show="show" mode="center" :closeable="true" @close="show=false" bgColor="transparent">
  82. <view class="imgView">
  83. <!-- <view class="closeIcon" @click="show=false">
  84. <u-icon name="close-circle" color="#fff" size="28"></u-icon>
  85. </view> -->
  86. <view class="img">
  87. <image :src="questionBank.img" mode="aspectFit"></image>
  88. </view>
  89. </view>
  90. </u-popup>
  91. </view>
  92. </view>
  93. </template>
  94. <script setup>
  95. import { detectOrient } from '@/utils/utils.js'
  96. import { startExamDo, startExam } from '@/config/api.js'
  97. import { ref, onMounted, nextTick } from 'vue'
  98. import {
  99. onLoad,
  100. } from "@dcloudio/uni-app"
  101. import carStore from '@/store/modules/car.js'
  102. let usecarStore = carStore()
  103. let randomNumber = ''
  104. onLoad((options)=>{
  105. randomNumber = options.randomNumber
  106. })
  107. let phone = uni.getStorageSync('loginInfo')?.phone
  108. const currentNav = ref('1')
  109. const show = ref(false)
  110. onMounted(()=>{
  111. detectOrient('#brushQuestions')
  112. })
  113. function previewImg() {
  114. show.value = true
  115. }
  116. function goBack() {
  117. console.log('返回吧')
  118. uni.navigateBack()
  119. }
  120. // 请求数据
  121. const questionBank = ref({})
  122. const questionBankList = ref([])
  123. let examInfo = ref([])
  124. let currentIndex = ref(0)
  125. async function startQuestionFn() {
  126. try{
  127. uni.showLoading({
  128. title: '正在加载...'
  129. })
  130. let obj = {
  131. carType: usecarStore.carInfo.carType,
  132. stepType: usecarStore.carInfo.stepType,
  133. examType: 2,
  134. }
  135. const {data: res} = await startExam(obj)
  136. uni.hideLoading()
  137. questionBank.value = res.questionBank[0]
  138. questionBankList.value = res.questionBank
  139. initOptionArr()
  140. examInfo.value = res
  141. }catch(e){
  142. uni.hideLoading()
  143. }
  144. }
  145. startQuestionFn()
  146. function initOptionArr() {
  147. questionBank.value.optionArr = []
  148. let abcd = [
  149. 'a',
  150. 'b',
  151. 'c',
  152. 'd',
  153. 'e',
  154. 'f'
  155. ]
  156. abcd.forEach((k,i)=>{
  157. let option = 'option'+k
  158. if(questionBank.value[option]) {
  159. let obj = {
  160. key: k.toLocaleUpperCase(),
  161. text: questionBank.value[option],
  162. index: i+1
  163. }
  164. questionBank.value.optionArr.push(obj)
  165. }
  166. })
  167. // 如果是判断题
  168. if(questionBank.value.types==3) {
  169. questionBank.value.optionArr[0].key1 = 'true'
  170. questionBank.value.optionArr[1].key1 = 'false'
  171. }
  172. console.log(questionBank.value.optionArr)
  173. }
  174. // 选择答案
  175. const curOption = ref({})
  176. async function chooseOption(item) {
  177. console.log(item)
  178. if(questionBank.value.types != 2) {
  179. item.answer = item.key
  180. curOption.value = item
  181. }else if(questionBank.value.types == 2){
  182. if(!curOption.value.ans) curOption.value.ans = ''
  183. if(curOption.value.ans.includes(item.key)) {
  184. curOption.value.ans = curOption.value.ans.replace(item.key, '')
  185. return
  186. }
  187. curOption.value.ans = curOption.value.ans + item.key
  188. // console.log(curOption.value.ans)
  189. }
  190. }
  191. // 交卷
  192. async function submitBtnFn() {
  193. let wrongArr = questionBankList.value.filter(item=>item.yes!=1)
  194. let worngId = wrongArr.map(item=>item.id).join(',')
  195. let obj = {
  196. "answer": null,
  197. "carType": usecarStore.carInfo.carType,
  198. "examId": examInfo.value.id,
  199. "examType": 1,
  200. "grade": questionBankList.value.length - wrongArr.length,
  201. "isEnd": 1,
  202. "pass": 1,
  203. "sort": examInfo.value.sort,
  204. "stepType": usecarStore.carInfo.stepType,
  205. "userId": examInfo.value.userId,
  206. "wrongQuestionIds": worngId
  207. }
  208. const res = await startExamDo(obj)
  209. console.log(res)
  210. uni.$u.toast('已交卷')
  211. setTimeout(()=>{
  212. uni.navigateBack()
  213. },1500)
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. uni-page-body {
  218. width: 100%;
  219. height: 100%;
  220. }
  221. html {
  222. width: 100vh;
  223. height: 100vw;
  224. -webkit-transform: rotate(90deg);
  225. -webkit-transform-origin: 50vw 50vw;
  226. transform: rotate(90deg);
  227. transform-origin: 50vw 50vw;
  228. }
  229. image {
  230. display: block;
  231. width: 100%;
  232. height: 100%;
  233. }
  234. .imgView {
  235. position: relative;
  236. background: none;
  237. // max-width: 80%;
  238. // padding: 50px;
  239. .closeIcon {
  240. position: absolute;
  241. color: #fff;
  242. top: 40rpx;
  243. left: 40rpx;
  244. z-index: 99;
  245. background-color: #333;
  246. border-radius: 50%;
  247. }
  248. .img {
  249. // width: calc(100vh - 200rpx);
  250. // height: calc(100vw - 100rpx);
  251. width: 750rpx;
  252. height: 750rpx;
  253. }
  254. }
  255. .content {
  256. padding: 30rpx 30rpx 0rpx 30rpx;
  257. width: 100%;
  258. height: 100%;
  259. display: flex;
  260. flex-direction: column;
  261. background-color: #F7FBFE;
  262. font-size: 20rpx;
  263. // display: flex;
  264. .h3 {
  265. position: absolute;
  266. top: -16rpx;
  267. left: 0;
  268. width: 100%;
  269. text-align: center;
  270. color: $themC;
  271. }
  272. .row {
  273. width: 100%;
  274. display: flex;
  275. .userInfoBox {
  276. width: 140rpx;
  277. // height: 408rpx;
  278. // background-color: pink;
  279. display: flex;
  280. flex-direction: column;
  281. .examNo {
  282. width: 100%;
  283. height: 60rpx;
  284. background: #FFFFFF;
  285. border: 1px solid #F0F0F0;
  286. position: relative;
  287. .card {
  288. line-height: 70rpx;
  289. text-align: center;
  290. padding-left: 20rpx;
  291. }
  292. .back {
  293. position: absolute;
  294. left: -20rpx;
  295. top: 50%;
  296. transform: translateY(-50%);
  297. width: 40rpx;
  298. height: 40rpx;
  299. background: #fff;
  300. border-radius: 50%;
  301. display: flex;
  302. align-items: center;
  303. justify-content: center;
  304. u-icon {
  305. }
  306. }
  307. }
  308. .user {
  309. // position: relative;
  310. flex: 1;
  311. height: 0;
  312. padding: 10rpx 0 0 0rpx;
  313. .h3 {
  314. }
  315. .card {
  316. padding-left: 15rpx;
  317. position: relative;
  318. background: #FFFFFF;
  319. border: 1px solid #F0F0F0;
  320. height: 100%;
  321. .avatar {
  322. width: 90rpx;
  323. height: 90rpx;
  324. border-radius: 50%;
  325. overflow: hidden;
  326. margin-top: 36rpx;
  327. margin-bottom: 20rpx;
  328. img {
  329. }
  330. }
  331. .txt {
  332. margin: 10px 0;
  333. font-size: 18rpx;
  334. }
  335. }
  336. }
  337. }
  338. .examConBox {
  339. width: 0;
  340. flex: 1;
  341. display: flex;
  342. // height: 408rpx;
  343. padding-left: 20rpx;
  344. .leftBox {
  345. flex: 2;
  346. background-color: #fff;
  347. position: relative;
  348. display: flex;
  349. flex-direction: column;
  350. .h3 {
  351. left: 40rpx;
  352. text-align: left;
  353. }
  354. .questionTxt {
  355. padding: 30rpx;
  356. flex: 1;
  357. line-height: 2em;
  358. .txt {
  359. }
  360. }
  361. .answer.flex-b {
  362. height: 60rpx;
  363. border-top: 1px solid #F0F0F0;
  364. padding-left: 20rpx;
  365. .lab {
  366. }
  367. .rightSelect {
  368. .lab {
  369. }
  370. .optio {
  371. padding-left: 20rpx;
  372. .optionItem {
  373. width: 38rpx;
  374. height: 38rpx;
  375. border: 1px solid #F0F0F0;
  376. font-size: 18rpx;
  377. color: #333;
  378. text-align: center;
  379. line-height: 38rpx;
  380. margin-right: 20rpx;
  381. &.active {
  382. color: #fff;
  383. background-color: $themC;
  384. }
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .rightBox {
  391. flex: 1;
  392. background-color: #fff;
  393. table {
  394. display: table;
  395. border-collapse: collapse;
  396. border-spacing: 0px;
  397. table-layout: fixed;
  398. td, th {
  399. width: 9.09%;
  400. // text-overflow: ellipsis;
  401. overflow: hidden;
  402. white-space: nowrap;
  403. }
  404. // border-color: gray;
  405. }
  406. .ansItem {
  407. font-size: 24rpx;
  408. text-align: center;
  409. border-bottom: 1px solid #E1DFDF;
  410. border-right: 1px solid #E1DFDF;
  411. color: green;
  412. &.green {
  413. color: green;
  414. }
  415. &.red {
  416. color: red;
  417. }
  418. }
  419. .blueItem {
  420. background-color: $themC;
  421. color: #fff;
  422. text-align: center;
  423. font-size: 24rpx;
  424. &.br {
  425. border-right: 1px solid #fff;
  426. &:last-child {
  427. border: none;
  428. }
  429. }
  430. &.bb {
  431. border-top: 1px solid #fff;
  432. // &:last-child {
  433. // border: none;
  434. // }
  435. }
  436. }
  437. }
  438. }
  439. &.row1 {
  440. flex: 4;
  441. }
  442. &.row2 {
  443. height: 100rpx;
  444. padding: 20rpx 0;
  445. .timeBox {
  446. width: 140rpx;
  447. height: 100%;
  448. background-color: #fff;
  449. border: 1px solid #F0F0F0;
  450. position: relative;
  451. .h3 {
  452. font-weight: 400;
  453. }
  454. .time {
  455. font-weight: bold;
  456. font-size: 24rpx;
  457. color: #333333;
  458. line-height: 60rpx;
  459. text-align: center;
  460. }
  461. }
  462. .leftTpsBox {
  463. padding-left: 20rpx;
  464. flex: 2;
  465. position: relative;
  466. .card {
  467. background-color: #fff;
  468. height: 100%;
  469. }
  470. .h3 {
  471. text-align: left;
  472. left: 40rpx;
  473. }
  474. .txt {
  475. padding: 14rpx 20rpx 0 20rpx;
  476. }
  477. }
  478. .rightBtnBox {
  479. flex: 1;
  480. padding-left: 20rpx;
  481. display: flex;
  482. // justify-content: space-between;
  483. justify-content: flex-end;
  484. .btn {
  485. width: 123rpx;
  486. // padding: 0 24rpx;
  487. margin-left: 20rpx;
  488. text-align: center;
  489. font-size: 24rpx;
  490. height: 60rpx;
  491. line-height: 60rpx;
  492. background: #F4F4F4;
  493. border: 1px solid #E1DFDF;
  494. line-height: 60rpx;
  495. background: #F4F4F4;
  496. }
  497. }
  498. }
  499. }
  500. .picBox {
  501. width: 100%;
  502. flex: 2;
  503. background-color: #fff;
  504. border: 1px solid #F0F0F0;
  505. padding: 20rpx;
  506. position: relative;
  507. .h3 {
  508. text-align: left;
  509. left: 40rpx;
  510. }
  511. .imgBox {
  512. width: 650px;
  513. // max-height: 163rpx;
  514. // background-color: skyblue;
  515. height: 100%;
  516. overflow: hidden;
  517. margin: 0 auto;
  518. }
  519. }
  520. }
  521. </style>