177 lines
3.9 KiB
Vue
177 lines
3.9 KiB
Vue
<template>
|
|
<view class="sub__tabbar">
|
|
<view
|
|
:class="['item', { current: current == 1 }]"
|
|
@click="gopage(1, `/pagesub/index/store?store_id=${storeId}`)"
|
|
>
|
|
<view class="box">
|
|
<image
|
|
v-if="current == 1"
|
|
class="icon"
|
|
src="https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/icon/icon_home_cur.png"
|
|
/>
|
|
<image v-else class="icon" src="https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/icon/icon_home.png" />
|
|
<view class="desc">首页</view>
|
|
</view>
|
|
</view>
|
|
<view
|
|
:class="['item', { current: current == 2 }]"
|
|
@click="
|
|
gopage(
|
|
2,
|
|
`/pagesub/index/category?category_id=${categoryId}&store_id=${storeId}`
|
|
)
|
|
"
|
|
>
|
|
<view class="box">
|
|
<image
|
|
v-if="current == 2"
|
|
class="icon"
|
|
src="https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/icon/icon_category_cur.png"
|
|
/>
|
|
<image v-else class="icon" src="https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/icon/icon_category.png" />
|
|
<view class="desc">分类</view>
|
|
</view>
|
|
</view>
|
|
<!-- <view
|
|
:class="['item', { current: current == 3 }]"
|
|
@click="gopage(3,'/pagesub/index/feed')"
|
|
>发现</view
|
|
> -->
|
|
<view
|
|
:class="['item', { current: current == 4 }]"
|
|
@click="gopage(4, '/pages/index/cart')"
|
|
>
|
|
<view class="box">
|
|
<image
|
|
v-if="current == 4"
|
|
class="icon"
|
|
src="https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/icon/icon_shop_cur.png"
|
|
/>
|
|
<image v-else class="icon" src="https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/icon/icon_shop.png" />
|
|
<view class="desc">购物车</view>
|
|
<text class="icon_badge">{{ goodsNum }}</text>
|
|
</view>
|
|
</view>
|
|
<!-- <view
|
|
:class="['item', { current: current == 5 }]"
|
|
@click="gopage(5,`/pagesub/index/goods?store_id=${storeId}`)"
|
|
>商品</view
|
|
> -->
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
props: {
|
|
current: {
|
|
type: Number,
|
|
default: 1,
|
|
},
|
|
cartNum: {
|
|
type: Number,
|
|
default: 0,
|
|
},
|
|
storeId: {
|
|
type: Number,
|
|
default: 0,
|
|
},
|
|
categoryId: {
|
|
type: Number,
|
|
default: 0,
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
goodsNum: 0,
|
|
};
|
|
},
|
|
watch: {
|
|
cartNum: {
|
|
handler(newVal) {
|
|
this.goodsNum = newVal;
|
|
},
|
|
immediate: true,
|
|
},
|
|
},
|
|
methods: {
|
|
gopage(tabIndex, url) {
|
|
if (tabIndex === this.current) {
|
|
console.log("当前页面,不执行跳转");
|
|
return;
|
|
}
|
|
this.$.navigateTo({
|
|
url,
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.sub__tabbar {
|
|
position: fixed;
|
|
bottom: 0;
|
|
right: 0;
|
|
left: 0;
|
|
z-index: 10;
|
|
display: flex;
|
|
align-items: center;
|
|
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
|
padding: 4rpx 0;
|
|
padding-bottom: var(--safe-area-inset-bottom, 4);
|
|
height: 48px;
|
|
background: #fff;
|
|
|
|
.item {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-direction: column;
|
|
flex: 1;
|
|
color: #666;
|
|
text-align: center;
|
|
position: relative;
|
|
|
|
.icon {
|
|
width: 48rpx;
|
|
height: 48rpx;
|
|
display: block;
|
|
}
|
|
|
|
.desc {
|
|
font-size: 24rpx;
|
|
line-height: 14rpx;
|
|
}
|
|
|
|
.icon_badge {
|
|
display: block;
|
|
position: absolute;
|
|
right: -5px;
|
|
top: -5px;
|
|
text-align: center;
|
|
line-height: 24rpx;
|
|
font-size: 24rpx;
|
|
padding: 4rpx 10rpx;
|
|
border-radius: 20rpx;
|
|
color: #fff;
|
|
background: #dd524d;
|
|
}
|
|
|
|
.box {
|
|
position: relative;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
gap: 10rpx;
|
|
}
|
|
|
|
&.current {
|
|
color: #dd524d;
|
|
font-weight: 900;
|
|
}
|
|
}
|
|
}
|
|
</style>
|