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

209 lines
4.4 KiB

3 years ago
<!--
* @Author: ch
* @Date: 2019-08-22 19:41:20
* @LastEditors: ch
* @LastEditTime: 2022-04-09 17:02:23
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 :data="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 :data="recommendedGoodsList"></Pick>
3 years ago
<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';
import {ApiGetCategoryNav, ApiGetRecommendedGoodsList} 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
],
recommendedGoodsList : []
3 years ago
}
},
onLoad(){
3 years ago
this.getCategoryList();
this.getRecommendedGoodsList();
},
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 : {
3 years ago
async getCategoryList(){
const {error, result} = await ApiGetCategoryNav();
if(result){
this.categoryList = result;
}
},
async getRecommendedGoodsList(){
console.log('-right');
const {error, result} = await ApiGetRecommendedGoodsList({
pageIndex : 1,
length : 3
});
if(result){
this.recommendedGoodsList = result.records
}
}
3 years ago
}
}
</script>
<style lang="scss" scoped>
3 years ago
page{
padding-bottom: 120rpx;
background: $color-grey1;
3 years ago
}
.header{
position: sticky;
top: var(--window-top);
z-index:999;
height: 88rpx;
display: flex;
align-items: center;
justify-content: space-between;
background: $color-blue5;
3 years ago
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: $color-blue5;
3 years ago
&__min{
width: 548rpx;
}
&--input{
display: flex;
height: 70rpx;
align-items: center;
justify-content: space-between;
background: rgba(255, 255, 255, .3);
color: $color-grey0;
3 years ago
border-radius: 8rpx;
padding: 0 30rpx;
font-size: $font-size-sm;
3 years ago
&::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: $font-size-sm;
color: $color-grey5;
3 years ago
text-align: center;
display: block;
}
}
.title{
font-size: 36rpx;
margin: 60rpx 30rpx 30rpx;
}
</style>