Files
soul-yongping/miniprogram/pages/profile-show/profile-show.js
卡若 fa3da12b16 feat: 小程序阅读记录与资料链路、管理端用户规则、API/VIP/推荐与运营脚本
- miniprogram: reading-records、imageUrl/mpNavigate、多页资料与 VIP 展示调整
- soul-admin: Users/Settings/UserDetailModal、dist 构建产物更新
- soul-api: user/vip/referral/ckb/db、MBTI 头像管理、user_rule_completion、迁移 SQL
- .cursor: karuo-party 与飞书文档;.gitignore 忽略 .tmp_skill_bundle

Made-with: Cursor
2026-03-23 18:38:23 +08:00

94 lines
3.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 卡若创业派对 - 个人资料展示页stitch_soul enhanced_professional_profile
* 从「我的」页编辑图标进入;展示基本信息、个人故事、互助需求、项目介绍
*/
const app = getApp()
const { isSafeImageSrc } = require('../../utils/imageUrl.js')
Page({
data: {
statusBarHeight: 44,
profile: null,
loading: true,
},
onLoad() {
this.setData({ statusBarHeight: app.globalData.statusBarHeight || 44 })
this.loadProfile()
},
onShow() {
if (this.data.profile) this.loadProfile()
},
async loadProfile() {
const userInfo = app.globalData.userInfo
if (!app.globalData.isLoggedIn || !userInfo?.id) {
this.setData({ loading: false })
wx.showToast({ title: '请先登录', icon: 'none' })
setTimeout(() => getApp().goBackOrToHome(), 1500)
return
}
this.setData({ loading: true })
try {
const res = await app.request({ url: `/api/miniprogram/user/profile?userId=${userInfo.id}`, silent: true })
if (res?.success && res.data) {
const d = res.data
const e = (v) => (v == null || v === undefined ? '' : (String(v).trim() === '' || String(v).trim() === '未填写' ? '' : String(v).trim()))
const phone = d.phone || ''
const wechat = d.wechatId || wx.getStorageSync('user_wechat') || ''
const av = d.avatar
this.setData({
profile: {
...d,
avatar: isSafeImageSrc(av) ? String(av).trim() : '',
industry: e(d.industry),
position: e(d.position),
businessScale: e(d.businessScale || d.business_scale),
skills: e(d.skills),
storyBestMonth: e(d.storyBestMonth || d.story_best_month),
storyAchievement: e(d.storyAchievement || d.story_achievement),
storyTurning: e(d.storyTurning || d.story_turning),
helpOffer: e(d.helpOffer || d.help_offer),
helpNeed: e(d.helpNeed || d.help_need),
projectIntro: e(d.projectIntro || d.project_intro),
phoneMask: phone ? phone.slice(0, 3) + '****' + phone.slice(-2) : '',
wechatMask: wechat ? (wechat.length > 8 ? wechat.slice(0, 4) + '****' + wechat.slice(-3) : wechat) : '',
phone,
wechat,
},
loading: false,
})
} else {
this.setData({ profile: null, loading: false })
}
} catch (e) {
this.setData({ profile: null, loading: false })
}
},
goBack() {
getApp().goBackOrToHome()
},
goToEdit() {
wx.navigateTo({ url: '/pages/profile-edit/profile-edit' })
},
copyPhone() {
const p = this.data.profile?.phone
if (!p) return
wx.setClipboardData({ data: p, success: () => wx.showToast({ title: '已复制', icon: 'success' }) })
},
copyWechat() {
const w = this.data.profile?.wechat
if (!w) return
wx.setClipboardData({ data: w, success: () => wx.showToast({ title: '已复制', icon: 'success' }) })
},
goToVip() {
wx.navigateTo({ url: '/pages/vip/vip' })
},
})