优化输入框和表单样式,确保在小程序和管理端开发中使用容器包裹输入框以避免布局问题。更新个人资料页,增加VIP用户的字段展示与编辑逻辑,确保用户体验一致性。调整相关文档以反映最新开发进展,提升功能可用性与用户体验。

This commit is contained in:
Alex-larget
2026-02-28 17:26:03 +08:00
parent 41e5b1258b
commit 8e2ea9b7c1
14 changed files with 195 additions and 114 deletions

View File

@@ -1,6 +1,12 @@
/**
* Soul创业派对 - 资料编辑完整版comprehensive_profile_editor_v1_1
* 温馨提示、头像、基本信息、核心联系方式、个人故事、互助需求、项目介绍
*
* 接口约定(/api/miniprogram/user/profile
* - GET ?userId= 返回 data: { avatar, nickname, mbti, region, industry, businessScale, position, skills, phone, wechatId, ... },空值统一为 ""
* - POST body普通用户提交基础字段VIP 提交全部字段(含 skills、个人故事、互助需求、项目介绍
*
* 表单展示:普通用户仅展示 温馨提示、头像、昵称、MBTI、地区、行业、业务体量、职位、核心联系方式VIP 展示全部
*/
const app = getApp()
@@ -9,6 +15,7 @@ const MBTI_OPTIONS = ['INTJ', 'INFP', 'INTP', 'ENTP', 'ENFP', 'ENTJ', 'ENFJ', 'I
Page({
data: {
statusBarHeight: 44,
isVip: false,
avatar: '',
nickname: '',
mbti: '',
@@ -46,28 +53,35 @@ Page({
return
}
try {
const res = await app.request({ url: `/api/miniprogram/user/profile?userId=${userInfo.id}`, silent: true })
const userId = userInfo.id
const [profileRes, vipRes] = await Promise.all([
app.request({ url: `/api/miniprogram/user/profile?userId=${userId}`, silent: true }),
app.request({ url: `/api/miniprogram/vip/status?userId=${userId}`, silent: true }),
])
this.setData({ isVip: vipRes?.data?.isVip || false })
const res = profileRes
if (res?.success && res.data) {
const d = res.data
const mbtiIndex = MBTI_OPTIONS.indexOf(d.mbti || '') >= 0 ? MBTI_OPTIONS.indexOf(d.mbti) : 0
const v = (k) => (d[k] != null && d[k] !== '') ? String(d[k]) : ''
const mbtiIndex = MBTI_OPTIONS.indexOf(v('mbti')) >= 0 ? MBTI_OPTIONS.indexOf(v('mbti')) : 0
this.setData({
avatar: d.avatar || '',
nickname: d.nickname || '',
mbti: d.mbti || '',
avatar: v('avatar'),
nickname: v('nickname'),
mbti: v('mbti'),
mbtiIndex,
region: d.region || '',
industry: d.industry || '',
businessScale: d.businessScale || '',
position: d.position || '',
skills: d.skills || '',
phone: d.phone || '',
wechatId: d.wechatId || wx.getStorageSync('user_wechat') || '',
storyBestMonth: d.storyBestMonth || '',
storyAchievement: d.storyAchievement || '',
storyTurning: d.storyTurning || '',
helpOffer: d.helpOffer || '',
helpNeed: d.helpNeed || '',
projectIntro: d.projectIntro || '',
region: v('region'),
industry: v('industry'),
businessScale: v('businessScale'),
position: v('position'),
skills: v('skills'),
phone: v('phone'),
wechatId: v('wechatId') || wx.getStorageSync('user_wechat') || '',
storyBestMonth: v('storyBestMonth'),
storyAchievement: v('storyAchievement'),
storyTurning: v('storyTurning'),
helpOffer: v('helpOffer'),
helpNeed: v('helpNeed'),
projectIntro: v('projectIntro'),
loading: false,
})
} else {
@@ -154,27 +168,35 @@ Page({
}
this.setData({ saving: true })
try {
const s = (v) => (v || '').toString().trim()
const isVip = this.data.isVip
const payload = {
userId,
nickname: this.data.nickname.trim() || undefined,
mbti: this.data.mbti || undefined,
region: this.data.region.trim() || undefined,
industry: this.data.industry.trim() || undefined,
businessScale: this.data.businessScale.trim() || undefined,
position: this.data.position.trim() || undefined,
skills: this.data.skills.trim() || undefined,
phone: this.data.phone.trim() || undefined,
wechatId: this.data.wechatId.trim() || undefined,
storyBestMonth: this.data.storyBestMonth.trim() || undefined,
storyAchievement: this.data.storyAchievement.trim() || undefined,
storyTurning: this.data.storyTurning.trim() || undefined,
helpOffer: this.data.helpOffer.trim() || undefined,
helpNeed: this.data.helpNeed.trim() || undefined,
projectIntro: this.data.projectIntro.trim() || undefined,
avatar: s(this.data.avatar),
nickname: s(this.data.nickname),
mbti: s(this.data.mbti),
region: s(this.data.region),
industry: s(this.data.industry),
businessScale: s(this.data.businessScale),
position: s(this.data.position),
phone: s(this.data.phone),
wechatId: s(this.data.wechatId),
}
const showHelp = isVip || this.data.helpOffer || this.data.helpNeed
if (isVip) {
payload.skills = s(this.data.skills)
payload.storyBestMonth = s(this.data.storyBestMonth)
payload.storyAchievement = s(this.data.storyAchievement)
payload.storyTurning = s(this.data.storyTurning)
payload.projectIntro = s(this.data.projectIntro)
}
if (showHelp) {
payload.helpOffer = s(this.data.helpOffer)
payload.helpNeed = s(this.data.helpNeed)
}
if (payload.wechatId) wx.setStorageSync('user_wechat', payload.wechatId)
if (payload.phone) wx.setStorageSync('user_phone', payload.phone)
const hasUpdate = Object.keys(payload).some(k => k !== 'userId' && payload[k] != null)
const hasUpdate = Object.keys(payload).some(k => k !== 'userId' && payload[k] !== '')
if (!hasUpdate) {
wx.showToast({ title: '无变更', icon: 'none' })
this.setData({ saving: false })
@@ -186,8 +208,9 @@ Page({
data: payload,
})
wx.showToast({ title: '保存成功', icon: 'success' })
if (app.globalData.userInfo && payload.nickname) {
app.globalData.userInfo.nickname = payload.nickname
if (app.globalData.userInfo) {
if (payload.nickname) app.globalData.userInfo.nickname = payload.nickname
if (payload.avatar) app.globalData.userInfo.avatar = payload.avatar
wx.setStorageSync('userInfo', app.globalData.userInfo)
}
setTimeout(() => wx.navigateBack(), 800)