| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- <template>
- <view class="container">
- <!-- 未登录 -->
- <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 class="exit-switch" v-if="isSwitchedChild" @click="exitSwitch">
- <text>🔄 退出切换</text>
- </view>
- <!-- 身克富状态条 -->
- <view class="section">
- <view class="section-header">
- <text class="section-title">⚖️ 身克富平衡</text>
- </view>
- <view class="body-wealth-bar" :class="'status-' + bodyWealthStatus">
- <view class="bar-row">
- <text class="bar-label">身体底盘</text>
- <view class="bar-track">
- <view class="bar-fill body-bar" :style="'width:' + bodyScore + '%'"></view>
- </view>
- <text class="bar-value">{{ bodyScore }}分</text>
- </view>
- <view class="bar-row">
- <text class="bar-label">财力素养</text>
- <view class="bar-track">
- <view class="bar-fill wealth-bar" :style="'width:' + wealthScore + '%'"></view>
- </view>
- <text class="bar-value">{{ wealthScore }}分</text>
- </view>
- <view v-if="bodyWealthMessage" class="bw-message">{{ bodyWealthMessage }}</view>
- </view>
- </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">
- <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">
- <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">
- <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">
- <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 class="service-item" @click="goToBadges">
- <text class="service-icon">🏅</text>
- <text class="service-label">成就系统</text>
- </view>
- <view class="service-item" @click="goToGrowthReport">
- <text class="service-icon">📈</text>
- <text class="service-label">成长报告</text>
- </view>
- </view>
- </view>
- <!-- 底部菜单(精简) -->
- <view class="menu-list">
- <view class="menu-item" v-if="role === 'parent'" @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>
- </template>
- </view>
- </template>
- <script>
- import PageBanner from '../../components/PageBanner.vue'
- import { getWealthDetail, verifyPassword, getChildren } from '../../utils/api.js'
- export default {
- components: { PageBanner },
- data() {
- return {
- role: 'parent',
- isSwitchedChild: false,
- // 身克富
- bodyScore: 0,
- wealthScore: 0,
- bodyWealthStatus: 'normal',
- bodyWealthMessage: '',
- // 子维度 - parent
- wealthIncome: null,
- wealthAchievement: null,
- wealthNetwork: null,
- // 子维度 - child
- wealthEducation: null,
- wealthSocial: null,
- wealthPoints: null,
- children: []
- }
- },
- computed: {
- isLoggedIn() {
- return !!uni.getStorageSync('token')
- }
- },
- onShow() {
- if (!uni.getStorageSync('token')) 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
- this.loadChildren()
- this.loadWealthDetail()
- },
- methods: {
- goLogin() {
- uni.navigateTo({ url: '/pages/login/login' })
- },
- 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.bodyScore = d.bodyScore || 0
- this.wealthScore = d.wealthScore || 0
- this.bodyWealthStatus = d.bodyWealthStatus || 'normal'
- this.bodyWealthMessage = d.bodyWealthMessage || ''
- 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
- }
- }
- } catch (e) {
- console.error('获取富维度详情失败', e)
- }
- },
- exitSwitch() {
- if (!this.isSwitchedChild) return
- uni.showModal({
- title: '退出切换',
- content: '请输入家长密码以确认退出',
- editable: true,
- success: async (res) => {
- if (res.confirm && res.content) {
- try {
- var verifyResult = await verifyPassword(res.content)
- if (verifyResult.code === 200) {
- this.$store.commit('switchBackToParent')
- this.isSwitchedChild = false
- this.role = 'parent'
- uni.showToast({ title: '已退出切换', icon: 'success' })
- uni.reLaunch({ url: '/pages/index/index' })
- } else {
- uni.showToast({ title: '密码错误', icon: 'none' })
- }
- } catch (e) {
- uni.showToast({ title: '验证失败', icon: 'none' })
- }
- }
- }
- })
- },
- goToCheckin() {
- uni.navigateTo({ url: '/pages/wealth/checkin' })
- },
- goToInsurance() {
- uni.showToast({ title: '即将上线', icon: 'none' })
- },
- goToCreator() {
- uni.showToast({ title: '即将上线', icon: 'none' })
- },
- goToBadges() {
- uni.showToast({ title: '即将上线', icon: 'none' })
- },
- goToGrowthReport() {
- uni.showToast({ title: '即将上线', icon: 'none' })
- },
- goToPointsLogs() {
- uni.navigateTo({ url: '/pages/points/points' })
- },
- goToPromotion() {
- uni.navigateTo({ url: '/pages/promotion/index' })
- },
- goToProfile() {
- uni.navigateTo({ url: '/pages/profile/index' })
- },
- goToIncome() {
- uni.showToast({ title: '即将上线', icon: 'none' })
- },
- goToAchievements() {
- uni.showToast({ title: '即将上线', icon: 'none' })
- },
- goToNetwork() {
- uni.showToast({ title: '即将上线', icon: 'none' })
- }
- }
- }
- </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;
- }
- /* 身克富状态条 */
- .body-wealth-bar {
- background: #fff;
- border-radius: 20rpx;
- padding: 30rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .body-wealth-bar.status-overdraw {
- background: #FFFBEB;
- border: 1rpx solid #F59E0B;
- }
- .body-wealth-bar.status-penalty {
- background: #FEF2F2;
- border: 1rpx solid #EF4444;
- }
- .bar-row {
- display: flex;
- align-items: center;
- margin-bottom: 16rpx;
- }
- .bar-row:last-of-type {
- margin-bottom: 0;
- }
- .bar-label {
- font-size: 26rpx;
- color: #666;
- width: 140rpx;
- }
- .bar-track {
- flex: 1;
- height: 16rpx;
- background: #f0f0f0;
- border-radius: 8rpx;
- overflow: hidden;
- margin: 0 16rpx;
- }
- .bar-fill {
- height: 100%;
- border-radius: 8rpx;
- transition: width 0.3s;
- }
- .bar-fill.body-bar {
- background: linear-gradient(90deg, #FF8C42, #F97316);
- }
- .bar-fill.wealth-bar {
- background: linear-gradient(90deg, #F59E0B, #FBBF24);
- }
- .bar-value {
- font-size: 24rpx;
- color: #999;
- width: 80rpx;
- text-align: right;
- }
- .bw-message {
- margin-top: 16rpx;
- font-size: 24rpx;
- color: #666;
- padding: 12rpx 16rpx;
- background: rgba(0,0,0,0.03);
- border-radius: 8rpx;
- }
- .status-overdraw .bw-message {
- color: #92400E;
- background: rgba(245,158,11,0.1);
- }
- .status-penalty .bw-message {
- color: #991B1B;
- background: rgba(239,68,68,0.1);
- }
- /* 三子维度卡片 */
- .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;
- }
- .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: 20%;
- 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;
- }
- /* 未登录 */
- .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>
|