标记店务小程序版本更新
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
"pages/color-setting/index",
|
||||
"pages/employee-orders/index",
|
||||
"pages/profile/index",
|
||||
"pages/profile-settings/index",
|
||||
"pages/shop-settings/index",
|
||||
"pages/export/index",
|
||||
"pages/password/index",
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
const { BRAND_CONFIG } = require('../../utils/config')
|
||||
const userApi = require('../../api/user')
|
||||
const auth = require('../../utils/auth')
|
||||
const { chooseImageFilePath, uploadAvatar } = require('../../utils/upload')
|
||||
|
||||
const DEFAULT_BACKEND_AVATAR_URL = 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
|
||||
|
||||
function resolveRoleText(type) {
|
||||
const role = Number(type)
|
||||
if (role === 2) return '店长'
|
||||
if (role === 3) return '美甲师'
|
||||
if (role === 4) return '管理员'
|
||||
return '管理端'
|
||||
}
|
||||
|
||||
function normalizeAvatarUrl(avatar) {
|
||||
const value = String(avatar || '').trim()
|
||||
if (!value) return ''
|
||||
return value.split('?')[0]
|
||||
}
|
||||
|
||||
function resolveDisplayAvatar(avatar) {
|
||||
const value = String(avatar || '').trim()
|
||||
if (!value) return ''
|
||||
if (normalizeAvatarUrl(value) === DEFAULT_BACKEND_AVATAR_URL) return ''
|
||||
return value
|
||||
}
|
||||
|
||||
function buildProfileForm(profile) {
|
||||
return {
|
||||
nickname: profile.nickname || '',
|
||||
avatar: resolveDisplayAvatar(profile.avatar || profile.displayAvatar || ''),
|
||||
contactPhone: profile.contactPhone || '',
|
||||
wechatId: profile.wechatId || '',
|
||||
signature: profile.signature || ''
|
||||
}
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
shopName: BRAND_CONFIG.defaultShopName,
|
||||
roleText: '管理端',
|
||||
userInfo: {},
|
||||
loading: false,
|
||||
profileSaving: false,
|
||||
avatarUploading: false,
|
||||
profileForm: buildProfileForm({})
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.refreshFromSession()
|
||||
this.loadProfile()
|
||||
},
|
||||
|
||||
refreshFromSession() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
const nextUserInfo = {
|
||||
...userInfo,
|
||||
displayAvatar: resolveDisplayAvatar(userInfo.avatar)
|
||||
}
|
||||
this.setData({
|
||||
shopName: app.globalData.shopName || BRAND_CONFIG.appName,
|
||||
roleText: resolveRoleText(nextUserInfo.type),
|
||||
userInfo: nextUserInfo,
|
||||
profileForm: buildProfileForm(nextUserInfo)
|
||||
})
|
||||
},
|
||||
|
||||
async loadProfile() {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const profile = await userApi.info()
|
||||
this.syncProfileToSession(profile)
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '个人信息加载失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
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,
|
||||
displayAvatar: resolveDisplayAvatar(profile.avatar || '')
|
||||
}
|
||||
app.setSession({
|
||||
...session,
|
||||
userInfo: nextUserInfo
|
||||
})
|
||||
this.setData({
|
||||
userInfo: nextUserInfo,
|
||||
roleText: resolveRoleText(nextUserInfo.type),
|
||||
profileForm: buildProfileForm(nextUserInfo)
|
||||
})
|
||||
},
|
||||
|
||||
onProfileInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
[`profileForm.${field}`]: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
async chooseProfileAvatar() {
|
||||
if (this.data.loading || this.data.avatarUploading || this.data.profileSaving) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const filePath = await chooseImageFilePath()
|
||||
if (!filePath) {
|
||||
return
|
||||
}
|
||||
this.setData({ avatarUploading: true })
|
||||
const avatar = await uploadAvatar(filePath)
|
||||
const profile = await userApi.info()
|
||||
this.syncProfileToSession({
|
||||
...profile,
|
||||
avatar: profile.avatar || avatar
|
||||
})
|
||||
this.setData({ 'profileForm.avatar': resolveDisplayAvatar(profile.avatar || avatar) })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '头像上传失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ avatarUploading: false })
|
||||
}
|
||||
},
|
||||
|
||||
removeProfileAvatar() {
|
||||
if (this.data.avatarUploading || this.data.profileSaving) {
|
||||
return
|
||||
}
|
||||
this.setData({ 'profileForm.avatar': '' })
|
||||
},
|
||||
|
||||
async saveProfile() {
|
||||
if (this.data.loading || this.data.profileSaving || this.data.avatarUploading) {
|
||||
return
|
||||
}
|
||||
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)
|
||||
wx.showToast({ title: '已保存', icon: 'success' })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '保存失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ profileSaving: false })
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "个人资料"
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<view class="page no-tab profile-settings-page">
|
||||
<view wx:if="{{loading}}" class="loading-state">个人资料加载中</view>
|
||||
<block wx:else>
|
||||
<view class="page-heading">
|
||||
<text class="page-title">个人资料</text>
|
||||
<text class="page-subtitle">把你的姓名、联系方式和头像整理成店内可识别的名片。</text>
|
||||
</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>
|
||||
</view>
|
||||
<view wx:else class="portrait-avatar portrait-empty">头像</view>
|
||||
<view class="portrait-copy">
|
||||
<text class="portrait-name">{{profileForm.nickname || userInfo.nickname || '个人头像'}}</text>
|
||||
<text class="portrait-desc">{{roleText}} · {{shopName}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="portrait-actions">
|
||||
<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 class="info-grid">
|
||||
<view class="info-tile">
|
||||
<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">
|
||||
<text class="field-label required-label">昵称</text>
|
||||
<input value="{{profileForm.nickname}}" data-field="nickname" bindinput="onProfileInput" placeholder="请输入昵称" />
|
||||
</view>
|
||||
<view class="profile-field">
|
||||
<text class="field-label">联系电话</text>
|
||||
<input value="{{profileForm.contactPhone}}" data-field="contactPhone" bindinput="onProfileInput" type="number" placeholder="请输入联系电话" />
|
||||
</view>
|
||||
<view class="profile-field">
|
||||
<text class="field-label">微信号</text>
|
||||
<input value="{{profileForm.wechatId}}" data-field="wechatId" bindinput="onProfileInput" placeholder="请输入微信号" />
|
||||
</view>
|
||||
<view class="profile-field signature-field">
|
||||
<text class="field-label">签名</text>
|
||||
<textarea value="{{profileForm.signature}}" data-field="signature" bindinput="onProfileInput" placeholder="请输入个人签名" />
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view class="fixed-bottom">
|
||||
<button class="primary-btn" loading="{{profileSaving}}" disabled="{{loading || profileSaving || avatarUploading}}" bindtap="saveProfile">保存个人信息</button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,295 @@
|
||||
.profile-settings-page {
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255, 250, 242, 0.96), rgba(247, 240, 232, 0.96)),
|
||||
linear-gradient(135deg, rgba(89, 121, 102, 0.14), rgba(181, 134, 86, 0.12));
|
||||
}
|
||||
|
||||
.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 {
|
||||
padding: 48rpx 24rpx;
|
||||
color: #7b7167;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.portrait-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 28rpx;
|
||||
min-width: 0;
|
||||
margin-bottom: 26rpx;
|
||||
padding: 30rpx;
|
||||
overflow: hidden;
|
||||
border-radius: 28rpx;
|
||||
background:
|
||||
linear-gradient(135deg, rgba(55, 79, 66, 0.96), rgba(175, 126, 83, 0.94)),
|
||||
radial-gradient(circle at 18% 18%, rgba(255, 246, 224, 0.3), transparent 38%);
|
||||
box-shadow: 0 22rpx 46rpx rgba(83, 64, 44, 0.18);
|
||||
}
|
||||
|
||||
.portrait-glow {
|
||||
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;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
gap: 22rpx;
|
||||
}
|
||||
|
||||
.portrait-avatar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 0 0 auto;
|
||||
width: 132rpx;
|
||||
height: 132rpx;
|
||||
overflow: hidden;
|
||||
border: 4rpx solid rgba(255, 253, 248, 0.78);
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 253, 248, 0.18);
|
||||
color: #fffdf8;
|
||||
font-size: 28rpx;
|
||||
font-weight: 900;
|
||||
box-shadow: 0 16rpx 34rpx rgba(32, 25, 18, 0.18);
|
||||
}
|
||||
|
||||
.portrait-avatar image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.portrait-empty {
|
||||
background: rgba(255, 253, 248, 0.2);
|
||||
}
|
||||
|
||||
.portrait-copy {
|
||||
min-width: 0;
|
||||
color: #fffdf8;
|
||||
}
|
||||
|
||||
.portrait-name,
|
||||
.portrait-desc {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.portrait-name {
|
||||
font-size: 38rpx;
|
||||
font-weight: 900;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.portrait-desc {
|
||||
margin-top: 10rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
opacity: 0.84;
|
||||
}
|
||||
|
||||
.portrait-actions {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 14rpx;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.avatar-btn,
|
||||
.avatar-remove {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 1 1 220rpx;
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
min-height: 68rpx;
|
||||
padding: 0 24rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 25rpx;
|
||||
font-weight: 900;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.avatar-btn {
|
||||
background: #fff8ed;
|
||||
color: #6d4d35;
|
||||
}
|
||||
|
||||
.avatar-remove {
|
||||
flex-grow: 0;
|
||||
min-width: 150rpx;
|
||||
background: rgba(255, 253, 248, 0.18);
|
||||
color: #fffdf8;
|
||||
}
|
||||
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16rpx;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.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;
|
||||
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 textarea {
|
||||
width: 100%;
|
||||
min-height: 76rpx;
|
||||
padding: 0 22rpx;
|
||||
border: 1rpx solid #eadfd2;
|
||||
border-radius: 18rpx;
|
||||
background: #fff8f2;
|
||||
color: #2d2722;
|
||||
font-size: 28rpx;
|
||||
line-height: 76rpx;
|
||||
}
|
||||
|
||||
.profile-field textarea {
|
||||
height: 150rpx;
|
||||
padding-top: 18rpx;
|
||||
padding-bottom: 18rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.signature-field {
|
||||
min-height: 218rpx;
|
||||
}
|
||||
|
||||
@media (max-width: 340px) {
|
||||
.portrait-main {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.portrait-avatar {
|
||||
width: 112rpx;
|
||||
height: 112rpx;
|
||||
}
|
||||
|
||||
.portrait-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.avatar-btn,
|
||||
.avatar-remove {
|
||||
flex: 0 0 auto;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.info-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ const userApi = require('../../api/user')
|
||||
const shopApi = require('../../api/shop')
|
||||
const authApi = require('../../api/auth')
|
||||
const auth = require('../../utils/auth')
|
||||
const { chooseImageFilePath, uploadAvatar } = require('../../utils/upload')
|
||||
|
||||
const DEFAULT_BACKEND_AVATAR_URL = 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
|
||||
|
||||
@@ -42,19 +41,9 @@ Page({
|
||||
phone: '店长端',
|
||||
roleText: '管理端',
|
||||
userInfo: {},
|
||||
editModalVisible: false,
|
||||
profileSaving: false,
|
||||
avatarUploading: false,
|
||||
loggingOut: false,
|
||||
profileForm: {
|
||||
nickname: '',
|
||||
avatar: '',
|
||||
contactPhone: '',
|
||||
wechatId: '',
|
||||
signature: ''
|
||||
},
|
||||
menus: [
|
||||
{ title: '个人信息', action: 'editProfile' },
|
||||
{ title: '个人信息', url: '/pages/profile-settings/index' },
|
||||
{ title: '店铺设置', url: '/pages/shop-settings/index' },
|
||||
{ title: '数据导出', url: '/pages/export/index' },
|
||||
{ title: '修改密码', url: '/pages/password/index' },
|
||||
@@ -104,10 +93,6 @@ Page({
|
||||
|
||||
go(event) {
|
||||
const action = event.currentTarget.dataset.action
|
||||
if (action === 'editProfile') {
|
||||
this.openEditProfile()
|
||||
return
|
||||
}
|
||||
if (action === 'logout') {
|
||||
this.confirmLogout()
|
||||
return
|
||||
@@ -189,91 +174,5 @@ Page({
|
||||
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.displayAvatar || '',
|
||||
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 uploadAvatar(filePath)
|
||||
const profile = await userApi.info()
|
||||
this.syncProfileToSession({
|
||||
...profile,
|
||||
avatar: profile.avatar || avatar
|
||||
})
|
||||
this.setData({ 'profileForm.avatar': resolveDisplayAvatar(profile.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 })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -42,62 +42,4 @@
|
||||
<text wx:if="{{item.action !== 'logout'}}" class="arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{editModalVisible}}" class="modal-mask" catchtap="stopTap">
|
||||
<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>
|
||||
<view class="profile-avatar-copy">
|
||||
<text class="profile-avatar-name">{{profileForm.nickname || userInfo.nickname || '个人头像'}}</text>
|
||||
<text class="profile-avatar-desc">这里只修改个人资料头像</text>
|
||||
</view>
|
||||
<view class="profile-avatar-actions">
|
||||
<button class="avatar-btn" loading="{{avatarUploading}}" bindtap="chooseProfileAvatar">{{avatarUploading ? '上传中' : profileForm.avatar ? '更换头像' : '上传头像'}}</button>
|
||||
<button wx:if="{{profileForm.avatar}}" class="avatar-remove" bindtap="removeProfileAvatar">移除</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="profile-info-grid">
|
||||
<view class="profile-info-item">
|
||||
<text>登录账号</text>
|
||||
<view>{{userInfo.account || '未设置'}}</view>
|
||||
</view>
|
||||
<view class="profile-info-item">
|
||||
<text>身份</text>
|
||||
<view>{{roleText}}</view>
|
||||
</view>
|
||||
<view class="profile-info-item">
|
||||
<text>登录手机号</text>
|
||||
<view>{{userInfo.phone || '未绑定'}}</view>
|
||||
</view>
|
||||
<view class="profile-info-item">
|
||||
<text>当前店铺</text>
|
||||
<view>{{shopName}}</view>
|
||||
</view>
|
||||
</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">
|
||||
<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>
|
||||
|
||||
@@ -204,168 +204,6 @@
|
||||
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(30rpx + 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: 18rpx;
|
||||
margin-bottom: 18rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 20rpx;
|
||||
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%;
|
||||
}
|
||||
|
||||
.profile-avatar-copy {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.profile-avatar-name,
|
||||
.profile-avatar-desc {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.profile-avatar-name {
|
||||
color: #29241f;
|
||||
font-size: 28rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.profile-avatar-desc {
|
||||
margin-top: 8rpx;
|
||||
color: #8a7f75;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.profile-avatar-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 0 0 auto;
|
||||
gap: 14rpx;
|
||||
width: 150rpx;
|
||||
}
|
||||
|
||||
.avatar-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
min-height: 60rpx;
|
||||
padding: 0 14rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #6f8f83;
|
||||
color: #fffdf8;
|
||||
font-size: 24rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.avatar-remove {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
min-height: 54rpx;
|
||||
padding: 0 14rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #f4e8e0;
|
||||
color: #9a5f43;
|
||||
font-size: 24rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
@media (max-width: 340px) {
|
||||
.profile-card-head {
|
||||
flex-wrap: wrap;
|
||||
@@ -382,114 +220,4 @@
|
||||
.profile-summary-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.profile-avatar-row {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.profile-avatar-actions {
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.profile-info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 14rpx;
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
|
||||
.profile-info-item {
|
||||
min-width: 0;
|
||||
padding: 16rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #f7efe7;
|
||||
}
|
||||
|
||||
.profile-info-item text,
|
||||
.profile-info-item view {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.profile-info-item text {
|
||||
color: #8a7f75;
|
||||
font-size: 22rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.profile-info-item view {
|
||||
margin-top: 8rpx;
|
||||
color: #2c2722;
|
||||
font-size: 25rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.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%;
|
||||
padding: 0 18rpx;
|
||||
border: 1rpx solid #eadfd2;
|
||||
border-radius: 16rpx;
|
||||
background: #fffdf8;
|
||||
color: #2c2722;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.modal-field input,
|
||||
.readonly-field view {
|
||||
min-height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
}
|
||||
|
||||
.modal-field textarea {
|
||||
min-height: 120rpx;
|
||||
padding-top: 18rpx;
|
||||
padding-bottom: 18rpx;
|
||||
}
|
||||
|
||||
.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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user