From c13ee387865604c8ce21202f8c8330fbe39fcc34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=98=E9=A3=8E?= Date: Fri, 13 Feb 2026 17:47:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BC=96=E8=BE=91=E8=B5=84?= =?UTF-8?q?=E6=96=99=E5=85=A5=E5=8F=A3=EF=BC=8C=E4=BC=98=E5=8C=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BD=93=E9=AA=8C=E3=80=82=E6=9B=B4=E6=96=B0=20app.json=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BB=A5=E5=8C=85=E5=90=AB=E6=96=B0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E8=B7=AF=E5=BE=84=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E5=8A=9F=E8=83=BD=E6=AD=A3=E5=B8=B8=E3=80=82=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=A0=B7=E5=BC=8F=E4=BB=A5=E6=8F=90=E5=8D=87=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=8F=8B=E5=A5=BD=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/app.json | 65 +---- miniprogram/pages/my/my.js | 9 + miniprogram/pages/my/my.wxml | 6 + miniprogram/pages/my/my.wxss | 28 +++ .../pages/profile-edit/profile-edit.js | 184 ++++++++++++++ .../pages/profile-edit/profile-edit.json | 4 + .../pages/profile-edit/profile-edit.wxml | 125 ++++++++++ .../pages/profile-edit/profile-edit.wxss | 227 ++++++++++++++++++ 8 files changed, 584 insertions(+), 64 deletions(-) create mode 100644 miniprogram/pages/profile-edit/profile-edit.js create mode 100644 miniprogram/pages/profile-edit/profile-edit.json create mode 100644 miniprogram/pages/profile-edit/profile-edit.wxml create mode 100644 miniprogram/pages/profile-edit/profile-edit.wxss diff --git a/miniprogram/app.json b/miniprogram/app.json index a8bb2bec..e70546ce 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,64 +1 @@ -{ - "pages": [ - "pages/index/index", - "pages/chapters/chapters", - "pages/match/match", - "pages/my/my", - "pages/read/read", - "pages/about/about", - "pages/agreement/agreement", - "pages/privacy/privacy", - "pages/referral/referral", - "pages/purchases/purchases", - "pages/settings/settings", - "pages/search/search", - "pages/addresses/addresses", - "pages/addresses/edit","pages/withdraw-records/withdraw-records","pages/scan/scan" - ], - "window": { - "backgroundTextStyle": "light", - "navigationBarBackgroundColor": "#000000", - "navigationBarTitleText": "Soul创业派对", - "navigationBarTextStyle": "white", - "backgroundColor": "#000000", - "navigationStyle": "custom" - }, - "tabBar": { - "custom": true, - "color": "#8e8e93", - "selectedColor": "#00CED1", - "backgroundColor": "#1c1c1e", - "borderStyle": "black", - "list": [ - { - "pagePath": "pages/index/index", - "text": "首页" - }, - { - "pagePath": "pages/chapters/chapters", - "text": "目录" - }, - { - "pagePath": "pages/match/match", - "text": "找伙伴" - }, - { - "pagePath": "pages/my/my", - "text": "我的" - } - ] - }, - "usingComponents": {}, - "__usePrivacyCheck__": true, - "permission": { - "scope.userLocation": { - "desc": "用于匹配附近的书友" - } - }, - "requiredPrivateInfos": [ - "getLocation" - ], - "lazyCodeLoading": "requiredComponents", - "style": "v2", - "sitemapLocation": "sitemap.json" -} +{"pages":["pages/index/index","pages/chapters/chapters","pages/match/match","pages/my/my","pages/read/read","pages/about/about","pages/agreement/agreement","pages/privacy/privacy","pages/referral/referral","pages/purchases/purchases","pages/settings/settings","pages/search/search","pages/addresses/addresses","pages/addresses/edit","pages/withdraw-records/withdraw-records","pages/scan/scan","pages/profile-edit/profile-edit"],"window":{"backgroundTextStyle":"light","navigationBarBackgroundColor":"#000000","navigationBarTitleText":"Soul创业派对","navigationBarTextStyle":"white","backgroundColor":"#000000","navigationStyle":"custom"},"tabBar":{"custom":true,"color":"#8e8e93","selectedColor":"#00CED1","backgroundColor":"#1c1c1e","borderStyle":"black","list":[{"pagePath":"pages/index/index","text":"首页"},{"pagePath":"pages/chapters/chapters","text":"目录"},{"pagePath":"pages/match/match","text":"找伙伴"},{"pagePath":"pages/my/my","text":"我的"}]},"usingComponents":{},"__usePrivacyCheck__":true,"permission":{"scope.userLocation":{"desc":"用于匹配附近的书友"}},"requiredPrivateInfos":["getLocation"],"lazyCodeLoading":"requiredComponents","style":"v2","sitemapLocation":"sitemap.json"} diff --git a/miniprogram/pages/my/my.js b/miniprogram/pages/my/my.js index 40ef6e66..117e954c 100644 --- a/miniprogram/pages/my/my.js +++ b/miniprogram/pages/my/my.js @@ -610,6 +610,15 @@ Page({ } }, + // 跳转编辑资料页 + goEditProfile() { + if (!this.data.isLoggedIn) { + this.showLogin() + return + } + wx.navigateTo({ url: '/pages/profile-edit/profile-edit' }) + }, + // 点击菜单 handleMenuTap(e) { const id = e.currentTarget.dataset.id diff --git a/miniprogram/pages/my/my.wxml b/miniprogram/pages/my/my.wxml index 9eb42a78..5d243308 100644 --- a/miniprogram/pages/my/my.wxml +++ b/miniprogram/pages/my/my.wxml @@ -73,6 +73,12 @@ + + + + ✏️ + 编辑资料 + diff --git a/miniprogram/pages/my/my.wxss b/miniprogram/pages/my/my.wxss index 611fbb78..aa085bd2 100644 --- a/miniprogram/pages/my/my.wxss +++ b/miniprogram/pages/my/my.wxss @@ -95,6 +95,34 @@ white-space: nowrap; } +/* 编辑资料入口 - 深色圆角按钮 */ +.edit-profile-entry { + display: flex; + align-items: center; + justify-content: center; + gap: 16rpx; + width: 100%; + padding: 28rpx 32rpx; + margin-bottom: 24rpx; + background: rgba(255, 255, 255, 0.06); + border: 2rpx solid rgba(0, 206, 209, 0.25); + border-radius: 24rpx; +} + +.edit-profile-entry:active { + background: rgba(255, 255, 255, 0.1); +} + +.edit-profile-icon { + font-size: 32rpx; +} + +.edit-profile-text { + font-size: 28rpx; + font-weight: 500; + color: #00CED1; +} + .card-gradient { background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%); border-radius: 32rpx; diff --git a/miniprogram/pages/profile-edit/profile-edit.js b/miniprogram/pages/profile-edit/profile-edit.js new file mode 100644 index 00000000..7d53c4db --- /dev/null +++ b/miniprogram/pages/profile-edit/profile-edit.js @@ -0,0 +1,184 @@ +/** + * Soul创业派对 - 编辑资料页 + * 图二样式,行业/业务体量拆成两个独立输入框 + */ + +const app = getApp() + +const MBTI_LIST = ['INTJ', 'INTP', 'ENTJ', 'ENTP', 'INFJ', 'INFP', 'ENFJ', 'ENFP', 'ISTJ', 'ISFJ', 'ESTJ', 'ESFJ', 'ISTP', 'ISFP', 'ESTP', 'ESFP'] + +Page({ + data: { + statusBarHeight: 44, + avatar: '', + nickname: '', + mbtiList: MBTI_LIST, + mbtiIndex: 0, + mbti: '', + region: '', + industry: '', + businessVolume: '', + position: '', + mostProfitableMonth: '', + howCanHelp: '' + }, + + onLoad() { + this.setData({ + statusBarHeight: app.globalData.statusBarHeight || 44 + }) + this.loadProfile() + }, + + loadProfile() { + const userInfo = app.globalData.userInfo || wx.getStorageSync('userInfo') || {} + const ext = wx.getStorageSync('userProfileExt') || {} + const mbti = ext.mbti || '' + const mbtiIndex = MBTI_LIST.indexOf(mbti) + this.setData({ + avatar: userInfo.avatar || '', + nickname: userInfo.nickname || '', + mbti: mbti, + mbtiIndex: mbtiIndex >= 0 ? mbtiIndex : 0, + region: ext.region || '', + industry: ext.industry || '', + businessVolume: ext.businessVolume || '', + position: ext.position || '', + mostProfitableMonth: ext.mostProfitableMonth || '', + howCanHelp: ext.howCanHelp || '' + }) + }, + + goBack() { + wx.navigateBack() + }, + + onNicknameInput(e) { + this.setData({ nickname: e.detail.value }) + }, + + onMbtiChange(e) { + const i = parseInt(e.detail.value, 10) + this.setData({ + mbtiIndex: i, + mbti: MBTI_LIST[i] || '' + }) + }, + + onRegionInput(e) { + this.setData({ region: e.detail.value }) + }, + + onIndustryInput(e) { + this.setData({ industry: e.detail.value }) + }, + + onBusinessVolumeInput(e) { + this.setData({ businessVolume: e.detail.value }) + }, + + onPositionInput(e) { + this.setData({ position: e.detail.value }) + }, + + onMostProfitableMonthInput(e) { + this.setData({ mostProfitableMonth: e.detail.value }) + }, + + onHowCanHelpInput(e) { + this.setData({ howCanHelp: e.detail.value }) + }, + + async onChooseAvatar(e) { + const tempAvatarUrl = e.detail.avatarUrl + if (!tempAvatarUrl) return + + wx.showLoading({ title: '上传中...', mask: true }) + + try { + const uploadRes = await new Promise((resolve, reject) => { + wx.uploadFile({ + url: app.globalData.baseUrl + '/api/miniprogram/upload', + filePath: tempAvatarUrl, + name: 'file', + formData: { folder: 'avatars' }, + success: (res) => { + try { + const data = JSON.parse(res.data) + if (data.success) resolve(data) + else reject(new Error(data.error || '上传失败')) + } catch (err) { + reject(new Error('解析响应失败')) + } + }, + fail: (err) => reject(err) + }) + }) + + const avatarUrl = app.globalData.baseUrl + uploadRes.data.url + this.setData({ avatar: avatarUrl }) + + const userInfo = app.globalData.userInfo + if (userInfo && userInfo.id) { + await app.request({ + url: '/api/miniprogram/user/update', + method: 'POST', + data: { userId: userInfo.id, avatar: avatarUrl } + }) + userInfo.avatar = avatarUrl + app.globalData.userInfo = userInfo + wx.setStorageSync('userInfo', userInfo) + } + + wx.hideLoading() + wx.showToast({ title: '头像已更新', icon: 'success' }) + } catch (e) { + wx.hideLoading() + wx.showToast({ title: e.message || '上传失败', icon: 'none' }) + } + }, + + async saveProfile() { + const { nickname, mbti, region, industry, businessVolume, position, mostProfitableMonth, howCanHelp } = this.data + const userInfo = app.globalData.userInfo + + wx.showLoading({ title: '保存中...', mask: true }) + + try { + if (userInfo && userInfo.id) { + const payload = { userId: userInfo.id } + if (nickname !== undefined && nickname !== userInfo.nickname) payload.nickname = nickname.trim() + if (Object.keys(payload).length > 1) { + await app.request({ + url: '/api/miniprogram/user/update', + method: 'POST', + data: payload + }) + if (payload.nickname !== undefined) { + userInfo.nickname = payload.nickname + app.globalData.userInfo = userInfo + wx.setStorageSync('userInfo', userInfo) + } + } + } + + const ext = { + mbti: (mbti || '').trim(), + region: (region || '').trim(), + industry: (industry || '').trim(), + businessVolume: (businessVolume || '').trim(), + position: (position || '').trim(), + mostProfitableMonth: (mostProfitableMonth || '').trim(), + howCanHelp: (howCanHelp || '').trim() + } + wx.setStorageSync('userProfileExt', ext) + + wx.hideLoading() + wx.showToast({ title: '保存成功', icon: 'success' }) + setTimeout(() => wx.navigateBack(), 500) + } catch (e) { + wx.hideLoading() + wx.showToast({ title: e.message || '保存失败', icon: 'none' }) + } + } +}) diff --git a/miniprogram/pages/profile-edit/profile-edit.json b/miniprogram/pages/profile-edit/profile-edit.json new file mode 100644 index 00000000..e90e9960 --- /dev/null +++ b/miniprogram/pages/profile-edit/profile-edit.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationStyle": "custom" +} diff --git a/miniprogram/pages/profile-edit/profile-edit.wxml b/miniprogram/pages/profile-edit/profile-edit.wxml new file mode 100644 index 00000000..64b1da4d --- /dev/null +++ b/miniprogram/pages/profile-edit/profile-edit.wxml @@ -0,0 +1,125 @@ + + + + + + + 编辑资料 + + + + + + + + + + + + + + 昵称 + + + + + + + MBTI + + + {{mbti || '请选择'}} + + + + + + 地区 + + 📍 + + + + + + + + 行业 + + + + + + 业务体量 + + + + + + 职位 + + + + + + 你最赚钱的一个月做的是什么 +