<template>
|
<view class="mall">
|
<view class="mall-zz" v-show="show"></view>
|
<view class="head" :style="{ height: 'calc(' + (navHeight + statusbarHeight + 'px + 188rpx)') }">
|
<view class="head-box">
|
<view :style="{ width: '100%', height: statusbarHeight + 'px' }"></view>
|
<view class="head-search":style="{ height: navHeight + 'px' }">
|
<text>商城</text>
|
<view class="head-search-input">
|
<u-search placeholder="搜索商品" height="30" searchIconColor="#999999" borderColor="#eeeeee"
|
bgColor="rgba(255,255,255,0.9)" :showAction="false" v-model="keyword" />
|
</view>
|
</view>
|
<view class="head-tabs">
|
<u-tabs lineColor="#E4001D" :list="list"></u-tabs>
|
</view>
|
</view>
|
|
<view class="head-list">
|
<view class="head-list-item" @click="openSearch(1)">
|
<text style="color: #222222; font-weight: 500;">综合排序</text>
|
<u-icon name="arrow-down" color="#222222" size="13"></u-icon>
|
</view>
|
<view class="head-list-item" @click="openSearch(2)">
|
<text>适用品牌</text>
|
<u-icon name="arrow-down" color="#777777" size="13"></u-icon>
|
</view>
|
<view class="head-list-item" @click="openSearch(3)">
|
<text>系列</text>
|
<u-icon name="arrow-down" color="#777777" size="13"></u-icon>
|
</view>
|
</view>
|
<!-- 排序 -->
|
<view class="list" v-if="show === 1">
|
<view :class="item.active ? 'list-item red' : 'list-item'" v-for="(item, index) in paixu" :key="index" @click="clickpx(index)">
|
<text>{{item.name}}</text>
|
<image src="/static/icon/ic_selete@2x.png" mode="widthFix" v-show="item.active"></image>
|
</view>
|
</view>
|
<!-- 品牌 -->
|
<view class="list" style="padding-top: 30rpx; box-sizing: border-box; justify-content: flex-start;" v-if="show === 2">
|
<view :class="item.active ? 'list-cate active' : 'list-cate'" v-for="(item, index) in pingpai" :key="index" @click="getXiLie(item.id)">{{item.name}}</view>
|
</view>
|
<!-- 系列 -->
|
<view class="list" v-if="show === 3">
|
<view :class="item.active ? 'list-item red' : 'list-item'" v-for="(item, index) in xilie" :key="index" @click="clickpx(index)">
|
<text>{{item.name}}</text>
|
<image src="/static/icon/ic_selete@2x.png" mode="widthFix" v-show="item.active"></image>
|
</view>
|
</view>
|
</view>
|
<view class="commodity">
|
<!-- <view class="commodity-wu">
|
<image src="/static/images/default_search@2x.png" mode="widthFix"></image>
|
</view> -->
|
<view class="commodity-item" v-for="(item, i) in 16" :key="i" @click="jump()">
|
<view class="commodity-item-image">
|
<image src="/static/logo.png" mode="widthFix"></image>
|
</view>
|
<view class="commodity-item-box">
|
<view class="commodity-item-box-title">
|
曲轴减震器皮带轮A12
|
</view>
|
<view class="commodity-item-box-price">
|
<view class="commodity-item-box-price-a">
|
<text>499</text>
|
<text>.00</text>
|
</view>
|
<view class="commodity-item-box-price-b">
|
¥699.00
|
</view>
|
</view>
|
<view class="commodity-item-shou">
|
<text>已售299</text>
|
<view class="commodity-item-shou-add">+</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
<view class="cart">
|
<view class="cart-box">
|
<image src="/static/icon/ic_cart@2x.png" mode="widthFix"></image>
|
<text>购物车</text>
|
<view class="cart-num">12</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
mapState
|
} from 'vuex'
|
export default {
|
computed: {
|
...mapState(['navHeight', 'statusbarHeight'])
|
},
|
data() {
|
return {
|
keyword: '',
|
show: null,
|
list: [],
|
paixu: [
|
{ name: '综合排序', id: 0, active: false },
|
{ name: '销量由低到高', id: 1, active: false },
|
{ name: '价格由低到高', id: 2, active: false },
|
{ name: '销量由高到低', id: 3, active: false },
|
{ name: '价格由高到低', id: 4, active: false },
|
],
|
pingpai: [],
|
xilie: []
|
};
|
},
|
onLoad() {
|
this.getLabels()
|
},
|
methods: {
|
// 获取分类
|
getLabels() {
|
this.$u.api.getGoodsLabelsByType({ type: 0 })
|
.then(res => {
|
if (res.code === 200) {
|
res.data.unshift({ name: '全部', id: '' })
|
this.list = res.data
|
}
|
})
|
this.$u.api.getGoodsLabelsByType({ type: 1 })
|
.then(res => {
|
if (res.code === 200) {
|
res.data.forEach(item => {
|
item.active = false
|
})
|
res.data.unshift({ name: '自营品牌', id: '', active: true })
|
this.pingpai = res.data
|
}
|
})
|
},
|
// 系列
|
getXiLie(parentId) {
|
this.$u.api.getGoodsLabelsByType({ type: 15, parentId })
|
.then(res => {
|
if (res.code === 200) {
|
console.log(res)
|
res.data.forEach(item => {
|
item.active = false
|
})
|
res.data.unshift({ name: '系列', id: '', active: true })
|
this.xilie = res.data
|
}
|
})
|
},
|
openSearch(type) {
|
if (type === this.show) {
|
this.show = null
|
} else {
|
this.show = type
|
}
|
},
|
jump() {
|
uni.navigateTo({
|
url: '/pages/details/details'
|
})
|
},
|
clickpx(i) {
|
this.paixu.forEach((item, index) => {
|
item.active = index === i
|
})
|
}
|
}
|
}
|
</script>
|
|
<style>
|
page {
|
background-color: #F9F9FB;
|
}
|
</style>
|
<style lang="scss" scoped>
|
.mall {
|
width: 100%;
|
.mall-zz {
|
width: 100vw;
|
height: 100vh;
|
background-color: rgba(0,0,0,.5);
|
position: fixed;
|
top: 0;
|
left: 0;
|
z-index: 2;
|
}
|
.cart {
|
position: fixed;
|
right: 30rpx;
|
bottom: 100rpx;
|
z-index: 999;
|
.cart-box {
|
width: 88rpx;
|
height: 88rpx;
|
border-radius: 50%;
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
background: rgba(255,255,255,0.96);
|
box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(0,0,0,0.16);
|
position: relative;
|
image {
|
width: 35rpx;
|
height: 35rpx;
|
}
|
text {
|
font-weight: 400;
|
font-size: 20rpx;
|
color: #333333;
|
}
|
.cart-num {
|
position: absolute;
|
top: -15rpx;
|
right: -15rpx;
|
border-radius: 50%;
|
width: 40rpx;
|
height: 40rpx;
|
line-height: 40rpx;
|
font-weight: 400;
|
font-size: 22rpx;
|
color: #FFFFFF;
|
text-align: center;
|
background: #E4001D;
|
}
|
}
|
}
|
.commodity {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
flex-wrap: wrap;
|
justify-content: space-between;
|
padding: 20rpx 30rpx;
|
box-sizing: border-box;
|
.commodity-wu {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
margin-top: 240rpx;
|
image {
|
width: 320rpx;
|
height: 320rpx;
|
}
|
}
|
.commodity-item {
|
width: 332rpx;
|
background-color: #ffffff;
|
margin-bottom: 20rpx;
|
.commodity-item-image {
|
width: 100%;
|
height: 336rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
image {
|
width: 100%;
|
}
|
}
|
.commodity-item-box {
|
width: 100%;
|
padding: 20rpx;
|
box-sizing: border-box;
|
.commodity-item-box-title {
|
font-weight: 600;
|
font-size: 30rpx;
|
color: #222222;
|
}
|
.commodity-item-box-price {
|
width: 100%;
|
display: flex;
|
align-items: baseline;
|
margin-top: 8rpx;
|
.commodity-item-box-price-a {
|
display: flex;
|
align-items: baseline;
|
margin-right: 8rpx;
|
text {
|
&:nth-child(1) {
|
font-weight: bold;
|
font-size: 32rpx;
|
color: #E4001D;
|
&::before {
|
content: '¥';
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #E4001D;
|
}
|
}
|
&:nth-child(2) {
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #E4001D;
|
}
|
}
|
}
|
.commodity-item-box-price-b {
|
font-weight: 400;
|
font-size: 22rpx;
|
color: #999999;
|
}
|
}
|
.commodity-item-shou {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
text {
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #999999;
|
}
|
.commodity-item-shou-add {
|
width: 44rpx;
|
height: 44rpx;
|
background: #004096;
|
border-radius: 50%;
|
line-height: 44rpx;
|
text-align: center;
|
font-size: 30rpx;
|
color: #fff;
|
}
|
}
|
}
|
}
|
}
|
.head {
|
width: 100%;
|
position: sticky;
|
top: 0;
|
left: 0;
|
z-index: 999;
|
.head-box {
|
width: 100%;
|
background: linear-gradient( 180deg, #FFD7C8 0%, #FFFFFF 100%);
|
.head-search {
|
width: 100%;
|
padding: 0 30rpx;
|
box-sizing: border-box;
|
display: flex;
|
align-items: center;
|
text {
|
font-weight: 500;
|
font-size: 40rpx;
|
color: #111111;
|
margin-right: 40rpx;
|
}
|
.head-search-input {
|
width: 374rpx;
|
}
|
}
|
.head-tabs {
|
width: 100%;
|
height: 100rpx;
|
display: flex;
|
align-items: flex-end;
|
border-bottom: 1rpx solid #E5E5E5;
|
}
|
}
|
.list {
|
width: 100%;
|
padding: 0 30rpx;
|
box-sizing: border-box;
|
background-color: #ffffff;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
flex-wrap: wrap;
|
border-radius: 0rpx 0rpx 24rpx 24rpx;
|
.active {
|
background: rgba(0,64,150,0.1) !important;
|
color: #004096 !important;
|
font-weight: 500 !important;
|
}
|
.list-cate {
|
width: 216rpx;
|
height: 72rpx;
|
line-height: 72rpx;
|
text-align: center;
|
background: #F7F7F7;
|
border-radius: 8rpx;
|
font-weight: 400;
|
font-size: 28rpx;
|
color: #333333;
|
margin-bottom: 24rpx;
|
margin-right: 20rpx;
|
&:last-child {
|
margin-right: 0 !important;
|
}
|
}
|
.red {
|
color: #E4001D !important;
|
}
|
.list-item {
|
width: 100%;
|
height: 96rpx;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
border-bottom: 1rpx solid #EEEEEE;
|
text {
|
font-weight: 400;
|
font-size: 28rpx;
|
color: #222222;
|
}
|
image {
|
width: 24rpx;
|
height: 18rpx;
|
}
|
}
|
}
|
.head-list {
|
width: 100%;
|
height: 88rpx;
|
display: flex;
|
align-items: center;
|
background-color: #ffffff;
|
.head-list-item {
|
flex: 1;
|
height: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
text {
|
font-weight: 400;
|
font-size: 28rpx;
|
color: #777777;
|
margin-right: 8rpx;
|
}
|
}
|
}
|
}
|
}
|
</style>
|