优化:我的页面展示账号头像昵称
This commit is contained in:
@@ -6,6 +6,7 @@ const planningApi = require('../../api/planning')
|
|||||||
const employeesApi = require('../../api/employees')
|
const employeesApi = require('../../api/employees')
|
||||||
const shopApi = require('../../api/shop')
|
const shopApi = require('../../api/shop')
|
||||||
const dateUtil = require('../../utils/date')
|
const dateUtil = require('../../utils/date')
|
||||||
|
const { buildProfileCard } = require('../../utils/profile-card')
|
||||||
|
|
||||||
function resolveRoleText(type) {
|
function resolveRoleText(type) {
|
||||||
const role = Number(type)
|
const role = Number(type)
|
||||||
@@ -17,10 +18,9 @@ function resolveRoleText(type) {
|
|||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
shopName: BRAND_CONFIG.defaultShopName,
|
|
||||||
phone: '店长端',
|
|
||||||
roleText: '管理端',
|
roleText: '管理端',
|
||||||
userInfo: {},
|
userInfo: {},
|
||||||
|
profileCard: buildProfileCard({}, BRAND_CONFIG.defaultShopName),
|
||||||
editModalVisible: false,
|
editModalVisible: false,
|
||||||
profileSaving: false,
|
profileSaving: false,
|
||||||
avatarUploading: false,
|
avatarUploading: false,
|
||||||
@@ -109,11 +109,11 @@ Page({
|
|||||||
refreshFromSession() {
|
refreshFromSession() {
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
const userInfo = app.globalData.userInfo || {}
|
const userInfo = app.globalData.userInfo || {}
|
||||||
|
const fallbackShopName = app.globalData.shopName || BRAND_CONFIG.defaultShopName
|
||||||
this.setData({
|
this.setData({
|
||||||
shopName: app.globalData.shopName || BRAND_CONFIG.appName,
|
|
||||||
phone: userInfo.contactPhone || userInfo.phone || userInfo.account || '店长端',
|
|
||||||
roleText: resolveRoleText(userInfo.type),
|
roleText: resolveRoleText(userInfo.type),
|
||||||
userInfo
|
userInfo,
|
||||||
|
profileCard: buildProfileCard(userInfo, fallbackShopName)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -152,16 +152,18 @@ Page({
|
|||||||
wechatId: profile.wechatId || '',
|
wechatId: profile.wechatId || '',
|
||||||
signature: profile.signature || '',
|
signature: profile.signature || '',
|
||||||
type: profile.type || currentUserInfo.type,
|
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({
|
app.setSession({
|
||||||
...session,
|
...session,
|
||||||
|
shopName: nextUserInfo.shopName || session.shopName,
|
||||||
userInfo: nextUserInfo
|
userInfo: nextUserInfo
|
||||||
})
|
})
|
||||||
this.setData({
|
this.setData({
|
||||||
userInfo: nextUserInfo,
|
userInfo: nextUserInfo,
|
||||||
phone: nextUserInfo.contactPhone || nextUserInfo.phone || nextUserInfo.account || '店长端',
|
roleText: resolveRoleText(nextUserInfo.type),
|
||||||
roleText: resolveRoleText(nextUserInfo.type)
|
profileCard: buildProfileCard(nextUserInfo, BRAND_CONFIG.defaultShopName)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
<view class="page">
|
<view class="page">
|
||||||
<view class="card profile-card">
|
<view class="card profile-card">
|
||||||
<view class="profile-main">
|
<view class="profile-main">
|
||||||
<view class="shop-logo">指</view>
|
<view class="account-avatar">
|
||||||
|
<image wx:if="{{profileCard.avatar}}" src="{{profileCard.avatar}}" mode="aspectFill"></image>
|
||||||
|
<text wx:else>{{profileCard.avatarText}}</text>
|
||||||
|
</view>
|
||||||
<view class="profile-copy">
|
<view class="profile-copy">
|
||||||
<text class="shop-name">{{shopName}}</text>
|
<text class="profile-name">{{profileCard.nickname}}</text>
|
||||||
<text class="phone">{{phone}}</text>
|
<text class="profile-shop">{{profileCard.shopName}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="role-badge">{{roleText}}</text>
|
<text class="role-badge">{{roleText}}</text>
|
||||||
|
|||||||
@@ -17,13 +17,14 @@
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.shop-logo {
|
.account-avatar {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
width: 96rpx;
|
width: 96rpx;
|
||||||
height: 96rpx;
|
height: 96rpx;
|
||||||
|
overflow: hidden;
|
||||||
border-radius: 24rpx;
|
border-radius: 24rpx;
|
||||||
background: #6f8f83;
|
background: #6f8f83;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
@@ -31,12 +32,17 @@
|
|||||||
font-weight: 900;
|
font-weight: 900;
|
||||||
}
|
}
|
||||||
|
|
||||||
.shop-name,
|
.account-avatar image {
|
||||||
.phone {
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-name,
|
||||||
|
.profile-shop {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.shop-name {
|
.profile-name {
|
||||||
font-size: 34rpx;
|
font-size: 34rpx;
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -44,7 +50,7 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.phone {
|
.profile-shop {
|
||||||
margin-top: 8rpx;
|
margin-top: 8rpx;
|
||||||
color: #91897f;
|
color: #91897f;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
|
|||||||
@@ -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 }
|
||||||
@@ -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: '未设置门店'
|
||||||
|
})
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
# 项目变更记录
|
# 项目变更记录
|
||||||
|
|
||||||
|
## 2026-10-10 Salon 小程序“我的”页面账号卡优化
|
||||||
|
|
||||||
|
- “我的”页面顶部卡片改为展示当前账号头像、昵称、所属门店和角色,不再展示固定品牌图标与“店长端”占位信息。
|
||||||
|
- 头像缺失时显示昵称首字;昵称缺失时使用登录账号或明确占位文案,门店名称优先取当前用户所属门店。
|
||||||
|
- 统一首次会话渲染、资料接口刷新和编辑保存后的展示规则,并补充账号卡兜底逻辑测试。
|
||||||
|
|
||||||
## 2026-10-10 Salon 小程序记住登录体验优化
|
## 2026-10-10 Salon 小程序记住登录体验优化
|
||||||
|
|
||||||
- 新增独立启动鉴权页;已记住且账号状态正常的用户启动后自动登录并直接进入规划页,不再短暂显示登录页。
|
- 新增独立启动鉴权页;已记住且账号状态正常的用户启动后自动登录并直接进入规划页,不再短暂显示登录页。
|
||||||
|
|||||||
Reference in New Issue
Block a user