aircraft-pilot/aircraft/server/index/index.vue

161 lines
4.0 KiB
Vue
Raw Normal View History

2025-07-02 14:58:38 +08:00
<template>
<view class="mobile-index">
<view class="u-page upage">
<!-- #ifdef MP-WEIXIN -->
2025-07-14 18:41:30 +08:00
<Order ref="pageRef" :topLevel="topLevel" v-if="current===0" />
<Equipment ref="pageRef" :topLevel="topLevel" v-if="current===1" />
<Route ref="pageRef" :topLevel="topLevel" v-else-if="current===2" />
<My ref="pageRef" :topLevel="topLevel" :isLogin="isLogin" @userLogOut="isLogin=''" v-else-if="current===3" />
2025-07-02 14:58:38 +08:00
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
2025-07-14 18:41:30 +08:00
<component ref="pageRef" :topLevel="topLevel" :is="refs[current]"
2025-07-02 14:58:38 +08:00
:isLogin="isLogin" @userLogOut="isLogin=''"></component>
<!-- #endif -->
</view>
<view class="navigation">
<view @click="changeCurrent(index)" class="nav-item" v-for="(item,index) in navicationList" :key="index">
<image :src="fileUrl+(current===index?item.select:item.icon)"></image>
</view>
</view>
<Loading :show="loading" />
<u-back-top :scrollTop="scrollTop" zIndex="100" :duration="500"
:iconStyle="{ color: '#fff' }" :customStyle="{background: 'linear-gradient(180deg, #96fe11 0%, #f0fdbf 100%)',filter: 'opacity(0.96)'}"></u-back-top>
</view>
</template>
<script>
2025-07-14 18:41:30 +08:00
import Order from '@/aircraft/server/order/order.vue';
import Equipment from '@/aircraft/server/equipment/equipment.vue';
import Route from '@/aircraft/server/route/route.vue';
2025-07-02 14:58:38 +08:00
import My from '@/aircraft/server/my/my.vue';
import configService from '@/common/config.service.js';
export default {
components: {
2025-07-14 18:41:30 +08:00
Order, Equipment, Route, My
2025-07-02 14:58:38 +08:00
},
data() {
return {
current: uni.getStorageSync('current')||0,// 当前页码下标
loading: false,
fileUrl: configService.fileUrl + 'pixel/navigation/',//导航栏图标基础路径
// 导航栏按钮
navicationList:[
{
2025-07-14 18:41:30 +08:00
name: '订单',
icon: 'order.png',
select: 'order-select.png'
2025-07-02 14:58:38 +08:00
},
{
2025-07-14 18:41:30 +08:00
name: '设备',
icon: 'equipment.png',
select: 'equipment-select.png'
},
{
name: '路线',
icon: 'route.png',
select: 'route-select.png'
2025-07-02 14:58:38 +08:00
},
{
name: '我的',
icon: 'my.png',
select: 'my-select.png'
}
],
topLevel: 0,// 页面是否滚动到顶
// 滚动顶部
scrollTop: 0,
// refs组件列表
2025-07-14 18:41:30 +08:00
refs: ['order','equipment','route','my'],
2025-07-02 14:58:38 +08:00
// 登录状态
isLogin: this.$store.state.vuex_token,
}
},
onPageScroll(e) {
const level = e.scrollTop/60;
if(level<=1) this.topLevel = level;
else this.topLevel = 1;
this.scrollTop = e.scrollTop;
},
onLoad(){
let index = uni.getStorageSync('current');
this.current = index?index:0;
this.isLogin = this.$store.state.vuex_token;
this.changeCurrent(this.current);
},
onShow(){
// 小程序除我的页,其它不要刷新
let index = uni.getStorageSync('current');
this.current = index?index:0;
this.isLogin = this.$store.state.vuex_token;
2025-07-14 18:41:30 +08:00
if(this.current === 3){
2025-07-02 14:58:38 +08:00
this.changeCurrent(this.current);
}
},
// 上拉刷新
onPullDownRefresh(){
try{
this.changeCurrent(this.current);
}catch(e){}
finally{
uni.stopPullDownRefresh();
}
},
// 滑动到底部
onReachBottom(){
},
methods:{
// 切换页面
changeCurrent(index){
this.current = index;
uni.setStorageSync('current',index);
if(this.current === 1 && !this.isLogin){
2025-07-14 18:41:30 +08:00
const url = '/aircraft/server/index/index';
2025-07-02 14:58:38 +08:00
uni.navigateTo({
2025-07-14 18:41:30 +08:00
url: `/aircraft/server/my/child_pages/login?nextUrl=${url}`
2025-07-02 14:58:38 +08:00
});
return;
}
this.$nextTick(()=>{
this.$refs.pageRef.init();
})
},
}
}
</script>
<style lang="scss" scoped>
.mobile-index{
position: relative;
// width: 100%;
// min-height: 100vh;
display: flex;
justify-content: center;
.upage{
width: 100%;
}
.navigation{
width: 80%;
height: 128rpx;
position: fixed;
bottom: 15rpx;
z-index: 85;
display: flex;
background-color: #ffffff;
border-radius: 40rpx;
justify-content: space-around;
padding: 25rpx;
align-items: center;
background-size: cover;
filter: drop-shadow(0 0 10rpx rgba(0,0,0,0.4));
.nav-item{
width: 54rpx;
height: 85rpx;
image{
width: 100%;
height: 100%;
}
}
}
}
</style>