| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457 |
- <template>
- <view class="container">
- <!-- 未登录 -->
- <view v-if="!isLoggedIn">
- <view class="login-prompt">
- <text class="prompt-icon">👤</text>
- <text class="prompt-title">登录浠艾福</text>
- <text class="prompt-desc">登录后查看个人资料、积分记录、能量数据与家庭管理</text>
- <button class="login-btn" @click="goLogin">登录 / 注册</button>
- <text class="skip-link" @click="goSkip">暂不登录,先逛逛 ›</text>
- </view>
- <view class="philosophy-card">
- <text class="philosophy-title">照顾家庭,从照顾好自己开始</text>
- <text class="philosophy-desc">你的状态,就是家的状态。先安顿好自己,才有余力温暖家人。</text>
- </view>
- </view>
- <!-- 已登录 -->
- <template v-else>
- <!-- 退出切换 -->
- <view class="exit-switch" v-if="isSwitchedChild" @click="onExitSwitch">
- <text>🔄 退出切换</text>
- </view>
- <!-- 身份卡 -->
- <view class="user-card">
- <view class="user-card-left">
- <view class="avatar-wrap" @click="goToEditInfo">
- <image v-if="userInfo.avatar" class="avatar-img" :src="userInfo.avatar" mode="aspectFill" />
- <text v-else class="avatar-text">{{ nickname.charAt(0) || '👤' }}</text>
- </view>
- <view class="user-meta">
- <view class="user-name-row">
- <text class="nickname">{{ nickname || '未设置昵称' }}</text>
- <text v-if="roleLabel" class="role-tag">{{ roleLabel }}</text>
- </view>
- <view class="user-sub" v-if="memberLevel">
- <view class="level-badge" :class="'level-' + memberLevel">{{ memberLevelText }}</view>
- <text v-if="isLifetime" class="days-left">永久有效</text>
- <text v-else-if="membershipDays > 0 && membershipDays <= 30" class="days-left">剩余 {{ membershipDays }} 天</text>
- <view v-if="hasUpgradeSpace" class="upgrade-btn" @click="goUpgrade">
- <text class="upgrade-btn-text">{{ upgradeBtnText }}</text>
- </view>
- </view>
- <view class="user-sub" v-else>
- <text class="days-left">开通会员解锁更多权益</text>
- <view class="upgrade-btn" @click="goUpgrade">
- <text class="upgrade-btn-text">立即开通</text>
- </view>
- </view>
- </view>
- </view>
- <view class="user-card-right" @click="goToPoints">
- <text class="points-num">{{ totalPoints }}</text>
- <text class="points-label">积分</text>
- </view>
- </view>
- <!-- 我的推广码浮动按钮 -->
- <view class="share-qr-float" @click="showShareQr">
- <text class="share-qr-icon">📱</text>
- </view>
- <!-- 家族成员速览 -->
- <view class="family-strip" v-if="familyMembers.length > 0">
- <view class="family-strip-header">
- <text class="family-strip-title">我的家庭</text>
- <text class="family-strip-count">{{ familyMembers.length }} 位成员</text>
- </view>
- <view class="family-avatars">
- <view
- v-for="member in familyMembers"
- :key="member.id"
- class="family-avatar-item"
- @click="goMemberDetail(member)"
- >
- <view class="family-avatar-wrap">
- <image v-if="member.avatar" class="family-avatar-img" :src="member.avatar" mode="aspectFill" />
- <text v-else class="family-avatar-text">{{ member.nickname ? member.nickname.charAt(0) : '?' }}</text>
- <view class="family-avatar-tag" :class="'tag-' + (member.effectiveRole || member.source || 'member')">{{ member.roleLabel || memberRoleLabel(member.effectiveRole) }}</view>
- </view>
- <text class="family-avatar-name">{{ member.nickname || member.realName || '成员' }}</text>
- </view>
- <view class="family-avatar-item" @click="goToFamily">
- <view class="family-avatar-wrap family-avatar-add">
- <text class="family-avatar-plus">+</text>
- </view>
- <text class="family-avatar-name">添加</text>
- </view>
- </view>
- </view>
- <!-- 个人成就统计 -->
- <view class="achievement-section">
- <view class="section-header-row">
- <text class="section-title">🏆 我的成就</text>
- <text class="section-sub">持续成长,看见改变</text>
- </view>
- <view class="achievement-grid">
- <view class="ach-item" @click="goToPoints">
- <view class="ach-icon-wrap" style="background:rgba(249,115,22,0.12)">
- <text class="ach-icon">💰</text>
- </view>
- <text class="ach-num">{{ totalPoints }}</text>
- <text class="ach-label">累计积分</text>
- </view>
- <view class="ach-item" @click="goToStreak">
- <view class="ach-icon-wrap" style="background:rgba(255,140,66,0.12)">
- <text class="ach-icon">🔥</text>
- </view>
- <text class="ach-num">{{ streakDays }}</text>
- <text class="ach-label">连续打卡</text>
- </view>
- <view class="ach-item" @click="goToTasks">
- <view class="ach-icon-wrap" style="background:rgba(99,102,241,0.12)">
- <text class="ach-icon">✅</text>
- </view>
- <text class="ach-num">{{ completedTasks }}</text>
- <text class="ach-label">完成任务</text>
- </view>
- <view class="ach-item" @click="goToWishes">
- <view class="ach-icon-wrap" style="background:rgba(245,158,11,0.12)">
- <text class="ach-icon">🎁</text>
- </view>
- <text class="ach-num">{{ rewardsEarned }}</text>
- <text class="ach-label">获得奖励</text>
- </view>
- <view class="ach-item" @click="goToBadges">
- <view class="ach-icon-wrap" style="background:rgba(236,72,153,0.12)">
- <text class="ach-icon">🏅</text>
- </view>
- <text class="ach-num">{{ badgesCollected }}</text>
- <text class="ach-label">收集勋章</text>
- </view>
- <view class="ach-item" @click="goToGrowth">
- <view class="ach-icon-wrap" style="background:rgba(16,185,129,0.12)">
- <text class="ach-icon">📈</text>
- </view>
- <text class="ach-num">{{ growthRecords }}</text>
- <text class="ach-label">成长记录</text>
- </view>
- <view class="ach-item" @click="goToChallenges">
- <view class="ach-icon-wrap" style="background:rgba(255,107,157,0.12)">
- <text class="ach-icon">🎯</text>
- </view>
- <text class="ach-num">{{ challengesJoined }}</text>
- <text class="ach-label">参加挑战</text>
- </view>
- <view class="ach-item" @click="goToHealthReports">
- <view class="ach-icon-wrap" style="background:rgba(14,165,233,0.12)">
- <text class="ach-icon">📋</text>
- </view>
- <text class="ach-num">{{ healthReports }}</text>
- <text class="ach-label">上传报告</text>
- </view>
- <view class="ach-item" @click="goToWealthCenter">
- <view class="ach-icon-wrap" style="background:rgba(245,158,11,0.12)">
- <text class="ach-icon">💰</text>
- </view>
- <text class="ach-num">{{ referralEarnings }}</text>
- <text class="ach-label">推广收益</text>
- </view>
- <view class="ach-item" @click="goTeamTree">
- <view class="ach-icon-wrap" style="background:rgba(16,185,129,0.12)">
- <text class="ach-icon">🌳</text>
- </view>
- <text class="ach-num">{{ teamMembers }}</text>
- <text class="ach-label">我的团队</text>
- </view>
- </view>
- </view>
- <!-- 我的订单(电商风格) -->
- <view class="order-section">
- <view class="order-section-header">
- <text class="section-title">🛒 我的订单</text>
- <text class="order-all-link" @click="goToOrders">全部订单 ›</text>
- </view>
- <view class="order-card">
- <view class="order-grid">
- <view class="order-grid-item" @click="goToOrderStatus('pending')">
- <view class="order-icon-wrap">
- <text class="order-icon">💳</text>
- <text class="order-badge" v-if="orderPending > 0">{{ orderPending }}</text>
- </view>
- <text class="order-grid-text">待付款</text>
- </view>
- <view class="order-grid-item" @click="goToOrderStatus('paid')">
- <view class="order-icon-wrap">
- <text class="order-icon">📦</text>
- <text class="order-badge" v-if="orderUnpaid > 0">{{ orderUnpaid }}</text>
- </view>
- <text class="order-grid-text">待发货</text>
- </view>
- <view class="order-grid-item" @click="goToOrderStatus('shipped')">
- <view class="order-icon-wrap">
- <text class="order-icon">🚚</text>
- <text class="order-badge" v-if="orderShipped > 0">{{ orderShipped }}</text>
- </view>
- <text class="order-grid-text">待收货</text>
- </view>
- <view class="order-grid-item" @click="goToOrderStatus('refunding')">
- <view class="order-icon-wrap">
- <text class="order-icon">🔧</text>
- <text class="order-badge" v-if="orderAfterSale > 0">{{ orderAfterSale }}</text>
- </view>
- <text class="order-grid-text">售后</text>
- </view>
- <view class="order-grid-item" @click="goToOrders">
- <view class="order-icon-wrap">
- <text class="order-icon">📋</text>
- </view>
- <text class="order-grid-text">全部</text>
- </view>
- </view>
- <view class="order-extra-row">
- <view class="order-extra-item" @click="goToCart">
- <text class="order-extra-icon">🛒</text>
- <text class="order-extra-text">购物车</text>
- <text class="order-extra-badge" v-if="cartCount > 0">{{ cartCount > 99 ? '99+' : cartCount }}</text>
- </view>
- <view class="order-extra-divider"></view>
- <view class="order-extra-item" @click="goToAddress">
- <text class="order-extra-icon">📍</text>
- <text class="order-extra-text">收货地址</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 规划师服务中心入口(仅规划师可见) -->
- <view class="service-center-section" v-if="role === 'teacher' && teacherStatus === 'approved'">
- <view class="service-center-card" @click="goToServiceCenter">
- <view class="service-center-icon">👨🏫</view>
- <view class="service-center-info">
- <text class="service-center-title">服务中心</text>
- <text class="service-center-desc">待处理任务:{{ pendingTasks }} 条 · 消息:{{ unreadMessages }} 条</text>
- </view>
- <text class="service-center-arrow">›</text>
- </view>
- </view>
- <!-- 规划师待审核提示 -->
- <view class="service-center-section" v-if="role === 'teacher' && teacherStatus !== 'approved'">
- <view class="service-center-card disabled-card">
- <view class="service-center-icon">👨🏫</view>
- <view class="service-center-info">
- <text class="service-center-title">服务中心</text>
- <text class="service-center-desc">{{ teacherStatus === 'pending' ? '申请审核中,暂未开放' : teacherStatus === 'rejected' ? '申请未通过,请联系管理员' : '规划师服务' }}</text>
- </view>
- </view>
- </view>
- <!-- 设置 + 退出 -->
- <view class="bottom-menu-section">
- <view class="menu-row" @click="goToSettings">
- <text class="menu-row-icon">⚙️</text>
- <text class="menu-row-text">设置</text>
- <text class="menu-row-arrow">›</text>
- </view>
- <view class="logout-btn" @click="logout">
- <text class="logout-text">退出登录</text>
- </view>
- </view>
- </template>
- <view class="share-qr-modal" v-if="showShareQrModal" @click="closeShareQrModal">
- <view class="modal-mask" @click.stop />
- <view class="modal-qr" @click.stop>
- <view class="modal-qr-header">
- <text class="modal-qr-title">我的分享海报</text>
- <text class="modal-qr-close" @click="closeShareQrModal">✕</text>
- </view>
- <view class="modal-qr-content">
- <view v-if="qrLoading" class="qrcode-loading">
- <text class="loading-spinner">⏳</text>
- <text class="loading-text">生成中...</text>
- </view>
- <view v-else="!qrBase64" class="qrcode-empty">
- <text>暂无二维码</text>
- </view>
- <view v-else class="qrcode-image">
- <image class="qrcode-img" :src="qrBase64" mode="aspectFit"></image>
- </view>
- <view class="qrcode-info">
- <text class="qrcode-text">邀请码: {{ referralCode }}</text>
- <text class="qrcode-desc">扫码注册,好友成为您的推荐人</text>
- </view>
- </view>
- <view class="modal-qr-actions">
- <view class="action-btn copy-btn" @click="copyReferralCode">
- <text class="copy-icon">📋</text>
- <text class="copy-text">复制邀请码</text>
- </view>
- <view class="action-btn share-btn" @click="shareToWechat">
- <text class="share-icon">📤</text>
- <text class="share-text">分享给朋友</text>
- </view>
- </view>
- </view>
- </view>
- <FloatingAvatar />
- </view>
- </template>
- <script>
- import FloatingAvatar from '../../components/AIFloatingAvatar.vue'
- import {
- getChildren, getFamilyMemberList,
- getTodayTasksByCategory, getChallengeList, getMyMembership,
- verifyPassword, getPointsBalance, getUserInfo,
- cartCount, getOrderCounts, getReferralSummary,
- getProfileStats, getMyReferrer, getTeamConsumption,
- getTeacherInfo, getTeacherPendingTasks, getTeacherUnreadCount,
- getReferralCode, extractReferralCode, getShareQrCode
- } from '../../utils/api.js'
- export default {
- components: { FloatingAvatar },
- data() {
- return {
- nickname: '',
- role: 'parent',
- isSwitchedChild: false,
- userInfo: {},
- memberLevel: null,
- membershipDays: 0,
- totalPoints: 0,
- referralEarnings: 0,
- teamMembers: 0,
- // 个人成就
- completedTasks: 0,
- streakDays: 0,
- rewardsEarned: 0,
- badgesCollected: 0,
- growthRecords: 0,
- challengesJoined: 0,
- healthReports: 0,
- // 家庭
- familyMembers: [],
- // 商城
- orderPending: 0,
- orderUnpaid: 0,
- orderShipped: 0,
- orderAfterSale: 0,
- cartCount: 0,
- // 待办
- pendingTasks: 0,
- unreadMessages: 0,
- teacherStatus: 'pending',
- profileProgress: 0,
- myReferrer: null,
- // 分享推广码
- showShareQrModal: false,
- referralCode: '',
- qrBase64: '',
- qrLoading: false,
- referralCodeLoaded: false,
- }
- },
- computed: {
- isLoggedIn() {
- return !!uni.getStorageSync('token')
- },
- roleLabel() {
- var map = { parent: '', child: '孩子', teacher: '规划师' }
- return map[this.role] || '用户'
- },
- memberLevelText() {
- var map = { FREE: '免费用户', FAMILY: '家庭会员', PREMIUM: '高级会员', LIFETIME: '终身会员' }
- return map[this.memberLevel] || this.memberLevel || ''
- },
- isLifetime() {
- return this.memberLevel === 'LIFETIME'
- },
- hasUpgradeSpace() {
- return this.memberLevel === 'FREE' || this.memberLevel === 'FAMILY'
- },
- upgradeBtnText() {
- return this.memberLevel === 'FAMILY' ? '升级' : '立即开通'
- }
- },
- onShow() {
- if (!this.isLoggedIn) {
- return
- }
- var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
- this.role = role
- this.isSwitchedChild = uni.getStorageSync('isSwitchedChild') || false
- this.nickname = (uni.getStorageSync('userInfo') || {}).nickname || ''
- // 规划师加载额外数据
- if (role === 'teacher') {
- this.loadTeacherStatus()
- this.loadTeacherData()
- } else {
- this.loadAllData()
- this.loadMyReferrer()
- }
- },
- methods: {
- loadTeacherStatus() {
- var self = this
- getTeacherInfo().then(function(res) {
- if (res && res.code === 200 && res.data) {
- self.teacherStatus = res.data.verificationStatus || res.data.status || 'pending'
- }
- }).catch(function() {})
- },
- loadTeacherData() {
- var self = this
- // 并行加载待处理任务和未读消息
- getTeacherPendingTasks().then(function(res) {
- if (res && res.data && Array.isArray(res.data)) {
- self.pendingTasks = res.data.length
- } else if (res && res.data && res.data.pendingCount != null) {
- self.pendingTasks = res.data.pendingCount
- }
- }).catch(function() {})
- getTeacherUnreadCount().then(function(res) {
- if (res && res.data != null) {
- self.unreadMessages = res.data
- }
- }).catch(function() {})
- },
- loadAllData() {
- this.loadUserInfo()
- this.loadMembership()
- this.loadPoints()
- this.loadFamily()
- this.loadTasks()
- this.loadChallenges()
- this.loadOrderCounts()
- this.loadCartCount()
- this.loadProfileStats()
- this.loadReferralEarnings()
- this.loadTeamInfo()
- },
- loadUserInfo() {
- var self = this
- getUserInfo().then(function(res) {
- if (res && res.code === 200 && res.data) {
- self.userInfo = res.data
- if (!self.nickname) self.nickname = res.data.nickname || ''
- }
- }).catch(function() {})
- },
- loadMembership() {
- var self = this
- getMyMembership().then(function(res) {
- if (res && res.data) {
- self.memberLevel = res.data.memberLevel || res.data.levelCode || null
- self.membershipDays = res.data.membershipDays || res.data.daysRemaining || 0
- }
- }).catch(function() {})
- },
- loadPoints() {
- // 累计积分由 loadProfileStats 汇总家庭成员积分,此处不再单独覆盖
- },
- loadFamily() {
- var self = this
- getFamilyMemberList({ visibleOnly: true }).then(function(res) {
- var data = res && res.data ? res.data : []
- self.familyMembers = Array.isArray(data) ? data : []
- }).catch(function() {
- self.familyMembers = []
- })
- },
- loadTasks() {
- var self = this
- var memberId = uni.getStorageSync('currentChildId') || uni.getStorageSync('userId')
- if (!memberId) return
- getTodayTasksByCategory(memberId, 'action').then(function(res) {
- if (res && res.data) {
- self.pendingTasks = Array.isArray(res.data) ? res.data.length : 0
- }
- }).catch(function() {})
- // fallback to storage
- if (!self.pendingTasks) {
- self.pendingTasks = parseInt(uni.getStorageSync('pendingTaskCount') || 0)
- }
- },
- loadChallenges() {
- var self = this
- getChallengeList({}).then(function(res) {
- if (res && res.data) {
- // 不在此处使用,仅确保请求
- }
- }).catch(function() {})
- },
- loadOrderCounts() {
- var self = this
- getOrderCounts().then(function(res) {
- if (res && res.data) {
- self.orderPending = res.data.pending || 0
- self.orderUnpaid = res.data.paid || 0
- self.orderShipped = res.data.shipped || 0
- self.orderAfterSale = res.data.refunding || 0
- }
- }).catch(function() {})
- },
- loadCartCount() {
- var self = this
- cartCount().then(function(res) {
- if (res && res.data != null) {
- self.cartCount = res.data || 0
- }
- }).catch(function() {})
- },
- loadProfileStats() {
- var self = this
- getProfileStats().then(function(res) {
- if (res && res.code === 200 && res.data) {
- var d = res.data
- if (d.totalPoints != null) self.totalPoints = d.totalPoints
- if (d.streakDays != null) self.streakDays = d.streakDays
- if (d.completedTasks != null) self.completedTasks = d.completedTasks
- if (d.rewardsEarned != null) self.rewardsEarned = d.rewardsEarned
- if (d.badgesCollected != null) self.badgesCollected = d.badgesCollected
- if (d.growthRecords != null) self.growthRecords = d.growthRecords
- if (d.challengesJoined != null) self.challengesJoined = d.challengesJoined
- if (d.healthReports != null) self.healthReports = d.healthReports
- }
- }).catch(function() {})
- },
- loadReferralEarnings() {
- var self = this
- getReferralSummary().then(function(res) {
- if (res && res.code === 200 && res.data) {
- self.referralEarnings = res.data.totalEarnings || 0
- }
- }).catch(function() {})
- },
- loadTeamInfo() {
- var self = this
- getTeamConsumption(3).then(function(res) {
- if (res && res.data && res.data.totalMembers != null) {
- self.teamMembers = res.data.totalMembers
- }
- }).catch(function() {})
- },
- async loadMyReferrer() {
- try {
- var memberId = uni.getStorageSync('currentMemberId') || uni.getStorageSync('currentChildId') || 0
- var res = await getMyReferrer(memberId)
- if (res && res.code === 200 && res.data && res.data.hasReferrer) {
- this.myReferrer = res.data
- }
- } catch (e) {
- console.error('获取推荐人失败', e)
- }
- },
- // ===== 分享推广码 =====
- showShareQr() {
- this.showShareQrModal = true
- if (!this.referralCodeLoaded) {
- this.loadReferralCode()
- } else if (this.referralCode && !this.qrBase64) {
- this.generateQrcode()
- }
- },
- closeShareQrModal() {
- this.showShareQrModal = false
- },
- async loadReferralCode() {
- if (this.referralCodeLoaded) return
- var self = this
- try {
- var res = await getReferralCode()
- var code = extractReferralCode(res)
- self.referralCode = code || ''
- self.referralCodeLoaded = true
- if (code) {
- self.generateQrcode()
- }
- } catch (e) {
- console.error('获取推广码失败', e)
- self.referralCodeLoaded = true
- }
- },
- generateQrcode() {
- if (!this.referralCode) return
- this.qrLoading = true
- var self = this
- var scene = 'ref=' + this.referralCode
- // 首页路径,扫码后进入首页并绑定推荐人
- getShareQrCode('/pages/index-home/index', scene)
- .then(function(res) {
- if (res && res.code === 200 && res.data) {
- self.qrBase64 = res.data.qrCodeBase64
- }
- })
- .catch(function(e) {
- console.error('生成二维码失败', e)
- uni.showToast({ title: '生成失败,请重试', icon: 'none' })
- })
- .finally(function() {
- self.qrLoading = false
- })
- },
- copyReferralCode() {
- if (!this.referralCode) return
- uni.setClipboardData({
- data: this.referralCode,
- success: function() {
- uni.showToast({ title: '邀请码已复制', icon: 'success' })
- }
- })
- },
- shareToWechat() {
- if (!this.referralCode) return
- var path = '/pages/index-home/index?refCode=' + this.referralCode
- uni.share({
- provider: 'weixin',
- scene: { type: 0 },
- type: 5,
- imageUrl: this.qrBase64,
- path: path,
- title: '浠艾福 — 邀请你加入',
- success: function() {
- uni.showToast({ title: '分享成功', icon: 'success' })
- },
- fail: function() {
- uni.showToast({ title: '分享失败', icon: 'none' })
- }
- })
- },
- goToServiceCenter() {
- uni.navigateTo({ url: '/pages/service-center/index' })
- },
- goTeamTree() {
- uni.navigateTo({ url: '/pages/profile/team-tree' })
- },
- goLogin: function() {
- uni.navigateTo({ url: '/pages/login/login' })
- },
- goSkip: function() {
- uni.switchTab({ url: '/pages/index-home/index' })
- },
- goToEditInfo: function() {
- uni.navigateTo({ url: '/pages/user-edit/user-edit' })
- },
- goToPoints: function() {
- uni.navigateTo({ url: '/pages/points/points' })
- },
- goToStreak: function() {
- var memberId = uni.getStorageSync('currentMemberId') || uni.getStorageSync('currentChildId')
- var url = '/pages/stats/completion-rate'
- if (memberId) {
- url += '?memberId=' + memberId
- } else {
- url += '?familyView=1'
- }
- uni.navigateTo({ url: url })
- },
- goToTasks: function() {
- uni.navigateTo({ url: '/pages/tasks/tasks' })
- },
- goToWishes: function() {
- uni.navigateTo({ url: '/pages/wishes/index' })
- },
- goToBadges: function() {
- uni.navigateTo({ url: '/pages/rewards/badge' })
- },
- goToGrowth: function() {
- uni.navigateTo({ url: '/pages/growth-main/index' })
- },
- goToChallenges: function() {
- uni.navigateTo({ url: '/pages/health/challenge-manage' })
- },
- goToHealthReports: function() {
- uni.navigateTo({ url: '/pages/health/report-list' })
- },
- goToWealthCenter: function() {
- uni.navigateTo({ url: '/pages/promotion/index' })
- },
- goUpgrade: function() {
- uni.navigateTo({ url: '/pages/membership/upgrade' })
- },
- goToFamily: function() {
- uni.navigateTo({ url: '/pages/profile-extra/family-members' })
- },
- goMemberDetail: function(member) {
- uni.navigateTo({ url: '/pages/home-pages/member-home-detail?memberId=' + member.id })
- },
- goToAppointments: function() {
- uni.navigateTo({ url: '/pages/parent/appointments' })
- },
- goToOrders: function() {
- uni.navigateTo({ url: '/pages/shop/order-list/order-list' })
- },
- goToOrderStatus: function(status) {
- uni.navigateTo({ url: '/pages/shop/order-list/order-list?status=' + status })
- },
- goToCart: function() {
- uni.navigateTo({ url: '/pages/shop/cart/cart' })
- },
- goToAddress: function() {
- uni.navigateTo({ url: '/pages/shop/address/address' })
- },
- goToSettings: function() {
- uni.showActionSheet({
- itemList: ['完善信息', '家庭成员', '邀请加入', '隐私政策', '用户协议', '我的画像'],
- success: function(res) {
- var urls = {
- 0: '/pages/user-edit/user-edit',
- 1: '/pages/profile-extra/family-members',
- 2: '/pages/guide/invite/share',
- 3: '/pages/policy/privacy',
- 4: '/pages/policy/agreement',
- 5: '/pages/profile/portrait-edit'
- }
- if (urls[res.tapIndex]) {
- uni.navigateTo({ url: urls[res.tapIndex] })
- }
- }
- })
- },
- memberRoleLabel: function(role) {
- var map = { parent: '家长', child: '孩子', teacher: '规划师' }
- return map[role] || '成员'
- },
- onExitSwitch: function() {
- var self = this
- uni.showModal({
- title: '退出切换',
- content: '请输入家长密码以确认退出',
- editable: true,
- success: function(res) {
- if (res.confirm && res.content) {
- verifyPassword(res.content).then(function(result) {
- if (result.code === 200) {
- self.$store.commit('switchBackToParent')
- self.isSwitchedChild = false
- self.role = 'parent'
- uni.showToast({ title: '已退出切换', icon: 'success' })
- uni.reLaunch({ url: '/pages/index-home/index' })
- } else {
- uni.showToast({ title: '密码错误', icon: 'none' })
- }
- }).catch(function() {
- uni.showToast({ title: '验证失败', icon: 'none' })
- })
- }
- }
- })
- },
- logout: function() {
- uni.showModal({
- title: '确认退出',
- content: '确定要退出登录吗?',
- success: function(res) {
- if (res.confirm) {
- this.$store.commit('logout')
- uni.reLaunch({ url: '/pages/index-home/index' })
- }
- }.bind(this)
- })
- }
- }
- }
- </script>
- <style scoped>
- .container {
- min-height: 100vh;
- background: #F8F4EF;
- padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
- }
- /* 登录引导 */
- .login-prompt {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 200rpx 60rpx;
- }
- .prompt-icon { font-size: 100rpx; margin-bottom: 30rpx; }
- .prompt-title { font-size: 40rpx; font-weight: bold; color: #333; margin-bottom: 16rpx; }
- .prompt-desc { font-size: 26rpx; color: #999; margin-bottom: 20rpx; }
- .login-btn {
- background: linear-gradient(135deg, #667eea, #764ba2);
- color: #fff;
- border-radius: 50rpx;
- font-size: 30rpx;
- padding: 24rpx 80rpx;
- }
- .skip-link {
- font-size: 26rpx;
- color: #999;
- margin-top: 24rpx;
- text-decoration: underline;
- }
- .philosophy-card {
- margin: 0 40rpx 48rpx;
- background: linear-gradient(135deg, #FFF7ED, rgba(249, 115, 22, 0.06));
- border-radius: 20rpx;
- padding: 28rpx 32rpx;
- border-left: 6rpx solid #F97316;
- }
- .philosophy-title {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- display: block;
- margin-bottom: 8rpx;
- }
- .philosophy-desc {
- font-size: 24rpx;
- color: #888;
- line-height: 1.6;
- display: block;
- }
- /* 退出切换 */
- .exit-switch {
- margin: 0 30rpx 16rpx;
- background: linear-gradient(135deg, #667eea, #764ba2);
- color: #fff;
- padding: 16rpx;
- border-radius: 12rpx;
- text-align: center;
- font-size: 26rpx;
- }
- /* 身份卡 */
- .user-card {
- margin: 24rpx 30rpx 20rpx;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- border-radius: 24rpx;
- padding: 32rpx 32rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- box-shadow: 0 8rpx 32rpx rgba(102,126,234,0.3);
- }
- .user-card-left {
- display: flex;
- align-items: center;
- flex: 1;
- }
- .avatar-wrap {
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- background: rgba(255,255,255,0.2);
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 20rpx;
- overflow: hidden;
- border: 3rpx solid rgba(255,255,255,0.3);
- }
- .avatar-img {
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- }
- .avatar-text {
- font-size: 44rpx;
- color: #fff;
- }
- .user-meta { flex: 1; }
- .user-name-row {
- display: flex;
- align-items: center;
- gap: 12rpx;
- margin-bottom: 8rpx;
- }
- .nickname {
- font-size: 34rpx;
- font-weight: bold;
- color: #fff;
- }
- .role-tag {
- font-size: 20rpx;
- background: rgba(255,255,255,0.2);
- color: #fff;
- padding: 4rpx 14rpx;
- border-radius: 20rpx;
- }
- .referrer-line {
- font-size: 24rpx;
- color: rgba(255,255,255,0.7);
- margin-bottom: 6rpx;
- }
- .user-sub {
- display: flex;
- align-items: center;
- gap: 12rpx;
- }
- .level-badge {
- font-size: 22rpx;
- padding: 6rpx 20rpx;
- border-radius: 22rpx;
- font-weight: bold;
- border: 2rpx solid rgba(255,255,255,0.35);
- display: flex;
- align-items: center;
- gap: 6rpx;
- box-sizing: border-box;
- height: 40rpx;
- }
- .level-badge::before {
- content: '👑';
- font-size: 18rpx;
- }
- .level-FREE { background: linear-gradient(135deg, #9CA3AF, #6B7280); color: #fff; }
- .level-FREE::before { content: ''; }
- .level-FAMILY { background: linear-gradient(135deg, #F59E0B, #D97706); color: #fff; }
- .level-PREMIUM { background: linear-gradient(135deg, #6366F1, #4F46E5); color: #fff; }
- .level-LIFETIME {
- background: linear-gradient(135deg, #EC4899, #DB2777);
- color: #fff;
- box-shadow: 0 4rpx 16rpx rgba(236,72,153,0.45);
- border-color: rgba(255,255,255,0.55);
- }
- .days-left {
- font-size: 20rpx;
- color: rgba(255,255,255,0.85);
- }
- .upgrade-btn {
- background: rgba(255,255,255,0.22);
- border: 2rpx solid rgba(255,255,255,0.6);
- border-radius: 20rpx;
- padding: 6rpx 20rpx;
- flex-shrink: 0;
- box-sizing: border-box;
- height: 40rpx;
- display: flex;
- align-items: center;
- }
- .upgrade-btn-text {
- font-size: 20rpx;
- font-weight: bold;
- color: #fff;
- line-height: 1;
- }
- .user-card-right {
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 6rpx;
- background: rgba(255,255,255,0.15);
- padding: 12rpx 24rpx;
- border-radius: 14rpx;
- }
- .points-num {
- font-size: 36rpx;
- font-weight: bold;
- color: #fff;
- }
- .points-label {
- font-size: 20rpx;
- color: rgba(255,255,255,0.7);
- }
- /* 家庭成员速览 */
- .family-strip {
- margin: 0 30rpx 20rpx;
- background: #fff;
- border-radius: 20rpx;
- padding: 20rpx 24rpx 16rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .family-strip-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 14rpx;
- }
- .family-strip-title {
- font-size: 26rpx;
- font-weight: bold;
- color: #333;
- }
- .family-strip-count {
- font-size: 22rpx;
- color: #999;
- }
- .family-avatars {
- display: flex;
- flex-direction: row;
- align-items: center;
- gap: 16rpx;
- overflow-x: auto;
- padding-bottom: 4rpx;
- }
- .family-avatar-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 6rpx;
- flex-shrink: 0;
- }
- .family-avatar-wrap {
- width: 72rpx;
- height: 72rpx;
- border-radius: 50%;
- background: #f0f0f0;
- display: flex;
- align-items: center;
- justify-content: center;
- overflow: hidden;
- position: relative;
- }
- .family-avatar-img {
- width: 72rpx;
- height: 72rpx;
- border-radius: 50%;
- }
- .family-avatar-text {
- font-size: 28rpx;
- color: #666;
- }
- .family-avatar-wrap.family-avatar-add {
- background: #F8F4EF;
- border: 2rpx dashed #ccc;
- }
- .family-avatar-plus {
- font-size: 36rpx;
- color: #999;
- }
- .family-avatar-tag {
- position: absolute;
- bottom: -4rpx;
- right: -4rpx;
- font-size: 14rpx;
- padding: 2rpx 6rpx;
- border-radius: 8rpx;
- color: #fff;
- }
- .family-avatar-tag.tag-parent { background: #6366F1; }
- .family-avatar-tag.tag-child { background: #F97316; }
- .family-avatar-tag.tag-teacher { background: #10B981; }
- .family-avatar-tag.tag-member { background: #9CA3AF; }
- .family-avatar-name {
- font-size: 20rpx;
- color: #666;
- white-space: nowrap;
- }
- /* 个人成就 */
- .achievement-section {
- margin: 0 30rpx 20rpx;
- background: #fff;
- border-radius: 20rpx;
- padding: 24rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .section-header-row {
- display: flex;
- justify-content: space-between;
- align-items: baseline;
- margin-bottom: 16rpx;
- }
- .section-title {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- }
- .section-sub {
- font-size: 22rpx;
- color: #999;
- }
- .achievement-grid {
- display: flex;
- flex-wrap: wrap;
- gap: 0;
- }
- .ach-item {
- width: 25%;
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 6rpx;
- padding: 10rpx 0;
- }
- .ach-icon-wrap {
- width: 64rpx;
- height: 64rpx;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 4rpx;
- }
- .ach-icon {
- font-size: 32rpx;
- line-height: 1;
- }
- .ach-num {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- line-height: 1;
- }
- .ach-label {
- font-size: 20rpx;
- color: #999;
- line-height: 1;
- }
- /* 我的订单(电商风格) */
- .order-section {
- margin: 0 30rpx 20rpx;
- }
- .order-section-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 14rpx;
- }
- .order-all-link {
- font-size: 24rpx;
- color: #999;
- }
- .order-card {
- background: #fff;
- border-radius: 20rpx;
- padding: 24rpx 12rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .order-grid {
- display: flex;
- flex-wrap: wrap;
- }
- .order-grid-item {
- width: 20%;
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 10rpx;
- padding: 8rpx 0;
- }
- .order-icon-wrap {
- position: relative;
- width: 64rpx;
- height: 64rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .order-icon {
- font-size: 40rpx;
- line-height: 1;
- }
- .order-badge {
- position: absolute;
- top: -8rpx;
- right: -14rpx;
- min-width: 30rpx;
- height: 30rpx;
- line-height: 30rpx;
- border-radius: 15rpx;
- background: #FF4D4F;
- color: #fff;
- font-size: 18rpx;
- text-align: center;
- padding: 0 6rpx;
- }
- .order-grid-text {
- font-size: 22rpx;
- color: #666;
- line-height: 1;
- }
- .order-extra-row {
- display: flex;
- align-items: center;
- margin-top: 20rpx;
- padding-top: 20rpx;
- border-top: 1rpx solid #F2F2F2;
- }
- .order-extra-item {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 8rpx;
- }
- .order-extra-icon {
- font-size: 28rpx;
- }
- .order-extra-text {
- font-size: 24rpx;
- color: #333;
- }
- .order-extra-badge {
- min-width: 30rpx;
- height: 30rpx;
- line-height: 30rpx;
- border-radius: 15rpx;
- background: #F97316;
- color: #fff;
- font-size: 18rpx;
- text-align: center;
- padding: 0 6rpx;
- }
- .order-extra-divider {
- width: 1rpx;
- height: 30rpx;
- background: #F2F2F2;
- }
- /* 规划师服务中心入口 */
- .service-center-section {
- margin: 0 30rpx 20rpx;
- }
- .service-center-card {
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- border-radius: 20rpx;
- padding: 24rpx;
- display: flex;
- align-items: center;
- gap: 20rpx;
- box-shadow: 0 4rpx 16rpx rgba(102,126,234,0.25);
- }
- .service-center-card.disabled-card {
- background: linear-gradient(135deg, #e2e8f0, #94a3b8);
- box-shadow: none;
- opacity: 0.8;
- }
- .service-center-icon {
- font-size: 48rpx;
- }
- .service-center-info {
- flex: 1;
- }
- .service-center-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #fff;
- display: block;
- }
- .service-center-desc {
- font-size: 22rpx;
- color: rgba(255,255,255,0.8);
- margin-top: 6rpx;
- display: block;
- }
- .service-center-card.disabled-card .service-center-title {
- color: #fff;
- }
- .service-center-card.disabled-card .service-center-desc {
- color: rgba(255,255,255,0.9);
- }
- .service-center-arrow {
- font-size: 40rpx;
- color: #fff;
- }
- /* 设置 + 退出 */
- .bottom-menu-section {
- margin: 0 30rpx;
- padding-bottom: 20rpx;
- }
- .menu-row {
- width: 100%;
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx;
- display: flex;
- align-items: center;
- gap: 14rpx;
- box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
- margin-bottom: 20rpx;
- }
- .menu-row-icon {
- font-size: 30rpx;
- }
- .menu-row-text {
- flex: 1;
- font-size: 26rpx;
- color: #333;
- }
- .menu-row-arrow {
- font-size: 28rpx;
- color: #ccc;
- }
- .logout-btn {
- width: 100%;
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx;
- text-align: center;
- box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
- }
- .logout-text {
- font-size: 26rpx;
- color: #FF4D4F;
- font-weight: 500;
- }
- /* 分享推广码浮动按钮 */
- .share-qr-float {
- position: fixed;
- top: 40rpx;
- right: 30rpx;
- width: 80rpx;
- height: 80rpx;
- border-radius: 50%;
- background: #fff;
- box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.15);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 99;
- }
- .share-qr-icon {
- font-size: 40rpx;
- line-height: 1;
- }
- /* 分享海报弹窗 */
- .share-qr-modal {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- z-index: 999;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .modal-mask {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.5);
- }
- .modal-qr {
- position: relative;
- width: 70%;
- max-width: 600rpx;
- background: #fff;
- border-radius: 24rpx;
- padding: 30rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .modal-qr-header {
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
- }
- .modal-qr-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #333;
- }
- .modal-qr-close {
- font-size: 32rpx;
- color: #999;
- padding: 10rpx;
- }
- .modal-qr-content {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 100%;
- }
- .qrcode-loading,
- .qrcode-empty {
- width: 340rpx;
- height: 340rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- background: #FAFAFA;
- border-radius: 16rpx;
- border: 2rpx dashed #E5E7EB;
- }
- .loading-spinner {
- font-size: 48rpx;
- margin-bottom: 16rpx;
- }
- .loading-text {
- font-size: 24rpx;
- color: #94A3B8;
- }
- .qrcode-empty text {
- font-size: 24rpx;
- color: #94A3B8;
- }
- .qrcode-image {
- width: 340rpx;
- height: 340rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- background: #fff;
- border-radius: 16rpx;
- border: 1rpx solid #E5E7EB;
- overflow: hidden;
- }
- .qrcode-img {
- width: 330rpx;
- height: 330rpx;
- }
- .qrcode-info {
- display: flex;
- flex-direction: column;
- align-items: center;
- margin-top: 20rpx;
- gap: 8rpx;
- }
- .qrcode-text {
- font-size: 28rpx;
- font-weight: bold;
- color: #F97316;
- }
- .qrcode-desc {
- font-size: 22rpx;
- color: #94A3B8;
- }
- .modal-qr-actions {
- width: 100%;
- display: flex;
- gap: 20rpx;
- margin-top: 24rpx;
- }
- .action-btn {
- flex: 1;
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 8rpx;
- padding: 24rpx;
- border-radius: 16rpx;
- font-size: 24rpx;
- font-weight: bold;
- }
- .copy-btn {
- background: #FFF7ED;
- color: #F97316;
- border: 1rpx solid #FED7AA;
- }
- .share-btn {
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- color: #fff;
- }
- .copy-icon, .share-icon {
- font-size: 40rpx;
- }
- .copy-text, .share-text {
- font-size: 24rpx;
- font-weight: bold;
- }
- </style>
|