| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779 |
- <template>
- <view class="container">
- <!-- TabTransition overlay -->
- <tab-transition v-if="showTabTransition" dimCode="wealth" />
- <!-- 未登录 -->
- <view v-if="!isLoggedIn" class="login-prompt">
- <view class="prompt-icon">👤</view>
- <text class="prompt-title">登录浠艾福</text>
- <text class="prompt-desc">登录后查看财富能量详情</text>
- <button class="login-btn" @click="goLogin">登录 / 注册</button>
- </view>
- <template v-else>
- <!-- 品牌头部 -->
- <PageBanner theme="wealth"
- tagline="利他创富 · 价值共享"
- quote="富足源于利他与坚持" />
- <!-- 模式切换 / 退出切换入口(家长未切时显示"切换到孩子视角";已切时显示"退出切换") -->
- <!-- 已切孩子态:点击"退出切换"回到家长模式 -->
- <view v-if="isSwitchedChild" class="exit-switch" @click="exitSwitch">
- <text>🔄 退出切换</text>
- </view>
- <!-- 家长且未切孩子态:此处展示"切换到孩子视角",点击完成模式切换 -->
- <view v-else class="exit-switch" @click="onSwitchMode">
- <text>👶 切换到孩子视角</text>
- </view>
- <!-- 用户卡片 -->
- <view class="user-card" @click="goToProfile">
- <view class="avatar">👤</view>
- <view class="user-info">
- <text class="nickname">{{ nickname || '未设置昵称' }}</text>
- <text class="role">{{ role === 'parent' ? '家长模式' : (role === 'child' ? '孩子模式' : '成长规划师模式') }}</text>
- </view>
- <text class="card-arrow">›</text>
- </view>
- <!-- 财富子维度卡片 -->
- <view class="section">
- <view class="section-header">
- <text class="section-title">💎 财富子维度</text>
- </view>
- <!-- 家长版 -->
- <view class="sub-dim-grid" v-if="role === 'parent'">
- <view class="sub-dim-card" @click="goToIncome">
- <text class="sub-dim-score">{{ wealthIncome || '-' }}</text>
- <text class="sub-dim-label">金钱收入</text>
- <text class="sub-dim-desc">累计佣金</text>
- </view>
- <view class="sub-dim-card" @click="goToAchievements">
- <text class="sub-dim-score">{{ wealthAchievement || '-' }}</text>
- <text class="sub-dim-label">个人成就</text>
- <text class="sub-dim-desc">认证成就</text>
- </view>
- <view class="sub-dim-card" @click="goToNetwork">
- <text class="sub-dim-score">{{ wealthNetwork || '-' }}</text>
- <text class="sub-dim-label">资源网络</text>
- <text class="sub-dim-desc">推荐关系</text>
- </view>
- </view>
- <!-- 孩子版 -->
- <view class="sub-dim-grid" v-else>
- <view class="sub-dim-card" @click="childSubDimClick('education')">
- <text class="sub-dim-score">{{ wealthEducation || '-' }}</text>
- <text class="sub-dim-label">学业成绩</text>
- <text class="sub-dim-desc">测评综合</text>
- </view>
- <view class="sub-dim-card" @click="childSubDimClick('social')">
- <text class="sub-dim-score">{{ wealthSocial || '-' }}</text>
- <text class="sub-dim-label">社交筹码</text>
- <text class="sub-dim-desc">活动参与</text>
- </view>
- <view class="sub-dim-card" @click="childSubDimClick('points')">
- <text class="sub-dim-score">{{ wealthPoints || '-' }}</text>
- <text class="sub-dim-label">规则博弈</text>
- <text class="sub-dim-desc">积分效率</text>
- </view>
- </view>
- </view>
- <!-- 心的子维度(仅孩子) -->
- <view class="section" v-if="role !== 'parent'">
- <view class="section-header">
- <text class="section-title">🔥 心的子维度</text>
- </view>
- <view class="sub-dim-grid heart-sub-dim">
- <view class="sub-dim-card" @click="childSubDimClick('emotion')">
- <text class="sub-dim-score">{{ heartEmotionStable || '-' }}</text>
- <text class="sub-dim-label">情绪稳定</text>
- <text class="sub-dim-desc">EMI情绪管理</text>
- </view>
- <view class="sub-dim-card" @click="childSubDimClick('understanding')">
- <text class="sub-dim-score">{{ heartUnderstanding || '-' }}</text>
- <text class="sub-dim-label">理解包容</text>
- <text class="sub-dim-desc">共情+社交适应</text>
- </view>
- <view class="sub-dim-card" @click="childSubDimClick('legacy')">
- <text class="sub-dim-score">{{ heartLegacy || '-' }}</text>
- <text class="sub-dim-label">传承传递</text>
- <text class="sub-dim-desc">未来开放</text>
- </view>
- </view>
- </view>
- <!-- 财富数据(仅家长) -->
- <view class="section" v-if="role === 'parent'">
- <view class="section-header">
- <text class="section-title">💰 财富数据</text>
- </view>
- <view class="wealth-card">
- <view class="wealth-item">
- <text class="wealth-value">{{ wealthData.totalEarnings || 0 }}</text>
- <text class="wealth-label">累计收益</text>
- </view>
- <view class="wealth-divider"></view>
- <view class="wealth-item">
- <text class="wealth-value">{{ wealthData.availableAmount || 0 }}</text>
- <text class="wealth-label">可提现</text>
- </view>
- <view class="wealth-divider"></view>
- <view class="wealth-item">
- <text class="wealth-value">{{ wealthData.referralCount || 0 }}</text>
- <text class="wealth-label">邀请人数</text>
- </view>
- </view>
- <!-- 邀请码复制 -->
- <view class="referral-code-bar" v-if="wealthData.referralCode" @click="copyReferralCode">
- <text class="referral-code-label">我的邀请码</text>
- <text class="referral-code-value">{{ wealthData.referralCode }}</text>
- <text class="referral-code-copy">复制</text>
- </view>
- </view>
- <!-- 增值服务入口 -->
- <view class="section">
- <view class="section-header">
- <text class="section-title">🚀 增值服务</text>
- </view>
- <view class="service-grid">
- <view class="service-item" @click="goToCheckin">
- <text class="service-icon">📝</text>
- <text class="service-label">记账打卡</text>
- </view>
- <view class="service-item" @click="goToInsurance">
- <text class="service-icon">🛡️</text>
- <text class="service-label">保单管理</text>
- </view>
- <view class="service-item" @click="goToCreator">
- <text class="service-icon">🎨</text>
- <text class="service-label">创客中心</text>
- </view>
- </view>
- </view>
- <!-- 商品推荐 -->
- <DimensionProductList
- v-if="isLoggedIn"
- dimensionCode="wealth"
- :familyId="activeChildId"
- title="为你推荐" />
- <!-- 底部菜单 -->
- <view class="menu-list">
- <view class="menu-item" @click="goToProfile">
- <text>👤 个人中心</text>
- <text class="arrow">›</text>
- </view>
- <view class="menu-item" @click="goToPointsLogs">
- <text>📊 积分记录</text>
- <text class="arrow">›</text>
- </view>
- <view class="menu-item" @click="goToPromotion">
- <text>📣 推广中心</text>
- <text class="arrow">›</text>
- </view>
- <view class="menu-item logout-item" @click="logout">
- <text>🚪 退出登录</text>
- <text class="arrow">›</text>
- </view>
- </view>
- </template>
- </view>
- </template>
- <script>
- import TabTransition from '../../components/tab-transition.vue'
- import PageBanner from '../../components/PageBanner.vue'
- import DimensionProductList from '../../components/DimensionProductList.vue'
- import {
- verifyPassword,
- getChildren,
- getWealthDetail,
- getReferralCode,
- getReferralSummary,
- getCommissionSummary
- } from '../../utils/api.js'
- export default {
- components: { TabTransition, PageBanner, DimensionProductList },
- data() {
- return {
- showTabTransition: true,
- role: 'parent',
- isSwitchedChild: false,
- nickname: '',
- // 五维评分
- bodyScore: 0,
- mindScore: 0,
- wisdomScore: 0,
- actionScore: 0,
- wealthScore: 0,
- // 心的子维度(仅孩子有真实数据)
- heartEmotionStable: null,
- heartUnderstanding: null,
- heartLegacy: null,
- // 子维度 - parent
- wealthIncome: null,
- wealthAchievement: null,
- wealthNetwork: null,
- // 子维度 - child
- wealthEducation: null,
- wealthSocial: null,
- wealthPoints: null,
- // 财富数据
- wealthData: {
- totalEarnings: 0,
- availableAmount: 0,
- referralCount: 0,
- referralCode: ''
- },
- children: []
- }
- },
- computed: {
- isLoggedIn() {
- return !!uni.getStorageSync('token')
- },
- activeChildId() {
- if (this.role === 'child') {
- return uni.getStorageSync('currentChildId')
- }
- return ''
- }
- },
- onShow() {
- this.showTabTransition = true
- if (!uni.getStorageSync('token')) {
- this._watchPageReady()
- return
- }
- var currentRole = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
- if (currentRole === 'teacher') {
- uni.redirectTo({ url: '/pages/teacher/teacher-profile' })
- return
- }
- this.role = currentRole
- this.isSwitchedChild = uni.getStorageSync('isSwitchedChild') || false
- var userInfo = uni.getStorageSync('userInfo')
- this.nickname = (userInfo && userInfo.nickname) || ''
- this.loadChildren()
- this.loadWealthDetail()
- this.loadWealthData()
- this._watchPageReady()
- },
- methods: {
- goLogin() {
- uni.navigateTo({ url: '/pages/login/login' })
- },
- _watchPageReady() {
- var self = this
- this.$nextTick(function() {
- self.showTabTransition = false
- })
- setTimeout(function() {
- self.showTabTransition = false
- }, 2000)
- },
- async loadChildren() {
- try {
- var res = await getChildren()
- this.children = res.data || []
- } catch (e) {
- console.error('获取孩子列表失败', e)
- }
- },
- async loadWealthDetail() {
- var memberId = null
- var memberType = this.role
- if (this.role === 'child') {
- memberId = uni.getStorageSync('currentChildId')
- if (!memberId && this.children.length > 0) {
- memberId = this.children[0].id
- }
- } else {
- memberId = uni.getStorageSync('userId')
- }
- if (!memberId) return
- try {
- var res = await getWealthDetail(memberId, memberType)
- if (res && res.data) {
- var d = res.data
- this.wealthScore = d.wealthScore || 0
- if (memberType === 'parent') {
- this.wealthIncome = d.wealthIncome
- this.wealthAchievement = d.wealthAchievement
- this.wealthNetwork = d.wealthNetwork
- } else {
- this.wealthEducation = d.wealthEducation
- this.wealthSocial = d.wealthSocial
- this.wealthPoints = d.wealthPoints
- this.heartEmotionStable = d.heartEmotionStable
- this.heartUnderstanding = d.heartUnderstanding
- this.heartLegacy = d.heartLegacy
- }
- }
- } catch (e) {
- console.error('获取富维度详情失败', e)
- }
- },
- async loadWealthData() {
- if (this.role !== 'parent') return
- try {
- var codeRes = await getReferralCode()
- if (codeRes && codeRes.code === 200 && codeRes.data) {
- this.wealthData.referralCode = codeRes.data.code || codeRes.data || ''
- }
- } catch (e) {
- console.error('获取邀请码失败', e)
- }
- try {
- var summaryRes = await getReferralSummary()
- if (summaryRes && summaryRes.code === 200 && summaryRes.data) {
- this.wealthData.referralCount = summaryRes.data.totalCount || summaryRes.data.count || 0
- }
- } catch (e) {
- console.error('获取邀请统计失败', e)
- }
- try {
- var commissionRes = await getCommissionSummary()
- if (commissionRes && commissionRes.code === 200 && commissionRes.data) {
- this.wealthData.totalEarnings = commissionRes.data.totalEarnings || 0
- this.wealthData.availableAmount = commissionRes.data.availableAmount || 0
- }
- } catch (e) {
- console.error('获取佣金统计失败', e)
- }
- },
- copyReferralCode() {
- if (!this.wealthData.referralCode) return
- uni.setClipboardData({
- data: this.wealthData.referralCode,
- success: function() {
- uni.showToast({ title: '邀请码已复制', icon: 'success' })
- }
- })
- },
- onSwitchMode() {
- if (this.role === 'child') {
- this.exitSwitch()
- return
- }
- // parent → switch to child
- if (this.children.length === 0) {
- this.loadChildren()
- if (this.children.length === 0) {
- uni.showModal({
- title: '提示',
- content: '您还没有添加孩子,是否现在去添加?',
- success: function(res) {
- if (res.confirm) {
- uni.navigateTo({ url: '/pages/profile/create-child' })
- }
- }
- })
- return
- }
- }
- if (this.children.length === 1) {
- this.$store.commit('switchToChild', this.children[0].id)
- this.role = 'child'
- this.isSwitchedChild = true
- uni.showToast({ title: '已切换为孩子模式', icon: 'success' })
- return
- }
- var self = this
- uni.showActionSheet({
- itemList: this.children.map(function(c) { return c.nickname }),
- success: function(res) {
- var selectedChild = self.children[res.tapIndex]
- self.$store.commit('switchToChild', selectedChild.id)
- self.role = 'child'
- self.isSwitchedChild = true
- uni.showToast({ title: '已切换为' + selectedChild.nickname + '模式', icon: 'success' })
- }
- })
- },
- exitSwitch() {
- if (!this.isSwitchedChild) return
- 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) {
- uni.removeStorageSync('isSwitchedChild')
- uni.removeStorageSync('currentChildId')
- self.isSwitchedChild = false
- self.role = 'parent'
- if (self.$store && self.$store.commit) {
- self.$store.commit('switchBackToParent')
- }
- uni.showToast({ title: '已退出切换', icon: 'success' })
- setTimeout(function() {
- uni.reLaunch({ url: '/pages/index/index' })
- }, 1000)
- } else {
- uni.showToast({ title: '密码错误', icon: 'none' })
- }
- }).catch(function() {
- uni.showToast({ title: '验证失败', icon: 'none' })
- })
- }
- }
- })
- },
- logout() {
- uni.showModal({
- title: '退出登录',
- content: '确定要退出登录吗?',
- success: function(res) {
- if (res.confirm) {
- uni.clearStorageSync()
- uni.reLaunch({ url: '/pages/login/login' })
- }
- }
- })
- },
- goToProfile() {
- uni.navigateTo({ url: '/pages/profile/profile' })
- },
- goToCheckin() {
- uni.navigateTo({ url: '/pages/wealth-sub/checkin' })
- },
- goToInsurance() {
- uni.navigateTo({ url: '/pages/wealth-sub/insurance-list' })
- },
- goToCreator() {
- uni.navigateTo({ url: '/pages/promotion/index' })
- },
- goToPointsLogs() {
- uni.navigateTo({ url: '/pages/points/points' })
- },
- goToPromotion() {
- uni.navigateTo({ url: '/pages/promotion/index' })
- },
- goToIncome() {
- uni.navigateTo({ url: '/pages/promotion/commission' })
- },
- goToAchievements() {
- uni.navigateTo({ url: '/pages/rewards/badge' })
- },
- goToNetwork() {
- uni.navigateTo({ url: '/pages/promotion/team' })
- },
- childSubDimClick(key) {
- var routes = {
- education: '/pages/assessment/results',
- social: '/pages/activity/index',
- points: '/pages/points/mall',
- emotion: '/pages/mind-detail/emotion-report',
- understanding: '/pages/mind-detail/emotion-trend',
- legacy: '/pages/wishes/index'
- }
- var url = routes[key]
- if (url) {
- uni.navigateTo({ url: url })
- }
- }
- }
- }
- </script>
- <style scoped>
- .container {
- min-height: 100vh;
- background: #f5f7fa;
- padding-bottom: 120rpx;
- }
- .section {
- margin: 20rpx 30rpx;
- }
- .section-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
- }
- .section-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #333;
- }
- .section-more {
- font-size: 24rpx;
- color: #999;
- }
- /* 用户卡片 */
- .user-card {
- display: flex;
- align-items: center;
- background: #fff;
- margin: 0 30rpx 20rpx;
- border-radius: 20rpx;
- padding: 30rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .avatar {
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- background: linear-gradient(135deg, #F59E0B, #FBBF24);
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 48rpx;
- margin-right: 24rpx;
- flex-shrink: 0;
- }
- .user-info {
- flex: 1;
- }
- .nickname {
- font-size: 34rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 8rpx;
- }
- .role {
- font-size: 24rpx;
- color: #999;
- }
- .card-arrow {
- color: #ccc;
- font-size: 40rpx;
- margin-left: 16rpx;
- }
- /* 切换区域 */
- .switch-section {
- margin: 0 30rpx 20rpx;
- }
- .btn-switch {
- background: linear-gradient(135deg, #F59E0B, #FBBF24);
- color: #fff;
- font-size: 26rpx;
- padding: 16rpx 0;
- border-radius: 40rpx;
- text-align: center;
- line-height: 1.5;
- }
- /* 财富数据卡片 */
- .wealth-card {
- background: #fff;
- border-radius: 20rpx;
- padding: 30rpx 20rpx;
- display: flex;
- align-items: center;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .wealth-item {
- flex: 1;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .wealth-value {
- font-size: 40rpx;
- font-weight: bold;
- color: #F97316;
- }
- .wealth-label {
- font-size: 24rpx;
- color: #999;
- margin-top: 8rpx;
- }
- .wealth-divider {
- width: 1rpx;
- height: 60rpx;
- background: #f0f0f0;
- }
- /* 邀请码复制条 */
- .referral-code-bar {
- display: flex;
- align-items: center;
- background: #fff;
- margin-top: 16rpx;
- border-radius: 16rpx;
- padding: 24rpx 30rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .referral-code-label {
- font-size: 26rpx;
- color: #666;
- margin-right: 16rpx;
- }
- .referral-code-value {
- flex: 1;
- font-size: 30rpx;
- font-weight: bold;
- color: #F59E0B;
- letter-spacing: 2rpx;
- }
- .referral-code-copy {
- font-size: 24rpx;
- color: #fff;
- background: linear-gradient(135deg, #F59E0B, #FBBF24);
- padding: 8rpx 24rpx;
- border-radius: 20rpx;
- }
- /* 三子维度卡片 */
- .sub-dim-grid {
- display: flex;
- }
- .sub-dim-card {
- flex: 1;
- margin-right: 16rpx;
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx 16rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .sub-dim-card:last-child {
- margin-right: 0;
- }
- .sub-dim-score {
- font-size: 48rpx;
- font-weight: bold;
- color: #F59E0B;
- }
- .heart-sub-dim .sub-dim-score {
- color: #FF6B9D;
- }
- .sub-dim-label {
- font-size: 24rpx;
- color: #333;
- margin-top: 8rpx;
- font-weight: 500;
- }
- .sub-dim-desc {
- font-size: 20rpx;
- color: #999;
- margin-top: 4rpx;
- }
- /* 增值服务 */
- .service-grid {
- display: flex;
- flex-wrap: wrap;
- background: #fff;
- border-radius: 20rpx;
- padding: 24rpx 16rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .service-item {
- width: 33.33%;
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 16rpx 0;
- }
- .service-icon {
- font-size: 48rpx;
- margin-bottom: 8rpx;
- }
- .service-label {
- font-size: 22rpx;
- color: #666;
- }
- /* 底部菜单 */
- .menu-list {
- margin: 30rpx 30rpx 0;
- background: #fff;
- border-radius: 16rpx;
- }
- .menu-item {
- padding: 30rpx;
- border-bottom: 1rpx solid #f0f0f0;
- display: flex;
- justify-content: space-between;
- font-size: 28rpx;
- }
- .menu-item:last-child {
- border-bottom: none;
- }
- .arrow {
- color: #ccc;
- font-size: 32rpx;
- }
- .logout-item {
- color: #EF4444;
- }
- /* 未登录 */
- .login-prompt {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- min-height: 80vh;
- padding: 60rpx;
- }
- .prompt-icon {
- font-size: 120rpx;
- margin-bottom: 30rpx;
- width: 160rpx;
- height: 160rpx;
- line-height: 160rpx;
- text-align: center;
- background: #f5f5f5;
- border-radius: 50%;
- }
- .prompt-title {
- font-size: 36rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 16rpx;
- }
- .prompt-desc {
- font-size: 26rpx;
- color: #999;
- text-align: center;
- margin-bottom: 40rpx;
- }
- .login-prompt .login-btn {
- width: 60%;
- height: 80rpx;
- line-height: 80rpx;
- background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
- color: #fff;
- font-size: 30rpx;
- font-weight: bold;
- border-radius: 40rpx;
- text-align: center;
- border: none;
- }
- .login-prompt .login-btn::after {
- border: none;
- }
- /* 退出切换 */
- .exit-switch {
- margin: 20rpx 30rpx 0;
- padding: 16rpx 24rpx;
- background: #FEF3C7;
- border-radius: 12rpx;
- text-align: center;
- font-size: 26rpx;
- color: #92400E;
- }
- </style>
|