From 9148bdb027263f466fd00ccfc6690e8d34f59b4f Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Sat, 10 Oct 2026 17:04:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E6=88=91=E7=9A=84?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=B1=95=E7=A4=BA=E8=B4=A6=E5=8F=B7=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E6=98=B5=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JC-Salon-WeChat/pages/profile/index.js | 18 +++++++------- JC-Salon-WeChat/pages/profile/index.wxml | 9 ++++--- JC-Salon-WeChat/pages/profile/index.wxss | 16 +++++++++---- JC-Salon-WeChat/utils/profile-card.js | 18 ++++++++++++++ JC-Salon-WeChat/utils/profile-card.test.js | 28 ++++++++++++++++++++++ docs/项目变更记录.md | 6 +++++ 6 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 JC-Salon-WeChat/utils/profile-card.js create mode 100644 JC-Salon-WeChat/utils/profile-card.test.js diff --git a/JC-Salon-WeChat/pages/profile/index.js b/JC-Salon-WeChat/pages/profile/index.js index 4126449d..74341b1f 100644 --- a/JC-Salon-WeChat/pages/profile/index.js +++ b/JC-Salon-WeChat/pages/profile/index.js @@ -6,6 +6,7 @@ const planningApi = require('../../api/planning') const employeesApi = require('../../api/employees') const shopApi = require('../../api/shop') const dateUtil = require('../../utils/date') +const { buildProfileCard } = require('../../utils/profile-card') function resolveRoleText(type) { const role = Number(type) @@ -17,10 +18,9 @@ function resolveRoleText(type) { Page({ data: { - shopName: BRAND_CONFIG.defaultShopName, - phone: '店长端', roleText: '管理端', userInfo: {}, + profileCard: buildProfileCard({}, BRAND_CONFIG.defaultShopName), editModalVisible: false, profileSaving: false, avatarUploading: false, @@ -109,11 +109,11 @@ Page({ refreshFromSession() { const app = getApp() const userInfo = app.globalData.userInfo || {} + const fallbackShopName = app.globalData.shopName || BRAND_CONFIG.defaultShopName this.setData({ - shopName: app.globalData.shopName || BRAND_CONFIG.appName, - phone: userInfo.contactPhone || userInfo.phone || userInfo.account || '店长端', roleText: resolveRoleText(userInfo.type), - userInfo + userInfo, + profileCard: buildProfileCard(userInfo, fallbackShopName) }) }, @@ -152,16 +152,18 @@ Page({ wechatId: profile.wechatId || '', signature: profile.signature || '', type: profile.type || currentUserInfo.type, - shopId: profile.shopId || currentUserInfo.shopId + shopId: profile.shopId || currentUserInfo.shopId, + shopName: profile.shopName || currentUserInfo.shopName || session.shopName || app.globalData.shopName || '' } app.setSession({ ...session, + shopName: nextUserInfo.shopName || session.shopName, userInfo: nextUserInfo }) this.setData({ userInfo: nextUserInfo, - phone: nextUserInfo.contactPhone || nextUserInfo.phone || nextUserInfo.account || '店长端', - roleText: resolveRoleText(nextUserInfo.type) + roleText: resolveRoleText(nextUserInfo.type), + profileCard: buildProfileCard(nextUserInfo, BRAND_CONFIG.defaultShopName) }) }, diff --git a/JC-Salon-WeChat/pages/profile/index.wxml b/JC-Salon-WeChat/pages/profile/index.wxml index c9654420..a6f9f363 100644 --- a/JC-Salon-WeChat/pages/profile/index.wxml +++ b/JC-Salon-WeChat/pages/profile/index.wxml @@ -1,10 +1,13 @@ - + - {{shopName}} - {{phone}} + {{profileCard.nickname}} + {{profileCard.shopName}} {{roleText}} diff --git a/JC-Salon-WeChat/pages/profile/index.wxss b/JC-Salon-WeChat/pages/profile/index.wxss index 6572fc15..448fddd6 100644 --- a/JC-Salon-WeChat/pages/profile/index.wxss +++ b/JC-Salon-WeChat/pages/profile/index.wxss @@ -17,13 +17,14 @@ min-width: 0; } -.shop-logo { +.account-avatar { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 96rpx; height: 96rpx; + overflow: hidden; border-radius: 24rpx; background: #6f8f83; color: #fff; @@ -31,12 +32,17 @@ font-weight: 900; } -.shop-name, -.phone { +.account-avatar image { + width: 100%; + height: 100%; +} + +.profile-name, +.profile-shop { display: block; } -.shop-name { +.profile-name { font-size: 34rpx; font-weight: 800; overflow: hidden; @@ -44,7 +50,7 @@ white-space: nowrap; } -.phone { +.profile-shop { margin-top: 8rpx; color: #91897f; font-size: 24rpx; diff --git a/JC-Salon-WeChat/utils/profile-card.js b/JC-Salon-WeChat/utils/profile-card.js new file mode 100644 index 00000000..fb9b2ebc --- /dev/null +++ b/JC-Salon-WeChat/utils/profile-card.js @@ -0,0 +1,18 @@ +function cleanText(value) { + return String(value || '').trim() +} + +function buildProfileCard(userInfo, fallbackShopName) { + const user = userInfo || {} + const nickname = cleanText(user.nickname) || cleanText(user.account) || '未设置昵称' + const shopName = cleanText(user.shopName) || cleanText(fallbackShopName) || '未设置门店' + + return { + avatar: cleanText(user.avatar), + avatarText: Array.from(nickname)[0] || '用', + nickname, + shopName + } +} + +module.exports = { buildProfileCard } diff --git a/JC-Salon-WeChat/utils/profile-card.test.js b/JC-Salon-WeChat/utils/profile-card.test.js new file mode 100644 index 00000000..278453ff --- /dev/null +++ b/JC-Salon-WeChat/utils/profile-card.test.js @@ -0,0 +1,28 @@ +const assert = require('assert') + +const { buildProfileCard } = require('./profile-card') + +assert.deepStrictEqual(buildProfileCard({ + nickname: '小屿', + avatar: 'https://example.com/avatar.png', + shopName: '甲屿中心店' +}, '默认门店'), { + avatar: 'https://example.com/avatar.png', + avatarText: '小', + nickname: '小屿', + shopName: '甲屿中心店' +}) + +assert.deepStrictEqual(buildProfileCard({ account: 'manager01' }, '默认门店'), { + avatar: '', + avatarText: 'm', + nickname: 'manager01', + shopName: '默认门店' +}) + +assert.deepStrictEqual(buildProfileCard({}, ''), { + avatar: '', + avatarText: '未', + nickname: '未设置昵称', + shopName: '未设置门店' +}) diff --git a/docs/项目变更记录.md b/docs/项目变更记录.md index 12b5278f..c85288e2 100644 --- a/docs/项目变更记录.md +++ b/docs/项目变更记录.md @@ -1,5 +1,11 @@ # 项目变更记录 +## 2026-10-10 Salon 小程序“我的”页面账号卡优化 + +- “我的”页面顶部卡片改为展示当前账号头像、昵称、所属门店和角色,不再展示固定品牌图标与“店长端”占位信息。 +- 头像缺失时显示昵称首字;昵称缺失时使用登录账号或明确占位文案,门店名称优先取当前用户所属门店。 +- 统一首次会话渲染、资料接口刷新和编辑保存后的展示规则,并补充账号卡兜底逻辑测试。 + ## 2026-10-10 Salon 小程序记住登录体验优化 - 新增独立启动鉴权页;已记住且账号状态正常的用户启动后自动登录并直接进入规划页,不再短暂显示登录页。