AnswerGame.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. <template>
  2. <div class="timeline-container">
  3. <div class="timeline-content">
  4. <div class="timeline-entry-list">
  5. <div class="gameBox">
  6. <div class="item" :class="{ 'dim': isDim }" v-if="isShowItem==true">
  7. <div class="integralBox">
  8. <div class="integral">125000</div>
  9. </div>
  10. <div class="timer">
  11. <div class="second">{{ countdown }}</div>
  12. </div>
  13. <div class="topicNum">
  14. <div class="topic">{{itemNum+1}}/5</div>
  15. </div>
  16. <div class="questionBox">
  17. <div class="title animated zoomIn">
  18. <span style="text-align: center;">{{ question[itemNum].ask }}</span>
  19. </div>
  20. <div class="content animated" :class="animate_showChoice" v-if="animate_showChoice">
  21. <div v-for="(item,index) in question[itemNum].answer" :key="index" class="answerItem" :class="index == clickIndex ? answerColor : ''" @click="answer(item,index)">
  22. <span>{{ item.answer }}</span>
  23. <img v-if="index == clickIndex&&answerColor=='error'" class="invisible" src="@/assets/image/answerGame/item/error.png" alt="错误">
  24. <img v-if="index == clickIndex&&answerColor=='right'" class="invisible" style="width: 25px;" src="@/assets/image/answerGame/item/right.png" alt="正确">
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="home" :class="{ 'dim': isDim }" v-else>
  30. <img class="rules" src="@/assets/image/answerGame/home/rules.png" alt="互动规则" @click="clickRuleWrapper">
  31. <img class="answer" src="@/assets/image/answerGame/home/answer.png" alt="答题按钮" @click="clickAnswer">
  32. <img class="exit" src="@/assets/image/answerGame/home/exit.png" alt="答题按钮">
  33. </div>
  34. <div class="ruleWrapper" v-if="isRuleWrapper">
  35. <el-card class="box-card">
  36. <div slot="header" class="clearfix">
  37. <span>互动规则</span>
  38. <span style="float: right; font-size: 20px;cursor: pointer;" @click="closeRuleWrapper">
  39. <i class="el-icon-close"></i>
  40. </span>
  41. </div>
  42. <div v-for="o in 4" :key="o">
  43. {{'列表内容 ' + o }}
  44. </div>
  45. </el-card>
  46. </div>
  47. <div class="confirmWrapper" v-if="isConfirmWrapper">
  48. <img class="goHome" src="@/assets/image/answerGame/item/goHome.png" alt="返回首页" @click="clickGoHome">
  49. </div>
  50. <div class="failWrapper" v-if="isFailWrapper">
  51. <img class="goHome" src="@/assets/image/answerGame/item/goHome.png" alt="返回首页" @click="clickGoHome">
  52. </div>
  53. </div>
  54. </div>
  55. <SiderInfo></SiderInfo>
  56. </div>
  57. </div>
  58. </template>
  59. <script>
  60. import SiderInfo from '@/components/SiderInfo.vue'
  61. export default{
  62. components: {
  63. SiderInfo
  64. },
  65. data() {
  66. return {
  67. isConfirmWrapper:false,
  68. isFailWrapper:false,
  69. animate_showChoice:'zoomIn',
  70. localClick:false,
  71. clickIndex:-1,
  72. answerColor:'',
  73. isShowItem:false,
  74. isRuleWrapper: false,
  75. isDim:false,
  76. question:[
  77. {
  78. id: 1,
  79. sortId: 1,
  80. ask: "最早的粽子并不是端午节的特产,那粽子是什么时期被正式定为端午节食品的?1111",
  81. answer: [
  82. {right: false, answer: "南北朝时期11"},
  83. {right: false, answer: "春秋时期11"},
  84. {right: true, answer: "晋代11"},
  85. {right: false, answer: "周商时期11"}],
  86. },
  87. {
  88. id: 2,
  89. sortId: 2,
  90. ask: "最早的粽子并不是端午节的特产,那粽子是什么时期被正式定为端午节食品的?2222",
  91. answer: [
  92. {right: false, answer: "南北朝时期22"},
  93. {right: false, answer: "春秋时期22"},
  94. {right: true, answer: "晋代22"},
  95. {right: false, answer: "周商时期22"}],
  96. },
  97. {
  98. id: 3,
  99. sortId: 3,
  100. ask: "最早的粽子并不是端午节的特产,那粽子是什么时期被正式定为端午节食品的?333",
  101. answer: [
  102. {right: false, answer: "南北朝时期33"},
  103. {right: false, answer: "春秋时期33"},
  104. {right: true, answer: "晋代33"},
  105. {right: false, answer: "周商时期33"}],
  106. },
  107. {
  108. id: 4,
  109. sortId: 4,
  110. ask: "最早的粽子并不是端午节的特产,那粽子是什么时期被正式定为端午节食品的?4444",
  111. answer: [
  112. {right: false, answer: "南北朝时期44"},
  113. {right: false, answer: "春秋时期44"},
  114. {right: true, answer: "晋代44"},
  115. {right: false, answer: "周商时期44"}],
  116. },
  117. {
  118. id: 5,
  119. sortId: 5,
  120. ask: "最早的粽子并不是端午节的特产,那粽子是什么时期被正式定为端午节食品的?5555",
  121. answer: [
  122. {right: false, answer: "南北朝时期55"},
  123. {right: false, answer: "春秋时期55"},
  124. {right: true, answer: "晋代55"},
  125. {right: false, answer: "周商时期55"}],
  126. }
  127. ],
  128. chooseStr: '',
  129. itemNum: 0,
  130. result: [],
  131. timer:null,
  132. countdown:60,
  133. };
  134. },
  135. created(){},
  136. methods:{
  137. clickGoHome(){
  138. this.isFailWrapper = false;
  139. this.isConfirmWrapper = false;
  140. this.isDim = false;
  141. this.isShowItem = false;
  142. },
  143. timerCountdown(){
  144. this.timer = setInterval(() => {
  145. this.countdown--;
  146. if (this.countdown == 0) {
  147. clearInterval(this.timer);
  148. let resLength = 5 - this.result.length;
  149. for (let i = 0; i < resLength; i++) {
  150. this.result.push('');
  151. }
  152. this.isDim = true;
  153. this.isFailWrapper = true;
  154. this.countdown = 60;
  155. console.log(this.result);
  156. }
  157. }, 1000)
  158. },
  159. answer(val,index){
  160. console.log(this.itemNum);
  161. if(!this.localClick && this.itemNum<5){
  162. this.clickIndex = index;
  163. if(val.right){
  164. this.answerColor = 'right';
  165. }else{
  166. this.answerColor = 'error';
  167. }
  168. this.localClick = true;
  169. setTimeout(() => {
  170. this.result.push(val.answer);
  171. this.clickIndex = -1;
  172. this.answerColor = '';
  173. this.animate_showChoice = 'fadeOut';
  174. if(this.itemNum==4){
  175. clearInterval(this.timer);
  176. this.localClick = true;
  177. this.isDim = true;
  178. this.isConfirmWrapper = true;
  179. this.countdown = 60;
  180. console.log(this.result);
  181. }else{
  182. this.itemNum++
  183. this.localClick = false;
  184. setTimeout(() => {
  185. this.animate_showChoice = 'fadeIn';
  186. }, 1500)
  187. }
  188. }, 1500)
  189. }
  190. },
  191. clickAnswer(){
  192. this.isShowItem = true;
  193. this.timerCountdown();
  194. },
  195. clickRuleWrapper(){
  196. this.isDim = true;
  197. this.isRuleWrapper = true;
  198. },
  199. closeRuleWrapper(){
  200. this.isDim = false;
  201. this.isRuleWrapper = false;
  202. }
  203. },
  204. }
  205. </script>
  206. <style scoped>
  207. .animated {
  208. animation-duration: 1s;
  209. animation-fill-mode: forwards;
  210. }
  211. @keyframes zoomIn {
  212. from {
  213. opacity: 0;
  214. transform: scale3d(.2, .2, .2);
  215. }
  216. 50% {
  217. opacity: 1;
  218. }
  219. }
  220. .zoomIn {
  221. animation-name: zoomIn;
  222. }
  223. @keyframes fadeIn {
  224. from {
  225. opacity: 0;
  226. }
  227. to {
  228. opacity: 1;
  229. }
  230. }
  231. .fadeIn {
  232. animation-name: fadeIn;
  233. }
  234. @keyframes fadeOut {
  235. from {
  236. opacity: 1;
  237. }
  238. to {
  239. opacity: 0;
  240. }
  241. }
  242. .fadeOut {
  243. animation-name: fadeOut;
  244. }
  245. .timeline-container{
  246. margin: 0 auto;
  247. }
  248. .timeline-entry-list{
  249. margin-right: 17.5rem;
  250. border-radius: 2px;
  251. width: 720px;
  252. position: relative;
  253. }
  254. .timeline-entry-list .gameBox{
  255. border-radius: 4px 4px 0 0;
  256. position: relative;
  257. padding: 2.667rem 0;
  258. z-index: 1;
  259. overflow: hidden;
  260. background-color: #fff;
  261. padding-left: 2.67rem;
  262. padding-right: 2.67rem;
  263. margin-bottom: 2rem;
  264. box-sizing: border-box;
  265. min-height: 280px;
  266. display: flex;
  267. justify-content: center;
  268. align-content: center;
  269. }
  270. .gameBox .item{
  271. position: relative;
  272. z-index: 10;
  273. background: url(@/assets/image/answerGame/item/itemBg.png) no-repeat;
  274. background-size: 100% 100%;
  275. width: 450px;
  276. height: 800px;
  277. }
  278. .item .integralBox{
  279. position: absolute;
  280. top: 7.3%;
  281. right: 8%;
  282. width: 90px;
  283. height: 35.2px;
  284. /* background: greenyellow; */
  285. display: flex;
  286. justify-content: center;
  287. line-height: 35.2px;
  288. }
  289. .integralBox .integral{
  290. font-size: 16px;
  291. color: orange;
  292. font-weight: 600;
  293. }
  294. .item .timer{
  295. position: absolute;
  296. background: url(@/assets/image/answerGame/item/timer.png) no-repeat;
  297. background-size: 100% 100%;
  298. width: 80px;
  299. height: 80px;
  300. top: 15%;
  301. right: 10%;
  302. display: flex;
  303. justify-content: center;
  304. align-items: center;
  305. }
  306. .timer .second{
  307. font-size: 16px;
  308. color: #fff;
  309. font-weight: 600;
  310. }
  311. .item .topicNum{
  312. position: absolute;
  313. background: url(@/assets/image/answerGame/item/topicNum.png) no-repeat;
  314. background-size: 100% 100%;
  315. width: 120px;
  316. height: 42px;
  317. top: 25%;
  318. left: 4.8%;
  319. display: flex;
  320. justify-content: center;
  321. align-items: center;
  322. }
  323. .topicNum .topic{
  324. font-size: 16px;
  325. color: #fff;
  326. font-weight: 600;
  327. }
  328. .item .questionBox{
  329. position: absolute;
  330. width: 450px;
  331. top: 35%;
  332. left: 0;
  333. right: 0;
  334. display: flex;
  335. flex-direction: column;
  336. justify-content: center;
  337. align-items: center;
  338. }
  339. .questionBox .title{
  340. margin:auto 50px;
  341. height: 180px;
  342. font-size: 18px;
  343. display: flex;
  344. flex-direction: column;
  345. justify-content: center;
  346. align-items: center;
  347. /* font-weight: 600; */
  348. }
  349. .content{
  350. width: 100%;
  351. display: flex;
  352. flex-direction: column;
  353. justify-content: center;
  354. align-items: center;
  355. }
  356. .answerItem{
  357. cursor: pointer;
  358. margin: 10px 0;
  359. color: #3883fa;
  360. background: rgb(221, 218, 218);
  361. border-radius: 20px;
  362. width: 80%;
  363. height: 40px;
  364. line-height: 40px;
  365. display: flex;
  366. justify-content: center;
  367. align-items: center;
  368. position: relative;
  369. }
  370. .right {
  371. /*选择正确的答案颜色*/
  372. background: #3ede58;
  373. color: #fff;
  374. }
  375. .error {
  376. /*选择错误的答案颜色*/
  377. background: #e53117;
  378. color: #fff;
  379. }
  380. .invisible{
  381. width: 25px;
  382. position: absolute;
  383. right: 15px;
  384. }
  385. .gameBox .home{
  386. position: relative;
  387. z-index: 10;
  388. background: url(@/assets/image/answerGame/home/homeBg.png) no-repeat;
  389. background-size: 100% 100%;
  390. width: 450px;
  391. height: 800px;
  392. }
  393. .home .rules{
  394. cursor: pointer;
  395. position: absolute;
  396. width: 50px;
  397. top: 32%;
  398. left: 5%;
  399. }
  400. .home .answer{
  401. cursor: pointer;
  402. position: absolute;
  403. width: 200px;
  404. bottom: 15%;
  405. left: 0;
  406. right: 0;
  407. margin:auto;
  408. }
  409. .home .exit{
  410. cursor: pointer;
  411. position: absolute;
  412. width: 200px;
  413. bottom: 8%;
  414. left: 0;
  415. right: 0;
  416. margin:auto;
  417. }
  418. .hidden {
  419. display: none;
  420. }
  421. .show {
  422. display: block;
  423. }
  424. .dim {
  425. opacity:0.6;
  426. /* filter: black(5px); */
  427. pointer-events: none;
  428. }
  429. .clearfix:before,
  430. .clearfix:after {
  431. display: table;
  432. content: "";
  433. }
  434. .clearfix:after {
  435. clear: both
  436. }
  437. .ruleWrapper{
  438. position: absolute;
  439. top: 50%;
  440. left: 50%;
  441. transform: translate(-50%, -50%);
  442. z-index: 12;
  443. }
  444. .box-card {
  445. width: 350px;
  446. }
  447. .confirmWrapper{
  448. position: absolute;
  449. background: url(@/assets/image/answerGame/item/finish.png) no-repeat;
  450. background-size: 100% 100%;
  451. width: 254px;
  452. height: 260px;
  453. top: 50%;
  454. left: 50%;
  455. transform: translate(-50%, -50%);
  456. z-index: 12;
  457. display: flex;
  458. justify-content: center;
  459. align-items: end;
  460. }
  461. .confirmWrapper .goHome{
  462. cursor: pointer;
  463. width: 112px;
  464. height: 55px;
  465. }
  466. .failWrapper{
  467. position: absolute;
  468. background: url(@/assets/image/answerGame/item/fail.png) no-repeat;
  469. background-size: 100% 100%;
  470. width: 240px;
  471. height: 208.5px;
  472. top: 50%;
  473. left: 50%;
  474. transform: translate(-50%, -50%);
  475. z-index: 12;
  476. display: flex;
  477. justify-content: center;
  478. align-items: end;
  479. }
  480. .failWrapper .goHome{
  481. cursor: pointer;
  482. width: 112px;
  483. height: 55px;
  484. }
  485. </style>
  486. <style>
  487. .el-card__header {
  488. padding: 10px 20px !important;
  489. }
  490. </style>