主要更新uniapp相关功能

This commit is contained in:
hero920103 committed 2026-10-07 00:59:05 +08:00
1 parent aa92ca40a2
commit 5b4dbb2b46
65 files changed
+8532 -1921

No files matched your search

+264 -223
View File
@@ -1,6 +1,7 @@
<template>
<view class="page">
<view class="head">
<template>
<view class="page" :class="{ embedded }">
<!-- 独立页模式:渐变用户头部(嵌入 tabs.vue 时由父页提供顶部条) -->
<view v-if="!embedded" class="head" :style="headPad">
<view class="head-row" @tap="goBackNav">
<FaIcon name="chevron-left" color="#ffffff" :size="18" />
<text class="head-back">返回导航</text>
@@ -25,68 +26,69 @@
</view>
</view>
<!-- 当前子系统 -->
<view class="block">
<view class="block-head"><text class="block-title">当前子系统</text></view>
<view class="card-row">
<view class="tint-icon row-icon" :class="sub.tint">
<FaIcon :name="sub.icon" color="#ffffff" :size="22" />
</view>
<view class="row-meta">
<text class="row-title">{{ sub.title }}</text>
<text class="row-sub">{{ allMenus.length }} 个功能 · {{ enabled ? '已开通' : '未开通' }}</text>
</view>
<text v-if="!enabled" class="lock-tag">未开通</text>
<!-- 用户卡(嵌入模式显示,独立页模式的用户信息已在头部) -->
<view v-if="embedded" class="user-card" @tap="goProfile">
<view class="avatar avatar-light">
<text class="avatar-text avatar-text-dark">{{ avatarText }}</text>
</view>
<view class="user-meta">
<text class="user-name user-name-dark">{{ user.name || '云泽用户' }}</text>
<text class="user-sub">{{ user.tenant || '云泽平台' }}<text v-if="user.account"> · {{ user.account }}</text></text>
</view>
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
</view>
<!-- 数据概览 -->
<view class="kpi-card">
<view class="kpi-item">
<text class="kpi-value">{{ pendingCount }}</text>
<text class="kpi-label">待办</text>
</view>
<view class="kpi-item">
<text class="kpi-value">{{ doneCount }}</text>
<text class="kpi-label">已完成</text>
</view>
<view class="kpi-item">
<text class="kpi-value" :class="{ warn: overdue > 0 }">{{ overdue }}</text>
<text class="kpi-label">已逾期</text>
</view>
<view class="kpi-item">
<text class="kpi-value">{{ leafMenus.length }}</text>
<text class="kpi-label">可用功能</text>
</view>
</view>
<!-- 我的数据 -->
<view class="block">
<view class="block-head"><text class="block-title">我的数据</text></view>
<view class="kpi">
<view class="kpi-item">
<text class="kpi-value" :class="{ warn: overdue > 0 }">{{ pendingCount }}</text>
<text class="kpi-label">待办</text>
</view>
<view class="kpi-item">
<text class="kpi-value" :class="{ warn: overdue > 0 }">{{ overdue }}</text>
<text class="kpi-label">已逾期</text>
</view>
<view class="kpi-item">
<text class="kpi-value">{{ doneCount }}</text>
<text class="kpi-label">已完成</text>
</view>
<view class="kpi-item">
<text class="kpi-value">{{ allMenus.length }}</text>
<text class="kpi-label">可用功能</text>
</view>
<!-- 常用操作:分组卡片模板,一行 4 个 -->
<view class="group-card">
<view class="group-head">
<view class="group-bar" />
<text class="group-title">常用操作</text>
<text class="group-count">3</text>
</view>
</view>
<!-- 操作 -->
<view class="block">
<view class="block-head"><text class="block-title">操作</text></view>
<view class="list-card">
<!-- 仅该子系统在 Web 端确有对应系统时展示(config/subsystems.js 的 webEntry) -->
<view v-if="sub.webEntry" class="list-item" @tap="enterSystem">
<view class="item-icon"><FaIcon name="display" color="#3973ff" :size="16" /></view>
<text class="item-text">进入完整系统(Web 端)</text>
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
<view class="grid">
<view class="cell" @tap="goFunctions">
<view class="fn-card">
<view class="tint-icon fn-icon tint-0">
<FaIcon name="table-cells" color="#ffffff" :size="18" />
</view>
<text class="fn-name">全部功能</text>
</view>
</view>
<view class="list-item" @tap="goFunctions">
<view class="item-icon"><FaIcon name="table-cells" color="#3973ff" :size="16" /></view>
<text class="item-text">全部功能</text>
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
<view class="cell" @tap="goProfile">
<view class="fn-card">
<view class="tint-icon fn-icon tint-1">
<FaIcon name="user" color="#ffffff" :size="18" />
</view>
<text class="fn-name">账号与安全</text>
</view>
</view>
<view class="list-item" @tap="goProfile">
<view class="item-icon"><FaIcon name="user" color="#3973ff" :size="16" /></view>
<text class="item-text">账号与安全</text>
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
</view>
<view class="list-item" @tap="goBackNav">
<view class="item-icon"><FaIcon name="table-cells" color="#3973ff" :size="16" /></view>
<text class="item-text">切换子系统</text>
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
<view class="cell" @tap="goBackNav">
<view class="fn-card">
<view class="tint-icon fn-icon tint-2">
<FaIcon name="arrow-right-arrow-left" color="#ffffff" :size="18" />
</view>
<text class="fn-name">切换子系统</text>
</view>
</view>
</view>
</view>
@@ -98,15 +100,17 @@
<view class="bottom-space" />
</view>
<AppTabbar :group="slug" current="mine" />
<AppTabbar v-if="!embedded" :group="slug" current="mine" />
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { mpHeadPad } from '@/utils/mpHead.js'
const headPad = mpHeadPad()
import { onShow } from '@dcloudio/uni-app'
import { isLoggedIn, logout, isSSOEnabled, getToken, clearPendingAuth } from '@/utils/auth.js'
import { openWebPage } from '@/utils/nav.js'
import { logoutUAC, logoutApi } from '@/api/auth.js'
import { request } from '@/api/request.js'
import { clearHomeCache } from '@/api/workspace.js'
@@ -114,15 +118,17 @@ import { useSubsystem } from '@/utils/subsystem.js'
import AppTabbar from '@/components/AppTabbar.vue'
const props = defineProps({
slug: { type: String, required: true }
slug: { type: String, required: true },
embedded: { type: Boolean, default: false }
})
const { sub, loading, loadError, user, allMenus, enabled, moduleMeta, load } = useSubsystem(props.slug)
const emit = defineEmits(['switch-tab', 'back'])
const { sub, loading, loadError, user, leafMenus, load } = useSubsystem(props.slug)
const pendingCount = ref(0)
const overdue = ref(0)
const doneCount = ref(0)
const entering = ref(false)
const avatarText = computed(() => {
const name = user.value.name || user.value.account || '云'
@@ -158,10 +164,19 @@ function todayStr() {
}
function goBackNav() {
if (props.embedded) {
emit('back')
return
}
uni.reLaunch({ url: '/pages/nav/nav' })
}
// 「功能」页签在 TAB_ORDER 中的下标为 1
function goFunctions() {
if (props.embedded) {
emit('switch-tab', 1)
return
}
uni.redirectTo({ url: `/pages/${props.slug}/functions/functions` })
}
@@ -169,25 +184,6 @@ function goProfile() {
uni.redirectTo({ url: '/pages/profile/profile' })
}
/** 打开 Web 端该模块首页(走票据免登录) */
async function enterSystem() {
if (entering.value) return
const target =
(moduleMeta.value && moduleMeta.value.path) ||
(allMenus.value[0] && allMenus.value[0].path) ||
''
if (!target) {
uni.showToast({ title: '该系统暂未开放', icon: 'none' })
return
}
entering.value = true
try {
await openWebPage(target, sub.name)
} finally {
entering.value = false
}
}
function handleLogout() {
uni.showModal({
title: '提示',
@@ -232,12 +228,20 @@ onShow(() => {
.page {
@include page-shell;
// 嵌入模式下由父页(tabs.vue)的 scroll-view 统一滚动,这里改为自然高度
&.embedded {
height: auto;
}
}
/* ============ 顶部用户区 ============ */
/* ============ 独立页模式的渐变用户头部 ============ */
.head {
flex-shrink: 0;
padding: calc(var(--status-bar-height, 44px) + 20rpx) $page-padding-x 40rpx;
/* #ifdef MP-WEIXIN */
padding-top: calc(env(safe-area-inset-top, 25px) + 84rpx);
/* #endif */
background: $hero-gradient;
}
@@ -273,7 +277,7 @@ onShow(() => {
}
.avatar-text {
font-size: 40rpx;
font-size: 38rpx;
font-weight: 600;
color: #ffffff;
}
@@ -293,40 +297,204 @@ onShow(() => {
.user-sub {
display: block;
margin-top: 8rpx;
font-size: 23rpx;
font-size: 22rpx;
color: rgba(255, 255, 255, 0.8);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* ============ 内容区 ============ */
.body {
flex: 1;
min-height: 0;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
padding: 24rpx $page-padding-x 0;
padding: 28rpx $page-padding-x 0;
}
.block {
/* ============ 嵌入模式的用户卡 ============ */
.user-card {
@include card;
display: flex;
align-items: center;
gap: 20rpx;
padding: 28rpx 24rpx;
margin-bottom: 32rpx;
&:active {
background: $color-bg-page;
}
}
.avatar-light {
width: 88rpx;
height: 88rpx;
background: $color-primary-bg;
border: none;
}
.avatar-text-dark {
font-size: 34rpx;
color: $color-primary;
}
.user-name-dark {
font-size: 32rpx;
color: $color-text;
}
.user-card .user-sub {
color: $color-text-muted;
}
/* ============ 数据概览 ============ */
.kpi-card {
@include card;
display: flex;
padding: 30rpx 0;
margin-bottom: 32rpx;
}
.block-head {
@include block-head;
.kpi-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
gap: 6rpx;
position: relative;
& + &::before {
content: '';
position: absolute;
left: 0;
top: 6rpx;
bottom: 6rpx;
width: 1rpx;
background: $color-divider;
}
}
.block-title {
@include section-title;
.kpi-value {
font-size: 40rpx;
font-weight: 600;
line-height: 1.1;
color: $color-text;
&.warn {
color: $color-danger;
}
}
.kpi-label {
font-size: 22rpx;
color: $color-text-muted;
}
/* ============ 常用操作:分组卡 + 一行 4 个格子 ============ */
.group-card {
@include card;
padding: 24rpx 20rpx 8rpx;
}
.group-head {
display: flex;
align-items: center;
gap: 14rpx;
padding: 0 4rpx 20rpx;
}
.group-bar {
width: 6rpx;
height: 28rpx;
border-radius: $radius-full;
background: $color-primary;
flex-shrink: 0;
}
.group-title {
flex: 1;
min-width: 0;
font-size: 28rpx;
font-weight: 600;
color: $color-text;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.group-count {
@include chip;
flex-shrink: 0;
}
/* cell 占 25% 并自带右间隙,容器负 margin 抵消末列间隙 */
.grid {
display: flex;
flex-wrap: wrap;
margin-right: -16rpx;
}
.cell {
width: 25%;
padding-right: 16rpx;
margin-bottom: 16rpx;
box-sizing: border-box;
}
.fn-card {
height: 100%;
padding: 18rpx 6rpx 16rpx;
border-radius: $radius-md;
background: $color-bg-page;
display: flex;
flex-direction: column;
align-items: center;
gap: 12rpx;
transition: transform 0.15s ease;
&:active {
transform: scale(0.95);
}
}
.fn-icon {
@include tint-icon(64rpx, 18rpx);
}
.fn-name {
max-width: 100%;
font-size: 22rpx;
line-height: 1.3;
color: $color-text;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.logout {
@include card;
margin-top: 40rpx;
padding: 28rpx 0;
text-align: center;
&:active {
background: $color-bg-page;
}
}
.logout-text {
font-size: 28rpx;
color: $color-danger;
}
/* ============ 错误态 ============ */
.err-box {
display: flex;
align-items: center;
gap: 16rpx;
margin-bottom: 24rpx;
padding: 24rpx 22rpx;
margin-bottom: 24rpx;
background: #fef3f2;
border: 1rpx solid #fdd8d4;
border-radius: $radius-md;
@@ -352,134 +520,7 @@ onShow(() => {
word-break: break-all;
}
/* 当前子系统行 */
.card-row {
@include card;
display: flex;
align-items: center;
gap: 18rpx;
padding: 26rpx 24rpx;
}
.row-icon {
@include tint-icon(80rpx, 20rpx);
}
.row-meta {
flex: 1;
min-width: 0;
}
.row-title {
display: block;
font-size: 30rpx;
font-weight: 600;
color: $color-text;
}
.row-sub {
display: block;
margin-top: 6rpx;
font-size: 22rpx;
color: $color-text-muted;
}
.lock-tag {
@include chip(#fef3f2, $color-danger);
}
/* 数据概览 */
.kpi {
@include card;
display: flex;
padding: 28rpx 0;
}
.kpi-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
gap: 6rpx;
position: relative;
& + &::before {
content: '';
position: absolute;
left: 0;
top: 6rpx;
bottom: 6rpx;
width: 1rpx;
background: $color-divider;
}
}
.kpi-value {
font-size: 36rpx;
font-weight: 600;
color: $color-text;
&.warn {
color: $color-danger;
}
}
.kpi-label {
font-size: 21rpx;
color: $color-text-muted;
}
/* 操作列表 */
.list-card {
@include card;
overflow: hidden;
}
.list-item {
display: flex;
align-items: center;
gap: 18rpx;
padding: 26rpx 24rpx;
& + & {
border-top: 1rpx solid $color-divider;
}
&:active {
background: $color-bg-page;
}
}
.item-icon {
@include icon-box(56rpx);
}
.item-text {
flex: 1;
min-width: 0;
font-size: 28rpx;
color: $color-text;
}
/* 退出 */
.logout {
@include card;
height: 100rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12rpx;
background: linear-gradient(135deg, rgba(240, 68, 56, 0.08) 0%, rgba(240, 68, 56, 0.04) 100%);
border: 1rpx solid rgba(240, 68, 56, 0.2);
}
.logout-text {
font-size: 30rpx;
font-weight: 600;
color: $color-danger;
}
.bottom-space {
height: 48rpx;
height: 32rpx;
}
</style>
</style>