QuestionPositionTip.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <div class="question-position-tip">
  3. <div
  4. class="wrapper-1"
  5. :style="{
  6. width: initialWrapperWidth + 'px',
  7. height: initialWrapperHeight + 'px',
  8. transform: wrapperTransformCss,
  9. }"
  10. >
  11. <button
  12. class="close"
  13. @click="$router.go(-1)"
  14. />
  15. <h1 class="introduction-title">
  16. {{ badgeTypeTxt }}
  17. </h1>
  18. <div class="introduction">
  19. <p class="txt">
  20. 请根据图片提示,寻找并查看知识点。超过{{ badgeGoalNum }}个知识点即可获得相应徽章。
  21. </p>
  22. <p
  23. v-if="!isMobile"
  24. class="number"
  25. >
  26. {{ badgeCurrNum }}/{{ badgeTotalNum }}
  27. </p>
  28. </div>
  29. <ul class="img-list">
  30. <li
  31. v-for="(item, index) in quizListInBadgeType"
  32. :key="index"
  33. >
  34. <img
  35. class="position"
  36. :src="require(`@/assets/images/quizScreenshots/${item.id}.png`)"
  37. alt=""
  38. draggable="false"
  39. >
  40. <img
  41. v-if="quizStatus(item.id) === 1"
  42. class="status"
  43. src="@/assets/images/quiz-status-correct.png"
  44. alt=""
  45. draggable="false"
  46. >
  47. <img
  48. v-if="quizStatus(item.id) === 0"
  49. class="status"
  50. src="@/assets/images/quiz-status-wrong.png"
  51. alt=""
  52. draggable="false"
  53. >
  54. <img
  55. v-if="quizStatus(item.id) === -1"
  56. class="status"
  57. src="@/assets/images/quiz-status-blank.png"
  58. alt=""
  59. draggable="false"
  60. >
  61. </li>
  62. </ul>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import quizData, { badgeTypeCode2txt } from "@/quizData.js"
  68. import globalApi from "@/api"
  69. export default {
  70. data() {
  71. return {
  72. answerRecord: null,
  73. }
  74. },
  75. computed: {
  76. ...globalMapState([
  77. 'badgeArchGoal',
  78. 'badgeHistoryGoal',
  79. 'badgeProtectorGoal',
  80. 'badgeArchCurrent',
  81. 'badgeHistoryCurrent',
  82. 'badgeProtectorCurrent',
  83. ]),
  84. badgeTypeTxt() {
  85. return badgeTypeCode2txt[this.$route.query.badgeCode]
  86. },
  87. badgeGoalNum() {
  88. switch (this.$route.query.badgeCode) {
  89. case '1':
  90. return this.badgeArchGoal
  91. case '2':
  92. return this.badgeHistoryGoal
  93. case '3':
  94. return this.badgeProtectorGoal
  95. default:
  96. return 5
  97. }
  98. },
  99. badgeCurrNum() {
  100. switch (this.$route.query.badgeCode) {
  101. case '1':
  102. return this.badgeArchCurrent
  103. case '2':
  104. return this.badgeHistoryCurrent
  105. case '3':
  106. return this.badgeProtectorCurrent
  107. default:
  108. return 0
  109. }
  110. },
  111. quizListInBadgeType() {
  112. return quizData.filter((item) => {
  113. return item.badgeTypeCode.includes(this.$route.query.badgeCode)
  114. })
  115. },
  116. badgeTotalNum() {
  117. return this.quizListInBadgeType.length
  118. },
  119. initialWrapperWidth() {
  120. return this.isMobile ? 330 : 1017
  121. },
  122. initialWrapperHeight() {
  123. return this.isMobile ? 678 : 691
  124. },
  125. wrapperTransformCss() {
  126. if (this.isMobile) {
  127. const WHRateViewport = window.innerWidth / window.innerHeight
  128. const WHRateComp = this.initialWrapperWidth / this.initialWrapperHeight
  129. if (WHRateViewport >= WHRateComp) { // 视口矮宽
  130. return `translate(-50%, -50%) scale(${window.innerHeight / this.initialWrapperHeight * 0.9})`
  131. } else {
  132. return `translate(-50%, -50%) scale(${window.innerWidth / this.initialWrapperWidth * 0.9})`
  133. }
  134. } else {
  135. return ''
  136. }
  137. }
  138. },
  139. mounted() {
  140. globalApi.getAnswerRecord().then((res) => {
  141. this.answerRecord = res
  142. })
  143. },
  144. methods: {
  145. quizStatus(id) {
  146. if (!this.answerRecord) {
  147. return undefined
  148. }
  149. const answerTarget = this.answerRecord.find(recordItem => {return recordItem.num === id})
  150. if (!answerTarget) {
  151. return -1 // 没答过
  152. }
  153. return answerTarget.hasRight // 0: 错 1:对
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="less" scoped>
  159. .question-position-tip {
  160. position: fixed;
  161. left: 0;
  162. top: 0;
  163. width: 100%;
  164. height: 100%;
  165. background: rgba(46,32,19,0.55);
  166. backdrop-filter: blur(5px);
  167. z-index: 10000;
  168. > .wrapper-1 {
  169. position: absolute;
  170. left: 50%;
  171. top: 50%;
  172. background-image: url(@/assets/images/quiz-position-tip-bg.png);
  173. background-size: contain;
  174. background-repeat: no-repeat;
  175. background-position: center center;
  176. padding: 50px 40px 40px 70px;
  177. display: flex;
  178. flex-direction: column;
  179. align-items: center;
  180. > .close {
  181. position: absolute;
  182. top: 52px;
  183. right: 47px;
  184. width: 42px;
  185. height: 45px;
  186. background-image: url(@/assets/images/close.png);
  187. background-size: contain;
  188. background-repeat: no-repeat;
  189. background-position: center center;
  190. }
  191. > h1.introduction-title {
  192. flex: 0 1 auto;
  193. display: inline-block;
  194. background-image: url(@/assets/images/title_decorator.png);
  195. background-size: contain;
  196. background-repeat: no-repeat;
  197. background-position: center center;
  198. padding: 0 92px 25px 92px;
  199. font-size: 36px;
  200. font-family: LiSu-Regular, LiSu;
  201. font-weight: 400;
  202. color: #ab3f14;
  203. }
  204. > .introduction {
  205. flex: 0 1 auto;
  206. margin-top: 5px;
  207. text-align: center;
  208. > p.txt {
  209. font-size: 16px;
  210. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  211. font-weight: 400;
  212. color: #A4573F;
  213. }
  214. > p.number {
  215. margin-top: 10px;
  216. font-size: 22px;
  217. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  218. font-weight: bold;
  219. color: #b3735c;
  220. }
  221. }
  222. > ul.img-list {
  223. margin-top: 10px;
  224. flex: 1 0 1px;
  225. width: 100%;
  226. overflow: auto;
  227. > li {
  228. display: inline-block;
  229. width: 270px;
  230. height: 192px;
  231. border-radius: 2px 2px 2px 2px;
  232. border: 1px solid #FFFFFF;
  233. position: relative;
  234. margin-right: 29px;
  235. margin-bottom: 24px;
  236. > img.position {
  237. position: absolute;
  238. width: 100%;
  239. height: 100%;
  240. object-fit: cover;
  241. }
  242. > img.status {
  243. position: absolute;
  244. right: 7px;
  245. bottom: 7px;
  246. width: 36px;
  247. height: 36px;
  248. }
  249. }
  250. }
  251. }
  252. }
  253. .mobile {
  254. .question-position-tip {
  255. > .wrapper-1 {
  256. background-image: url(@/assets/images/quiz-position-tip-bg-mobile.png);
  257. padding: 50px 21px 40px 32px;
  258. > .close {
  259. top: 52px;
  260. right: 25px;
  261. width: 23px;
  262. height: 23px;
  263. }
  264. > h1.introduction-title {
  265. margin-right: 15px;
  266. background-image: url(@/assets/images/title-decorator-mobile.png);
  267. font-size: 24px;
  268. padding: 0 30px 15px 30px;
  269. }
  270. > .introduction {
  271. margin-top: 5px;
  272. margin-right: 15px;
  273. > p.txt {
  274. text-align: justify;
  275. font-size: 14px;
  276. opacity: 0.8;
  277. }
  278. }
  279. > ul.img-list {
  280. margin-top: 10px;
  281. padding-right: 13px;
  282. > li {
  283. width: 100%;
  284. height: 170px;
  285. margin-bottom: 10px;
  286. margin-right: initial;
  287. > img.position {
  288. position: absolute;
  289. width: 100%;
  290. height: 100%;
  291. object-fit: cover;
  292. }
  293. > img.status {
  294. position: absolute;
  295. right: 5px;
  296. bottom: 5px;
  297. width: 32px;
  298. height: 32px;
  299. }
  300. }
  301. }
  302. }
  303. }
  304. }
  305. </style>