优化店务小程序个人中心界面

This commit is contained in:
2026-07-24 17:20:44 +08:00
parent 4f9962ec71
commit 32924f8e36
8 changed files with 1152 additions and 433 deletions
+9
View File
@@ -0,0 +1,9 @@
const request = require('../utils/request')
module.exports = {
stats() {
return request({
url: '/dashboard/stats'
})
}
}
@@ -1,53 +1,26 @@
<view class="page no-tab profile-settings-page"> <view class="page no-tab profile-settings-page">
<view wx:if="{{loading}}" class="loading-state">个人资料加载中</view> <view wx:if="{{loading}}" class="loading-state">个人资料加载中</view>
<block wx:else> <block wx:else>
<view class="page-heading"> <view class="profile-hero">
<text class="page-title">个人资料</text> <view class="hero-main">
<text class="page-subtitle">把你的姓名、联系方式和头像整理成店内可识别的名片。</text> <view wx:if="{{profileForm.avatar}}" class="hero-avatar image-avatar">
</view>
<view class="portrait-card">
<view class="portrait-glow"></view>
<view class="portrait-main">
<view wx:if="{{profileForm.avatar}}" class="portrait-avatar image-avatar">
<image src="{{profileForm.avatar}}" mode="aspectFill"></image> <image src="{{profileForm.avatar}}" mode="aspectFill"></image>
</view> </view>
<view wx:else class="portrait-avatar portrait-empty">头像</view> <view wx:else class="hero-avatar hero-avatar-empty">头像</view>
<view class="portrait-copy"> <view class="hero-copy">
<text class="portrait-name">{{profileForm.nickname || userInfo.nickname || '个人头像'}}</text> <view class="hero-title-row">
<text class="portrait-desc">{{roleText}} · {{shopName}}</text> <text class="hero-title">{{profileForm.nickname || userInfo.nickname || '个人资料'}}</text>
<text class="role-badge">{{roleText}}</text>
</view>
<text class="hero-shop">{{shopName}}</text>
<button class="avatar-change-btn" loading="{{avatarUploading}}" disabled="{{loading || avatarUploading || profileSaving}}" bindtap="chooseProfileAvatar">{{avatarUploading ? '上传中' : profileForm.avatar ? '更换头像' : '上传头像'}}</button>
</view> </view>
</view> </view>
<view class="portrait-actions"> <button wx:if="{{profileForm.avatar}}" class="avatar-remove" disabled="{{loading || avatarUploading || profileSaving}}" bindtap="removeProfileAvatar">移除头像</button>
<button class="avatar-btn" loading="{{avatarUploading}}" disabled="{{loading || avatarUploading || profileSaving}}" bindtap="chooseProfileAvatar">{{avatarUploading ? '上传中' : profileForm.avatar ? '更换头像' : '上传头像'}}</button>
<button wx:if="{{profileForm.avatar}}" class="avatar-remove" disabled="{{loading || avatarUploading || profileSaving}}" bindtap="removeProfileAvatar">移除</button>
</view>
</view> </view>
<view class="info-grid"> <view class="info-card">
<view class="info-tile"> <text class="card-title">基础资料</text>
<text>登录账号</text>
<view>{{userInfo.account || '未设置'}}</view>
</view>
<view class="info-tile">
<text>身份</text>
<view>{{roleText}}</view>
</view>
<view class="info-tile">
<text>登录手机号</text>
<view>{{userInfo.phone || '未绑定'}}</view>
</view>
<view class="info-tile">
<text>当前店铺</text>
<view>{{shopName}}</view>
</view>
</view>
<view class="card form-card">
<view class="form-header">
<text class="form-kicker">资料档案</text>
<text class="form-title">用于店内识别与客户沟通</text>
</view>
<view class="profile-field"> <view class="profile-field">
<text class="field-label required-label">昵称</text> <text class="field-label required-label">昵称</text>
<input value="{{profileForm.nickname}}" data-field="nickname" bindinput="onProfileInput" placeholder="请输入昵称" /> <input value="{{profileForm.nickname}}" data-field="nickname" bindinput="onProfileInput" placeholder="请输入昵称" />
@@ -61,13 +34,33 @@
<input value="{{profileForm.wechatId}}" data-field="wechatId" bindinput="onProfileInput" placeholder="请输入微信号" /> <input value="{{profileForm.wechatId}}" data-field="wechatId" bindinput="onProfileInput" placeholder="请输入微信号" />
</view> </view>
<view class="profile-field signature-field"> <view class="profile-field signature-field">
<text class="field-label">签名</text> <text class="field-label">个人简介</text>
<textarea value="{{profileForm.signature}}" data-field="signature" bindinput="onProfileInput" placeholder="请输入个人签名" /> <textarea value="{{profileForm.signature}}" data-field="signature" bindinput="onProfileInput" placeholder="请输入个人简介" />
</view>
</view>
<view class="info-card">
<text class="card-title">账号信息</text>
<view class="info-row">
<text class="row-label">登录账号</text>
<text class="row-value">{{userInfo.account || '未设置'}}</text>
</view>
<view class="info-row">
<text class="row-label">身份</text>
<text class="row-value">{{roleText}}</text>
</view>
<view class="info-row">
<text class="row-label">所属门店</text>
<text class="row-value">{{shopName}}</text>
</view>
<view class="info-row">
<text class="row-label">登录手机号</text>
<text class="row-value">{{userInfo.phone || '未绑定'}}</text>
</view> </view>
</view> </view>
</block> </block>
<view class="fixed-bottom"> <view class="fixed-bottom">
<button class="primary-btn" loading="{{profileSaving}}" disabled="{{loading || profileSaving || avatarUploading}}" bindtap="saveProfile">保存个人信息</button> <button class="primary-btn" loading="{{profileSaving}}" disabled="{{loading || profileSaving || avatarUploading}}" bindtap="saveProfile">保存修改</button>
</view> </view>
</view> </view>
+160 -205
View File
@@ -1,103 +1,71 @@
.profile-settings-page { .profile-settings-page {
min-height: 100vh;
padding: 20rpx 24rpx 196rpx;
background: background:
linear-gradient(180deg, rgba(255, 250, 242, 0.96), rgba(247, 240, 232, 0.96)), linear-gradient(180deg, rgba(253, 249, 242, 0.98), rgba(248, 244, 237, 0.98)),
linear-gradient(135deg, rgba(89, 121, 102, 0.14), rgba(181, 134, 86, 0.12)); linear-gradient(135deg, rgba(116, 148, 130, 0.12), rgba(230, 205, 160, 0.1));
}
.page-heading {
display: flex;
flex-direction: column;
gap: 8rpx;
margin: 4rpx 0 22rpx;
}
.page-title {
color: #2f2a25;
font-size: 36rpx;
font-weight: 900;
line-height: 1.25;
}
.page-subtitle {
color: #8a796a;
font-size: 23rpx;
line-height: 1.4;
} }
.loading-state { .loading-state {
padding: 48rpx 24rpx; padding: 56rpx 24rpx;
color: #7b7167; color: #7b7167;
text-align: center; text-align: center;
} }
.portrait-card { .profile-hero {
position: relative;
display: flex;
flex-direction: column;
gap: 28rpx;
min-width: 0;
margin-bottom: 26rpx;
padding: 30rpx;
overflow: hidden; overflow: hidden;
border-radius: 28rpx; margin-bottom: 28rpx;
border-radius: 8px;
background: background:
linear-gradient(135deg, rgba(55, 79, 66, 0.96), rgba(175, 126, 83, 0.94)), radial-gradient(circle at 92% 4%, rgba(255, 255, 255, 0.72), transparent 32%),
radial-gradient(circle at 18% 18%, rgba(255, 246, 224, 0.3), transparent 38%); linear-gradient(135deg, #eef8eb, #fffaf2);
box-shadow: 0 22rpx 46rpx rgba(83, 64, 44, 0.18); box-shadow: 0 16rpx 40rpx rgba(77, 91, 72, 0.1);
} }
.portrait-glow { .hero-main {
position: absolute;
top: -82rpx;
right: -72rpx;
width: 220rpx;
height: 220rpx;
border: 1rpx solid rgba(255, 251, 238, 0.28);
border-radius: 50%;
}
.portrait-main {
position: relative;
z-index: 1;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 26rpx;
min-width: 0; min-width: 0;
gap: 22rpx; padding: 42rpx 34rpx 30rpx;
} }
.portrait-avatar { .hero-avatar {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex: 0 0 auto; flex: 0 0 auto;
width: 132rpx; width: 138rpx;
height: 132rpx; height: 138rpx;
overflow: hidden; overflow: hidden;
border: 4rpx solid rgba(255, 253, 248, 0.78); border: 4rpx solid rgba(255, 255, 255, 0.86);
border-radius: 50%; border-radius: 50%;
background: rgba(255, 253, 248, 0.18); background: #d8e8d9;
color: #fffdf8; color: #5a8d68;
font-size: 28rpx; font-size: 26rpx;
font-weight: 900; font-weight: 900;
box-shadow: 0 16rpx 34rpx rgba(32, 25, 18, 0.18); box-shadow: 0 12rpx 28rpx rgba(76, 105, 82, 0.14);
} }
.portrait-avatar image { .hero-avatar image {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.portrait-empty { .hero-copy {
background: rgba(255, 253, 248, 0.2); flex: 1;
}
.portrait-copy {
min-width: 0; min-width: 0;
color: #fffdf8;
} }
.portrait-name, .hero-title-row {
.portrait-desc { display: flex;
align-items: center;
gap: 14rpx;
min-width: 0;
}
.hero-title,
.hero-shop {
display: block; display: block;
min-width: 0; min-width: 0;
overflow: hidden; overflow: hidden;
@@ -105,191 +73,178 @@
white-space: nowrap; white-space: nowrap;
} }
.portrait-name { .hero-title {
font-size: 38rpx; color: #25211d;
font-size: 34rpx;
font-weight: 900; font-weight: 900;
line-height: 1.25; line-height: 1.2;
} }
.portrait-desc { .role-badge {
margin-top: 10rpx; flex: 0 0 auto;
font-size: 24rpx; padding: 6rpx 16rpx;
border-radius: 999rpx;
background: #dcefe0;
color: #4e8a61;
font-size: 21rpx;
font-weight: 900;
line-height: 1.2;
}
.hero-shop {
margin-top: 12rpx;
color: #67615a;
font-size: 26rpx;
font-weight: 700; font-weight: 700;
line-height: 1.4; line-height: 1.2;
opacity: 0.84;
} }
.portrait-actions { .avatar-change-btn {
position: relative; display: inline-flex;
z-index: 1; align-items: center;
display: flex; justify-content: center;
flex-wrap: wrap; width: auto;
gap: 14rpx; min-width: 150rpx;
width: 100%; min-height: 46rpx;
min-width: 0; margin-top: 18rpx;
padding: 0 18rpx;
border-radius: 999rpx;
background: #dcefe0;
color: #4e8a61;
font-size: 22rpx;
font-weight: 900;
} }
.avatar-btn,
.avatar-remove { .avatar-remove {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex: 1 1 220rpx; width: 100%;
width: auto; min-height: 74rpx;
max-width: 100%; border-top: 1rpx solid rgba(103, 131, 105, 0.1);
min-height: 68rpx; background: rgba(255, 255, 255, 0.56);
padding: 0 24rpx; color: #9a6f62;
border-radius: 20rpx;
font-size: 25rpx; font-size: 25rpx;
font-weight: 800;
}
.info-card {
overflow: hidden;
margin-bottom: 28rpx;
padding-top: 20rpx;
border-radius: 8px;
background: rgba(255, 255, 255, 0.9);
box-shadow: 0 12rpx 30rpx rgba(65, 54, 42, 0.06);
}
.card-title {
display: block;
padding: 0 28rpx 14rpx;
color: #302b26;
font-size: 28rpx;
font-weight: 900; font-weight: 900;
line-height: 1.2; line-height: 1.2;
} }
.avatar-btn { .profile-field,
background: #fff8ed; .info-row {
color: #6d4d35; display: flex;
align-items: center;
min-height: 96rpx;
padding: 0 28rpx;
border-top: 1rpx solid #eee8df;
} }
.avatar-remove { .profile-field {
flex-grow: 0; gap: 20rpx;
min-width: 150rpx;
background: rgba(255, 253, 248, 0.18);
color: #fffdf8;
} }
.info-grid { .field-label,
display: grid; .row-label {
grid-template-columns: repeat(2, minmax(0, 1fr)); flex: 0 0 auto;
gap: 16rpx; width: 178rpx;
margin-bottom: 24rpx; color: #443e38;
} font-size: 26rpx;
.info-tile {
min-width: 0;
padding: 18rpx;
border: 1rpx solid rgba(50, 43, 34, 0.06);
border-radius: 20rpx;
background: #fffdf8;
box-shadow: 0 10rpx 28rpx rgba(58, 48, 34, 0.05);
}
.info-tile text,
.info-tile view {
display: block;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.info-tile text {
color: #8a7f75;
font-size: 22rpx;
font-weight: 800; font-weight: 800;
line-height: 1.2; line-height: 1.2;
} }
.info-tile view {
margin-top: 10rpx;
color: #2c2722;
font-size: 25rpx;
font-weight: 900;
line-height: 1.2;
}
.form-card {
padding: 12rpx 0;
overflow: hidden;
}
.form-header {
display: flex;
flex-direction: column;
gap: 6rpx;
padding: 26rpx 26rpx 8rpx;
}
.form-kicker {
color: #92734f;
font-size: 22rpx;
font-weight: 900;
line-height: 1.2;
}
.form-title {
color: #8d8175;
font-size: 23rpx;
line-height: 1.35;
}
.profile-field {
display: flex;
flex-direction: column;
align-items: stretch;
gap: 12rpx;
min-height: 130rpx;
padding: 20rpx 24rpx;
border-bottom: 1rpx solid #eee8df;
}
.profile-field:last-child {
border-bottom: 0;
}
.profile-field .field-label {
width: auto;
color: #62574d;
font-size: 25rpx;
font-weight: 900;
line-height: 1.2;
}
.profile-field input, .profile-field input,
.profile-field textarea { .profile-field textarea,
width: 100%; .row-value {
min-height: 76rpx; flex: 1;
padding: 0 22rpx; min-width: 0;
border: 1rpx solid #eadfd2; color: #302b26;
border-radius: 18rpx; font-size: 27rpx;
background: #fff8f2; line-height: 1.35;
color: #2d2722; text-align: right;
font-size: 28rpx; }
line-height: 76rpx;
.profile-field input {
min-height: 80rpx;
} }
.profile-field textarea { .profile-field textarea {
height: 150rpx; height: 150rpx;
padding-top: 18rpx; padding: 22rpx 0;
padding-bottom: 18rpx;
line-height: 1.5;
} }
.signature-field { .signature-field {
min-height: 218rpx; align-items: flex-start;
min-height: 164rpx;
padding-top: 12rpx;
padding-bottom: 12rpx;
}
.row-value {
display: block;
overflow: hidden;
color: #827a72;
text-overflow: ellipsis;
white-space: nowrap;
}
.fixed-bottom {
padding: 18rpx 34rpx calc(18rpx + env(safe-area-inset-bottom));
}
.primary-btn {
min-height: 82rpx;
border-radius: 8px;
background: #4f8b63;
box-shadow: 0 14rpx 28rpx rgba(79, 139, 99, 0.26);
} }
@media (max-width: 340px) { @media (max-width: 340px) {
.portrait-main { .hero-main {
align-items: flex-start; align-items: flex-start;
gap: 18rpx;
padding: 32rpx 24rpx 26rpx;
} }
.portrait-avatar { .hero-avatar {
width: 112rpx; width: 112rpx;
height: 112rpx; height: 112rpx;
} }
.portrait-actions { .profile-field,
.info-row {
align-items: flex-start;
flex-direction: column; flex-direction: column;
gap: 12rpx;
padding-top: 20rpx;
padding-bottom: 20rpx;
} }
.avatar-btn, .field-label,
.avatar-remove { .row-label {
flex: 0 0 auto; width: auto;
}
.profile-field input,
.profile-field textarea,
.row-value {
width: 100%; width: 100%;
min-width: 0; text-align: left;
}
.info-grid {
grid-template-columns: 1fr;
} }
} }
+83 -9
View File
@@ -1,6 +1,7 @@
const { BRAND_CONFIG } = require('../../utils/config') const { BRAND_CONFIG } = require('../../utils/config')
const userApi = require('../../api/user') const userApi = require('../../api/user')
const shopApi = require('../../api/shop') const shopApi = require('../../api/shop')
const dashboardApi = require('../../api/dashboard')
const authApi = require('../../api/auth') const authApi = require('../../api/auth')
const auth = require('../../utils/auth') const auth = require('../../utils/auth')
@@ -34,21 +35,74 @@ function resolveShopCoverImage(settings) {
return String(settings.coverImageUrls[0] || '').trim() return String(settings.coverImageUrls[0] || '').trim()
} }
function formatCount(value) {
const count = Number(value)
if (!Number.isFinite(count)) return '--'
return String(Math.max(0, Math.trunc(count)))
}
function formatMoney(value) {
const amount = Number(value)
if (!Number.isFinite(amount)) return '--'
return `¥${amount.toFixed(2).replace(/\.00$/, '')}`
}
function resolveTodayAppointments(stats) {
return stats.todayAppointments || stats.todayAppointmentCount || stats.todayServiceCount || stats.todayServices || stats.todayOrders
}
function buildDashboardStats(stats) {
const data = stats || {}
return [
{ mark: '今', label: '今日预约', value: formatCount(resolveTodayAppointments(data)), unit: '单' },
{ mark: '单', label: '今日订单', value: formatCount(data.todayOrders), unit: '单' },
{ mark: '¥', label: '今日收入', value: formatMoney(data.todayOrderAmount), unit: '' }
]
}
function resolveBusinessStatus(settings) {
if (Number(settings.status) === 0) {
return { text: '已停用', className: 'closed' }
}
if (settings.authorizationExpired) {
return { text: '授权到期', className: 'warning' }
}
return { text: '营业中', className: 'open' }
}
function resolveBusinessHours(settings) {
const businessHours = String(settings.businessHours || '').trim()
if (businessHours) return `今日营业 ${businessHours}`
const startTime = String(settings.startTime || '').slice(0, 5)
const endTime = String(settings.endTime || '').slice(0, 5)
if (startTime && endTime) return `今日营业 ${startTime} - ${endTime}`
return '营业时间未设置'
}
Page({ Page({
data: { data: {
shopName: BRAND_CONFIG.defaultShopName, shopName: BRAND_CONFIG.defaultShopName,
shopCoverImage: '', shopCoverImage: '',
phone: '店长端', phone: '店长端',
roleText: '管理端', roleText: '管理端',
businessStatusText: '营业中',
businessStatusClass: 'open',
businessHoursText: '营业时间未设置',
dashboardStats: buildDashboardStats({}),
userInfo: {}, userInfo: {},
loggingOut: false, loggingOut: false,
menus: [ managementMenus: [
{ title: '个人信息', url: '/pages/profile-settings/index' }, { mark: '店', title: '我的店铺', desc: '店铺信息、营业设置等', url: '/pages/shop-settings/index' },
{ title: '店铺设置', url: '/pages/shop-settings/index' }, { mark: '员', title: '员工管理', desc: '员工信息、排班与权限', url: '/pages/employees/index' },
{ title: '数据导出', url: '/pages/export/index' }, { mark: '会', title: '会员管理', desc: '客户管理、会员等级', url: '/pages/customers/index' },
{ title: '修改密码', url: '/pages/password/index' }, { mark: '数', title: '经营数据', desc: '营业统计、数据导出', url: '/pages/export/index' }
{ title: '关于系统', url: '/pages/about/index' }, ],
{ title: '退出登录', action: 'logout', danger: true } settingMenus: [
{ mark: '人', title: '个人资料', desc: '头像、昵称、联系方式等', url: '/pages/profile-settings/index' },
{ mark: '安', title: '账号与安全', desc: '修改密码、绑定手机号等', url: '/pages/password/index' },
{ mark: '知', title: '消息通知', desc: '系统通知与消息偏好', url: '', disabled: true },
{ mark: '?', title: '帮助中心', desc: '使用帮助与常见问题', url: '/pages/about/index' },
{ mark: '关', title: '关于甲屿店务', desc: '当前版本 1.2.0', url: '/pages/about/index' }
] ]
}, },
@@ -56,6 +110,7 @@ Page({
this.refreshFromSession() this.refreshFromSession()
this.loadShopHeader() this.loadShopHeader()
this.loadProfile() this.loadProfile()
this.loadDashboardStats()
}, },
refreshFromSession() { refreshFromSession() {
@@ -80,24 +135,43 @@ Page({
const app = getApp() const app = getApp()
const shopName = settings.shopName || settings.name || app.globalData.shopName || BRAND_CONFIG.appName const shopName = settings.shopName || settings.name || app.globalData.shopName || BRAND_CONFIG.appName
const shopCoverImage = resolveShopCoverImage(settings) const shopCoverImage = resolveShopCoverImage(settings)
const status = resolveBusinessStatus(settings || {})
app.globalData.shopName = shopName app.globalData.shopName = shopName
app.globalData.shopCoverImage = shopCoverImage app.globalData.shopCoverImage = shopCoverImage
this.setData({ this.setData({
shopName, shopName,
shopCoverImage shopCoverImage,
businessStatusText: status.text,
businessStatusClass: status.className,
businessHoursText: resolveBusinessHours(settings || {})
}) })
} catch (error) { } catch (error) {
wx.showToast({ title: error.message || '店铺信息加载失败', icon: 'none' }) wx.showToast({ title: error.message || '店铺信息加载失败', icon: 'none' })
} }
}, },
async loadDashboardStats() {
try {
const stats = await dashboardApi.stats()
this.setData({ dashboardStats: buildDashboardStats(stats || {}) })
} catch (error) {
this.setData({ dashboardStats: buildDashboardStats({}) })
wx.showToast({ title: error.message || '经营数据加载失败', icon: 'none' })
}
},
go(event) { go(event) {
const action = event.currentTarget.dataset.action const action = event.currentTarget.dataset.action
if (action === 'logout') { if (action === 'logout') {
this.confirmLogout() this.confirmLogout()
return return
} }
wx.navigateTo({ url: event.currentTarget.dataset.url }) const url = event.currentTarget.dataset.url
if (!url) {
wx.showToast({ title: '功能即将开放', icon: 'none' })
return
}
wx.navigateTo({ url })
}, },
confirmLogout() { confirmLogout() {
+47 -30
View File
@@ -1,45 +1,62 @@
<view class="page"> <view class="page profile-page">
<view class="card profile-card"> <view class="profile-hero">
<view class="profile-card-head"> <view class="hero-main">
<view wx:if="{{userInfo.displayAvatar || shopCoverImage}}" class="shop-logo image-avatar"> <view wx:if="{{userInfo.displayAvatar || shopCoverImage}}" class="hero-avatar image-avatar">
<image src="{{userInfo.displayAvatar || shopCoverImage}}" mode="aspectFill"></image> <image src="{{userInfo.displayAvatar || shopCoverImage}}" mode="aspectFill"></image>
</view> </view>
<view wx:else class="shop-logo">我</view> <view wx:else class="hero-avatar hero-avatar-empty">我</view>
<view class="profile-copy"> <view class="hero-copy">
<view class="profile-title-row"> <view class="hero-title-row">
<text class="profile-name">{{userInfo.nickname || shopName}}</text> <text class="hero-title">{{userInfo.nickname || shopName}}</text>
<text class="role-badge">{{roleText}}</text> <text class="role-badge">{{roleText}}</text>
</view> </view>
<view class="profile-meta-row"> <view class="shop-line" data-url="/pages/shop-settings/index" bindtap="go">
<text class="profile-meta-label">登录账号</text> <text>{{shopName}}</text>
<text class="profile-meta-value">{{userInfo.account || '未设置'}}</text> <text class="hero-arrow">›</text>
</view> </view>
<view class="profile-meta-row"> <view class="business-line">
<text class="profile-meta-label">手机号</text> <text class="status-badge {{businessStatusClass}}">{{businessStatusText}}</text>
<text class="profile-meta-value">{{userInfo.phone || userInfo.contactPhone || phone || '未绑定'}}</text> <text class="business-hours">{{businessHoursText}}</text>
</view> </view>
</view> </view>
<view class="shop-summary">
<text>当前所属店铺</text>
<view>{{shopName}}</view>
</view>
</view> </view>
<view class="profile-summary-grid"> <view class="stats-card">
<view class="profile-summary-item"> <view wx:for="{{dashboardStats}}" wx:key="label" class="stat-item">
<text>身份</text> <view class="stat-mark">{{item.mark}}</view>
<view>{{roleText}}</view> <text class="stat-label">{{item.label}}</text>
</view> <view class="stat-value">{{item.value}}</view>
<view class="profile-summary-item"> <text wx:if="{{item.unit}}" class="stat-unit">{{item.unit}}</text>
<text>店铺</text>
<view>{{shopName}}</view>
</view> </view>
</view> </view>
</view> </view>
<view class="section menu-list card"> <view class="menu-section">
<view wx:for="{{menus}}" wx:key="title" class="menu-row {{item.danger ? 'danger-row' : ''}}" data-url="{{item.url}}" data-action="{{item.action}}" bindtap="go"> <text class="section-title">我的管理</text>
<text>{{item.action === 'logout' && loggingOut ? '退出中...' : item.title}}</text> <view class="menu-card">
<text wx:if="{{item.action !== 'logout'}}" class="arrow">›</text> <view wx:for="{{managementMenus}}" wx:key="title" class="menu-row" data-url="{{item.url}}" bindtap="go">
<view class="menu-mark">{{item.mark}}</view>
<view class="menu-copy">
<text class="menu-title">{{item.title}}</text>
<text class="menu-desc">{{item.desc}}</text>
</view>
<text class="arrow">›</text>
</view>
</view> </view>
</view> </view>
<view class="menu-section">
<text class="section-title">设置与帮助</text>
<view class="menu-card">
<view wx:for="{{settingMenus}}" wx:key="title" class="menu-row {{item.disabled ? 'disabled' : ''}}" data-url="{{item.url}}" bindtap="go">
<view class="menu-mark">{{item.mark}}</view>
<view class="menu-copy">
<text class="menu-title">{{item.title}}</text>
<text class="menu-desc">{{item.desc}}</text>
</view>
<text class="arrow">›</text>
</view>
</view>
</view>
<button class="logout-card" loading="{{loggingOut}}" disabled="{{loggingOut}}" data-action="logout" bindtap="go">{{loggingOut ? '退出中...' : '退出登录'}}</button>
</view> </view>
+265 -143
View File
@@ -1,223 +1,345 @@
.profile-card { .profile-page {
min-height: 100vh;
padding: 20rpx 24rpx 156rpx;
background:
linear-gradient(180deg, rgba(253, 249, 242, 0.98), rgba(248, 244, 237, 0.98)),
linear-gradient(135deg, rgba(116, 148, 130, 0.12), rgba(230, 205, 160, 0.1));
}
.profile-hero {
overflow: hidden;
border-radius: 8px;
background:
radial-gradient(circle at 92% 4%, rgba(255, 255, 255, 0.72), transparent 32%),
linear-gradient(135deg, #eef8eb, #fffaf2);
box-shadow: 0 16rpx 40rpx rgba(77, 91, 72, 0.1);
}
.hero-main {
display: flex; display: flex;
flex-direction: column; align-items: center;
gap: 24rpx; gap: 24rpx;
padding: 28rpx;
}
.profile-card-head {
display: flex;
align-items: stretch;
min-width: 0; min-width: 0;
width: 100%; padding: 34rpx 30rpx 26rpx;
gap: 18rpx;
} }
.profile-copy { .hero-avatar {
flex: 1;
min-width: 0;
}
.shop-logo {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex-shrink: 0; flex: 0 0 auto;
width: 90rpx; width: 128rpx;
height: 90rpx; height: 128rpx;
overflow: hidden; overflow: hidden;
border: 2rpx solid #dce8e1; border: 4rpx solid rgba(255, 255, 255, 0.86);
border-radius: 22rpx; border-radius: 50%;
background: #edf5ef; background: #d8e8d9;
color: #638978; color: #5a8d68;
font-size: 38rpx; font-size: 42rpx;
font-weight: 900; font-weight: 900;
box-shadow: 0 12rpx 28rpx rgba(76, 105, 82, 0.14);
} }
.shop-logo image { .hero-avatar image {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.profile-title-row, .hero-copy {
.profile-meta-row, flex: 1;
.profile-name,
.profile-meta-label,
.profile-meta-value {
display: block;
min-width: 0; min-width: 0;
} }
.profile-title-row { .hero-title-row,
.shop-line,
.business-line {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 14rpx; min-width: 0;
margin-top: 2rpx;
} }
.profile-name { .hero-title-row {
color: #2d2621; gap: 14rpx;
font-size: 32rpx; }
.hero-title {
display: block;
min-width: 0;
overflow: hidden;
color: #25211d;
font-size: 34rpx;
font-weight: 900; font-weight: 900;
line-height: 1.2; line-height: 1.2;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.profile-meta-row {
display: flex;
align-items: center;
gap: 8rpx;
margin-top: 8rpx;
color: #6d6258;
font-size: 24rpx;
line-height: 1.2;
}
.profile-meta-label {
flex-shrink: 0;
color: #9a9086;
}
.profile-meta-value {
overflow: hidden;
color: #4e7165;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.role-badge { .role-badge {
flex-shrink: 0; flex: 0 0 auto;
padding: 7rpx 16rpx; padding: 6rpx 16rpx;
border-radius: 999rpx; border-radius: 999rpx;
background: #e5eee9; background: #dcefe0;
color: #4e7165; color: #4e8a61;
font-size: 22rpx; font-size: 21rpx;
font-weight: 800; font-weight: 900;
line-height: 1.2; line-height: 1.2;
} }
.shop-summary { .shop-line {
gap: 8rpx;
margin-top: 14rpx;
color: #67615a;
font-size: 26rpx;
font-weight: 700;
line-height: 1.2;
}
.shop-line text:first-child {
display: block;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.hero-arrow {
flex: 0 0 auto;
color: #938b82;
font-size: 38rpx;
line-height: 1;
}
.business-line {
flex-wrap: wrap;
gap: 12rpx;
margin-top: 16rpx;
}
.status-badge {
flex: 0 0 auto;
padding: 5rpx 14rpx;
border-radius: 999rpx;
color: #fff;
font-size: 21rpx;
font-weight: 900;
line-height: 1.2;
}
.status-badge.open {
background: #5e9a71;
}
.status-badge.warning {
background: #c68a33;
}
.status-badge.closed {
background: #9a9a9a;
}
.business-hours {
display: block;
min-width: 0;
overflow: hidden;
color: #858077;
font-size: 24rpx;
line-height: 1.2;
text-overflow: ellipsis;
white-space: nowrap;
}
.stats-card {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
border-top: 1rpx solid rgba(103, 131, 105, 0.1);
background: rgba(255, 255, 255, 0.62);
}
.stat-item {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center;
flex: 0 0 184rpx;
min-width: 0;
padding: 18rpx;
border-radius: 22rpx;
background: #f7efe7;
}
.shop-summary text,
.shop-summary view {
display: block;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.shop-summary text {
color: #94877b;
font-size: 19rpx;
line-height: 1.2;
}
.shop-summary view {
margin-top: 10rpx;
color: #2c2722;
font-size: 26rpx;
font-weight: 900;
line-height: 1.2;
}
.profile-summary-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 20rpx;
width: 100%;
}
.profile-summary-item {
display: flex;
align-items: center; align-items: center;
min-width: 0; min-width: 0;
min-height: 56rpx; padding: 22rpx 10rpx 24rpx;
gap: 14rpx; border-right: 1rpx solid rgba(103, 131, 105, 0.1);
padding: 0 20rpx;
border-radius: 18rpx;
background: #f7efe7;
} }
.profile-summary-item text, .stat-item:last-child {
.profile-summary-item view { border-right: 0;
}
.stat-mark {
display: flex;
align-items: center;
justify-content: center;
width: 34rpx;
height: 34rpx;
margin-bottom: 8rpx;
border-radius: 50%;
background: #6d9878;
color: #fff;
font-size: 20rpx;
font-weight: 900;
line-height: 1;
}
.stat-label,
.stat-value,
.stat-unit {
display: block; display: block;
min-width: 0; max-width: 100%;
overflow: hidden; overflow: hidden;
text-align: center;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.profile-summary-item text { .stat-label {
flex-shrink: 0; color: #8c857d;
color: #94877b; font-size: 22rpx;
font-size: 21rpx; font-weight: 700;
line-height: 1.2; line-height: 1.2;
} }
.profile-summary-item view { .stat-value {
flex: 1; margin-top: 10rpx;
color: #2c2722; color: #25211d;
font-size: 25rpx; font-size: 34rpx;
font-weight: 900;
line-height: 1.05;
}
.stat-unit {
margin-top: 4rpx;
color: #a29a92;
font-size: 20rpx;
line-height: 1.2;
}
.menu-section {
margin-top: 34rpx;
}
.section-title {
display: block;
margin: 0 8rpx 16rpx;
color: #302b26;
font-size: 28rpx;
font-weight: 900; font-weight: 900;
line-height: 1.2; line-height: 1.2;
} }
.menu-list { .menu-card {
overflow: hidden; overflow: hidden;
border-radius: 8px;
background: rgba(255, 255, 255, 0.86);
box-shadow: 0 12rpx 30rpx rgba(65, 54, 42, 0.06);
} }
.menu-row { .menu-row {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; gap: 20rpx;
min-height: 104rpx; min-height: 92rpx;
padding: 0 26rpx; padding: 14rpx 24rpx;
border-bottom: 1rpx solid #eee8df; border-bottom: 1rpx solid #eee8df;
color: #302c27;
font-size: 28rpx;
font-weight: 700;
} }
.menu-row:last-child { .menu-row:last-child {
border-bottom: 0; border-bottom: 0;
} }
.danger-row { .menu-row.disabled {
opacity: 0.58;
}
.menu-mark {
display: flex;
align-items: center;
justify-content: center; justify-content: center;
color: #c96868; flex: 0 0 auto;
width: 46rpx;
height: 46rpx;
border-radius: 12rpx;
background: #e8f3e9;
color: #63936c;
font-size: 23rpx;
font-weight: 900;
line-height: 1;
}
.menu-copy {
flex: 1;
min-width: 0;
}
.menu-title,
.menu-desc {
display: block;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.menu-title {
color: #2f2a25;
font-size: 28rpx;
font-weight: 800;
line-height: 1.25;
}
.menu-desc {
margin-top: 6rpx;
color: #938b82;
font-size: 22rpx;
line-height: 1.2;
} }
.arrow { .arrow {
color: #b0a79e; flex: 0 0 auto;
font-size: 44rpx; color: #b7afa6;
font-size: 42rpx;
line-height: 1;
}
.logout-card {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 86rpx;
margin-top: 34rpx;
border-radius: 8px;
background: rgba(255, 255, 255, 0.9);
color: #d55e58;
font-size: 28rpx;
font-weight: 900;
box-shadow: 0 12rpx 30rpx rgba(65, 54, 42, 0.05);
} }
@media (max-width: 340px) { @media (max-width: 340px) {
.profile-card-head { .hero-main {
flex-wrap: wrap; align-items: flex-start;
gap: 18rpx;
padding: 28rpx 22rpx 22rpx;
} }
.profile-copy { .hero-avatar {
flex: 1 1 0; width: 108rpx;
height: 108rpx;
} }
.shop-summary { .stats-card {
flex: 1 1 100%;
}
.profile-summary-grid {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
.stat-item {
border-right: 0;
border-bottom: 1rpx solid rgba(103, 131, 105, 0.1);
}
.stat-item:last-child {
border-bottom: 0;
}
} }
@@ -0,0 +1,40 @@
# 店务小程序个人中心 UI 优化设计
## 范围
本次只优化 `JY-Salon-WeChat` 的 `我的` 和 `个人资料` 两页。`店铺设置`、`店铺档案` 和当前已有的店铺资料改动不纳入本次实现,避免扩大变更范围。
## 我的页
页面采用设计稿中的浅暖背景、浅绿色资料头图、圆形头像、身份标签、店铺信息和统计卡结构。资料区展示当前已有字段:头像、昵称、身份、所属店铺、账号或手机号、店铺营业状态。
顶部三项统计接入现有后端 `/admin/dashboard/stats`,小程序 API 层使用 `/dashboard/stats` 交给统一请求层补齐后台前缀:
- 今日预约:优先使用接口返回的今日预约或今日服务字段,缺失时使用今日订单数兜底。
- 今日订单:使用 `todayOrders`。
- 今日收入:使用 `todayOrderAmount`,按人民币金额格式展示。
统计接口加载失败时不影响个人中心主体显示,统计值展示为 `--`,并用 toast 提示经营数据加载失败。
## 个人资料页
页面改为设计稿中的顶部个人资料卡、分组信息卡和底部保存按钮。可编辑字段保持当前系统已有保存边界:头像、昵称、联系电话、微信号、个人签名。
账号信息只展示不可编辑字段:登录账号、身份、所属门店、登录手机号。设计稿中的生日字段当前系统没有保存字段,本次不新增、不展示,避免前端假字段。
## 技术方案
新增 `JY-Salon-WeChat/api/dashboard.js`,封装 `/admin/dashboard/stats`。`pages/profile/index.js` 在进入页面时并行加载用户信息、店铺信息和经营统计,分别处理失败状态。`pages/profile/index.wxml/.wxss` 和 `pages/profile-settings/index.wxml/.wxss` 按设计稿调整结构与样式。
实现保持页面函数职责单一,新增格式化函数只返回展示值,不修改输入对象。小程序 `.js/.wxml/.wxss/.json` 文件保持 UTF-8 无 BOM。
## 验证
实现后执行:
- 小程序 JS 语法检查。
- `git diff --check`。
- 修改文件 UTF-8 BOM 检查。
- GitNexus `detect_changes`,确认影响范围只包含预期小程序页面和新增 API。
如微信开发者工具自动化连接可用,再进入 `pages/profile/index` 和 `pages/profile-settings/index` 做页面冒烟验证。
File diff suppressed because one or more lines are too long