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

237 lines
5.1 KiB

<!--
* @Author: ch
* @Date: 2019-08-22 19:41:20
* @LastEditors: ch
* @LastEditTime: 2022-05-06 15:29:41
* @Description: file content
-->
<template>
<view>
<view class="header">
<view class="logo" :class="{'logo__min' : scrollTop > 35 }"></view>
<view class="search search__min" v-if="scrollTop > 35" @click="$Router.push('/search')">
<text class="search--input">请输入您想搜索的商品名称</text>
</view>
<view class="msg" @click="$Router.push('/messageGroup')">
<u-badge class="msg--badge" max="99" :value="$store.state.imMsgCount"></u-badge>
<image class="msg--icon" src="@/static/index/msg.png"></image>
</view>
</view>
<view class="search" @click="$Router.push('/search')">
<text class="search--input">请输入您想搜索的商品名称</text>
</view>
<Banner :data="bannerList"></Banner>
<view class="category">
<view class="category--item" v-for="item in categoryList" :key="item.id"
@click="$Router.push(`/goodsList?categoryId=${item.id}`)">
<view class="category--image-box">
<image class="category--image" :src="item.picture"></image>
</view>
<text class="category--title">{{item.name}}</text>
</view>
</view>
<Seckill :data="seckillData" v-if="seckillData.activityTimeVO"></Seckill>
<view class="title">甄选推荐</view>
<Pick :data="recommendedGoodsList"></Pick>
<view class="title">为您精选</view>
<BsChoiceGoods ref="goodsGroup" ></BsChoiceGoods>
</view>
</template>
<script>
import BsChoiceGoods from '@/components/BsChoiceGoods';
import Seckill from './components/Seckill';
import Pick from './components/Pick';
import Banner from './components/Banner';
import {ApiGetBannerData} from '@/common/api/index.js';
import {ApiGetHomeSeckill} from '@/common/api/seckill.js';
import {ApiGetCategoryNav, ApiGetRecommendedGoodsList} from '@/common/api/goods.js';
export default {
components : {BsChoiceGoods, Pick, Banner, Seckill},
data(){
return {
scrollTop : 0,
bannerList: [
{ url : 'https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/banner4.jpg',
id : 13
},
{ url : 'https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/1.png',
id : 30
},
{ url : 'https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/2banner.png',
id : 15
},
{ url : 'https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/3banner.png',
id : 40
}
],
categoryList : [
],
recommendedGoodsList : [],
seckillData : {activityTimeVO:{}}
}
},
onLoad(){
this.getCategoryList();
this.getRecommendedGoodsList();
this.getSeckillList();
},
onReachBottom(){
this.$refs.goodsGroup.next();
},
onShow(){
uni.pageScrollTo({
scrollTop: 0,
duration : 0
});
this.scrollTop = 0;
},
onPageScroll({scrollTop}){
if(this.scrollTop > 36 && scrollTop > 36){
return
}
this.scrollTop = scrollTop;
},
methods : {
async getCategoryList(){
const {error, result} = await ApiGetCategoryNav();
if(result){
this.categoryList = result;
}
},
async getRecommendedGoodsList(){
const {error, result} = await ApiGetRecommendedGoodsList();
if(result){
this.recommendedGoodsList = result;
}
},
async getSeckillList(){
const {error, result} = await ApiGetHomeSeckill();
if(result){
this.seckillData = result
}
}
}
}
</script>
<style lang="scss">
page {
padding-bottom: 120rpx;
background: $color-grey1;
}
</style>
<style lang="scss" scoped>
.header{
position: sticky;
top: var(--window-top);
z-index:999;
/* #ifdef H5 */
height: 88rpx;
padding: 0 30rpx;
/* #endif */
/* #ifndef H5 */
height: 176rpx;
padding: 88rpx 30rpx 0;
/* #endif */
display: flex;
align-items: center;
justify-content: space-between;
background: #F3574D;
}
.logo{
width: 265rpx;
height: 50rpx;
background: url("@/static/index/logo.png") no-repeat;
background-size: 244rpx;
&__min{
width: 50rpx;
}
}
.msg{
padding-right: 10rpx;
position: relative;
&--badge{
position: absolute;
right: 0;
top: -14rpx;
z-index: 999;
border:1px solid $color-grey0
}
&--icon{
width: 33rpx;
height: 42rpx;
}
}
.search{
padding: 5rpx 30rpx 0;
background: #F3574D;
&__min{
width: 548rpx;
padding: 0;
}
&--input{
display: flex;
height: 70rpx;
align-items: center;
justify-content: space-between;
background: rgba(255, 255, 255, .3);
color: $color-grey0;
border-radius: 8rpx;
padding: 0 30rpx;
font-size: $font-size-base;
&::after{
display: block;
content: "";
width: 34rpx;
height: 42rpx;
background: url("@/static/index/search.png") 0 6rpx no-repeat;
background-size: 100%;
}
}
}
.category{
display: flex;
padding: 0 35rpx;
flex-wrap: wrap;
justify-content: space-between;
&--item{
width: 130rpx;
margin-bottom: 40rpx;
}
&--image-box{
width: 120rpx;
height: 120rpx;
margin: 0 auto;
}
&--image{
width: 120rpx;
height: 120rpx;
}
&--title{
font-size: $font-size-sm;
color: $color-grey5;
text-align: center;
display: block;
}
}
.title{
font-size: 36rpx;
font-weight: bold;
margin: 60rpx 30rpx 30rpx;
}
</style>