敢为人鲜小程序前端代码仓库
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.
 
 
 

140 lines
2.7 KiB

<template>
<view class="page">
<!-- 导航栏 -->
<navbar title="商品列表"
leftClick
@leftClick="$utils.navigateBack"
bgColor="#E3441A"
color="#fff" />
<!-- 搜索栏 -->
<view class="search">
<uv-search placeholder="搜你喜欢的产品" bgColor="#fff" @search="getData" @custom="getData"
v-model="queryParams.title"></uv-search>
</view>
<!-- 分类商品列表 -->
<view class="category">
<uv-vtabs :list="category"
:current="current"
keyName="title" @change="change">
<view class="list">
<uv-vtabs-item>
<productItem v-for="(item, index) in list" :key="index" :item="item"
@click="$utils.navigateTo(`/pages_order/product/productDetail?id=${item.id}`)" />
<uv-empty mode="list" v-if="list.length == 0"></uv-empty>
</uv-vtabs-item>
</view>
</uv-vtabs>
</view>
<!-- tabbar -->
<tabber select="category" />
</view>
</template>
<script>
import productItem from '@/components/product/productItem.vue';
import mixinsList from '@/mixins/list.js'
import {
mapState
} from 'vuex'
import tabber from '@/components/base/tabbar.vue'
export default {
mixins: [mixinsList],
components: {
productItem,
tabber,
},
data() {
return {
mixinsListApi: 'getClassShopPageList',
current : 0,
}
},
computed: {
...mapState(['category'])
},
onLoad({
search,
cid
}) {
if (search) {
this.queryParams.title = search
}
this.$store.commit('getCategoryList')
if(this.category.length > 0 && cid){
this.category.forEach((n, i) => {
if(n.id == cid){
this.current = i
}
})
this.queryParams.classId = cid
}else if (this.category.length > 0) {
this.queryParams.classId = this.category[0].id
}
},
methods: {
change(e) {
this.queryParams.classId = this.category[e].id
this.getData()
},
}
}
</script>
<style scoped lang="scss">
.page {
/deep/ .uv-vtabs {
height: calc(100vh - 470rpx) !important;
}
/deep/ .uv-vtabs__bar {
height: calc(100vh - 470rpx) !important;
}
/deep/ .uv-vtabs__content {
height: calc(100vh - 470rpx) !important;
}
.search {
position: relative;
background: #FFFFFF;
margin: 20rpx;
border-radius: 41rpx;
padding: 10rpx 20rpx;
display: flex;
align-items: center;
/deep/ .uv-search__action {
background-color: $uni-color;
color: #FFFFFF;
padding: 10rpx 20rpx;
border-radius: 30rpx;
}
}
&::v-deep .uv-vtabs__content {
background: transparent !important;
overflow: hidden;
}
}
.category {
font-size: 30rpx;
color: #333;
&::v-deep .uv-vtabs {
width: 750rpx;
overflow: hidden;
}
.list {
width: 100%;
padding: 0rpx 20rpx;
box-sizing: border-box;
}
}
</style>