feat:首页接口联调

master
ewall 5 years ago
parent fac7a1f358
commit 4b45eb3d27

@ -0,0 +1,8 @@
import request from '@/utils/request'
export function getBanner() {
return request({
url: '/home/banner',
method: 'get'
})
}

@ -1,7 +1,7 @@
<template> <template>
<div class="back-top" v-show="isShow"> <div class="back-top" v-show="isShow">
<span v-scroll-to="'body'"> <span v-scroll-to="'body'">
<svg-icon icon-class="backtop" :width="30" :height="30"/> <svg-icon icon-class="backtop" :width="28" :height="28"/>
</span> </span>
</div> </div>
</template> </template>

@ -2,6 +2,9 @@
<div> <div>
<!-- https://youzan.github.io/vant/#/zh-CN/image#api --> <!-- https://youzan.github.io/vant/#/zh-CN/image#api -->
<van-image v-bind="$attrs" lazy-load> <van-image v-bind="$attrs" lazy-load>
<template v-slot:loading>
<van-loading type="spinner" size="20" />
</template>
<template v-slot:error>加载失败</template> <template v-slot:error>加载失败</template>
</van-image> </van-image>
</div> </div>

@ -15,7 +15,8 @@ import {
Image, Image,
Lazyload, Lazyload,
Swipe, Swipe,
SwipeItem SwipeItem,
Loading
} from 'vant' } from 'vant'
Vue.use(Toast) Vue.use(Toast)
@ -32,3 +33,4 @@ Vue.use(Toast)
.use(Lazyload) .use(Lazyload)
.use(Swipe) .use(Swipe)
.use(SwipeItem) .use(SwipeItem)
.use(Loading)

@ -1,18 +1,18 @@
<template> <template>
<div class="home"> <div class="home">
<Header /> <Header />
<Swiper /> <Swiper :banner="banner"/>
<back-top />
<Category :cateList="cateList" /> <Category :cateList="cateList" />
<Goods /> <Goods />
<back-top />
</div> </div>
</template> </template>
<script> <script>
import { getBanner } from '@/api/home'
import Header from './modules/Header' import Header from './modules/Header'
import Swiper from './modules/Swiper' import Swiper from './modules/Swiper'
import Category from './modules/Category' import Category from './modules/Category'
import Goods from './modules/Goods' import Goods from './modules/Goods'
import BackTop from '@/components/BackTop' import BackTop from '@/components/BackTop'
@ -27,14 +27,12 @@ export default {
}, },
data() { data() {
return { return {
val: '11111', banner: [],
value: 0,
switch1: false,
switch2: false,
cateList: {} cateList: {}
} }
}, },
mounted() { mounted() {
this.getBanner()
const data = [ const data = [
{ {
categoryName: '食品', categoryName: '食品',
@ -150,6 +148,11 @@ export default {
} }
}, },
methods: { methods: {
getBanner() {
getBanner().then(res => {
this.banner = res.entry
})
},
onConfirm() { onConfirm() {
this.$refs.item.toggle() this.$refs.item.toggle()
} }

@ -1,8 +1,8 @@
<template> <template>
<div> <div>
<van-swipe :autoplay="3000" indicator-color="white"> <van-swipe :autoplay="3000" indicator-color="white">
<van-swipe-item v-for="(image, index) in images" :key="index"> <van-swipe-item v-for="(image, index) in banner" :key="index">
<img v-lazy="image" width="100%" height="150" /> <image-pic width="100%" height="150px" :src="image" />
</van-swipe-item> </van-swipe-item>
</van-swipe> </van-swipe>
</div> </div>
@ -10,17 +10,6 @@
<script> <script>
export default { export default {
data() { props: ['banner']
return {
images: [
'https://m.360buyimg.com/babel/s750x300_jfs/t1/91722/36/15702/155940/5e743902E12329b15/bf74028004890c45.jpg',
'https://m.360buyimg.com/babel/s750x300_jfs/t1/101273/30/14675/149408/5e698fd3E34e671d0/20f810d02067d342.jpg',
'https://m.360buyimg.com/babel/s750x300_jfs/t1/104517/14/15980/188439/5e7311fcE32a88066/4461e1fb99fc7cf6.jpg'
]
}
}
} }
</script> </script>
<style>
</style>

Loading…
Cancel
Save