caiyunyi/components/tabbar.vue
2025-04-02 14:57:21 +08:00

153 lines
3.4 KiB
Vue

<template>
<view class="main">
<div class="content">
<div class="tabItem" @click="goPages('/pages/index/index')">
<image
class="tabItemIcon"
:src="
selectIndex === '/pages/index/index'
? '/static/images/tabbar/home-active.png'
: '/static/images/tabbar/home.png'
"
/>
<span
class="tabItemText"
:style="{
color: selectIndex === '/pages/index/index' ? '#009F43' : '#3A3D48',
}"
>首页</span
>
</div>
<div class="postiton">
<view class="tabbarLogo" @click="handleGoShop"></view>
<!-- <image
class="tabbarLogo"
src="/static/images/tabbar/CYYIconNew.jpg"
@click="handleGoShop"
/> -->
<!-- src="https://eshangtech.com/minTestImg/CYYIconNew.jpg" -->
</div>
<div class="tabItem" @click="goPages('/pages/user/index')">
<image
class="tabItemIcon"
:src="
selectIndex === '/pages/user/index'
? '/static/images/tabbar/user_active.png'
: '/static/images/tabbar/user.png'
"
/>
<span
class="tabItemText"
:style="{
color: selectIndex === '/pages/user/index' ? '#009F43' : '#3A3D48',
}"
>我的</span
>
</div>
</div>
</view>
</template>
<script>
export default {
data() {
return {
selectIndex: "/pages/index/index",
};
},
props: {
page: {
type: String,
default: "",
},
},
watch: {
page: {
handler(value) {
this.selectIndex = value;
},
deep: true,
immediate: true,
},
},
methods: {
goPages(pageIndex) {
uni.switchTab({
url: pageIndex,
});
},
// 跳转商城
handleGoShop() {
uni.navigateTo({
url: "/pages/shopMallPage/index/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;
.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;
border-radius: 50%;
.tabbarLogo {
width: 120rpx; //112
height: 120rpx;
background-image: url(https://eshangtech.com/minTestImg/CYYIconNew.jpg);
background-repeat: no-repeat;
background-size: contain;
position: absolute;
left: 50%;
transform: translateX(-50%);
top: -36rpx;
border-radius: 50%;
}
}
}
}
</style>