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

-8
View File
@@ -10,7 +10,6 @@
</view>
<scroll-view class="body" scroll-y>
<!-- 已绑定企业 -->
<view class="card">
<view class="card-head">
<text class="card-title">已绑定企业</text>
@@ -27,7 +26,6 @@
</view>
</view>
<!-- 绑定其他企业 -->
<view class="card">
<text class="card-title">绑定其他企业</text>
<view class="field">
@@ -75,7 +73,6 @@
<text class="form-tip">提交后由该企业管理员审核,通过后可在工作台切换企业</text>
</view>
<!-- 申请记录 -->
<view class="card">
<text class="card-title">申请记录</text>
<view v-if="!applies.length" class="empty">暂无申请记录</view>
@@ -96,10 +93,6 @@
</template>
<script setup>
/**
* 「我的 → 企业绑定」:展示已绑定的多租户,并向其他企业提交绑定申请。
* 复用挂靠申请链路(企业搜索 / 部门 / 职位 / 微信手机号只读 / 租户管理员审核)。
*/
import { ref, computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import {
@@ -144,7 +137,6 @@ async function loadStatus() {
tenants.value = list
applies.value = Array.isArray(res?.applies) ? res.applies : []
mobileMask.value = res?.mobile_mask || ''
// 同步本地企业列表,工作台右上角「切换」立即可用
setTenants(list.map((t) => ({ tid: t.tid, tenant_name: t.tenant_name })))
} catch (e) {
console.warn('[bindTenant] status failed:', e)
+277
View File
@@ -0,0 +1,277 @@
<template>
<view class="page">
<view class="nav" :style="headPad">
<view class="nav-back" @tap="goBack">
<FaIcon name="chevron-left" color="#1e293b" :size="18" />
<text class="nav-text">返回</text>
</view>
</view>
<view class="header">
<text class="title">修改密码</text>
<text class="subtitle">统一认证账号密码,修改后全端同步生效</text>
</view>
<view class="form-card">
<view class="field">
<text class="label">当前密码</text>
<view class="input-wrap">
<FaIcon name="lock" color="#94a3b8" :size="15" />
<input
v-model="form.old_password"
class="input"
:password="!showPassword"
placeholder="请输入当前密码"
placeholder-class="ph"
/>
<view class="eye" @tap="showPassword = !showPassword">
<FaIcon
:name="showPassword ? 'eye-slash' : 'eye'"
color="#a7b1c7"
:size="15"
/>
</view>
</view>
</view>
<view class="field">
<text class="label">新密码</text>
<view class="input-wrap">
<FaIcon name="key" color="#94a3b8" :size="15" />
<input
v-model="form.new_password"
class="input"
:password="!showPassword"
placeholder="至少 6 位字符"
placeholder-class="ph"
/>
</view>
</view>
<view class="field">
<text class="label">确认新密码</text>
<view class="input-wrap">
<FaIcon name="key" color="#94a3b8" :size="15" />
<input
v-model="form.confirm_password"
class="input"
:password="!showPassword"
placeholder="再次输入新密码"
placeholder-class="ph"
/>
</view>
</view>
<text v-if="errorText" class="error-text">{{ errorText }}</text>
<view class="submit" :class="{ disabled: submitting }" @tap="submit">
{{ submitting ? '提交中…' : '确认修改' }}
</view>
<view class="tip">
<FaIcon name="circle-info" color="#94a3b8" :size="12" />
<text class="tip-text">修改成功后手机端、Web 后台与小程序密码同时更新,无需重新登录。</text>
</view>
</view>
</view>
</template>
<script setup>
import { reactive, ref } from 'vue'
import { mpHeadPad } from '@/utils/mpHead.js'
import { changePassword } from '@/api/auth.js'
const headPad = mpHeadPad()
const form = reactive({
old_password: '',
new_password: '',
confirm_password: ''
})
const showPassword = ref(false)
const submitting = ref(false)
const errorText = ref('')
async function submit() {
if (submitting.value) return
errorText.value = ''
if (!form.old_password) {
errorText.value = '请输入当前密码'
return
}
if (!form.new_password || form.new_password.length < 6) {
errorText.value = '新密码长度不能少于 6 位'
return
}
if (form.new_password !== form.confirm_password) {
errorText.value = '两次输入的新密码不一致'
return
}
if (form.new_password === form.old_password) {
errorText.value = '新密码不能与当前密码相同'
return
}
submitting.value = true
try {
await changePassword({
old_password: form.old_password,
new_password: form.new_password,
confirm_password: form.confirm_password
})
uni.showToast({ title: '密码已修改', icon: 'success' })
setTimeout(() => {
goBack()
}, 700)
} catch (e) {
errorText.value = (e && e.message) || '修改失败,请重试'
} finally {
submitting.value = false
}
}
function goBack() {
uni.navigateBack({ fail: () => uni.reLaunch({ url: '/pages/nav/nav' }) })
}
</script>
<style lang="scss" scoped>
@import '@/src/styles/page-common.scss';
.page {
min-height: 100vh;
background: $color-bg-page;
padding: 0 $page-padding-x calc(env(safe-area-inset-bottom, 0px) + 40rpx);
box-sizing: border-box;
}
.nav {
padding-top: calc(var(--status-bar-height, 44px) + 16rpx);
/* #ifdef MP-WEIXIN */
padding-top: calc(env(safe-area-inset-top, 25px) + 80rpx);
/* #endif */
}
.nav-back {
display: flex;
align-items: center;
gap: 4rpx;
padding: 8rpx 0;
width: fit-content;
}
.nav-text {
font-size: 28rpx;
color: $color-text;
}
.header {
padding: 20rpx 0 32rpx;
}
.title {
display: block;
font-size: 44rpx;
font-weight: 600;
color: $color-text;
}
.subtitle {
display: block;
margin-top: 10rpx;
font-size: 24rpx;
color: $color-text-muted;
}
.form-card {
@include card;
padding: 32rpx 28rpx;
}
.field {
margin-bottom: 28rpx;
}
.label {
display: block;
margin-bottom: 12rpx;
font-size: 26rpx;
font-weight: 500;
color: $color-text-secondary;
}
.input-wrap {
display: flex;
align-items: center;
gap: 12rpx;
padding: 0 20rpx;
border-radius: $radius-md;
background: $color-bg-page;
border: 1rpx solid $color-border;
}
.input {
flex: 1;
min-width: 0;
height: 92rpx;
font-size: 30rpx;
color: $color-text;
}
.ph {
color: #adb6c9;
font-size: 28rpx;
}
.eye {
width: 52rpx;
height: 52rpx;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.error-text {
display: block;
margin-bottom: 8rpx;
font-size: 24rpx;
color: $color-danger;
}
.submit {
height: 96rpx;
margin-top: 16rpx;
border-radius: $radius-md;
background: $color-primary;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
font-weight: 600;
color: #ffffff;
&:active {
background: $color-primary-dark;
}
&.disabled {
opacity: 0.7;
}
}
.tip {
display: flex;
align-items: flex-start;
gap: 8rpx;
margin-top: 24rpx;
}
.tip-text {
flex: 1;
font-size: 22rpx;
line-height: 1.6;
color: $color-text-muted;
}
</style>
+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;