odf_new/odf-uniapp/pages/home/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

219 lines
4.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="home-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_back.png"
mode="aspectFit"
@click="goBack"
/>
<text class="nav-title">公司列表</text>
<view class="nav-right">
<image
class="nav-icon"
src="/static/images/ic_refresh.png"
mode="aspectFit"
@click="handleRefresh"
/>
<image
class="nav-icon nav-icon-ml"
src="/static/images/ic_set.png"
mode="aspectFit"
@click="goSettings"
/>
</view>
</view>
</view>
<!-- 搜索入口栏 -->
<view class="search-bar" @click="goSearch">
<image class="search-icon" src="/static/images/ic_search.png" mode="aspectFit" />
<text class="search-placeholder">请输入要搜索的备注内容</text>
</view>
<!-- 公司列表 -->
<scroll-view class="company-list" scroll-y>
<view
class="company-card"
v-for="item in companyList"
:key="item.deptId"
@click="goRegion(item)"
>
<text class="company-name">{{ item.deptName }}</text>
</view>
</scroll-view>
</view>
<!-- 版本更新弹窗 -->
<update-dialog :visible="showUpdate" :downloadUrl="updateUrl" />
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
import store from '@/store'
import { getCompanyList, getDictUnitType, getDictBusinessType, checkAppVersion } from '@/services/home'
import updateDialog from '@/components/update-dialog.vue'
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
const companyList = ref([])
const showUpdate = ref(false)
const updateUrl = ref('')
async function loadCompanyList() {
const res = await getCompanyList()
if (res.code === 200) {
companyList.value = res.data || []
}
}
async function loadDictData() {
const [unitRes, bizRes] = await Promise.all([
getDictUnitType(),
getDictBusinessType()
])
if (unitRes.code === 200) {
store.dictUnitTypes = unitRes.data || []
}
if (bizRes.code === 200) {
store.dictBusinessTypes = bizRes.data || []
}
}
async function loadVersionCheck() {
const res = await checkAppVersion()
if (res.code === 200 && res.data && res.data.needUpdate) {
updateUrl.value = res.data.downloadUrl || ''
showUpdate.value = true
}
}
function handleRefresh() {
loadCompanyList()
}
function goBack() {
uni.navigateBack({
fail() {
// H5下navigateBack失败时如页面栈只有一层回到portal
uni.reLaunch({ url: '/pages/portal/index' })
}
})
}
function goSearch() {
uni.navigateTo({ url: '/pages/search/index' })
}
function goSettings() {
uni.navigateTo({ url: '/pages/settings/index' })
}
function goRegion(item) {
uni.navigateTo({ url: '/pages/region/index?deptId=' + item.deptId })
}
onLoad(() => {
loadCompanyList()
loadDictData()
loadVersionCheck()
})
onPullDownRefresh(() => {
loadCompanyList().finally(() => {
uni.stopPullDownRefresh()
})
})
</script>
<style scoped>
.home-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-right {
display: flex;
align-items: center;
}
.nav-icon-ml {
margin-left: 24rpx;
}
.nav-title {
font-size: 34rpx;
font-weight: 600;
color: #fff;
}
.search-bar {
display: flex;
align-items: center;
margin: 16rpx 24rpx;
padding: 0 24rpx;
height: 72rpx;
background-color: rgba(255, 255, 255, 0.9);
border-radius: 36rpx;
}
.search-icon {
width: 32rpx;
height: 32rpx;
margin-right: 16rpx;
}
.search-placeholder {
font-size: 26rpx;
color: #999;
}
.company-list {
padding: 16rpx 24rpx;
height: calc(100vh - 400rpx);
}
.company-card {
display: flex;
align-items: center;
padding: 32rpx 24rpx;
margin-bottom: 20rpx;
background-color: #fff;
border-radius: 12rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
}
.company-name {
font-size: 30rpx;
font-weight: 500;
color: #333;
}
</style>