统一甲屿云命名体系

This commit is contained in:
2026-06-29 23:26:43 +08:00
parent 48c47fe3ff
commit bc8a7d8d4c
1268 changed files with 3477 additions and 3511 deletions
+181
View File
@@ -0,0 +1,181 @@
const { BRAND_CONFIG } = require('../../utils/config')
const userApi = require('../../api/user')
const auth = require('../../utils/auth')
const { chooseImageFilePath, uploadProfileImage } = require('../../utils/upload')
function resolveRoleText(type) {
const role = Number(type)
if (role === 2) return '店长'
if (role === 3) return '美甲师'
if (role === 4) return '管理员'
return '管理端'
}
Page({
data: {
shopName: BRAND_CONFIG.defaultShopName,
phone: '店长端',
roleText: '管理端',
userInfo: {},
editModalVisible: false,
profileSaving: false,
avatarUploading: false,
profileForm: {
nickname: '',
avatar: '',
contactPhone: '',
wechatId: '',
signature: ''
},
menus: [
{ title: '个人信息', action: 'editProfile' },
{ title: '店铺设置', url: '/pages/shop-settings/index' },
{ title: '数据导出', url: '/pages/export/index' },
{ title: '修改密码', url: '/pages/password/index' },
{ title: '关于系统', url: '/pages/about/index' }
]
},
onShow() {
this.refreshFromSession()
this.loadProfile()
},
refreshFromSession() {
const app = getApp()
const userInfo = app.globalData.userInfo || {}
this.setData({
shopName: app.globalData.shopName || BRAND_CONFIG.appName,
phone: userInfo.contactPhone || userInfo.phone || userInfo.account || '店长端',
roleText: resolveRoleText(userInfo.type),
userInfo
})
},
go(event) {
const action = event.currentTarget.dataset.action
if (action === 'editProfile') {
this.openEditProfile()
return
}
wx.navigateTo({ url: event.currentTarget.dataset.url })
},
async loadProfile() {
try {
const profile = await userApi.info()
this.syncProfileToSession(profile)
} catch (error) {
wx.showToast({ title: error.message || '个人信息加载失败', icon: 'none' })
}
},
syncProfileToSession(profile) {
const app = getApp()
const session = auth.getSession()
const currentUserInfo = session.userInfo || app.globalData.userInfo || {}
const nextUserInfo = {
...currentUserInfo,
id: profile.id || currentUserInfo.id,
account: profile.account || currentUserInfo.account,
nickname: profile.nickname || '',
avatar: profile.avatar || '',
phone: profile.phone || currentUserInfo.phone || '',
contactPhone: profile.contactPhone || '',
wechatId: profile.wechatId || '',
signature: profile.signature || '',
type: profile.type || currentUserInfo.type,
shopId: profile.shopId || currentUserInfo.shopId
}
app.setSession({
...session,
userInfo: nextUserInfo
})
this.setData({
userInfo: nextUserInfo,
phone: nextUserInfo.contactPhone || nextUserInfo.phone || nextUserInfo.account || '店长端',
roleText: resolveRoleText(nextUserInfo.type)
})
},
openEditProfile() {
const userInfo = this.data.userInfo || {}
this.setData({
editModalVisible: true,
profileForm: {
nickname: userInfo.nickname || '',
avatar: userInfo.avatar || '',
contactPhone: userInfo.contactPhone || '',
wechatId: userInfo.wechatId || '',
signature: userInfo.signature || ''
}
})
},
closeEditProfile() {
if (this.data.profileSaving || this.data.avatarUploading) {
return
}
this.setData({ editModalVisible: false })
},
stopTap() {
},
onProfileInput(event) {
const field = event.currentTarget.dataset.field
this.setData({
[`profileForm.${field}`]: event.detail.value
})
},
async chooseProfileAvatar() {
if (this.data.avatarUploading || this.data.profileSaving) {
return
}
try {
const filePath = await chooseImageFilePath()
if (!filePath) {
return
}
this.setData({ avatarUploading: true })
const avatar = await uploadProfileImage(filePath)
this.setData({ 'profileForm.avatar': avatar })
} catch (error) {
wx.showToast({ title: error.message || '头像上传失败', icon: 'none' })
} finally {
this.setData({ avatarUploading: false })
}
},
removeProfileAvatar() {
this.setData({ 'profileForm.avatar': '' })
},
async saveProfile() {
const form = this.data.profileForm
const nickname = String(form.nickname || '').trim()
if (!nickname) {
wx.showToast({ title: '请填写昵称', icon: 'none' })
return
}
this.setData({ profileSaving: true })
try {
await userApi.updateInfo({
nickname,
avatar: form.avatar || '',
contactPhone: String(form.contactPhone || '').trim(),
wechatId: String(form.wechatId || '').trim(),
signature: String(form.signature || '').trim()
})
const profile = await userApi.info()
this.syncProfileToSession(profile)
this.setData({ editModalVisible: false })
wx.showToast({ title: '已保存', icon: 'success' })
} catch (error) {
wx.showToast({ title: error.message || '保存失败', icon: 'none' })
} finally {
this.setData({ profileSaving: false })
}
}
})
+3
View File
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "我的"
}
+65
View File
@@ -0,0 +1,65 @@
<view class="page">
<view class="card profile-card">
<view class="profile-main">
<view class="shop-logo">指</view>
<view class="profile-copy">
<text class="shop-name">{{shopName}}</text>
<text class="phone">{{phone}}</text>
</view>
</view>
<text class="role-badge">{{roleText}}</text>
</view>
<view class="section menu-list card">
<view wx:for="{{menus}}" wx:key="title" class="menu-row" data-url="{{item.url}}" data-action="{{item.action}}" bindtap="go">
<text>{{item.title}}</text>
<text class="arrow">›</text>
</view>
</view>
<view wx:if="{{editModalVisible}}" class="modal-mask" bindtap="closeEditProfile">
<view class="profile-modal" catchtap="stopTap">
<view class="modal-head">
<text class="modal-title">个人信息</text>
<view class="modal-close" bindtap="closeEditProfile">×</view>
</view>
<view class="profile-avatar-row">
<view wx:if="{{profileForm.avatar}}" class="profile-avatar image-avatar">
<image src="{{profileForm.avatar}}" mode="aspectFill"></image>
</view>
<view wx:else class="profile-avatar">头像</view>
<button class="secondary-btn avatar-btn" loading="{{avatarUploading}}" bindtap="chooseProfileAvatar">上传头像</button>
<button wx:if="{{profileForm.avatar}}" class="text-btn avatar-remove" bindtap="removeProfileAvatar">移除</button>
</view>
<view class="modal-field">
<text class="required-label">昵称</text>
<input value="{{profileForm.nickname}}" data-field="nickname" bindinput="onProfileInput" placeholder="请输入昵称" />
</view>
<view class="modal-field readonly-field">
<text>登录账号</text>
<view>{{userInfo.account || '未设置'}}</view>
</view>
<view class="modal-field readonly-field">
<text>身份</text>
<view>{{roleText}}</view>
</view>
<view class="modal-field readonly-field">
<text>登录手机号</text>
<view>{{userInfo.phone || '未绑定'}}</view>
</view>
<view class="modal-field">
<text>联系电话</text>
<input value="{{profileForm.contactPhone}}" data-field="contactPhone" bindinput="onProfileInput" type="number" placeholder="请输入联系电话" />
</view>
<view class="modal-field">
<text>微信号</text>
<input value="{{profileForm.wechatId}}" data-field="wechatId" bindinput="onProfileInput" placeholder="请输入微信号" />
</view>
<view class="modal-field">
<text>签名</text>
<textarea value="{{profileForm.signature}}" data-field="signature" bindinput="onProfileInput" placeholder="请输入个人签名" />
</view>
<button class="primary-btn modal-submit" loading="{{profileSaving}}" bindtap="saveProfile">保存个人信息</button>
</view>
</view>
</view>
+256
View File
@@ -0,0 +1,256 @@
.profile-card {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20rpx;
padding: 28rpx;
}
.profile-main {
display: flex;
align-items: center;
min-width: 0;
gap: 20rpx;
}
.profile-copy {
min-width: 0;
}
.shop-logo {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 96rpx;
height: 96rpx;
border-radius: 24rpx;
background: #6f8f83;
color: #fff;
font-size: 40rpx;
font-weight: 900;
}
.shop-name,
.phone {
display: block;
}
.shop-name {
font-size: 34rpx;
font-weight: 800;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.phone {
margin-top: 8rpx;
color: #91897f;
font-size: 24rpx;
}
.role-badge {
flex-shrink: 0;
padding: 8rpx 18rpx;
border-radius: 999rpx;
background: #e5eee9;
color: #4e7165;
font-size: 23rpx;
font-weight: 800;
line-height: 1.2;
}
.menu-list {
overflow: hidden;
}
.menu-row {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 104rpx;
padding: 0 26rpx;
border-bottom: 1rpx solid #eee8df;
color: #302c27;
font-size: 28rpx;
font-weight: 700;
}
.menu-row:last-child {
border-bottom: 0;
}
.arrow {
color: #b0a79e;
font-size: 44rpx;
}
.modal-mask {
position: fixed;
inset: 0;
z-index: 80;
display: flex;
align-items: flex-end;
justify-content: center;
background: rgba(18, 15, 12, 0.48);
animation: maskIn 180ms ease both;
}
.profile-modal {
width: 100%;
max-height: 88vh;
overflow-y: auto;
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
border-radius: 28rpx 28rpx 0 0;
background: #fffaf4;
box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16);
animation: modalUp 220ms ease both;
}
.modal-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20rpx;
margin-bottom: 20rpx;
}
.modal-title {
color: #27211d;
font-size: 34rpx;
font-weight: 900;
}
.modal-close {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 48rpx;
min-width: 48rpx;
height: 48rpx;
border-radius: 50%;
border: 1rpx solid #e4d8ca;
background: #fffaf4;
color: transparent;
font-size: 0;
line-height: 0;
}
.modal-close::before,
.modal-close::after {
content: "";
position: absolute;
width: 22rpx;
height: 3rpx;
border-radius: 999rpx;
background: #61554c;
}
.modal-close::before {
transform: rotate(45deg);
}
.modal-close::after {
transform: rotate(-45deg);
}
.profile-avatar-row {
display: flex;
align-items: center;
gap: 16rpx;
margin-bottom: 18rpx;
padding: 18rpx;
border-radius: 18rpx;
background: #f7efe7;
}
.profile-avatar {
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 auto;
width: 92rpx;
height: 92rpx;
overflow: hidden;
border-radius: 50%;
background: #6f8f83;
color: #fff;
font-size: 24rpx;
font-weight: 900;
}
.profile-avatar image {
width: 100%;
height: 100%;
}
.avatar-btn {
flex: 1;
min-width: 0;
max-width: none;
}
.avatar-remove {
flex: 0 0 auto;
}
.modal-field {
margin-bottom: 16rpx;
padding: 16rpx 18rpx;
border-radius: 18rpx;
background: #f7efe7;
}
.modal-field text {
display: block;
margin-bottom: 8rpx;
color: #6c5f54;
font-size: 24rpx;
font-weight: 800;
}
.modal-field input,
.modal-field textarea,
.readonly-field view {
width: 100%;
color: #2c2722;
font-size: 28rpx;
}
.modal-field input,
.readonly-field view {
min-height: 58rpx;
line-height: 58rpx;
}
.modal-field textarea {
min-height: 120rpx;
}
.readonly-field view {
color: #7f756b;
}
.modal-submit {
margin-top: 22rpx;
}
@keyframes maskIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes modalUp {
from {
transform: translateY(40rpx);
}
to {
transform: translateY(0);
}
}