| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <template>
- <main>
- <header>
- <!-- <p>试一试这样问我:</p>
- <a-button size="small" type="outline" shape="round" @click="changeCards"
- ><template #icon> <icon-swap /> </template>换一换</a-button
- > -->
- </header>
- <section>
- <!-- <div
- v-for="(item, key) in listData"
- :key="key"
- :class="{ rotate: isRotate, 'no-rotate': isOver }"
- @click="selectCard(item.sug)"
- >
- <div>
- <img :src="item.img" />
- <p>{{ item.title }}</p>
- </div>
- <p>{{ item.content }}</p>
- </div> -->
- </section>
- </main>
- </template>
- <script>
- import { defineComponent, inject, ref } from "vue";
- export default defineComponent({
- props: ["data"],
- setup(props) {
- const { helper } = inject("$global");
- const isTest = ref(true);
- const isRotate = ref(false);
- const isOver = ref(false);
- const selectCard = (data) => {
- helper.$bus.emit("set-input", data);
- };
- const listData = ref(props.data);
- const changeCards = () => {
- isRotate.value = true;
- setTimeout(() => {
- listData.value = helper.shuffleArray(listData.value);
- isTest.value = !isTest.value;
- isOver.value = true;
- isRotate.value = false;
- }, 500);
- setTimeout(() => {
- isOver.value = false;
- }, 550);
- };
- return { listData, changeCards, isRotate, isOver, selectCard };
- }
- });
- </script>
- <style lang="scss" scoped>
- main {
- height: 100%;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- > header {
- display: flex;
- justify-content: space-between;
- margin-bottom: 18px;
- > p {
- color: #7f7f7f;
- }
- }
- > section {
- overflow-y: auto;
- display: flex;
- flex-wrap: wrap;
- gap: 12px;
- > div {
- width: calc(33.33333% - 13.33333px);
- height: 128px;
- background: #f6fbfd;
- border-radius: 12px;
- cursor: pointer;
- transition: all 0.5s linear;
- &.no-rotate {
- transform-style: flat;
- transition-duration: 0.5s;
- opacity: 1;
- }
- &.rotate {
- transform-style: preserve-3d;
- transform: rotateY(180deg);
- opacity: 0;
- }
- &:hover {
- background: #e9f7f8;
- }
- > div {
- display: flex;
- align-items: center;
- margin: 24px 20px 12px;
- > img {
- width: 28px;
- height: 28px;
- margin-right: 12px;
- }
- > p {
- font-size: 18px;
- font-weight: 600;
- color: #000;
- }
- }
- > p {
- font-size: 15px;
- font-family: MiSans;
- font-weight: 400;
- color: #7a7d7e;
- margin: 0 20px;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- line-height: 1.4;
- }
- }
- }
- }
- </style>
|