Commit eba58ed8 authored by 罗超's avatar 罗超

优化

parent cca67d1c
<style scoped>
.tabbarMain {
height: 100upx;
position: fixed;
z-index: 50;
flex: 1;
bottom: 0;
left: 0;
right: 0;
z-index: 99999999;
border-top: 1upx solid #ddd;
padding-top: 96rpx;
background: #fff;
}
.tabbarMainIphone {
height: 156upx;
padding-bottom: 64upx;
}
.tabBtnMina {
width: 750upx;
height: 88upx;
position: absolute;
z-index: 2;
bottom: 0;
flex-direction: row;
display: flex;
left: 0;
right: 0;
z-index: 99999999;
}
.tabBtnMinaIphone {
height: 156upx;
padding-bottom: 64upx;
}
.imgse {
height: 48upx;
width: 48upx;
}
.txtBtn {
font-size: 24upx;
color: #666666;
}
.txtBtnSel {
font-size: 24upx;
color: #333333;
}
.itmMain {
width: 150upx;
flex: 1;
justify-content: center;
align-items: center;
display: flex;
flex-direction: column;
}
.imgseTs {
width: 150upx;
height: 140upx;
margin-bottom: 90upx;
position: relative;
z-index: 1;
bottom: 0upx;
}
.btnfixMin {
width: 750upx;
height: 178upx;
position: absolute;
z-index: 1;
bottom: 0;
}
.btnfixMinIphone {
bottom: 64upx;
}
.fixTpm {
width: 150upx;
height: 140upx;
flex-direction: row;
justify-content: center;
align-items: center;
position: relative;
z-index: 0;
}
.imgseTsAnds {
width: 150upx;
height: 150upx;
position: fixed;
z-index: 1;
bottom: 10upx;
border-radius: 150upx;
}
</style>
<template> <template>
<view <view class="tabbarMain" :style="{paddingBottom: `${bottomSafeHeight}px`}" v-if="navs.length">
class="tabbarMain bar-box" <view class="tabBtnMina">
:class="[flagTypeInfo ? 'tabbarMainIphone' : '']" <view
v-if="navs && navs.length > 0" class="itmMain"
> v-for="(x, i) in navs"
<view :key="i"
class="tabBtnMina"
:class="[flagTypeInfo ? 'tabBtnMinaIphone' : '']"
mode=""
>
<view
class="itmMain"
v-for="(x, i) in navs"
:key="i"
@click.stop="goUrl(x.url)" @click.stop="goUrl(x.url)"
> >
<image <image
class="imgse" class="imgse"
:fade-show="false" :src="active === i ? x.active_icon : x.icon"
v-if="active != i"
mode="aspectFit" mode="aspectFit"
:src="x.icon" />
></image> <text class="txtBtn" :style="{ color: active == i ? x.active_color : x.color }">
<image {{ x.text }}
class="imgse" </text>
:fade-show="false"
v-if="active === i"
mode="aspectFit"
:src="x.active_icon"
></image>
<text
class="txtBtn"
:style="{ color: active == i ? x.active_color : x.color }"
>{{ x.text }}</text
>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
active: 0, active: 0,
platforms: "",
leftWidth: 0,
flagTypeInfo: false,
navs: [], navs: [],
crtPath: "", bottomSafeHeight: 0,
currentPath:''
}; };
}, },
created() {
},
mounted() { mounted() {
this.flagTypeInfo = this.$uiConfig.is_bang; this.navs = uni.getStorageSync("navs") || []
let tempSystem = uni.getSystemInfoSync(); this.calcSafeArea()
this.platforms = tempSystem.platform; this.activeHandler()
this.$nextTick(() => {
// #ifdef APP-NVUE || APP-PLUS || APP-PLUS-NVUE ||APP-VUE
if (this.platforms == "android") {
let temp = this.$refs.leftWidth;
this.leftWidth = tempSystem.screenWidth / 2;
}
// #endif
});
if (uni.getStorageSync("navs")) {
this.navs = uni.getStorageSync("navs") ?? [];
} else {
setTimeout(() => {
this.navs = uni.getStorageSync("navs") ?? [];
this.activeHandler();
}, 3000);
}
this.activeHandler();
}, },
methods: { methods: {
calcSafeArea() {
const { safeAreaInsets } = uni.getSystemInfoSync()
this.bottomSafeHeight = safeAreaInsets.bottom > 0 ? safeAreaInsets.bottom : 10
},
activeHandler() { activeHandler() {
let t = getCurrentPages(); const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
// #ifdef MP-WEIXIN const query = currentPage.options
let query = t[t.length - 1].__displayReporter.query; const queryString = Object.keys(query)
let queryString = ""; .map(key => `${key}=${query[key]}`)
for (var k in query) { .join('&')
queryString += `&${k}=${query[k]}`; this.currentPath = `/${currentPage.route}${queryString ? '?' + queryString : ''}`
}
if (queryString != "") { this.navs.forEach((item, index) => {
queryString = "?" + queryString.substring(1, queryString.length); if (this.currentPath === item.url) {
} this.active = index
this.crtPath = "/" + t[t.length - 1].route + queryString;
// #endif
// #ifdef MP-ALIPAY
this.crtPath = t[t.length - 1].$page.fullPath;
// #endif
this.navs.forEach((x, i) => {
if (x.url == this.crtPath) {
this.active = i;
} }
}); })
}, },
goUrl(url) { goUrl(url) {
if (this.crtPath != url) { if (this.currentPath !== url) {
uni.redirectTo({ uni.redirectTo({ url })
url: url,
});
} else { } else {
uni.reLaunch({ uni.reLaunch({
url: url, url
}); })
} }
}, }
}, }
}; }
</script> </script>
<!-- <template>
<view class="bar-box">
<div class="bar-box-line">
<view class="bar-item" v-for="(x,i) in menus" @click="changeMenuHandler(x)">
<i class="icon iconfont" :class="[x.icon]" v-if="current != x.page"></i>
<view class="acitve" v-else>
{{x.name}}
</view>
</view>
</div>
</view>
</template>
<script>
export default {
data() {
return {
menus: [],
current: ''
};
},
mounted() {
let pages = getCurrentPages()
this.current = "/" + pages[pages.length - 1].route ? ? ''
this.menus = [{
name: '首页',
icon: 'icon-home',
page: '/pages/index/index'
},
{
name: '订单',
icon: 'icon-Work',
page: '/pages/jiuzhai/jz_MyOrder'
},
{
name: '我的',
icon: 'icon-my1',
page: '/pages/user-center/user-center'
}
]
},
methods: {
changeMenuHandler(menu) {
this.current = menu.page
if (menu.page.indexOf('pages') != -1) {
uni.redirectTo({
url: menu.page
})
}
}
}
}
</script>
-->
<style> <style>
/* 在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */ .tabbarMain {
@font-face { position: fixed;
font-family: "nav-font"; z-index: 999;
src: url("//at.alicdn.com/wf/webfont/MQHUV6e56ce5/tcIItWsk6dTo.woff2") format("woff2"), bottom: 0;
url("//at.alicdn.com/wf/webfont/MQHUV6e56ce5/RZzswoFvsjUs.woff") format("woff"); left: 0;
font-display: swap; right: 0;
} background: #fff;
border-top: 1rpx solid #E0E0E0;
.bar-box { padding: 20rpx 0 0;
padding-bottom: env(safe-area-inset-bottom); }
background-color: #FFF;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
box-shadow: 0 0 6px rgba(0, 0, 0, .12);
position: fixed;
z-index: 50;
flex: 1;
bottom: 0;
left: 0;
right: 0;
z-index: 99999999;
}
.bar-box-line {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
padding: 20upx 0 30upx;
}
.bar-box-line.uninset {
padding: 20upx 0 40upx;
}
.bar-box-line.inset { .tabBtnMina {
padding: 20upx 0; display: flex;
} flex-direction: row;
}
.bar-box-line .bar-item { .itmMain {
flex: 1; flex: 1;
width: 1px; display: flex;
text-align: center; flex-direction: column;
color: #abadb9; align-items: center;
position: relative; justify-content: center;
} }
.bar-box-line .bar-item .icon { .imgse {
font-size: 50rpx; width: 48rpx;
} height: 48rpx;
}
.bar-box-line .bar-item .acitve { .txtBtn {
font-size: 32rpx; font-size: 20rpx;
font-weight: bold; color: #666;
color: #1F2429; margin-top: 8rpx;
text-align: center; line-height: 1;
font-family: nav-font; }
}
.bar-box-line .bar-item .acitve::after { .txtBtnSel {
display: inline-block; color: #333;
content: ' '; font-size: 24rpx;
width: 4px; }
height: 4px; </style>
border-radius: 4px; \ No newline at end of file
background-color: #1F2429;
position: absolute;
left: calc(50% - 2px);
top: 60rpx;
}
</style>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment