91 lines
2.9 KiB
JavaScript
91 lines
2.9 KiB
JavaScript
/**
|
||
* Soul创业派对 - 个人资料展示页(stitch_soul enhanced_professional_profile)
|
||
* 从「我的」页编辑图标进入;展示基本信息、个人故事、互助需求、项目介绍
|
||
*/
|
||
const app = getApp()
|
||
|
||
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') || ''
|
||
this.setData({
|
||
profile: {
|
||
...d,
|
||
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' })
|
||
},
|
||
})
|