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

217 lines
4.6 KiB

3 years ago
<!--
* @Author: ch
* @Date: 2019-08-22 19:41:20
* @LastEditors: ch
3 years ago
* @LastEditTime: 2022-04-21 22:01:41
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">
3 years ago
<u-badge class="msg--badge" max="99" :value="0"></u-badge>
3 years ago
<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>
3 years ago
<Seckill :data="seckillData" v-if="seckillData.activityTimeVO"></Seckill>
3 years ago
<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 Seckill from './components/Seckill';
3 years ago
import Pick from './components/Pick';
import Banner from './components/Banner';
import {ApiGetBannerData} from '@/common/api/index.js';
3 years ago
import {ApiGetHomeSeckill} from '@/common/api/seckill.js';
import {ApiGetCategoryNav, ApiGetRecommendedGoodsList} from '@/common/api/goods.js';
3 years ago
export default {
3 years ago
components : {BsChoiceGoods, Pick, Banner, Seckill},
3 years ago
data(){
return {
scrollTop : 0,
3 years ago
bannerList: [
3 years ago
'https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/banner.png',
'https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/banner.png'
3 years ago
],
categoryList : [
3 years ago
],
3 years ago
recommendedGoodsList : [],
seckillData : {activityTimeVO:{}}
3 years ago
}
},
onLoad(){
3 years ago
this.getCategoryList();
this.getRecommendedGoodsList();
3 years ago
this.getSeckillList();
},
3 years ago
onReachBottom(){
3 years ago
this.$refs.goodsGroup.next();
3 years ago
},
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(){
3 years ago
const {error, result} = await ApiGetRecommendedGoodsList();
if(result){
3 years ago
this.recommendedGoodsList = result
}
3 years ago
},
async getSeckillList(){
const {error, result} = await ApiGetHomeSeckill();
if(result){
this.seckillData = result
}
}
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;
3 years ago
background: url("@/static/index/logo.png") no-repeat;
background-size: 244rpx;
3 years ago
&__min{
width: 50rpx;
}
}
.msg{
3 years ago
padding-right: 10rpx;
position: relative;
&--badge{
position: absolute;
right: 0;
top: -14rpx;
z-index: 999;
border:1px solid $color-grey0
}
3 years ago
&--icon{
3 years ago
width: 33rpx;
height: 42rpx;
3 years ago
}
}
.search{
3 years ago
padding: 5rpx 30rpx 0;
background: $color-blue5;
3 years ago
&__min{
width: 548rpx;
3 years ago
padding: 0;
3 years ago
}
&--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;
3 years ago
font-size: $font-size-base;
3 years ago
&::after{
display: block;
content: "";
width: 34rpx;
height: 42rpx;
background: url("@/static/index/search.png") 0 6rpx no-repeat;
3 years ago
background-size: 100%;
}
}
}
.category{
display: flex;
3 years ago
padding: 0 35rpx;
3 years ago
flex-wrap: wrap;
3 years ago
justify-content: space-between;
3 years ago
&--item{
3 years ago
width: 130rpx;
3 years ago
margin-bottom: 40rpx;
}
&--image-box{
width: 120rpx;
height: 120rpx;
3 years ago
margin: 0 auto;
3 years ago
}
&--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;
3 years ago
font-weight: bold;
3 years ago
margin: 60rpx 30rpx 30rpx;
}
</style>