重构项目文件夹目录

This commit is contained in:
2026-06-15 15:53:55 +08:00
parent 8093e07190
commit 7cbe5b3de5
1098 changed files with 34 additions and 4441 deletions
@@ -0,0 +1,76 @@
const userApi = require('../../api/user')
const auth = require('../../utils/auth')
const navigation = require('../../utils/navigation')
const theme = require('../../utils/theme')
const { runWithLoading } = require('../../utils/loading')
Page({
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
loading: false,
saving: false,
isLoggedIn: false,
userInfo: null,
form: {
nickname: '',
signature: ''
}
}),
onShow() {
this.loadProfile()
},
handleBack() {
navigation.goBack('/pages/settings/index')
},
async loadProfile() {
const isLoggedIn = auth.isLoggedIn()
this.setData({ isLoggedIn })
if (!isLoggedIn) {
navigation.openAuth(navigation.getCurrentPageUrl())
return
}
this.setData({ loading: true })
try {
const userInfo = await userApi.getUserInfo()
this.setData({
userInfo,
'form.nickname': userInfo.nickname || '',
'form.signature': userInfo.signature || ''
})
} catch (error) {
wx.showToast({ title: error.message || '资料加载失败', icon: 'none' })
} finally {
this.setData({ loading: false })
}
},
handleInput(event) {
const field = event.currentTarget.dataset.field
this.setData({
[`form.${field}`]: event.detail.value
})
},
async saveProfile() {
const nickname = String(this.data.form.nickname || '').trim()
if (!nickname) {
wx.showToast({ title: '请输入昵称', icon: 'none' })
return
}
this.setData({ saving: true })
try {
await runWithLoading(() => userApi.updateUserInfo({
nickname,
signature: String(this.data.form.signature || '').trim()
}))
wx.showToast({ title: '资料已更新', icon: 'none' })
await this.loadProfile()
} catch (error) {
wx.showToast({ title: error.message || '资料更新失败', icon: 'none' })
} finally {
this.setData({ saving: false })
}
}
})
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,23 @@
<navigation-bar title="账号资料" showBack="{{true}}" fallbackPath="/pages/settings/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
<view class="page-shell" style="{{themeVars}}">
<view class="page-content">
<view class="page-hero">
<text class="hero-kicker">Account</text>
<text class="hero-title">账号资料</text>
<text class="hero-desc">维护昵称、个性签名和基础资料�?/text>
</view>
<view class="page-card form-card">
<view class="field-block">
<text class="field-label">昵称</text>
<input class="field-input" value="{{form.nickname}}" data-field="nickname" bindinput="handleInput" placeholder="请输入昵�? placeholder-class="field-placeholder" />
</view>
<view class="field-block">
<text class="field-label">个��签�?/text>
<textarea class="field-textarea" maxlength="120" value="{{form.signature}}" data-field="signature" bindinput="handleInput" placeholder="写一句介绍自�? placeholder-class="field-placeholder"></textarea>
</view>
<button class="primary-btn" loading="{{saving}}" bindtap="saveProfile">保存资料</button>
</view>
</view>
</view>
@@ -0,0 +1,12 @@
.form-card {
margin-top: 22rpx;
padding: 28rpx;
}
.field-block + .field-block {
margin-top: 24rpx;
}
.primary-btn {
margin-top: 28rpx;
}