NormalCards.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <main>
  3. <header>
  4. <!-- <p>试一试这样问我:</p>
  5. <a-button size="small" type="outline" shape="round" @click="changeCards"
  6. ><template #icon> <icon-swap /> </template>换一换</a-button
  7. > -->
  8. </header>
  9. <section>
  10. <!-- <div
  11. v-for="(item, key) in listData"
  12. :key="key"
  13. :class="{ rotate: isRotate, 'no-rotate': isOver }"
  14. @click="selectCard(item.sug)"
  15. >
  16. <div>
  17. <img :src="item.img" />
  18. <p>{{ item.title }}</p>
  19. </div>
  20. <p>{{ item.content }}</p>
  21. </div> -->
  22. </section>
  23. </main>
  24. </template>
  25. <script>
  26. import { defineComponent, inject, ref } from "vue";
  27. export default defineComponent({
  28. props: ["data"],
  29. setup(props) {
  30. const { helper } = inject("$global");
  31. const isTest = ref(true);
  32. const isRotate = ref(false);
  33. const isOver = ref(false);
  34. const selectCard = (data) => {
  35. helper.$bus.emit("set-input", data);
  36. };
  37. const listData = ref(props.data);
  38. const changeCards = () => {
  39. isRotate.value = true;
  40. setTimeout(() => {
  41. listData.value = helper.shuffleArray(listData.value);
  42. isTest.value = !isTest.value;
  43. isOver.value = true;
  44. isRotate.value = false;
  45. }, 500);
  46. setTimeout(() => {
  47. isOver.value = false;
  48. }, 550);
  49. };
  50. return { listData, changeCards, isRotate, isOver, selectCard };
  51. }
  52. });
  53. </script>
  54. <style lang="scss" scoped>
  55. main {
  56. height: 100%;
  57. display: flex;
  58. flex-direction: column;
  59. overflow: hidden;
  60. > header {
  61. display: flex;
  62. justify-content: space-between;
  63. margin-bottom: 18px;
  64. > p {
  65. color: #7f7f7f;
  66. }
  67. }
  68. > section {
  69. overflow-y: auto;
  70. display: flex;
  71. flex-wrap: wrap;
  72. gap: 12px;
  73. > div {
  74. width: calc(33.33333% - 13.33333px);
  75. height: 128px;
  76. background: #f6fbfd;
  77. border-radius: 12px;
  78. cursor: pointer;
  79. transition: all 0.5s linear;
  80. &.no-rotate {
  81. transform-style: flat;
  82. transition-duration: 0.5s;
  83. opacity: 1;
  84. }
  85. &.rotate {
  86. transform-style: preserve-3d;
  87. transform: rotateY(180deg);
  88. opacity: 0;
  89. }
  90. &:hover {
  91. background: #e9f7f8;
  92. }
  93. > div {
  94. display: flex;
  95. align-items: center;
  96. margin: 24px 20px 12px;
  97. > img {
  98. width: 28px;
  99. height: 28px;
  100. margin-right: 12px;
  101. }
  102. > p {
  103. font-size: 18px;
  104. font-weight: 600;
  105. color: #000;
  106. }
  107. }
  108. > p {
  109. font-size: 15px;
  110. font-family: MiSans;
  111. font-weight: 400;
  112. color: #7a7d7e;
  113. margin: 0 20px;
  114. overflow: hidden;
  115. text-overflow: ellipsis;
  116. display: -webkit-box;
  117. -webkit-line-clamp: 2;
  118. -webkit-box-orient: vertical;
  119. line-height: 1.4;
  120. }
  121. }
  122. }
  123. }
  124. </style>