Files
Mycontent/miniprogram/pages/profile-show/profile-show.js
乘风 83a420f1b9 feat: implement audit mode restrictions across various pages
- Added checks for audit mode in VIP navigation and member detail pages, preventing access and displaying appropriate messages.
- Updated UI elements to conditionally render based on audit mode, enhancing user experience by hiding VIP-related options when in audit mode.
- Introduced loading indicators on the VIP page to manage user expectations during content validation.
- Enhanced error handling for image uploads in the article editor, ensuring a smoother content creation process.

This update aims to improve the overall user experience by enforcing access restrictions and providing clear feedback in audit mode.
2026-04-24 18:23:34 +08:00

111 lines
3.6 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')
const { resolveAvatarWithMbti } = require('../../utils/mbtiAvatar.js')
Page({
data: {
statusBarHeight: 44,
profile: null,
loading: true,
auditMode: false,
},
onLoad() {
this.setData({ statusBarHeight: app.globalData.statusBarHeight || 44, auditMode: app.globalData.auditMode || false })
this.loadProfile()
},
onShow() {
this.setData({ auditMode: !!app.globalData.auditMode })
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 {
try {
if (app.loadMbtiAvatarsMap) await app.loadMbtiAvatarsMap()
} catch (_) {}
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
const safeAv = isSafeImageSrc(av) ? String(av).trim() : ''
const displayAv = resolveAvatarWithMbti(
safeAv,
d.mbti,
app.globalData.mbtiAvatarsMap || {},
app.globalData.baseUrl || ''
)
this.setData({
profile: {
...d,
avatar: displayAv,
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() {
if (app.globalData.auditMode) {
wx.showToast({ title: '当前为体验版,暂无法访问', icon: 'none' })
return
}
wx.navigateTo({ url: '/pages/vip/vip' })
},
})