index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <!-- -->
  2. <template>
  3. <div class="answer">
  4. <Header title="诗潮岳涌" />
  5. <div class="bg-container">
  6. <div class="bg-img">
  7. <img src="@/assets/images/anserHome.png" alt="" />
  8. </div>
  9. <div class="control-box">
  10. <div class="pic"></div>
  11. <div class="content">
  12. <div class="title">
  13. <div class="icon"></div>
  14. <span>{{ custom[answerIndex].question }}</span>
  15. </div>
  16. <div class="options">
  17. <div
  18. @click="changeOption(index, i)"
  19. class="item"
  20. v-for="(i, index) in custom[answerIndex].options"
  21. :class="{ isTrue: optionIndex != -1 && i.correct, isFalse: optionIndex == index && !i.correct }"
  22. >
  23. <span>{{ i.text }}</span>
  24. <!-- <div v-if="optionIndex != -1 && i.correct" class="icon true"></div>
  25. <div v-if="optionIndex == index && !i.correct" class="icon false"></div> -->
  26. </div>
  27. </div>
  28. <div class="viewer" :class="{ show: isCheck }" @click="showReview = true">查看解析</div>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="review-layer" v-if="showReview">
  33. <div class="review-bg">
  34. <div class="text-box">
  35. <div class="header">
  36. <p class="review-title">{{ custom[answerIndex].content.title }}</p>
  37. <span class="review-author">{{ custom[answerIndex].content.time }} {{ custom[answerIndex].content.author }} </span>
  38. <p class="review-content" v-html="custom[answerIndex].content.text"></p>
  39. </div>
  40. <div class="body">
  41. <p class="desc-title">诗词译文</p>
  42. <p class="desc" v-html="custom[answerIndex].content.explain"></p>
  43. <p class="desc-title">诗词赏析</p>
  44. <p class="desc" v-html="custom[answerIndex].content.appreciate"></p>
  45. </div>
  46. </div>
  47. <div class="controls-box">
  48. <div class="replay" @click="reStartOrContinue(0)">重新开始</div>
  49. <div class="continue" @click="reStartOrContinue()">继续</div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="complete-layer" v-if="showComplete">
  54. <div>
  55. <div class="complete-content">
  56. <div class="pic"></div>
  57. <p>恭喜您!</p>
  58. <p class="complete-title">您已完成全部题目</p>
  59. <p class="complete-count">
  60. 答对<span>{{ counts }}</span
  61. >道题目
  62. </p>
  63. <div class="replay" @click="reStartOrContinue(0)">重新开始</div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. <script setup>
  70. import { reactive, ref, toRefs, onBeforeMount, onMounted, watch } from "vue";
  71. import Header from "@/components/header/index.vue";
  72. import { custom } from "./constant";
  73. const answerIndex = ref(0);
  74. const optionIndex = ref(-1);
  75. const isCheck = ref(false);
  76. const counts = ref(0);
  77. const showReview = ref(false);
  78. const showComplete = ref(false);
  79. const changeOption = (index, i) => {
  80. if (!isCheck.value) {
  81. optionIndex.value = index;
  82. if (i.correct) {
  83. counts.value++;
  84. }
  85. isCheck.value = true;
  86. // setTimeout(() => {
  87. // showReview.value = true;
  88. // }, 1000);
  89. }
  90. };
  91. watch(
  92. () => isCheck.value,
  93. (val) => {
  94. if (val) {
  95. // answerIndex.value++;
  96. // optionIndex.value = -1;
  97. }
  98. }
  99. );
  100. const reStartOrContinue = (type = 1) => {
  101. if (type == 0) {
  102. answerIndex.value = 0;
  103. showComplete.value = false;
  104. } else {
  105. if (answerIndex.value >= custom.length - 1) {
  106. showComplete.value = true;
  107. } else {
  108. answerIndex.value++;
  109. }
  110. }
  111. optionIndex.value = -1;
  112. isCheck.value = false;
  113. showReview.value = false;
  114. };
  115. </script>
  116. <style lang="scss" scoped>
  117. .answer {
  118. width: 100%;
  119. height: 100%;
  120. .bg-container {
  121. width: 100%;
  122. height: 100%;
  123. position: relative;
  124. .bg-img {
  125. height: 100%;
  126. img {
  127. width: 100%;
  128. height: 100%;
  129. object-fit: cover;
  130. }
  131. }
  132. .control-box {
  133. min-height: 40%;
  134. width: 100%;
  135. background: url("@/assets/images/answerBg.png") no-repeat;
  136. background-size: cover;
  137. position: absolute;
  138. bottom: 0;
  139. left: 0;
  140. padding: 0.9333rem 1.1467rem 0;
  141. padding-top: 0.4rem;
  142. .pic {
  143. width: 3.8667rem;
  144. height: 1.6667rem;
  145. background: url("@/assets/images/answerTitle.png") no-repeat;
  146. background-size: 100% 100%;
  147. position: absolute;
  148. top: -2.4rem;
  149. left: 50%;
  150. transform: translateX(-50%);
  151. }
  152. .content {
  153. width: 100%;
  154. height: 100%;
  155. overflow-y: auto;
  156. .title {
  157. min-height: 0.9333rem;
  158. border-radius: 0.4667rem;
  159. padding: 0.1333rem 0.2667rem;
  160. display: flex;
  161. align-items: center;
  162. // justify-content: flex-start;
  163. font-size: 0.3733rem;
  164. color: #3d2924;
  165. margin-top: 1.3333rem;
  166. margin-bottom: 0.5867rem;
  167. .icon {
  168. width: 0.3067rem;
  169. height: 0.3067rem;
  170. background: url("../../assets/images/answerTitleIcon.png");
  171. background-size: 100% 100%;
  172. display: inline-block;
  173. }
  174. span {
  175. padding-left: 0.1333rem;
  176. display: inline-block;
  177. width: calc(100% - 0.3067rem);
  178. }
  179. }
  180. .viewer {
  181. width: 4.2667rem;
  182. height: 1.0933rem;
  183. color: #fff;
  184. font-size: 0.3733rem;
  185. display: flex;
  186. align-items: center;
  187. justify-content: center;
  188. background: url("../../assets/images/fristBtn.png");
  189. background-size: 100% 100%;
  190. margin: 2.6667rem auto 1.8267rem;
  191. // margin-bottom: 1.8267rem;
  192. visibility: hidden;
  193. &.show {
  194. visibility: visible;
  195. }
  196. }
  197. .options {
  198. margin-top: 0.5333rem;
  199. .item {
  200. background: #fff;
  201. min-height: 1.28rem;
  202. border-radius: 0.4533rem;
  203. padding: 0.1333rem 0.2667rem;
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. // box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.25); /* 内阴影效果 */
  208. font-size: 0.3733rem;
  209. color: rgba(0, 0, 0, 0.8);
  210. margin-bottom: 0.2667rem;
  211. border-radius: 1.1733rem;
  212. border: 1px solid rgba(106, 73, 52, 0.5);
  213. background: none;
  214. &.isFalse {
  215. background: rgba(227, 97, 97, 0.3);
  216. border: 1px solid rgba(167, 9, 9, 0.5);
  217. color: rgba(146, 37, 37, 1);
  218. }
  219. &.isTrue {
  220. background: rgba(76, 179, 127, 0.3);
  221. border: 1px solid #4cb37f;
  222. color: rgba(14, 132, 73, 1);
  223. }
  224. span {
  225. width: 100%;
  226. text-align: center;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. }
  233. .review-layer {
  234. width: 100%;
  235. height: 100%;
  236. position: absolute;
  237. top: 0;
  238. left: 0;
  239. z-index: 10;
  240. // background: url("@/assets/images/reviewBg.png") no-repeat;
  241. // background-size: cover;
  242. padding: 1.12rem 0 0 1.1467rem;
  243. .review-bg {
  244. width: 100%;
  245. height: calc(100% - 1.0667rem);
  246. padding: 1.6rem .5333rem 1.3333rem;
  247. // overflow-y: auto;
  248. background: url("@/assets/images/reviewBg.png") no-repeat;
  249. background-size: 100% 100%;
  250. background-color: #f2f2f2;
  251. position: absolute;
  252. bottom: 0;
  253. left: 0;
  254. .text-box {
  255. width: 100%;
  256. height: 85%;
  257. overflow-y: auto;
  258. .header {
  259. width: 90%;
  260. padding: 0 0.4rem 0.5333rem;
  261. border-bottom: 0.0267rem dashed #9c8f86;
  262. margin: 0 auto;
  263. .review-title {
  264. font-weight: bold;
  265. font-size: 0.4667rem;
  266. color: #3d2924;
  267. text-align: center;
  268. margin-top: 0.4rem;
  269. }
  270. .review-author {
  271. font-weight: 400;
  272. font-size: 0.3733rem;
  273. color: #3d2924;
  274. display: flex;
  275. align-items: center;
  276. justify-content: flex-end;
  277. padding: 0 1.0667rem;
  278. margin-top: 0.4rem;
  279. }
  280. .review-content {
  281. font-size: 0.3733rem;
  282. color: #3d2924;
  283. line-height: 0.6533rem;
  284. letter-spacing: 0.12rem;
  285. display: flex;
  286. margin-top: 0.2rem;
  287. align-items: center;
  288. justify-content: center;
  289. }
  290. }
  291. .body {
  292. width: 90%;
  293. // padding: 0 0.4rem 0.5333rem;
  294. margin: 0 auto;
  295. .desc-title {
  296. font-weight: bold;
  297. font-size: 0.4667rem;
  298. color: #6a4934;
  299. margin-top: 0.9067rem;
  300. &::before {
  301. content: "";
  302. width: 0.3067rem;
  303. height: 0.3067rem;
  304. display: inline-block;
  305. background: url("@/assets/images/reviewTitleIcon.png") no-repeat;
  306. background-size: 100% 100%;
  307. margin-right: 0.16rem;
  308. }
  309. }
  310. .desc {
  311. font-weight: 400;
  312. font-size: 0.3333rem;
  313. color: rgba(106, 73, 52, 0.8);
  314. line-height: 0.4933rem;
  315. margin-top: 0.5333rem;
  316. }
  317. }
  318. }
  319. .controls-box {
  320. width: 100%;
  321. height: 20%;
  322. font-weight: normal;
  323. display: flex;
  324. align-items: center;
  325. justify-content: center;
  326. > div {
  327. display: flex;
  328. align-items: center;
  329. justify-content: center;
  330. width: 2.7067rem;
  331. height: 0.8267rem;
  332. font-weight: 400;
  333. font-size: 0.3333rem;
  334. color: #fff;
  335. background: none;
  336. background: url("@/assets/images/answer-btn.png") no-repeat;
  337. background-size: 100% 100%;
  338. }
  339. .replay {
  340. margin-right: 0.2667rem;
  341. }
  342. .continue {
  343. }
  344. }
  345. }
  346. }
  347. .complete-layer {
  348. background: url("@/assets/images/anserHome.png") no-repeat;
  349. background-size: cover;
  350. width: 100%;
  351. height: 100%;
  352. position: absolute;
  353. top: 0;
  354. left: 0;
  355. z-index: 11;
  356. color: #fff;
  357. display: flex;
  358. align-items: center;
  359. flex-direction: column;
  360. justify-content: center;
  361. > div {
  362. width: 90%;
  363. height: 80%;
  364. background: url("@/assets/images/answerBg.png") no-repeat;
  365. background-size: 100% 100%;
  366. position: absolute;
  367. display: flex;
  368. align-items: center;
  369. justify-content: center;
  370. .complete-content {
  371. display: flex;
  372. align-items: center;
  373. justify-content: center;
  374. flex-direction: column;
  375. .pic {
  376. width: 6.0667rem;
  377. height: 2.08rem;
  378. background: url("@/assets/images/complete@2x.png") no-repeat;
  379. background-size: 100% 100%;
  380. margin-bottom: 1.0667rem;
  381. }
  382. p {
  383. font-weight: 400;
  384. font-size: 0.3333rem;
  385. color: #3d2924;
  386. line-height: 0.4933rem;
  387. display: flex;
  388. align-items: center;
  389. justify-content: center;
  390. }
  391. .complete-count {
  392. font-size: 0.3333rem;
  393. margin-top: 0.4rem;
  394. span {
  395. font-size: 0.84rem;
  396. font-weight: bold;
  397. }
  398. }
  399. .replay {
  400. display: flex;
  401. align-items: center;
  402. justify-content: center;
  403. width: 4.2667rem;
  404. height: 1.0933rem;
  405. font-weight: 400;
  406. font-size: 0.4267rem;
  407. color: #fff;
  408. line-height: 0.4933rem;
  409. background: url("@/assets/images/fristBtn.png") no-repeat;
  410. background-size: 100% 100%;
  411. border-radius: 1.1733rem;
  412. margin-top: 1.84rem;
  413. }
  414. }
  415. }
  416. }
  417. }
  418. .icon {
  419. width: 0.5333rem;
  420. height: 0.5333rem;
  421. &.true {
  422. background: url("@/assets/images/true.png") no-repeat;
  423. background-size: 100% 100%;
  424. }
  425. &.false {
  426. background: url("@/assets/images/false.png") no-repeat;
  427. background-size: 100% 100%;
  428. }
  429. }
  430. </style>