detail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. <template>
  2. <view>
  3. <view class="head box" style="margin-bottom: 10px;">
  4. <view>
  5. <text class="iconfont icon-shijian" />
  6. <timer ref="timer" />
  7. </view>
  8. <text class="iconfont icon-tika" @click="openTopicCard = true">
  9. 题卡
  10. </text>
  11. </view>
  12. <My_listbox :pullDown="false">
  13. <swiper :style="{ height: tovw(swiperHeight), marginTop: 0 }" :current-item-id="currentItemId"
  14. @change="swiperChange">
  15. <swiper-item v-for="item in detail.testquestions" :key="item.sat_courseware_testitemsid"
  16. :item-id="item.rowindex + ''">
  17. <view class="box">
  18. <view class="typemxstr">
  19. {{ item.rowindex }} {{ item.typemxstr }}<text class="score">({{ item.score }})</text>
  20. </view>
  21. <image class="image" v-if="item.attinfos.length" :src="item.attinfos[0].src" mode="aspectFill"
  22. lazy-load="true" />
  23. <view class="content">
  24. <view class="title">{{ item.question }}</view>
  25. <view class="option" v-for="option in item.options" :key="option.sequence"
  26. @click="selectOption(item.rowindex, option.option)"
  27. :class="item.answer.includes(option.option) ? 'active' : ''">
  28. <image class="image" v-if="option.url.length" :src="option.url[0].url" mode="aspectFill"
  29. lazy-load="true" />
  30. <view class="text">
  31. {{ option.option }} {{ option.content }}
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="box" v-if="detail.status == '已完成'">
  37. <view class="typemxstr">答案</view>
  38. <view class="row" style="padding-top: 10px;">
  39. 结果:<text class="res-f" v-if="item.result == 0">答错</text><text v-else class="res-t">答对</text>
  40. </view>
  41. <view class="row">
  42. 结果:<text style="font-weight: bold;color:#009270 ;">{{ item.answer_fact.join(",") }}</text>
  43. </view>
  44. <view class="row">
  45. 分数:<text class="score">{{ item.result == 1 ? item.score : 0 }}</text>
  46. </view>
  47. </view>
  48. </swiper-item>
  49. </swiper>
  50. <view :style="{ height: tovw(80) }" />
  51. </My_listbox>
  52. <view class="bottom">
  53. <view v-if="currentItemId != 1" class="but up" hover-class="navigator-hover" @click="changeQuestions('-')">
  54. 上一题
  55. </view>
  56. <view v-if="detail.testquestions.length != currentItemId" class="but down" hover-class="navigator-hover"
  57. @click="changeQuestions('+')">
  58. 下一题
  59. </view>
  60. <view v-if="detail.testquestions.length == currentItemId && detail.status != '已完成'" class="but submit"
  61. @click="submit" hover-class="navigator-hover">
  62. 提交
  63. </view>
  64. </view>
  65. <u-popup :show="openTopicCard" :safeAreaInsetBottom="false" round="8" @close="openTopicCard = false">
  66. <My_listbox :pullDown="false" :automatic="false" defaultHeight="500">
  67. <view class="topic-card">
  68. <view class="topic-card-title">选择题目</view>
  69. <view class="topic-card-content">
  70. <view class="topic-card-item"
  71. :class="[currentItemId == item.rowindex ? 'topic-card-active' : '', item.answer.length > 0 ? 'topic-card-filled' : '']"
  72. v-for="item in detail.testquestions " :key="item.sat_courseware_testitemsid"
  73. :data-currentItemId="item.rowindex + ''" @click="swiperChange">
  74. {{ item.rowindex }}
  75. <view class="res" v-if="detail.status == '已完成'"
  76. :style="{ background: item.result == 1 ? '#70D95D' : '#E3041F' }" />
  77. </view>
  78. </view>
  79. </view>
  80. </My_listbox>
  81. <view class="bottom" style="position: relative;">
  82. <view class="but down" hover-class="navigator-hover" @click="openTopicCard = false">
  83. 关 闭
  84. </view>
  85. </view>
  86. </u-popup>
  87. <u-popup :show="showFinish" mode="center" round="8" :safeAreaInsetBottom="false">
  88. <view class="finish">
  89. <image class="result" src="../../static//examination-result.png" mode="aspectFill" />
  90. <view class="shadow" />
  91. <view class="finish-title">考试结果</view>
  92. <view class="finish-result">
  93. <view class="finish-result-item">
  94. <view class="finish-result-item-data" style="color:#FF3B30;">
  95. {{ detail.score }}
  96. </view>
  97. 成绩(分)
  98. </view>
  99. <view class="finish-result-item">
  100. <view class="finish-result-item-data" style="color:#3874F6;">
  101. {{ detail.answercount + ' / ' + detail.num }}
  102. </view>
  103. 答题数
  104. </view>
  105. </view>
  106. <view class="tips">
  107. <view class="row">
  108. <view class="dot" style="background: #52C41A;" />
  109. 答对<text class="text">{{ detail.rightcount }}</text>题
  110. </view>
  111. <view class="row">
  112. <view class="dot" style="background: #FF3B30;" />
  113. 答错<text class="text">{{ detail.errcount }}</text>题
  114. </view>
  115. </view>
  116. <view class="but but-res" @click="showFinish = false">
  117. 查看答案
  118. </view>
  119. <view class="but" @click="returnList">
  120. 返回
  121. </view>
  122. </view>
  123. </u-popup>
  124. <view class="quere-height">
  125. <view :id="'Item' + item.rowindex" v-for=" item in detail.testquestions "
  126. :key="item.sat_courseware_testitemsid" :item-id="item.rowindex + ''">
  127. <view class="box">
  128. <view class="typemxstr">
  129. {{ item.rowindex }} {{ item.typemxstr }}<text class="score">({{ item.score }})</text>
  130. </view>
  131. <image class="image" v-if="item.attinfos.length" :src="item.attinfos[0].src" mode="aspectFill"
  132. lazy-load="true" />
  133. <view class="content">
  134. <view class="title">{{ item.question }}</view>
  135. <view class="option" v-for=" option in item.options " :key="option.sequence"
  136. @click="selectOption(item.rowindex, option.option)"
  137. :class="item.answer.includes(option.option) ? 'active' : ''">
  138. <image class="image" v-if="option.url.length" :src="option.url[0].url" mode="aspectFill"
  139. lazy-load="true" />
  140. <view class="text">
  141. {{ option.option }} {{ option.content }}
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. <view class="box" v-if="detail.status == '已完成'">
  147. <view class="typemxstr">答案</view>
  148. <view class="row" style="padding-top: 10px;">
  149. 结果:<text class="res-f">答错</text><text class="res-t">答对</text>
  150. </view>
  151. <view class="row">
  152. 结果:<text style="font-weight: bold;color:#009270 ;">{{ item.answer_fact }}</text>
  153. </view>
  154. <view class="row">
  155. 分数:<text class="score">{{ item.result == 1 ? item.score : 0 }}</text>
  156. </view>
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. </template>
  162. <script>
  163. import timer from "./modules/timer.vue"
  164. export default {
  165. components: { timer },
  166. data() {
  167. return {
  168. sat_courseware_testheadid: 0,
  169. currentItemId: '1',
  170. detail: {
  171. testquestions: []
  172. },
  173. swiperHeight: 10,
  174. openTopicCard: false,
  175. showFinish: false
  176. }
  177. },
  178. onLoad(options) {
  179. this.sat_courseware_testheadid = options.id || 0;
  180. this.getDetail();
  181. },
  182. methods: {
  183. getDetail() {
  184. this.$Http.basic({
  185. "id": 20240325102202,
  186. "content": {
  187. "sat_courseware_testheadid": this.sat_courseware_testheadid
  188. }
  189. }).then(res => {
  190. console.log("生成试卷并获取详情", res)
  191. if (this.cutoff(res.msg)) return;
  192. this.detail = res.data;
  193. if (this.detail.status != '已完成') {
  194. this.$refs.timer.startCounting()
  195. } else {
  196. this.$refs.timer.showTime = res.data.countdown;
  197. this.showFinish = true;
  198. }
  199. uni.setNavigationBarTitle({
  200. title: res.data.title,
  201. })
  202. this.$nextTick(() => { this.setSwiperHeight() })
  203. })
  204. },
  205. selectOption(rowindex, option) {
  206. if (this.detail.status == '已完成') return;
  207. let item = this.detail.testquestions[rowindex - 1],
  208. answer = item.answer;
  209. switch (item.typemxstr) {
  210. case '单选':
  211. answer = [option]
  212. break;
  213. case '多选':
  214. answer.some(v => v == option) ? answer = answer.filter(v => v != option) : answer.push(option)
  215. break;
  216. }
  217. this.$set(item, 'answer', answer)
  218. },
  219. swiperChange(e) {
  220. this.currentItemId = e.target.currentItemId || e.currentTarget.dataset.currentitemid;
  221. this.$nextTick(() => { this.setSwiperHeight() })
  222. },
  223. changeQuestions(e) {
  224. if (e == '+') {
  225. this.currentItemId = String(this.currentItemId - 0 + 1);
  226. } else {
  227. this.currentItemId = String(this.currentItemId - 1);
  228. }
  229. },
  230. setSwiperHeight() {
  231. let that = this;
  232. const element = `#Item${this.currentItemId}`;
  233. const query = uni.createSelectorQuery().in(that);
  234. setTimeout(() => {
  235. query.select(element).boundingClientRect();
  236. query.exec(res => {
  237. if (res && res[0]) that.swiperHeight = res[0].height - 10;
  238. });
  239. }, 100)
  240. },
  241. submit() {
  242. let content = {
  243. "sat_courseware_testid": this.detail.sat_courseware_testid,
  244. "answers": this.detail.testquestions.map(v => {
  245. return {
  246. sat_courseware_testitemsid: v.sat_courseware_testitemsid,
  247. answer: v.answer,
  248. rowindex: v.rowindex
  249. }
  250. })
  251. },
  252. notFilleds = content.answers.filter(v => v.answer.length == 0).map(v => v.rowindex),
  253. tips = "是否确定提交",
  254. that = this;
  255. if (notFilleds.length) tips = `题号“${notFilleds.join(',')}”还未完成!是否继续提交?`;
  256. content.countdown = that.$refs.timer.getTime();
  257. uni.showModal({
  258. title: '提示',
  259. content: tips,
  260. success: ({ confirm }) => {
  261. if (confirm) that.$Http.basic({
  262. "id": 20240326145902,
  263. content
  264. }).then(res => {
  265. console.log('提交试卷', res)
  266. if (this.cutoff(res.msg, '', true)) return that.$refs.timer.startCounting();
  267. that.$refs.timer.endTiming();
  268. that.getDetail();
  269. })
  270. },
  271. })
  272. },
  273. returnList() {
  274. uni.navigateBack();
  275. }
  276. }
  277. }
  278. </script>
  279. <style lang="scss" scoped>
  280. body,
  281. page {
  282. height: 100vh;
  283. overflow: hidden;
  284. }
  285. .box {
  286. width: 355px;
  287. background: #FFFFFF;
  288. border-radius: 8px;
  289. margin: 10px auto 0;
  290. box-sizing: border-box;
  291. .row {
  292. padding: 5px 10px;
  293. .score {
  294. font-weight: bold;
  295. color: #095DE0;
  296. }
  297. .res-t,
  298. .res-f {
  299. font-family: Source Han Sans SC, Source Han Sans SC;
  300. font-weight: bold;
  301. font-size: 14px;
  302. }
  303. .res-t {
  304. color: #009270;
  305. }
  306. .res-f {
  307. color: #E3041F;
  308. }
  309. }
  310. .row:last-child {
  311. padding-bottom: 10px;
  312. }
  313. }
  314. .image {
  315. width: 163px;
  316. height: 100px;
  317. border-radius: 8px;
  318. }
  319. .head {
  320. display: flex;
  321. align-items: center;
  322. justify-content: space-between;
  323. padding: 0 10px;
  324. height: 50px;
  325. /deep/ .time,
  326. .iconfont {
  327. font-family: Source Han Sans SC, Source Han Sans SC;
  328. font-size: 14px;
  329. color: #333333;
  330. }
  331. .icon-tika:before,
  332. .icon-shijian:before {
  333. color: #999999;
  334. margin-right: 5px;
  335. }
  336. }
  337. .quere-height {
  338. position: fixed;
  339. z-index: -9999;
  340. top: -99999999999999999;
  341. opacity: 0;
  342. }
  343. .typemxstr {
  344. width: 100%;
  345. height: 50px;
  346. padding: 15px 10px;
  347. border-bottom: 1px solid #DDDDDD;
  348. box-sizing: border-box;
  349. .score {
  350. color: #999999;
  351. margin-left: 5px;
  352. }
  353. }
  354. .content {
  355. padding: 10px;
  356. padding-bottom: 20px;
  357. .title {
  358. font-family: Source Han Sans SC, Source Han Sans SC;
  359. font-size: 14px;
  360. color: #333333;
  361. }
  362. .option {
  363. border-radius: 8px;
  364. border: 1px solid #CCCCCC;
  365. padding: 10px;
  366. margin-top: 10px;
  367. .text {
  368. font-family: PingFang SC, PingFang SC;
  369. }
  370. }
  371. .active {
  372. border: 1px solid #095DE0 !important;
  373. .text {
  374. color: #095DE0 !important;
  375. }
  376. }
  377. }
  378. .bottom {
  379. display: flex;
  380. position: fixed;
  381. bottom: 0;
  382. width: 375px;
  383. height: 64px;
  384. background: #FFFFFF;
  385. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  386. padding-right: 10px;
  387. box-sizing: border-box;
  388. .but {
  389. display: flex;
  390. align-items: center;
  391. justify-content: center;
  392. flex: 1;
  393. margin-left: 10px;
  394. width: 168px;
  395. height: 45px;
  396. border-radius: 5px;
  397. margin-top: 4px;
  398. box-sizing: border-box;
  399. }
  400. .up {
  401. background: #FFFFFF;
  402. border: 1px solid #999999;
  403. font-size: 16px;
  404. color: #666666;
  405. }
  406. .down,
  407. .submit {
  408. background: #095DE0;
  409. font-family: PingFang SC, PingFang SC;
  410. font-size: 16px;
  411. color: #FFFFFF;
  412. }
  413. .submit {
  414. background: #C30D23;
  415. }
  416. }
  417. .topic-card {
  418. .topic-card-title {
  419. font-family: PingFang SC, PingFang SC;
  420. font-weight: bold;
  421. font-size: 16px;
  422. color: #333333;
  423. margin: 20px;
  424. text-align: center;
  425. }
  426. .topic-card-content {
  427. display: flex;
  428. flex-wrap: wrap;
  429. padding-left: 8px;
  430. .topic-card-item {
  431. position: relative;
  432. width: 35px;
  433. text-align: center;
  434. height: 50px;
  435. line-height: 50px;
  436. border-radius: 5px;
  437. border: 1px solid #999999;
  438. margin-right: 10px;
  439. margin-bottom: 10px;
  440. .res {
  441. position: absolute;
  442. width: 4px;
  443. height: 4px;
  444. border-radius: 2px;
  445. bottom: 6px;
  446. left: 16px;
  447. background: red;
  448. }
  449. }
  450. .topic-card-active {
  451. border: 1px solid #095DE0;
  452. color: #095DE0;
  453. }
  454. .topic-card-filled {
  455. background: #F4F5F7 !important;
  456. }
  457. .topic-card-item:nth-child(8n) {
  458. margin-right: 0;
  459. }
  460. }
  461. }
  462. .finish {
  463. position: relative;
  464. width: 240px;
  465. background: #FFFFFF;
  466. box-shadow: 0px 2px 10px 1px rgba(98, 98, 241, 0.12);
  467. border-radius: 8px;
  468. padding-bottom: 20px;
  469. .result {
  470. position: absolute;
  471. width: 88px;
  472. height: 88px;
  473. top: -20px;
  474. left: 76px;
  475. }
  476. .shadow {
  477. position: absolute;
  478. top: 65px;
  479. left: 76px;
  480. width: 88px;
  481. height: 11px;
  482. background: rgba(227, 4, 31, 0.15);
  483. filter: blur(7.4338297843933105px);
  484. }
  485. &-title {
  486. font-family: Source Han Sans SC, Source Han Sans SC;
  487. font-size: 14px;
  488. color: #222222;
  489. text-align: center;
  490. padding-top: 96px;
  491. }
  492. &-result {
  493. display: flex;
  494. justify-content: space-around;
  495. height: 67px;
  496. width: 180px;
  497. margin: 18px auto 0;
  498. border-bottom: 1px solid #DDDDDD;
  499. &-item {
  500. text-align: center;
  501. font-family: PingFang HK, PingFang HK;
  502. font-size: 13px;
  503. color: #666666;
  504. &-data {
  505. height: 24px;
  506. line-height: 24px;
  507. font-family: Source Han Sans SC, Source Han Sans SC;
  508. font-weight: bold;
  509. font-size: 16px;
  510. margin-bottom: 5px;
  511. }
  512. }
  513. }
  514. .tips {
  515. display: flex;
  516. flex-direction: column;
  517. align-items: center;
  518. margin-top: 8px;
  519. .row {
  520. display: flex;
  521. align-items: center;
  522. margin-top: 10px;
  523. .dot {
  524. width: 6px;
  525. height: 6px;
  526. border-radius: 3px;
  527. margin-right: 10px;
  528. }
  529. .text {
  530. color: #3874F6;
  531. font-size: 16px;
  532. font-weight: bold;
  533. padding: 0 4px;
  534. }
  535. }
  536. }
  537. .but {
  538. width: 160px;
  539. height: 45px;
  540. text-align: center;
  541. line-height: 45px;
  542. background: #C30D23;
  543. border-radius: 22.5px;
  544. margin: 0 auto;
  545. font-family: PingFang SC, PingFang SC;
  546. font-weight: bold;
  547. font-size: 14px;
  548. color: #FFFFFF;
  549. margin-top: 10px;
  550. }
  551. .but-res {
  552. background: #FFFFFF;
  553. border: 1px solid #CCCCCC;
  554. margin-top: 25px;
  555. font-family: PingFang SC, PingFang SC;
  556. font-weight: bold;
  557. font-size: 14px;
  558. color: #333333;
  559. }
  560. }
  561. </style>