chuangte_bike_newxcx/components/tab-bar/tab-bar.vue
2025-04-11 18:23:16 +08:00

331 lines
8.0 KiB
Vue

<template>
<view class="cont">
<div class="tab" @tap.stop="changeTabbar(0)">
<view class="" v-show="indexs!=0">
<image src="https://api.ccttiot.com/smartmeter/img/static/u8cnGrKmtwZ6osNdmWHn" mode=""></image>
<text>首页</text>
</view>
<view class="" v-show="indexs==0">
<image src="https://api.ccttiot.com/smartmeter/img/static/uhLJf25q3aMvpLRSXGk5" mode=""></image>
<text style="color: #4297F3;">首页</text>
</view>
<!-- 首页-->
</div>
<div class="tab" @tap.stop="changeTabbar(1)">
<view class="" v-show="indexs!=1">
<image src="https://api.ccttiot.com/smartmeter/img/static/u95KNKXT4UPEjucK65wp" mode=""></image>
<text>地图</text>
</view>
<view class="" v-show="indexs==1">
<image src="https://api.ccttiot.com/smartmeter/img/static/uarHoVhvSeCk6xcxJEYz" mode=""></image>
<text style="color: #4297F3;">地图</text>
</view>
<!-- 地图 -->
</div>
<div @tap.stop="changeTabbar(2)">
<image style="width: 102rpx;height: 102rpx;position: fixed;left: 50%;transform: translateX(-50%);bottom:98rpx;" src="https://api.ccttiot.com/smartmeter/img/static/uPWK1kW1mCc2CPVyO7JM" mode="" v-show="indexs!=2"></image>
<image style="width: 102rpx;height: 102rpx;position: fixed;left: 50%;transform: translateX(-50%);bottom:98rpx;" src="https://api.ccttiot.com/smartmeter/img/static/uPWK1kW1mCc2CPVyO7JM" mode="" v-show="indexs==2"></image>
<div class="txt" style="margin-top: 60rpx;color: #979797;font-size: 26rpx;color: #808080;">扫码用车</div>
</div>
<div class="tab" @tap.stop="changeTabbar(3)">
<view class="" v-show="indexs!=3">
<image src="https://api.ccttiot.com/smartmeter/img/static/uIiSizdNVb65ATEXvxfT" mode=""></image>
<text>车辆</text>
</view>
<view class="" v-show="indexs==3">
<image src="https://api.ccttiot.com/smartmeter/img/static/uwQMnTgMLKGyZSMv0qD4" mode=""></image>
<text style="color: #4297F3;">车辆</text>
</view>
<!-- 车辆 -->
</div>
<div class="tab" @tap.stop="changeTabbar(4)">
<view class="" v-show="indexs!=4">
<image src="https://api.ccttiot.com/smartmeter/img/static/uZRI3UlVUa2Cn9Fw6M1i" mode=""></image>
<text>我的</text>
</view>
<view class="" v-show="indexs==4">
<image src="https://api.ccttiot.com/smartmeter/img/static/uZAXujab08DiHZcoZaTU" mode=""></image>
<text style="color: #4297F3;">我的</text>
</view>
<!-- 我的 -->
</div>
<image class="botimg" src="https://api.ccttiot.com/smartmeter/img/static/uV7nJgKVc4tgTuSqB699" mode=""></image>
<!-- 用车选项 -->
<view class="yongche" v-if="show">
<view class="" @click="btnyc(1)">
输入编号用车
</view>
<view class="" @click="btnyc(2)">
扫码用车
</view>
<view class="" @click="btnyc(3)">
立即租车
</view>
<view class="qx">
</view>
<view class="" @click="show = false">
取消
</view>
</view>
<view class="mask" v-if="show"></view>
</view>
</template>
<script>
export default {
props: {
indexs: [Number, String], //题目id
},
data() {
return {
currentTabbarIndex: 0,
show:false,
// 自定义底栏对应页面的加载情况
tabberPageLoadFlag: [],
ispop: false,
modelId:'',
sn:''
}
},
mounted() {
this.currentTabbarIndex = this.indexs
},
methods:{
// 点击用车
btnyc(num){
this.show = false
if(num == 1){
uni.navigateTo({
url:'/page_fenbao/index'
})
}else if(num == 2){
uni.scanCode({
onlyFromCamera: true,
scanType: ['qrCode'],
success: res => {
console.log(res);
},
fail: err => {
console.error('扫描失败:', err)
uni.showToast({
title: '扫描失败',
icon: 'none'
})
}
})
}else{
uni.navigateTo({
url:'/page_fenbao/storedlist/fujinshop'
})
}
},
changeTabbar(index) {
if (this.currentTabbarIndex === index) return
if(index==0){ //首页
uni.switchTab({
url:'/pages/index/index',
routeType: 'wx://modal',
success() {
this.currentTabbarIndex = index
}
})
}else if(index==1){ //地图
uni.switchTab({
url:'/pages/nearbystores/index',
routeType: 'wx://modal',
success() {
this.currentTabbarIndex = index
}
})
}else if(index==2){ //用车
uni.scanCode({
onlyFromCamera: true,
scanType: ['qrCode'],
success: res => {
console.log(res);
function getQueryParam(url, paramName) {
let regex = new RegExp(`[?&]${paramName}=([^&]*)`)
let results = regex.exec(url)
return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null
}
let sceneValue = res.result
let decodedValue = decodeURIComponent(sceneValue)
this.sn = getQueryParam(decodedValue, 's')
this.$u.get(`/app/device/availableDetail?sn=${this.sn}`).then((res) => {
if (res.code == 200) {
if(res.data){
this.modelId = res.data.modelId
uni.navigateTo({
url:'/page_fenbao/storedlist/trueorder?modelId=' + this.modelId + '&sn=' + this.sn
})
}else{
uni.showToast({
title: '当前车辆不可用',
icon: 'none'
})
}
}else{
uni.showToast({
title: res.msg,
icon: 'none'
})
}
})
},
fail: err => {
console.error('扫描失败:', err)
uni.showToast({
title: '扫描失败',
icon: 'none'
})
}
})
}else if(index==3){ //车辆
uni.switchTab({
url:'/pages/myorder/returned/index',
routeType: 'wx://modal',
success() {
this.currentTabbarIndex = index
}
})
}else if(index==4){ //我的
uni.switchTab({
url:'/pages/my',
routeType: 'wx://modal',
success() {
this.currentTabbarIndex = index
}
})
}
},
}
}
</script>
<style lang="scss" scoped>
/deep/.u-tabbar__content__item__button {
top: 20rpx !important;
}
/deep/.u-tabbar {
.u-tabbar__content__item:nth-child(2) {
.u-tabbar__content__item__button {
width: 32rpx !important;
}
}
}
// 用车选项
.yongche{
position: fixed;
left: 0;
bottom: 0;
width: 750rpx;
height: 538rpx;
background: #FFFFFF;
box-shadow: 0rpx 4rpx 28rpx 0rpx rgba(0,0,0,0.16);
border-radius: 50rpx 50rpx 0 0;
z-index: 99;
animation: fadeIn 0.5s ease-in-out forwards;
view{
border-bottom: 2rpx solid #D8D8D8;
width: 100%;
height: 138rpx;
font-size: 40rpx;
color: #3D3D3D;
text-align: center;
line-height: 138rpx;
font-weight: 500;
}
.qx{
width: 750rpx;
height: 12rpx;
background: #D8D8D8;
border-radius: 0rpx 0rpx 0rpx 0rpx;
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.mask{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background-color: rgba(0, 0, 0, 0.3);
z-index: 98;
animation: fadeIn 0.5s ease-in-out forwards;
}
.botimg{
width: 100%;
height: 166rpx;
position: fixed;
left: 0;
bottom: 0;
z-index: -1;
box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3);
}
.cont {
padding: 0 14rpx;
box-sizing: border-box;
position: fixed;
left: 0;
bottom: 0;
width:100%;
background-color: #eee;
height: 166rpx;
box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(53, 140, 255, 0.1);
display: flex;
align-items: center;
justify-content: space-around;
.tab{
width: 60rpx;
display: flex;
flex-wrap: wrap;
justify-content: center;
view{
image{
width: 50rpx;
height: 50rpx;
}
text{
font-size: 26rpx;
color:#979797;
}
}
image{
width: 56rpx;
height: 94rpx;
}
.txt{
margin-top: 10rpx;
font-size: 24rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #808080;
}
.act1{
color: #48893B;
}
}
}
</style>