odf_new/odf-uniapp/pages/portal/index.vue
zpc 7e260a1d57 feat(odf-uniapp): Refactor global background styling to use centralized page background
- Replace individual page background images with global page background in App.vue
- Update pages.json global styles to use transparent colors for navigation and backgrounds
- Remove redundant bg-image elements and styles from all page components
- Set global page background with login_bg.png image, cover sizing, and fixed attachment
- Simplify individual page styling by removing duplicate background color declarations
- Consolidate background management to single source of truth in App.vue for consistent theming
2026-04-04 00:20:24 +08:00

154 lines
3.1 KiB
Vue

<template>
<view class="portal-page">
<view class="content">
<!-- 顶部导航栏 -->
<view class="nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
<view class="nav-bar-inner">
<image
class="nav-icon"
src="/static/images/ic_refresh.png"
mode="aspectFit"
@click="handleRefresh"
/>
<text class="nav-title">功能列表</text>
<image
class="nav-icon"
src="/static/images/ic_set.png"
mode="aspectFit"
@click="goSettings"
/>
</view>
</view>
<!-- 功能入口网格 -->
<view class="module-grid" v-if="filteredModules.length > 0">
<view
class="module-card"
v-for="item in filteredModules"
:key="item.code"
@click="handleModuleClick(item)"
>
<text class="module-name">{{ item.name }}</text>
</view>
</view>
<!-- 空权限提示 -->
<view class="empty-state" v-else>
<text class="empty-text">暂无可用功能模块</text>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import store from '@/store'
import { getUserModules } from '@/services/permission'
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
// 所有可用功能版块定义
const allModules = [
{ code: 'odf', name: '机房', icon: '/static/images/ic_odf.png', url: '/pages/home/index' },
{ code: 'trunk', name: '干线', icon: '/static/images/ic_trunk.png', url: '/pages/trunk/index' }
]
// 根据权限过滤显示的版块
const filteredModules = computed(() => {
return allModules.filter(m => store.modules.includes(m.code))
})
function handleModuleClick(item) {
uni.navigateTo({ url: item.url })
}
async function handleRefresh() {
const res = await getUserModules()
if (res.code === 200) {
store.setModules(res.data)
}
}
function goSettings() {
uni.navigateTo({ url: '/pages/settings/index' })
}
onLoad(() => {
// 页面加载时刷新权限
handleRefresh()
})
</script>
<style scoped>
.portal-page {
position: relative;
min-height: 100vh;
background-color: transparent;
}
.content {
position: relative;
z-index: 1;
}
.nav-bar {
width: 100%;
}
.nav-bar-inner {
display: flex;
align-items: center;
justify-content: space-between;
height: 88rpx;
padding: 0 24rpx;
}
.nav-icon {
width: 44rpx;
height: 44rpx;
}
.nav-title {
font-size: 34rpx;
font-weight: 600;
color: #fff;
}
.module-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 24rpx;
padding: 24rpx;
}
.module-card {
display: flex;
align-items: center;
justify-content: center;
height: 160rpx;
background-color: #fff;
border-radius: 12rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
}
.module-name {
font-size: 32rpx;
color: #333;
font-weight: 500;
text-align: center;
}
.empty-state {
display: flex;
align-items: center;
justify-content: center;
padding: 200rpx 0;
}
.empty-text {
font-size: 28rpx;
color: #999;
}
</style>