This commit is contained in:
lik
2026-09-03 13:29:39 +08:00
parent 16ba1f654a
commit e7b27888e3
17 changed files with 565 additions and 265 deletions
+32 -35
View File
@@ -3,8 +3,9 @@ const API = require('../../utils/api.js')
Page({
data: {
isLoggedIn: false,
userInfo: null,
phoneNumber: '',
displayName: '',
avatar: '',
levelText: '初级陪诊员',
version: '1.0.0',
showLoginPopup: false,
loginForm: {
@@ -12,7 +13,7 @@ Page({
mobile: ''
},
menuList: [
{ icon: 'user', title: '个人资料', url: '' },
{ icon: 'user', title: '个人资料', url: '/pages/me/index' },
{ icon: 'notification', title: '消息通知', url: '' },
{ icon: 'lock-on', title: '账号安全', url: '' },
{ icon: 'help-circle', title: '帮助中心', url: '' },
@@ -38,28 +39,34 @@ Page({
},
onUserLogin(user) {
this.setData({
isLoggedIn: true,
userInfo: user,
phoneNumber: this.maskPhoneNumber(user.mobile || '')
})
this.applyUser(user)
},
checkLoginStatus() {
const app = getApp()
const user = app.globalData.user
if (user && user.security && user.security.token) {
this.setData({
isLoggedIn: true,
userInfo: user,
phoneNumber: this.maskPhoneNumber(user.mobile || '')
})
}
this.applyUser(app.globalData.user)
},
maskPhoneNumber(phone) {
if (!phone || phone.length < 7) return phone
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
/**
* 将用户对象映射为页面展示字段(真实信息)
*/
applyUser(user) {
if (!user || !user.security || !user.security.token) {
this.setData({
isLoggedIn: false,
displayName: '',
avatar: '',
levelText: '初级陪诊员'
})
return
}
const p = user.profile || {}
this.setData({
isLoggedIn: true,
displayName: p.name || '管理员',
avatar: p.avatar || '',
levelText: user.level || p.level || '初级陪诊员'
})
},
getAppVersion() {
@@ -112,14 +119,12 @@ Page({
if (data.code == 0) {
const app = getApp()
app.globalData.user = data.data.user
this.applyUser(app.globalData.user)
this.setData({
isLoggedIn: true,
userInfo: app.globalData.user,
phoneNumber: this.maskPhoneNumber(app.globalData.user.profile.mobile || ''),
showLoginPopup: false,
loginForm: { name: '', mobile: '' }
})
wx.showToast({ title: '登录成功', icon: 'success' })
} else {
wx.showToast({ title: '登录失败', icon: 'none' })
@@ -159,7 +164,7 @@ Page({
wx.showModal({
title: '退出登录',
content: '确定要退出登录吗?',
confirmColor: '#4c6ef5',
confirmColor: '#1a8a63',
success: (res) => {
if (res.confirm) {
wx.showLoading({ title: '退出中...' })
@@ -183,11 +188,7 @@ Page({
wx.removeStorageSync('admin_ai_session_id')
wx.removeStorageSync('admin_ai_chat_history')
this.setData({
isLoggedIn: false,
userInfo: null,
phoneNumber: ''
})
this.applyUser(null)
wx.showToast({ title: '已退出登录', icon: 'success' })
},
@@ -200,18 +201,14 @@ Page({
wx.showModal({
title: '清除缓存',
content: '确定要清除所有缓存数据吗?',
confirmColor: '#4c6ef5',
confirmColor: '#1a8a63',
success: (res) => {
if (res.confirm) {
wx.clearStorage({
success: () => {
const app = getApp()
app.globalData.user = null
this.setData({
isLoggedIn: false,
userInfo: null,
phoneNumber: ''
})
this.applyUser(null)
wx.showToast({ title: '缓存已清除', icon: 'success' })
}
})
+32 -21
View File
@@ -1,21 +1,23 @@
<view class="set-page">
<!-- 用户信息卡片 -->
<!-- 用户卡片 -->
<view class="user-card">
<view class="user-info" wx:if="{{isLoggedIn}}">
<view class="user-avatar">
<text class="avatar-text">{{userInfo.nickname ? userInfo.nickname[0] : '管'}}</text>
<image wx:if="{{avatar}}" class="avatar-img" src="{{avatar}}" mode="aspectFill" />
<text wx:else class="avatar-text">{{displayName[0]}}</text>
</view>
<view class="user-detail">
<text class="user-name">{{userInfo.nickname || '管理员'}}</text>
<text class="user-phone">{{phoneNumber}}</text>
</view>
<view class="logout-btn" bindtap="onLogout">
<text class="logout-text">退出</text>
<view class="name-row">
<text class="user-name">{{displayName}}</text>
<view class="level-tag">
<text class="level-text">{{levelText}}</text>
</view>
</view>
</view>
</view>
<view class="user-info login-area" wx:else>
<view class="user-avatar default-avatar">
<t-icon name="user" size="40rpx" color="#9ca3af" />
<t-icon name="user" size="40rpx" color="#8f9d97" />
</view>
<view class="user-detail">
<text class="login-title">未登录</text>
@@ -28,31 +30,40 @@
</view>
<!-- 菜单列表 -->
<view class="menu-section">
<view class="menu-list">
<view class="section">
<view class="menu-list card">
<view class="menu-item" wx:for="{{menuList}}" wx:key="index" data-index="{{index}}" bindtap="onMenuTap">
<view class="menu-left">
<t-icon name="{{item.icon}}" size="32rpx" color="#4c6ef5" />
<view class="menu-icon">
<t-icon name="{{item.icon}}" size="32rpx" color="#1a8a63" />
</view>
<text class="menu-title">{{item.title}}</text>
</view>
<view class="menu-right">
<t-icon name="chevron-right" size="28rpx" color="#9ca3af" />
</view>
<t-icon name="chevron-right" size="28rpx" color="#b7c6c0" />
</view>
</view>
</view>
<!-- 系统操作 -->
<view class="menu-section">
<view class="menu-list">
<view class="section">
<view class="menu-list card">
<view class="menu-item" bindtap="onClearCache">
<view class="menu-left">
<t-icon name="delete" size="32rpx" color="#ff6b6b" />
<view class="menu-icon danger-bg">
<t-icon name="delete" size="32rpx" color="#e05a4e" />
</view>
<text class="menu-title danger">清除缓存</text>
</view>
<view class="menu-right">
<t-icon name="chevron-right" size="28rpx" color="#9ca3af" />
<t-icon name="chevron-right" size="28rpx" color="#b7c6c0" />
</view>
<view class="menu-item" wx:if="{{isLoggedIn}}" bindtap="onLogout">
<view class="menu-left">
<view class="menu-icon danger-bg">
<t-icon name="logout" size="32rpx" color="#e05a4e" />
</view>
<text class="menu-title danger">退出登录</text>
</view>
<t-icon name="chevron-right" size="28rpx" color="#b7c6c0" />
</view>
</view>
</view>
@@ -78,7 +89,7 @@
</view>
<view class="popup-footer">
<view class="submit-btn" bindtap="onLoginSubmit">
<text class="submit-btn-text">登录</text>
<text class="submit-btn-text">登 录</text>
</view>
</view>
</view>
@@ -86,6 +97,6 @@
<!-- 版本信息 -->
<view class="version-info">
<text class="version-text">版本 {{version}}</text>
<text class="version-text">暖橙陪诊 · {{version}}</text>
</view>
</view>
+121 -96
View File
@@ -1,56 +1,104 @@
page {
background-color: #f5f6fa;
background: linear-gradient(180deg, #eaf6f1 0%, #f5f6fa 360rpx);
color: #1a1a2e;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
.set-page {
padding: 24rpx;
padding: 24rpx 24rpx 64rpx;
min-height: 100vh;
box-sizing: border-box;
}
/* === 用户卡片(翡翠绿,呼应首页头部) === */
.user-card {
background-color: #ffffff;
border-radius: 24rpx;
border: 1rpx solid #e5e7eb;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
position: relative;
overflow: hidden;
margin-bottom: 24rpx;
background: linear-gradient(135deg, #29b785 0%, #1a8a63 100%);
border-radius: 28rpx;
box-shadow: 0 12rpx 32rpx rgba(26, 138, 99, 0.25);
margin-bottom: 32rpx;
}
.user-card::before,
.user-card::after {
content: '';
position: absolute;
border-radius: 50%;
background: rgba(255, 255, 255, 0.07);
pointer-events: none;
}
.user-card::before {
width: 240rpx;
height: 240rpx;
top: -110rpx;
right: -60rpx;
}
.user-card::after {
width: 140rpx;
height: 140rpx;
bottom: -70rpx;
left: -30rpx;
background: rgba(255, 255, 255, 0.05);
}
.user-info {
position: relative;
z-index: 1;
display: flex;
align-items: center;
padding: 40rpx 32rpx;
padding: 44rpx 32rpx;
gap: 24rpx;
}
.user-info.login-area {
align-items: center;
}
.user-avatar {
width: 100rpx;
height: 100rpx;
background: linear-gradient(135deg, #4c6ef5, #748ffc);
width: 104rpx;
height: 104rpx;
background-color: rgba(255, 255, 255, 0.2);
border: 2rpx solid rgba(255, 255, 255, 0.45);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
box-shadow: 0 4rpx 12rpx rgba(76, 110, 245, 0.25);
}
.user-avatar.default-avatar {
background: #f3f4f6;
box-shadow: none;
background-color: rgba(255, 255, 255, 0.16);
}
.avatar-text {
font-size: 36rpx;
font-size: 40rpx;
font-weight: 600;
color: #ffffff;
}
.avatar-img {
width: 100%;
height: 100%;
border-radius: 50%;
}
.name-row {
display: flex;
align-items: center;
}
.level-tag {
margin-left: 12rpx;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 16rpx;
padding: 4rpx 14rpx;
flex-shrink: 0;
}
.level-text {
font-size: 20rpx;
color: #ffffff;
}
.user-detail {
flex: 1;
display: flex;
@@ -58,95 +106,61 @@ page {
gap: 8rpx;
}
.user-name {
font-size: 32rpx;
font-weight: 600;
color: #1a1a2e;
}
.user-phone {
font-size: 26rpx;
color: #9ca3af;
}
.user-name,
.login-title {
font-size: 32rpx;
font-weight: 600;
color: #1a1a2e;
font-size: 34rpx;
font-weight: 700;
color: #ffffff;
}
.login-desc {
font-size: 24rpx;
color: #9ca3af;
}
.logout-btn {
padding: 12rpx 28rpx;
background-color: rgba(255, 107, 107, 0.1);
border-radius: 28rpx;
display: flex;
align-items: center;
justify-content: center;
}
.logout-btn:active {
transform: scale(0.95);
opacity: 0.9;
}
.logout-text {
font-size: 24rpx;
color: #ff6b6b;
font-weight: 500;
color: rgba(255, 255, 255, 0.65);
}
.login-btn {
margin: 0;
padding: 16rpx 32rpx;
background: linear-gradient(135deg, #4c6ef5, #748ffc);
padding: 14rpx 32rpx;
background-color: #ffffff;
border-radius: 28rpx;
display: flex;
align-items: center;
justify-content: center;
line-height: 1;
border: none;
}
.login-btn::after {
border: none;
}
.login-btn:active {
transform: scale(0.95);
opacity: 0.9;
}
.login-btn-text {
font-size: 26rpx;
color: #ffffff;
font-weight: 500;
color: #1a8a63;
font-weight: 600;
}
.menu-section {
background-color: #ffffff;
border-radius: 24rpx;
border: 1rpx solid #e5e7eb;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
overflow: hidden;
/* === 菜单分组 === */
.section {
margin-bottom: 24rpx;
}
.card {
background-color: #ffffff;
border-radius: 24rpx;
border: 1rpx solid rgba(31, 61, 56, 0.06);
box-shadow: 0 6rpx 20rpx rgba(31, 61, 56, 0.07);
}
.menu-list {
padding: 0 32rpx;
padding: 8rpx 28rpx;
}
.menu-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 32rpx 0;
border-bottom: 1rpx solid #f3f4f6;
transition: background-color 0.2s ease;
padding: 28rpx 0;
border-bottom: 1rpx solid rgba(31, 61, 56, 0.06);
transition: opacity 0.2s ease;
}
.menu-item:last-child {
@@ -154,7 +168,7 @@ page {
}
.menu-item:active {
background-color: rgba(76, 110, 245, 0.05);
opacity: 0.6;
}
.menu-left {
@@ -163,21 +177,31 @@ page {
gap: 20rpx;
}
.menu-icon {
width: 64rpx;
height: 64rpx;
border-radius: 18rpx;
background-color: rgba(26, 138, 99, 0.08);
display: flex;
align-items: center;
justify-content: center;
}
.menu-icon.danger-bg {
background-color: rgba(224, 90, 78, 0.08);
}
.menu-title {
font-size: 28rpx;
color: #1a1a2e;
color: #1a1a1a;
font-weight: 500;
}
.menu-title.danger {
color: #ff6b6b;
}
.menu-right {
display: flex;
align-items: center;
color: #e05a4e;
}
/* === 版本信息 === */
.version-info {
display: flex;
align-items: center;
@@ -187,17 +211,17 @@ page {
.version-text {
font-size: 24rpx;
color: #9ca3af;
color: #9fb0a9;
}
/* 登录弹窗 */
/* === 登录弹窗 === */
.login-popup {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
background-color: rgba(0, 0, 0, 0.45);
display: flex;
align-items: center;
justify-content: center;
@@ -205,12 +229,12 @@ page {
}
.login-popup-content {
width: 80%;
width: 82%;
max-width: 600rpx;
background-color: #ffffff;
border-radius: 24rpx;
border-radius: 28rpx;
overflow: hidden;
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.12);
box-shadow: 0 16rpx 48rpx rgba(31, 61, 56, 0.18);
}
.popup-header {
@@ -223,7 +247,7 @@ page {
.popup-title {
font-size: 32rpx;
font-weight: 600;
color: #1a1a2e;
color: #1a1a1a;
}
.popup-close {
@@ -262,17 +286,17 @@ page {
.form-input {
width: 100%;
height: 80rpx;
background-color: #f5f6fa;
background-color: #f7f9f8;
border-radius: 16rpx;
padding: 0 24rpx;
font-size: 28rpx;
color: #1a1a2e;
color: #1a1a1a;
box-sizing: border-box;
border: 1rpx solid #e5e7eb;
border: 1rpx solid #e5eae8;
}
.form-input:focus {
border-color: #4c6ef5;
border-color: #1a8a63;
}
.popup-footer {
@@ -282,12 +306,12 @@ page {
.submit-btn {
width: 100%;
height: 88rpx;
background: linear-gradient(135deg, #4c6ef5, #748ffc);
background: linear-gradient(135deg, #29b785, #1a8a63);
border-radius: 44rpx;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4rpx 16rpx rgba(76, 110, 245, 0.25);
box-shadow: 0 6rpx 18rpx rgba(26, 138, 99, 0.28);
transition: all 0.2s ease;
}
@@ -300,4 +324,5 @@ page {
font-size: 30rpx;
color: #ffffff;
font-weight: 600;
letter-spacing: 4rpx;
}