caiyunyi/components/shopTabbar.vue
ylj20011123 81a29d01bc update
2025-08-07 19:03:51 +08:00

253 lines
6.4 KiB
Vue

<template>
<view class="main" :style="{ zIndex: zIndex === 98 ? 98 : 99999 }">
<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/newIndex')">
<image class="tabItemIcon" :src="selectIndex === '/pages/shopMallPage/user/newIndex'
? '/static/images/shopTabbar/active_user.png'
: '/static/images/shopTabbar/user.png'
" />
<span class="tabItemText" :style="{
color:
selectIndex === '/pages/shopMallPage/user/newIndex'
? '#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,
},
zIndex: {
type: Number,
default: 99,
},
comeForm: {
type: String,
default: "",
},
},
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 (this.selectIndex === pageIndex) {
return
}
if (pageIndex === '/pages/shopMallPage/index/index') {
if (this.comeForm === 'index') {
uni.redirectTo({
url: '/pages/shopMallPage/index/index',
});
} else {
uni.navigateBack({
delta: 1,
});
}
} else if (pageIndex === "/pages/shopMallPage/shopCar/index") {
if (!this.user && !this.user.MEMBERSHIP_ID) {
uni.showModal({
title: "温馨提示",
content: "请您授权登录后再操作。",
success(res) {
if (res.confirm) {
uni.navigateTo({ url: "/pages/register/index" });
}
},
});
} else {
if (this.selectIndex === '/pages/shopMallPage/index/index') {
uni.navigateTo({ url: `${pageIndex}?pageType=${this.pageType}`, });
} else {
uni.redirectTo({
url: `${pageIndex}?pageType=${this.pageType}`,
});
}
}
} else {
if (this.selectIndex === '/pages/shopMallPage/index/index') {
uni.navigateTo({
url: `${pageIndex}?pageType=${this.pageType}`,
});
} else {
uni.redirectTo({
url: `${pageIndex}?pageType=${this.pageType}`,
});
}
}
// else if (pageIndex === "/pages/user/index") {
// // 判断是不是在购物车里面 2 表示工会商城 1 表示精选商城
// uni.setStorageSync("inShop", this.pageType ? 2 : 1)
// uni.switchTab({
// url: "/pages/user/index",
// })
// }
},
},
};
</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%;
height: 50px;
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;
background: #4BCB7E;
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>