首页页面跳转

This commit is contained in:
Jason 2022-09-09 11:06:58 +08:00
parent 5b1da086ba
commit cda8b3e3b3
2 changed files with 34 additions and 7 deletions

View File

@ -1,7 +1,11 @@
<template> <template>
<view class="search px-[24rpx] py-[14rpx] bg-white"> <navigator
<u-search placeholder="请输入关键子" disabled :show-action="false"></u-search> url="/pages/search/search"
</view> class="search px-[24rpx] py-[14rpx] bg-white"
hover-class="none"
>
<u-search placeholder="请输入关键词搜索" disabled :show-action="false"></u-search>
</navigator>
</template> </template>
<script setup lang="ts"></script> <script setup lang="ts"></script>

View File

@ -11,7 +11,19 @@
<w-nav :content="item.content" :styles="item.styles" /> <w-nav :content="item.content" :styles="item.styles" />
</template> </template>
</view> </view>
<view class="article"> </view> <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>
</view> </view>
</template> </template>
@ -20,15 +32,26 @@ import { getIndex } from '@/api/shop'
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'
const state = reactive<{ const state = reactive<{
pages: any[] pages: any[]
article: any[]
}>({ }>({
pages: [] pages: [],
article: []
}) })
const getData = async () => { const getData = async () => {
const data = await getIndex() const data = await getIndex()
state.pages = JSON.parse(data.pages) state.pages = JSON.parse(data.pages)
console.log(state.pages) state.article = data.article
} }
getData() getData()
</script> </script>
<style></style> <style lang="scss">
.article-title {
&::before {
width: 8rpx;
height: 34rpx;
display: block;
background: $u-type-primary;
}
}
</style>