标记店务小程序版本更新

This commit is contained in:
2026-07-22 20:40:13 +08:00
parent 5536acc4d4
commit 6806ac14c9
8 changed files with 550 additions and 432 deletions
+1 -102
View File
@@ -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 })
}
}
})