edu/app/src/pages/index/index.vue

58 lines
1.5 KiB
Vue
Raw Normal View History

2022-08-26 09:52:43 +00:00
<template>
2022-09-07 13:00:03 +00:00
<view class="index">
2022-09-08 08:28:56 +00:00
<view v-for="(item, index) in state.pages" :key="index">
<template v-if="item.name == 'search'">
<w-search :content="item.content" :styles="item.styles" />
</template>
<template v-if="item.name == 'banner'">
<w-banner :content="item.content" :styles="item.styles" />
</template>
<template v-if="item.name == 'nav'">
<w-nav :content="item.content" :styles="item.styles" />
</template>
</view>
2022-09-09 03:06:58 +00:00
<view class="article" v-if="state.article.length">
<view
class="flex items-center article-title mx-[20rpx] my-[30rpx] text-2xl font-medium"
>
最新资讯
</view>
<news-card
v-for="item in state.article"
:key="item.id"
:news-id="item.id"
:item="item"
/>
</view>
2022-08-26 09:52:43 +00:00
</view>
</template>
2022-09-07 13:00:03 +00:00
<script setup lang="ts">
import { getIndex } from '@/api/shop'
2022-09-08 08:28:56 +00:00
import { reactive, ref } from 'vue'
const state = reactive<{
pages: any[]
2022-09-09 03:06:58 +00:00
article: any[]
2022-09-08 08:28:56 +00:00
}>({
2022-09-09 03:06:58 +00:00
pages: [],
article: []
2022-09-07 13:00:03 +00:00
})
const getData = async () => {
const data = await getIndex()
state.pages = JSON.parse(data.pages)
2022-09-09 03:06:58 +00:00
state.article = data.article
2022-09-07 13:00:03 +00:00
}
getData()
</script>
2022-08-26 09:52:43 +00:00
2022-09-09 03:06:58 +00:00
<style lang="scss">
.article-title {
&::before {
width: 8rpx;
height: 34rpx;
display: block;
background: $u-type-primary;
}
}
</style>