index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <div class="bg-gray w-full min-h-screen">
  3. <div class="pt30 pr30 pl30 pb30 w-full">
  4. <div class="w-full gray-border flex flex-wrap">
  5. <div class="pt30 pl30 text-left font26 pb50 bg-white flex-1">
  6. <span
  7. >{{ listIndex + 1 }}.<span v-html="list[listIndex].question"></span
  8. ></span>
  9. <div v-if="list[listIndex].type !== 1" class="mt30 text-left pl20">
  10. <div class="" v-if="list[listIndex]['an1']">
  11. A.&nbsp;&nbsp;{{ list[listIndex]["an1"] }}
  12. </div>
  13. <div class="" v-if="list[listIndex]['an2']">
  14. B.&nbsp;&nbsp;{{ list[listIndex]["an2"] }}
  15. </div>
  16. <div class="" v-if="list[listIndex]['an3']">
  17. C.&nbsp;&nbsp;{{ list[listIndex]["an3"] }}
  18. </div>
  19. <div class="" v-if="list[listIndex]['an4']">
  20. D.&nbsp;&nbsp;{{ list[listIndex]["an4"] }}
  21. </div>
  22. </div>
  23. <div
  24. v-if="list[listIndex].isComplete && !list[listIndex].isError"
  25. class="inline-block pl15 pr5 mt15"
  26. style="background-color: #d9ffeb"
  27. >
  28. <img
  29. class="inline-block w42 h42 align-middle"
  30. src="@/assets/img/studySkill/smile_express.png"
  31. />
  32. <span style="color: #21a65f" class="lh60 align-middle"> 恭喜!回答正确!</span>
  33. </div>
  34. <div
  35. v-if="list[listIndex].isComplete && list[listIndex].isError"
  36. class="inline-block pl15 pr15 mt15"
  37. style="background-color: rgba(255, 220, 217, 1)"
  38. >
  39. <img
  40. class="inline-block w42 h42 align-middle"
  41. src="@/assets/img/studySkill/cry_express.png"
  42. />
  43. <span
  44. v-if="list[listIndex].type !== 3"
  45. style="color: rgba(239, 54, 41, 1)"
  46. class="lh60 align-middle"
  47. >
  48. 正确答案是:{{
  49. switchPageNumBySelect(list[listIndex].answertrue)
  50. }}</span
  51. >
  52. </div>
  53. <div>
  54. <div
  55. @click="playIssueAudio"
  56. class="mt30 w88 items-center bottom-button flex h40 justify-center"
  57. >
  58. <img
  59. class="w18 h18 inline-block mr10"
  60. src="@/assets/img/studySkill/voice_icon.png"
  61. />
  62. <span class="font16">读题</span>
  63. </div>
  64. </div>
  65. <div class="flex cursor-pointer mt20">
  66. <div
  67. v-if="list[listIndex]['an1']"
  68. @click="
  69. list[listIndex].isComplete
  70. ? ''
  71. : setUserAnswerAndRes(list[listIndex]['an1'])
  72. "
  73. class="w46 lh46 h46 answer-select font20 font-bold mr15 flex-grow-0 bottom-button"
  74. >
  75. <span v-if="list[listIndex].type == 1">{{ "√" }}</span>
  76. <span v-if="list[listIndex].type !== 1">{{
  77. switchIndexBySelect(0)
  78. }}</span>
  79. </div>
  80. <div
  81. v-if="list[listIndex]['an2']"
  82. @click="
  83. list[listIndex].isComplete
  84. ? ''
  85. : setUserAnswerAndRes(list[listIndex]['an2'])
  86. "
  87. class="w46 lh46 h46 answer-select font20 font-bold mr15 flex-grow-0 bottom-button"
  88. >
  89. <span v-if="list[listIndex].type == 1">{{ "×" }}</span>
  90. <span v-if="list[listIndex].type !== 1">{{
  91. switchIndexBySelect(1)
  92. }}</span>
  93. </div>
  94. <div
  95. v-if="list[listIndex]['an3']"
  96. @click="
  97. list[listIndex].isComplete
  98. ? ''
  99. : setUserAnswerAndRes(list[listIndex]['an3'])
  100. "
  101. class="w46 lh46 h46 answer-select font20 font-bold mr15 flex-grow-0 bottom-button"
  102. >
  103. <span v-if="list[listIndex].type == 1">{{ "×" }}</span>
  104. <span v-if="list[listIndex].type !== 1">{{
  105. switchIndexBySelect(2)
  106. }}</span>
  107. </div>
  108. <div
  109. v-if="list[listIndex]['an4']"
  110. @click="
  111. list[listIndex].isComplete
  112. ? ''
  113. : setUserAnswerAndRes(list[listIndex]['an4'])
  114. "
  115. class="w46 lh46 h46 answer-select font20 font-bold mr15 flex-grow-0 bottom-button"
  116. >
  117. <span v-if="list[listIndex].type == 1">{{ "×" }}</span>
  118. <span v-if="list[listIndex].type !== 1">{{
  119. switchIndexBySelect(3)
  120. }}</span>
  121. </div>
  122. </div>
  123. <div v-if="list[listIndex].questionType === 1" class="flex mt15">
  124. <div
  125. @click="setUserAnswerAndRes(item)"
  126. v-for="(item, index) in list[listIndex].optsArr"
  127. :key="index"
  128. class="w57 lh46 bottom-button mr15"
  129. >
  130. {{ item }}
  131. </div>
  132. </div>
  133. <div v-if="list[listIndex].questionType !== 1" class="flex mt15">
  134. <div
  135. @click="setUserAnswerAndRes(item)"
  136. v-for="(item, index) in list[listIndex].optsArr"
  137. :key="index"
  138. class="w57 lh46 bottom-button mr15"
  139. >
  140. {{ switchIndexBySelect(index) }}
  141. </div>
  142. </div>
  143. </div>
  144. <div class="w430 pr30 flex items-center bg-white">
  145. <img
  146. class="w400"
  147. v-if="isImageUrl(list[listIndex].mediaUrl)"
  148. :src="list[listIndex].mediaUrl"
  149. />
  150. <video
  151. class="w400"
  152. autoplay
  153. loop
  154. v-if="isVideoUrl(list[listIndex].mediaUrl)"
  155. :src="list[listIndex].mediaUrl"
  156. ></video>
  157. </div>
  158. </div>
  159. <div class="w-full pt30">
  160. <div class="w1200 flex justify-between mr-auto ml-auto">
  161. <div
  162. @click="preProblem()"
  163. @keydown.up="preProblem()"
  164. class="w120 lh46 bottom-button lh46"
  165. >
  166. 上一题
  167. </div>
  168. <div
  169. @click="nextProblem()"
  170. @keydown.down="nextProblem()"
  171. class="w120 lh46 bottom-button lh46"
  172. >
  173. 下一题
  174. </div>
  175. <div
  176. @click="
  177. () => {
  178. alertVisible = true;
  179. }
  180. "
  181. class="w120 lh46 bottom-button lh46"
  182. >
  183. 本题解析
  184. </div>
  185. <div @click="playIssueAudio()" class="w120 lh46 bottom-button lh46">
  186. 语音播报
  187. </div>
  188. <div class="w120 lh46 bottom-button lh46">不设为错题</div>
  189. <div
  190. @click="
  191. () => {
  192. dialogVisible = true;
  193. }
  194. "
  195. class="w120 lh46 bottom-button lh46"
  196. >
  197. 交卷
  198. </div>
  199. </div>
  200. </div>
  201. <div class="w-full mt20">
  202. <div
  203. class="flex w1200 mr-auto ml-auto h30 items-center content-center justify-around"
  204. >
  205. <div class="flex items-center">
  206. <div class="pr2 pl2">转到</div>
  207. <input
  208. @keydown.enter="setPageToListIndex(listPageNum)"
  209. class="outline-none input-border w35 h30 text-center"
  210. type="text"
  211. v-model.number="listPageNum"
  212. />
  213. <div class="pr2 pl2">题(请按回车)</div>
  214. </div>
  215. <div>
  216. 共 <span class="font-semibold">{{ list.length }}</span> 题
  217. </div>
  218. <div class="align-baseline">
  219. <input
  220. v-model="sysConfig.autoNext"
  221. class=""
  222. @change="changeSysConfig"
  223. type="checkbox"
  224. />
  225. <span>答对自动跳转到下一题</span>
  226. </div>
  227. <div>
  228. <div class="mr15 inline-block tracking5">
  229. 答对<span style="color: #21a65f">{{ trueNum }}</span
  230. >题
  231. </div>
  232. <div class="inline-block tracking5">
  233. 答错<span style="color: #ef3629">{{ falseNum }}</span
  234. >题
  235. </div>
  236. </div>
  237. <div class=""><span class="text-black font16">正确率100%</span></div>
  238. <div class="">
  239. <span class="text-black font16"
  240. >进度{{
  241. fixedNumber(((trueNum + falseNum) * 100) / list.length, 2)
  242. }}%</span
  243. >
  244. </div>
  245. <div class="flex items-center content-center">
  246. <!-- <div class="mr15">
  247. <input
  248. class=""
  249. v-model="sysConfig.autoRead"
  250. type="checkbox"
  251. @change="changeSysConfig"
  252. />
  253. <span>自动播放</span>
  254. </div> -->
  255. <!-- <div>
  256. <input
  257. class=""
  258. v-model="sysConfig.autoRed"
  259. type="checkbox"
  260. @change="changeSysConfig"
  261. />
  262. <span>提示红字</span>
  263. </div> -->
  264. </div>
  265. </div>
  266. </div>
  267. </div>
  268. <mProblemAlert
  269. v-model:visible="alertVisible"
  270. :content="list[listIndex].explainJs"
  271. title="题目解析"
  272. ></mProblemAlert>
  273. <mProblemDialog
  274. @confirm="submitThreeExam()"
  275. v-model:visible="dialogVisible"
  276. title="提示"
  277. content="是否真的要交卷(按确定键交卷,按取消键继续答题)"
  278. ></mProblemDialog>
  279. </div>
  280. </template>
  281. <script lang="ts">
  282. import { defineComponent, ref } from "vue";
  283. import api from "@/api";
  284. import { useRoute } from "vue-router";
  285. import { useDriverExam } from "@/hooks/exam/driverExam";
  286. import mProblemAlert from "@/components/mProblemAlert/index.vue";
  287. import mProblemDialog from "@/components/mProblemDialog/index.vue";
  288. import { useStore } from "vuex";
  289. import { message } from "ant-design-vue";
  290. import { useThreeExam } from "@/hooks/exam/threeExam";
  291. export default defineComponent({
  292. name: "studySkill",
  293. setup() {
  294. let route = useRoute();
  295. let store = useStore();
  296. let sysConfig = ref({
  297. autoRed: store.state.sysConfig.autoRed,
  298. autoRead: store.state.sysConfig.autoRead,
  299. autoNext: store.state.sysConfig.autoNext,
  300. });
  301. const changeSysConfig = (event: any) => {
  302. console.log(sysConfig.value);
  303. store.commit("SET_SYSCONFIG", sysConfig.value);
  304. };
  305. const fixedNumber = (decimal: number, digit: number) => {
  306. return decimal.toFixed(digit);
  307. };
  308. const isImageUrl = (url: string) => {
  309. var reg = /\.(png|jpg|gif|jpeg|webp)$/;
  310. return reg.test(url);
  311. };
  312. const isVideoUrl = (url: string) => {
  313. var reg = /\.(mp4|rmvb|3gp|flv|avi)$/;
  314. return reg.test(url);
  315. };
  316. let wrongList: { id: number; timestamp: number }[] = [];
  317. wrongList = JSON.parse(
  318. window.localStorage.getItem("threeExam_local_wrong_list") || "[]"
  319. ) as { id: number; timestamp: number }[];
  320. return {
  321. sysConfig,
  322. alertVisible: ref(false),
  323. dialogVisible: ref(false),
  324. ...useThreeExam(
  325. api.three.threeForceGetThreeForceListIds({
  326. ids: wrongList.map((item) => item.id).join(","),
  327. }),
  328. {
  329. autoAnswer: false,
  330. countDown: false,
  331. recordUncomplete: false,
  332. }
  333. ),
  334. changeSysConfig,
  335. fixedNumber,
  336. isImageUrl,
  337. isVideoUrl,
  338. };
  339. },
  340. components: {
  341. mProblemAlert,
  342. mProblemDialog,
  343. },
  344. });
  345. </script>
  346. <style scoped>
  347. .bottom-button {
  348. text-align: center;
  349. border: 1px solid #f9de5b;
  350. cursor: pointer;
  351. }
  352. input[type="checkbox"] {
  353. margin-right: 5px;
  354. cursor: pointer;
  355. font-size: 14px;
  356. width: 15px;
  357. height: 12px;
  358. position: relative;
  359. }
  360. input[type="checkbox"]:after {
  361. position: absolute;
  362. width: 16px;
  363. height: 16px;
  364. top: 0;
  365. left: 0px;
  366. content: " ";
  367. background-color: #f9de5b;
  368. color: #fff;
  369. display: inline-block;
  370. visibility: visible;
  371. border-radius: 3px;
  372. }
  373. input[type="checkbox"]:checked:after {
  374. width: 16px;
  375. height: 16px;
  376. background-size: 100%;
  377. background-image: url("./../../assets/img/login/checked_icon.png");
  378. }
  379. .input-border {
  380. border: 1px solid #707070;
  381. }
  382. .bg-gray {
  383. background: #f5f5f5;
  384. }
  385. .gray-border {
  386. border: 1px solid #d8d8d8;
  387. }
  388. .bg-primary-yellow {
  389. background: #f9de5b;
  390. }
  391. .bottom-button {
  392. text-align: center;
  393. border: 1px solid #f9de5b;
  394. cursor: pointer;
  395. }
  396. .bottom-button:focus {
  397. background: #f9de5b;
  398. border: 1px solid #f9de5b;
  399. outline: none;
  400. }
  401. .bottom-button:hover {
  402. background: #fff7cc;
  403. }
  404. .w1200 {
  405. width: 1200px;
  406. }
  407. </style>