更新密码找回uniapp

This commit is contained in:
hero920103 committed 2026-11-16 17:22:50 +08:00
1 parent 7f9a66da0f
commit 3fdda89833
1304 files changed
+3503 -26132

No files matched your search

+89 -204
View File
@@ -1,6 +1,5 @@
<template>
<view class="page" :class="{ embedded }">
<!-- 独立页模式:渐变用户头部(嵌入 tabs.vue 时由父页提供顶部条) -->
<view v-if="!embedded" class="head" :style="headPad">
<view class="user">
<view class="avatar">
@@ -22,7 +21,6 @@
</view>
</view>
<!-- 用户卡(嵌入模式显示,独立页模式的用户信息已在头部) -->
<view v-if="embedded" class="user-card" @tap="goProfile">
<view class="avatar avatar-light">
<text class="avatar-text avatar-text-dark">{{ avatarText }}</text>
@@ -34,57 +32,51 @@
<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 class="menu-card">
<view class="menu-row" @tap="onSubscribe">
<view class="tint-icon row-icon tint-0">
<FaIcon name="bell" color="#ffffff" :size="16" />
</view>
<view class="row-main">
<text class="row-title">订阅消息提醒</text>
<text class="row-sub">审批、日程与公告的微信通知</text>
</view>
<text class="row-value">去开启</text>
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
</view>
</view>
<!-- 常用操作:分组卡片模板,一行 4 个 -->
<view class="group-card">
<view class="group-head">
<view class="group-bar" />
<text class="group-title">常用操作</text>
<view class="menu-card">
<view class="menu-row" @tap="goChangePassword">
<view class="tint-icon row-icon tint-1">
<FaIcon name="key" color="#ffffff" :size="16" />
</view>
<view class="row-main">
<text class="row-title">修改密码</text>
<text class="row-sub">定期更换密码,保障账号安全</text>
</view>
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
</view>
<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="menu-card">
<view class="menu-row" @tap="goHelp">
<view class="tint-icon row-icon tint-2">
<FaIcon name="circle-question" color="#ffffff" :size="16" />
</view>
<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 class="row-main">
<text class="row-title">帮助中心</text>
</view>
<!-- <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> -->
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
</view>
<view class="menu-row" @tap="goSettings">
<view class="tint-icon row-icon tint-3">
<FaIcon name="gear" color="#ffffff" :size="16" />
</view>
<view class="row-main">
<text class="row-title">设置</text>
</view>
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
</view>
</view>
@@ -100,15 +92,15 @@
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { 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 { logoutUAC, logoutApi } from '@/api/auth.js'
import { request } from '@/api/request.js'
import { clearHomeCache } from '@/api/workspace.js'
import { requestSubscribeNotice } from '@/utils/subscribe.js'
import { useSubsystem } from '@/utils/subsystem.js'
import AppTabbar from '@/components/AppTabbar.vue'
@@ -117,68 +109,33 @@ const props = defineProps({
embedded: { type: Boolean, default: false }
})
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 { loading, loadError, user, load } = useSubsystem(props.slug)
const avatarText = computed(() => {
const name = user.value.name || user.value.account || '云'
return String(name).charAt(0).toUpperCase()
})
async function loadStats() {
try {
const [p, d] = await Promise.all([
request({ url: '/api/schedule/list', data: { status: 'pending', pageSize: 50 } }),
request({ url: '/api/schedule/list', data: { status: 'done', pageSize: 50 } })
])
const pending = (p && p.list) || []
pendingCount.value = pending.length
overdue.value = pending.filter((s) => isOverdue(s)).length
doneCount.value = ((d && d.list) || []).length
} catch (e) {
pendingCount.value = 0
overdue.value = 0
doneCount.value = 0
}
}
function isOverdue(item) {
const t = String(item.schedule_time || item.created_at || '')
return t.length >= 10 && t.slice(0, 10) < todayStr()
}
function todayStr() {
const d = new Date()
const p = (n) => String(n).padStart(2, '0')
return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate())
}
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` })
}
function goProfile() {
uni.redirectTo({ url: '/pages/profile/profile' })
}
function onSubscribe() {
requestSubscribeNotice({ tip: '已开启消息提醒' })
}
function goChangePassword() {
uni.navigateTo({ url: '/pages/profile/changePassword' })
}
function goHelp() {
uni.navigateTo({ url: '/pages/common/developing?t=' + encodeURIComponent('帮助中心') })
}
function goSettings() {
uni.navigateTo({ url: '/pages/common/developing?t=' + encodeURIComponent('设置') })
}
function handleLogout() {
uni.showModal({
title: '提示',
@@ -187,7 +144,6 @@ function handleLogout() {
cancelText: '取消',
success(res) {
if (!res.confirm) return
// 统一认证:先吊销服务端会话与令牌
if (isSSOEnabled() && getToken()) {
logoutUAC().catch(() => {})
} else {
@@ -202,16 +158,13 @@ function handleLogout() {
}
onMounted(() => {
// 游客进入免登录模块:停留外壳,不拉受保护数据,也不强制跳登录
if (!isLoggedIn()) return
load()
loadStats()
})
onShow(() => {
if (isLoggedIn() && !loading.value) {
load()
loadStats()
}
})
</script>
@@ -222,13 +175,11 @@ 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;
@@ -242,7 +193,6 @@ onShow(() => {
display: flex;
align-items: center;
gap: 20rpx;
/* 取消顶部返回按钮后,补偿其占位 */
margin-top: 42rpx;
}
@@ -294,7 +244,6 @@ onShow(() => {
padding: 28rpx $page-padding-x 0;
}
/* ============ 嵌入模式的用户卡 ============ */
.user-card {
@include card;
display: flex;
@@ -329,126 +278,63 @@ onShow(() => {
color: $color-text-muted;
}
/* ============ 数据概览 ============ */
.kpi-card {
.menu-card {
@include card;
display: flex;
padding: 30rpx 0;
margin-bottom: 32rpx;
padding: 0 24rpx;
margin-bottom: 24rpx;
overflow: hidden;
}
.kpi-item {
flex: 1;
.menu-row {
display: flex;
flex-direction: column;
align-items: center;
gap: 6rpx;
position: relative;
gap: 18rpx;
padding: 26rpx 0;
& + &::before {
content: '';
position: absolute;
left: 0;
top: 6rpx;
bottom: 6rpx;
width: 1rpx;
background: $color-divider;
& + & {
border-top: 1rpx solid $color-divider;
}
&:active {
opacity: 0.75;
}
}
.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;
.row-icon {
@include tint-icon(64rpx, 18rpx);
flex-shrink: 0;
}
.group-title {
.row-main {
flex: 1;
min-width: 0;
}
.row-title {
display: block;
font-size: 28rpx;
font-weight: 600;
color: $color-text;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* 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%;
.row-sub {
display: block;
margin-top: 6rpx;
font-size: 22rpx;
line-height: 1.3;
color: $color-text;
text-align: center;
color: $color-text-muted;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.row-value {
flex-shrink: 0;
font-size: 24rpx;
color: $color-primary;
}
.logout {
@include card;
margin-top: 40rpx;
@@ -465,7 +351,6 @@ onShow(() => {
color: $color-danger;
}
/* ============ 错误态 ============ */
.err-box {
display: flex;
align-items: center;
@@ -500,4 +385,4 @@ onShow(() => {
.bottom-space {
height: 32rpx;
}
</style>
</style>