优化项目

This commit is contained in:
yangyao committed 2026-01-05 10:19:48 +08:00
1 parent 6f9c52a2c6
commit 1facf7d6c8
16 files changed
+111 -101

No files matched your search

+109 -92
View File
@@ -1,108 +1,125 @@
<template>
<view class="custom-tab-bar">
<view
v-for="(item, index) in tabList"
:key="index"
class="tab-bar-item"
@click="switchTab(item.pagePath)"
>
<!-- 图标 -->
<image
class="icon"
:src="currentPath === item.pagePath ? item.selectedIconPath : item.iconPath"
></image>
<!-- 文字 -->
<text
class="text"
:style="{color: currentPath === item.pagePath ? selectedColor : color}"
>
{{ item.text }}
</text>
</view>
</view>
<view class="custom-tab-bar">
<!-- 首页 -->
<view class="tab-bar-item" @click="switchTab(homeTab.pagePath)">
<image class="icon" :src="currentPath === homeTab.pagePath ? homeTab.selectedIconPath : homeTab.iconPath"></image>
<text class="text" :style="{color: currentPath === homeTab.pagePath ? selectedColor : color}">
{{ homeTab.text }}
</text>
</view>
<!-- 发现页 -->
<view class="tab-bar-item relative" @click="switchTab(findTab.pagePath)">
<image class="absolute top-[-10px] w-[36px] h-[36px]" :src="currentPath === findTab.pagePath ? findTab.selectedIconPath : findTab.iconPath"></image>
<!-- <text class="text" :style="{color: currentPath === findTab.pagePath ? selectedColor : color}">
{{ findTab.text }}
</text> -->
</view>
<!-- 个人页面 -->
<view class="tab-bar-item" @click="switchTab(mineTab.pagePath)">
<image class="icon" :src="currentPath === mineTab.pagePath ? mineTab.selectedIconPath : mineTab.iconPath"></image>
<text class="text" :style="{color: currentPath === mineTab.pagePath ? selectedColor : color}">
{{ mineTab.text }}
</text>
</view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import {
ref,
onMounted
} from 'vue'
import {
onLoad
} from '@dcloudio/uni-app'
// ========== 配置数据 ==========
// 从你原来的配置迁移过来的数据
const color = '#999999'
const selectedColor = '#AB002D'
const tabList = ref([
{
pagePath: "pages/index/index",
iconPath: "/static/tabbar/home.png",
selectedIconPath: "/static/tabbar/active-home.png",
text: "首页"
},
{
pagePath: "pages/order/index",
iconPath: "/static/tabbar/order.png",
selectedIconPath: "/static/tabbar/active-order.png",
text: "订单"
},
{
pagePath: "pages/mine/index",
iconPath: "/static/tabbar/mine.png",
selectedIconPath: "/static/tabbar/active-mine.png",
text: "我的"
}
])
// ========== 配置数据 ==========
// 从你原来的配置迁移过来的数据
const color = '#999999'
const selectedColor = '#000'
//首页配置
const homeTab = {
pagePath: "pages/index/index",
iconPath: "/static/tabbar/home.png",
selectedIconPath: "/static/tabbar/active-home.png",
text: "首页"
}
// ========== 逻辑处理 ==========
const currentPath = ref('')
//发现页
const findTab = {
pagePath: "pages/order/index",
iconPath: "/static/tabbar/find.png",
selectedIconPath: "/static/tabbar/active-find.png",
text: "发现"
}
//个人页
const mineTab = {
pagePath: "pages/mine/index",
iconPath: "/static/tabbar/mine.png",
selectedIconPath: "/static/tabbar/active-mine.png",
text: "我的"
}
// 获取当前页面路径,用于匹配高亮
const updateSelected = () => {
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
currentPath.value = currentPage.route
}
// ========== 逻辑处理 ==========
const currentPath = ref('')
// 切换页面
const switchTab = (url) => {
// 如果点击的是当前页,不执行跳转
if (currentPath.value === url) return
uni.switchTab({ url: '/' + url })
}
// 获取当前页面路径,用于匹配高亮
const updateSelected = () => {
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
currentPath.value = currentPage.route
}
// 组件挂载后获取当前路径
onMounted(() => {
updateSelected()
})
// 切换页面
const switchTab = (url) => {
// 如果点击的是当前页,不执行跳转
if (currentPath.value === url) return
uni.switchTab({
url: '/' + url
})
}
// 组件挂载后获取当前路径
onMounted(() => {
updateSelected()
})
</script>
<style scoped>
.custom-tab-bar {
display: flex;
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 50px; /* 根据需要调整高度 */
background-color: #ffffff;
border-top: 1px solid #000000; /* 对应 borderStyle: black */
z-index: 999;
}
.custom-tab-bar {
display: flex;
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 50px;
/* 根据需要调整高度 */
background-color: #ffffff;
/* 对应 borderStyle: black */
z-index: 999;
}
.tab-bar-item {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.tab-bar-item {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.icon {
width: 24px;
height: 24px;
margin-bottom: 2px;
}
.icon {
width: 24px;
height: 24px;
margin-bottom: 2px;
}
.text {
font-size: 12px;
}
.text {
font-size: 12px;
}
</style>
+1 -1
View File
@@ -88,7 +88,7 @@
},
"proxy" : {
"/sale" : {
"target" : "http://110.v2-app.devcn.dabapiao.com",
"target" : "",
"changeOrigin" : true,
"secure" : false,
"pathRewrite" : {
-7
View File
@@ -30,13 +30,6 @@
"navigationStyle": "custom"
}
},
{
"path": "pages/product/index",
"style": {
+1 -1
View File
@@ -79,7 +79,7 @@ const handleBook = (productId) => {
</script>
<template>
<view class="h-[100vh] bg-[#9C032D]">
<view class="h-[100vh] bg-[#fff]">
<CustomTabBar />
</view>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1013 B

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 789 B