144 lines
3.6 KiB
Vue
144 lines
3.6 KiB
Vue
<template>
|
|
<view class="page-total">
|
|
<view class="tab-list">
|
|
<view class="list" v-for="(item,index) in TabBarList"
|
|
@tap="onTabBar(index)" :style="{marginTop: (index == 1) ? '-26px' : '0px'}"
|
|
:key="index">
|
|
<image :src="item.img" mode="widthFix" v-show="tabBarShow === index" :style="{width: (index == 1) ? '40px' : '28px',borderRadius: (index == 1) ? '12px' : '0px'}"></image>
|
|
<image :src="item.acImg" mode="widthFix" v-show="tabBarShow != index" :style="{width: (index == 1) ? '40px' : '28px',borderRadius: (index == 1) ? '12px' : '0px'}"></image>
|
|
|
|
<!-- background: (index == 2) ? 'red' : '' -->
|
|
<text :class="{'action':tabBarShow===index}" :style="{marginTop: (index == 1) ? '4px' : '0px'}">{{item.name}}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref } from 'vue'
|
|
import { carlist } from '@/utils/service'
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
|
|
const TabBarList = [
|
|
{
|
|
index: 0,
|
|
name: '首页',
|
|
img: '../../static/img/tabbar/home.png',
|
|
acImg: '../../static/img/tabbar/home.png'
|
|
},
|
|
{
|
|
index: 1,
|
|
name: '扫码换电',
|
|
img: '../../static/img/tabbar/saom.png',
|
|
acImg: '../../static/img/tabbar/saom.png'
|
|
},
|
|
{
|
|
index: 2,
|
|
name: '我的',
|
|
img: '../../static/img/tabbar/wode.png',
|
|
acImg: '../../static/img/tabbar/wode.png'
|
|
}
|
|
]
|
|
|
|
|
|
let codeheight = ref(0)
|
|
let isOverall = ref(0)
|
|
let phoneModel = ref('')
|
|
|
|
const props = withDefaults(defineProps<{
|
|
tabBarShow?:string|number
|
|
}>(), {
|
|
tabBarShow:0
|
|
})
|
|
|
|
function onTabBar(index:string|number){
|
|
|
|
switch (index){
|
|
case 0:
|
|
uni.switchTab({
|
|
url:'/pages/home/index'
|
|
})
|
|
break
|
|
case 1:
|
|
if(uni.getStorageSync('wxuid')){
|
|
carlist(uni.getStorageSync('wxuid')).then((rps:any) => {
|
|
if(rps.data && rps.data.length > 0){
|
|
uni.scanCode({
|
|
onlyFromCamera:true,
|
|
success(res){
|
|
let pars = ''
|
|
if(res.path){
|
|
pars = res.path.split('?')[1]
|
|
}
|
|
if(/hdzcode/.test(pars)){
|
|
uni.navigateTo({
|
|
url:`/homePages/reservation/index?${pars}&phoneNumber=${uni.getStorageSync('userInfor').phoneNumber?uni.getStorageSync('userInfor').phoneNumber:''}`
|
|
})
|
|
}else{
|
|
uni.showToast({
|
|
title:'请扫码换电站小程序码',
|
|
icon:'none'
|
|
})
|
|
}
|
|
|
|
},
|
|
fail() {
|
|
uni.switchTab({
|
|
url: '/pages/home/index'
|
|
})
|
|
}
|
|
})
|
|
}else{
|
|
uni.showToast({
|
|
title:'请您联系管理员绑定车辆',
|
|
icon:'none'
|
|
})
|
|
}
|
|
})
|
|
|
|
}else{
|
|
uni.showToast({
|
|
title:'请您先登录',
|
|
icon:'none'
|
|
})
|
|
}
|
|
break
|
|
case 2:
|
|
uni.switchTab({
|
|
url:'/pages/mine/index'
|
|
})
|
|
break
|
|
}
|
|
}
|
|
|
|
onLoad(() =>{
|
|
try {
|
|
const res = uni.getSystemInfoSync();
|
|
// 获取系统信息
|
|
uni.getSystemInfo({
|
|
success(res) {
|
|
console.log(res.brand) //手机牌子
|
|
console.log(res.model) //手机型号
|
|
console.log(res.screenWidth) //屏幕宽度
|
|
console.log(res.screenHeight) //屏幕高度
|
|
|
|
codeheight.value = Math.round(res.screenHeight);
|
|
phoneModel.value =res.model
|
|
if(res.model.search('iPhone')){
|
|
isOverall.value = 0;
|
|
}else if(Math.round(res.screenHeight)>740){
|
|
isOverall.value = 1;
|
|
}
|
|
console.log(isOverall);
|
|
}
|
|
});
|
|
} catch (e) {
|
|
// error
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
@import 'mytabbar.scss';
|
|
</style>
|