You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shop-app/pages/index/index.vue

198 lines
4.2 KiB

3 years ago
<!--
* @Author: ch
* @Date: 2019-08-22 19:41:20
* @LastEditors: ch
3 years ago
* @LastEditTime: 2022-04-07 16:47:31
3 years ago
* @Description: file content
-->
<template>
<view>
<view class="header">
<view class="logo" :class="{'logo__min' : scrollTop > 35 }"></view>
3 years ago
<view class="search search__min" v-if="scrollTop > 35" @click="$Router.push('/search')">
3 years ago
<text class="search--input">请输入您想搜索的商品名称</text>
</view>
<view class="msg">
<image class="msg--icon" src="@/static/index/msg.png"></image>
</view>
</view>
3 years ago
<view class="search" @click="$Router.push('/search')">
3 years ago
<text class="search--input">请输入您想搜索的商品名称</text>
</view>
<Banner :bannerList="bannerList"></Banner>
3 years ago
<view class="category">
3 years ago
<view class="category--item" v-for="item in categoryList" :key="item.id"
@click="$Router.push(`/goodsList?categoryId=${item.id}`)">
3 years ago
<view class="category--image-box">
3 years ago
<image class="category--image" :src="item.picture"></image>
3 years ago
</view>
3 years ago
<text class="category--title">{{item.name}}</text>
3 years ago
</view>
</view>
<Sekill></Sekill>
<view class="title">甄选推荐</view>
<Pick></Pick>
<view class="title">为您推荐</view>
3 years ago
<BsChoiceGoods ref="goodsGroup" ></BsChoiceGoods>
3 years ago
</view>
</template>
<script>
3 years ago
import BsChoiceGoods from '@/components/BsChoiceGoods';
3 years ago
import Sekill from './components/Sekill';
import Pick from './components/Pick';
import Banner from './components/Banner';
import {ApiGetBannerData} from '@/common/api/index.js';
3 years ago
import {ApiGetCategoryNav} from '@/common/api/goods.js';
3 years ago
export default {
3 years ago
components : {BsChoiceGoods, Pick, Banner, Sekill},
3 years ago
data(){
return {
scrollTop : 0,
3 years ago
bannerList: [
'https://cdn.uviewui.com/uview/swiper/swiper1.png',
'https://cdn.uviewui.com/uview/swiper/swiper2.png',
'https://cdn.uviewui.com/uview/swiper/swiper3.png',
],
categoryList : [
{ url : 'bz2.png', title : '数码周边'},
{ url : 'bz1.png', title : '数码周边'},
{ url : 'bz3.png', title : '数码周边'},
{ url : 'bz4.png', title : '数码周边'},
{ url : 'bz5.png', title : '数码周边'},
{ url : 'bz6.png', title : '数码周边'},
3 years ago
],
goodsData:[]
3 years ago
}
},
onLoad(){
3 years ago
this.getCategoryList();
},
3 years ago
onReachBottom(){
this.$refs.goodsGroup.next()
},
onShow(){
uni.pageScrollTo({
scrollTop: 0,
duration : 0
});
this.scrollTop = 0;
},
3 years ago
onPageScroll({scrollTop}){
if(this.scrollTop > 36 && scrollTop > 36){
return
}
3 years ago
this.scrollTop = scrollTop;
},
methods : {
async getBannerList(){
3 years ago
// const {error, result} = await ApiGetBannerData({pageIndex:1, length:999});
// console.log(result)
// this.bannerList = result.concat(result).map(i => i.imgUrl);
3 years ago
},
async getCategoryList(){
const {error, result} = await ApiGetCategoryNav();
this.categoryList = result;
}
3 years ago
}
}
</script>
<style lang="scss">
page{
background: #f8f8f8;
padding-bottom: 120rpx;
}
.header{
position: sticky;
top: var(--window-top);
z-index:999;
height: 88rpx;
display: flex;
align-items: center;
justify-content: space-between;
background: #69ADE5;
padding: 0 30rpx;
}
.logo{
width: 265rpx;
height: 50rpx;
background: url("@/static/index/logo.png");
background-size: 265rpx;
&__min{
width: 50rpx;
}
}
.msg{
&--icon{
width: 32rpx;
height: 38rpx;
}
}
.search{
padding: 0 30rpx;
background: #69ADE5;
&__min{
width: 548rpx;
}
&--input{
display: flex;
height: 70rpx;
align-items: center;
justify-content: space-between;
background: rgba(255, 255, 255, .3);
color: #fff;
border-radius: 8rpx;
padding: 0 30rpx;
font-size: 24rpx;
&::after{
display: block;
content: "";
width: 34rpx;
height: 36rpx;
background: url("@/static/index/search.png");
background-size: 100%;
}
}
&--icon{
width: 34rpx;
height: 36rpx;
}
}
.category{
display: flex;
padding: 0 20rpx;
flex-wrap: wrap;
&--item{
padding: 0 10rpx;
margin-bottom: 40rpx;
}
&--image-box{
width: 120rpx;
height: 120rpx;
}
&--image{
width: 120rpx;
height: 120rpx;
}
&--title{
font-size: 24rpx;
color: #666;
text-align: center;
display: block;
}
}
.title{
font-size: 36rpx;
margin: 60rpx 30rpx 30rpx;
}
</style>