更新密码找回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

+140 -145
View File
@@ -13,53 +13,76 @@
<FaIcon name="pen-to-square" color="#ffffff" :size="16" />
</view>
</view>
<view class="profile-stats">
<view class="profile-stat" v-for="item in profileStats" :key="item.label">
<text class="stat-num">{{ item.value }}</text>
<text class="stat-label">{{ item.label }}</text>
</view>
</view>
</view>
<view class="main-scroll" style="margin-top:10rpx">
<view class="menu-group" v-for="(group, gIndex) in menuGroups" :key="gIndex">
<u-cell-group :border="false">
<u-cell
v-for="item in group"
:key="item.title"
:title="item.title"
is-link
@click="onMenuTap(item)"
>
<template #icon>
<view class="menu-icon">
<FaIcon :name="item.icon" color="#2563eb" :size="18" />
</view>
</template>
<template #value>
<text v-if="item.badge" class="menu-badge">{{ item.badge }}</text>
</template>
</u-cell>
</u-cell-group>
<scroll-view class="main-scroll" scroll-y>
<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>
<view class="logout-wrap">
<u-button
type="error"
plain
shape="circle"
text="退出登录"
@click="handleLogout"
/>
<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="menu-row" @tap="goBindTenant">
<view class="tint-icon row-icon tint-2">
<FaIcon name="building" 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>
<view class="menu-card">
<view class="menu-row" @tap="goHelp">
<view class="tint-icon row-icon tint-3">
<FaIcon name="circle-question" 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 class="menu-row" @tap="goSettings">
<view class="tint-icon row-icon tint-4">
<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>
<view class="logout" @tap="handleLogout">
<text class="logout-text">退出登录</text>
</view>
<view class="bottom-space" />
</view>
</scroll-view>
<AppTabbar current="profile" :tabs="profileTabs" />
<!-- 编辑资料:姓名 / 邮箱可改,手机号由微信验证只读 -->
<view v-if="editVisible" class="edit-mask" @tap="closeEdit">
<view class="edit-sheet" @tap.stop>
<view class="edit-head">
@@ -102,7 +125,6 @@ import AppTabbar from '@/components/MainTabbar.vue'
const user = ref(null)
// 个人中心底部只保留两项:左侧「我的」、右侧「回平台」(platform 由 MainTabbar 处理跳转)
const profileTabs = [
{ name: 'profile', text: '我的', icon: 'user' },
{ name: 'platform', text: '回平台', icon: 'arrow-left' }
@@ -122,31 +144,6 @@ const userId = computed(() => {
return '-'
})
const profileStats = ref([
{ label: '关注', value: '128' },
{ label: '粉丝', value: '256' },
{ label: '获赞', value: '1.2k' }
])
const menuGroups = ref([
[
{ title: '我的订单', icon: 'clipboard-list' },
{ title: '我的收藏', icon: 'star' },
{ title: '浏览历史', icon: 'clock-rotate-left' }
],
[
{ title: '企业绑定', icon: 'building' },
{ title: '消息通知', icon: 'bell', badge: '3' },
{ title: '账号安全', icon: 'lock' },
{ title: '隐私设置', icon: 'eye' }
],
[
{ title: '帮助中心', icon: 'circle-question' },
{ title: '关于我们', icon: 'circle-info' },
{ title: '设置', icon: 'gear' }
]
])
async function loadUser() {
user.value = getUser()
try {
@@ -162,27 +159,43 @@ async function loadUser() {
user.value = merged
}
} catch {
// 401 时 request 会跳转登录
user.value = getUser()
}
}
onMounted(() => {
if (!isLoggedIn()) {
// 新流程没有独立登录页:回平台点击模块即可重新授权手机号
uni.reLaunch({ url: '/pages/nav/nav' })
return
}
loadUser()
})
/* ==================== 编辑资料 ==================== */
function onSubscribe() {
requestSubscribeNotice({ tip: '已开启消息提醒' })
}
function goChangePassword() {
uni.navigateTo({ url: '/pages/profile/changePassword' })
}
function goBindTenant() {
uni.navigateTo({ url: '/pages/profile/bindTenant' })
}
function goHelp() {
uni.navigateTo({ url: '/pages/common/developing?t=' + encodeURIComponent('帮助中心') })
}
function goSettings() {
uni.navigateTo({ url: '/pages/common/developing?t=' + encodeURIComponent('设置') })
}
const editVisible = ref(false)
const saving = ref(false)
const editError = ref('')
const editForm = reactive({ name: '', email: '' })
// 手机号来自微信验证,只读展示(掩码),不随表单提交
const phoneText = computed(() => {
const u = user.value || {}
const p = u.phone || (u.account && /^1\d{10}$/.test(String(u.account)) ? String(u.account) : '')
@@ -235,25 +248,6 @@ async function saveProfile() {
}
}
function onMenuTap(item) {
if (item.title === '企业绑定') {
uni.navigateTo({ url: '/pages/profile/bindTenant' })
return
}
if (item.title === '账号安全') {
uni.navigateTo({ url: '/pages/login/forget' })
return
}
if (item.title === '消息通知') {
// 订阅消息授权:用户同意后,服务器才有一次主动推送的机会
requestSubscribeNotice()
return
}
uni.showToast({ title: item.title, icon: 'none' })
}
function handleLogout() {
uni.showModal({
title: '提示',
@@ -262,13 +256,11 @@ function handleLogout() {
cancelText: '取消',
success(res) {
if (!res.confirm) return
// 统一认证:先吊销服务端会话与令牌(默认 1 号 1 机,不吊销会占着名额)
if (isSSOEnabled() && getToken()) {
logoutUAC().catch(() => {})
} else {
logoutApi().catch(() => {})
}
// 再清本地并跳转,避免接口超时/失败导致“退出无效”
logout()
uni.reLaunch({ url: '/pages/nav/nav' })
}
@@ -322,7 +314,6 @@ function handleLogout() {
display: flex;
align-items: center;
gap: 24rpx;
/* 取消顶部回平台按钮后补偿占位,headPad 内联 paddingTop 继续避让状态栏/胶囊 */
margin-top: 20rpx;
position: relative;
z-index: 1;
@@ -380,84 +371,88 @@ function handleLogout() {
}
}
.profile-stats {
display: flex;
justify-content: space-around;
margin-top: 40rpx;
padding-top: 32rpx;
border-top: 1rpx solid rgba(255, 255, 255, 0.2);
position: relative;
z-index: 1;
}
.profile-stat {
display: flex;
flex-direction: column;
align-items: center;
}
.stat-num {
font-size: 36rpx;
font-weight: 600;
color: #ffffff;
}
.stat-label {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.75);
margin-top: 6rpx;
}
.main-scroll {
@include scroll-body;
margin-top: -20rpx;
}
.menu-group {
.menu-card {
@include card;
padding: 0 24rpx;
margin-bottom: 24rpx;
overflow: hidden;
border-radius: 16rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
transition: box-shadow 0.3s ease;
}
.menu-group:active {
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.12);
}
.menu-icon {
width: 56rpx;
height: 56rpx;
border-radius: 12rpx;
background: linear-gradient(135deg, rgba(57, 115, 255, 0.12) 0%, rgba(82, 168, 255, 0.14) 100%);
.menu-row {
display: flex;
align-items: center;
justify-content: center;
gap: 18rpx;
padding: 26rpx 0;
& + & {
border-top: 1rpx solid $color-divider;
}
&:active {
opacity: 0.75;
}
}
.row-icon {
@include tint-icon(64rpx, 18rpx);
flex-shrink: 0;
}
.menu-badge {
font-size: 20rpx;
font-weight: 600;
color: #ffffff;
background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
padding: 6rpx 14rpx;
border-radius: 12rpx;
min-width: 36rpx;
text-align: center;
line-height: 1.4;
box-shadow: 0 4rpx 12rpx rgba(37, 99, 235, 0.3);
.row-main {
flex: 1;
min-width: 0;
}
.logout-wrap {
margin-bottom: 12rpx;
.row-title {
display: block;
font-size: 28rpx;
color: $color-text;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.row-sub {
display: block;
margin-top: 6rpx;
font-size: 22rpx;
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: 12rpx;
padding: 28rpx 0;
text-align: center;
&:active {
background: $color-bg-page;
}
}
.logout-text {
font-size: 28rpx;
color: $color-danger;
}
.bottom-space {
height: 48rpx;
}
/* ============ 编辑资料弹层 ============ */
.edit-mask {
position: fixed;
left: 0;