caiyunyi/components/shopTabbar.vue
2025-01-15 18:49:37 +08:00

240 lines
5.6 KiB
Vue

<template>
<view class="main">
<div class="content">
<div class="tabItem" @click="goPages('/pages/shopMallPage/index/index')">
<image
class="tabItemIcon"
:src="
selectIndex === '/pages/shopMallPage/index/index'
? '/static/images/shopTabbar/active_home.png'
: '/static/images/shopTabbar/home.png'
"
/>
<span
class="tabItemText"
:style="{
color:
selectIndex === '/pages/shopMallPage/index/index'
? '#1890FF'
: '#3A3D48',
}"
>首页</span
>
</div>
<div
class="tabItem"
@click="goPages('/pages/shopMallPage/shopType/index')"
>
<image
class="tabItemIcon"
:src="
selectIndex === '/pages/shopMallPage/shopType/index'
? '/static/images/shopTabbar/active_classification.png'
: '/static/images/shopTabbar/classification.png'
"
/>
<span
class="tabItemText"
:style="{
color:
selectIndex === '/pages/shopMallPage/shopType/index'
? '#1890FF'
: '#3A3D48',
}"
>分类</span
>
</div>
<div
class="tabItem"
@click="goPages('/pages/shopMallPage/shopCar/index')"
>
<span class="shopCarNumber" v-if="shopCount > 0">{{ shopCount }}</span>
<image
class="tabItemIcon"
:src="
selectIndex === '/pages/shopMallPage/shopCar/index'
? '/static/images/shopTabbar/active_shopCar.png'
: '/static/images/shopTabbar/shopCar.png'
"
/>
<span
class="tabItemText"
:style="{
color:
selectIndex === '/pages/shopMallPage/shopCar/index'
? '#1890FF'
: '#3A3D48',
}"
>购物车</span
>
</div>
<div class="tabItem" @click="goPages('/pages/shopMallPage/user/index')">
<image
class="tabItemIcon"
:src="
selectIndex === '/pages/shopMallPage/user/index'
? '/static/images/shopTabbar/active_user.png'
: '/static/images/shopTabbar/user.png'
"
/>
<span
class="tabItemText"
:style="{
color:
selectIndex === '/pages/shopMallPage/user/index'
? '#1890FF'
: '#3A3D48',
}"
>我的</span
>
</div>
</div>
</view>
</template>
<script>
import { mapGetters } from "vuex";
export default {
data() {
return {
selectIndex: "/pages/index/index",
shopCount: 0,
};
},
computed: {
...mapGetters({
user: "user",
}),
},
props: {
page: {
type: String,
default: "",
},
pageType: {
type: String,
default: "",
},
shopCarLength: {
type: Number,
default: 0,
},
},
watch: {
page: {
handler(value) {
this.selectIndex = value;
},
deep: true,
immediate: true,
},
shopCarLength: {
handler(value) {
this.shopCount = value;
},
deep: true,
immediate: true,
},
},
methods: {
goPages(pageIndex) {
if (pageIndex === "/pages/shopMallPage/shopCar/index") {
if (!this.user.MEMBERSHIP_ID) {
uni.showModal({
title: "温馨提示",
content: "请您授权登录后再操作。",
success(res) {
if (res.confirm) {
uni.navigateTo({ url: "/pages/register/index" });
}
},
});
} else {
uni.redirectTo({
url: `${pageIndex}?pageType=${this.pageType}`,
});
}
} else {
uni.redirectTo({
url: `${pageIndex}?pageType=${this.pageType}`,
});
}
},
},
};
</script>
<style lang="less" scoped>
.main {
width: 100vw;
position: fixed;
bottom: 0rpx;
background: #ffffff;
border-top: 1px solid #e8e8ea;
box-sizing: border-box;
z-index: 99999;
.content {
width: 100%;
background: #f7f8f8;
display: flex;
align-items: center;
padding-bottom: env(safe-area-inset-bottom);
.tabItem {
width: calc(100vw / 3);
height: 100%;
box-sizing: border-box;
padding-top: 10rpx;
display: flex;
flex-direction: column;
align-items: center;
position: relative;
.shopCarNumber {
position: absolute;
top: 0;
left: 60%;
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 28rpx;
color: #fdfdfd;
line-height: 28rpx;
text-align: left;
font-style: normal;
background: #fa5151;
border-radius: 16rpx;
padding: 2rpx 8rpx;
}
.tabItemIcon {
width: 48rpx;
height: 48rpx;
margin-bottom: 4rpx;
}
.tabItemText {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 20rpx;
color: #3a3d48;
line-height: 28rpx;
text-align: justify;
font-style: normal;
}
}
.postiton {
width: calc(100vw / 3);
height: 100%;
box-sizing: border-box;
padding-bottom: 68rpx;
position: relative;
.tabbarLogo {
width: 112rpx;
height: 112rpx;
position: absolute;
left: 50%;
transform: translateX(-50%);
top: -36rpx;
}
}
}
}
</style>