| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <template>
- <view class="custom_tabbar">
- <view class="side_help">
- <view class="help" @click="navTo('help')">
- <image class="w-30 h-30 mgb-6" src="/static/image/tabbar/help.png" mode="scaleToFill" />
- <view class="text">帮助</view>
- </view>
- <view class="mgt-20" @click="navTo('complaint')">
- <image class="w-30 h-30 mgb-6" src="/static/image/tabbar/complaint.png" mode="scaleToFill" />
- <view class="text">投诉</view>
- </view>
- </view>
- <view class="tools" @click="navTo('toolsMall')">
- <image class="w-80 h-80" src="/static/image/tabbar/tools_icon.png" mode="scaleToFill" />
- <view class="title">工具广场</view>
- </view>
- <view class="red_packet" @click="navTo('redPacket')">
- <image class="img" src="/static/image/tabbar/red_packet.png" mode="scaleToFill" />
- </view>
- <view class="custom-tabbar">
- <view v-for="(item, index) in list" :key="index" class="tabbar-item" @click="switchTab(index)">
- <view class="menu-item">
- <image v-if="currentIndex === index" class="w-48 h-48" :src="item.check_icon" mode="scaleToFill" />
- <image v-else class="w-48 h-48" :src="item.icon" mode="scaleToFill" />
- <text class="mgt-4" :class="{ active: currentIndex === index }">{{ item.text }}</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import { ref } from 'vue';
- // 当前选中的 Tab 索引
- const props = defineProps(["currentIndex"])
- // TabBar 列表
- const list = ref([{
- text: "书架",
- pagePath: "/pages/index/index",
- icon: '/static/image/tabbar/bookshelf.png',
- check_icon: '/static/image/tabbar/bookshelf_on.png'
- },
- {
- text: "书城",
- pagePath: "/pages/bookMall/index",
- icon: '/static/image/tabbar/bookMall.png',
- check_icon: '/static/image/tabbar/bookMall_on.png'
- },
- {
- text: "我的",
- pagePath: "/pages/my/index",
- icon: '/static/image/tabbar/my.png',
- check_icon: '/static/image/tabbar/my_on.png'
- },
- ]);
- // 切换 Tab
- const switchTab = (index) => {
- uni.switchTab({
- url: list.value[index].pagePath,
- });
- };
- const navList = {
- help: '/pages/commonModule/help',
- complaint: '/pages/commonModule/complaint',
- redPacket: '/pages/commonModule/redPacket',
- toolsMall: '/pages/toolsMall/index'
- }
- const navTo = (name) => {
- uni.navigateTo({
- url: navList[name],
- });
- }
- </script>
- <style lang="scss" scoped>
- .custom_tabbar {
- z-index: 9999;
- }
- .side_help {
- position: fixed;
- left: 0;
- bottom: 20%;
- width: 50rpx;
- background-color: red;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- color: #fff;
- text-align: center;
- padding: 20rpx 0;
- border-radius: 0 30rpx 30rpx 0;
- z-index: 9999;
- .text {
- text-align: center;
- }
- }
- .tools {
- position: fixed;
- right: 20rpx;
- bottom: 33%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- z-index: 9999;
- .title {
- margin-top: 2rpx;
- font-size: 20rpx;
- width: 100rpx;
- height: 30rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- background: linear-gradient(to right, #c7dae2, #84c9e6);
- border-radius: 50rpx;
- color: #fff;
- }
- }
- .red_packet {
- position: fixed;
- right: 20rpx;
- bottom: 20%;
- z-index: 9999;
- .img {
- width: 127rpx;
- height: 96rpx;
- }
- }
- .custom-tabbar {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 0;
- z-index: 9999;
- display: flex;
- height: 100rpx;
- /* 适配安全区 */
- padding-top: 10rpx;
- /* 默认 Android */
- padding-bottom: 10rpx;
- background-color: #ffffff;
- /* background-color: transparent; */
- justify-content: space-between;
- }
- /* 兼容 iOS 安全区域 */
- @supports (bottom: env(safe-area-inset-bottom)) {
- .custom-tabbar {
- height: calc(100rpx + env(safe-area-inset-bottom));
- padding-bottom: env(safe-area-inset-bottom);
- }
- }
- .tabbar-item {
- flex: 1;
- }
- .menu-item {
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: center;
- color: #E5DCD6;
- font-size: 20rpx;
- }
- .add_icon {
- position: absolute;
- top: -30rpx;
- width: 96rpx;
- height: 96rpx;
- }
- .active {
- color: #FFA74F;
- }
- </style>
|