index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <view class="container">
  3. <!-- 未登录 -->
  4. <view v-if="!isLoggedIn" class="login-prompt">
  5. <view class="prompt-icon">👤</view>
  6. <text class="prompt-title">登录浠艾福</text>
  7. <text class="prompt-desc">登录后查看财富能量详情</text>
  8. <button class="login-btn" @click="goLogin">登录 / 注册</button>
  9. </view>
  10. <template v-else>
  11. <!-- 品牌头部 -->
  12. <PageBanner theme="wealth"
  13. tagline="利他创富 · 价值共享"
  14. quote="富足源于利他与坚持" />
  15. <!-- 退出切换按钮 -->
  16. <view class="exit-switch" v-if="isSwitchedChild" @click="exitSwitch">
  17. <text>🔄 退出切换</text>
  18. </view>
  19. <!-- 身克富状态条 -->
  20. <view class="section">
  21. <view class="section-header">
  22. <text class="section-title">⚖️ 身克富平衡</text>
  23. </view>
  24. <view class="body-wealth-bar" :class="'status-' + bodyWealthStatus">
  25. <view class="bar-row">
  26. <text class="bar-label">身体底盘</text>
  27. <view class="bar-track">
  28. <view class="bar-fill body-bar" :style="'width:' + bodyScore + '%'"></view>
  29. </view>
  30. <text class="bar-value">{{ bodyScore }}分</text>
  31. </view>
  32. <view class="bar-row">
  33. <text class="bar-label">财力素养</text>
  34. <view class="bar-track">
  35. <view class="bar-fill wealth-bar" :style="'width:' + wealthScore + '%'"></view>
  36. </view>
  37. <text class="bar-value">{{ wealthScore }}分</text>
  38. </view>
  39. <view v-if="bodyWealthMessage" class="bw-message">{{ bodyWealthMessage }}</view>
  40. </view>
  41. </view>
  42. <!-- 三子维度卡片 -->
  43. <view class="section">
  44. <view class="section-header">
  45. <text class="section-title">💎 财富子维度</text>
  46. </view>
  47. <!-- 家长版 -->
  48. <view class="sub-dim-grid" v-if="role === 'parent'">
  49. <view class="sub-dim-card" @click="goToIncome">
  50. <text class="sub-dim-score">{{ wealthIncome || '-' }}</text>
  51. <text class="sub-dim-label">金钱/收入</text>
  52. <text class="sub-dim-desc">累计佣金</text>
  53. </view>
  54. <view class="sub-dim-card" @click="goToAchievements">
  55. <text class="sub-dim-score">{{ wealthAchievement || '-' }}</text>
  56. <text class="sub-dim-label">个人成就</text>
  57. <text class="sub-dim-desc">认证成就</text>
  58. </view>
  59. <view class="sub-dim-card" @click="goToNetwork">
  60. <text class="sub-dim-score">{{ wealthNetwork || '-' }}</text>
  61. <text class="sub-dim-label">资源网络</text>
  62. <text class="sub-dim-desc">推荐关系</text>
  63. </view>
  64. </view>
  65. <!-- 孩子版 -->
  66. <view class="sub-dim-grid" v-else>
  67. <view class="sub-dim-card">
  68. <text class="sub-dim-score">{{ wealthEducation || '-' }}</text>
  69. <text class="sub-dim-label">学业成绩</text>
  70. <text class="sub-dim-desc">测评综合</text>
  71. </view>
  72. <view class="sub-dim-card">
  73. <text class="sub-dim-score">{{ wealthSocial || '-' }}</text>
  74. <text class="sub-dim-label">社交筹码</text>
  75. <text class="sub-dim-desc">活动参与</text>
  76. </view>
  77. <view class="sub-dim-card">
  78. <text class="sub-dim-score">{{ wealthPoints || '-' }}</text>
  79. <text class="sub-dim-label">规则博弈</text>
  80. <text class="sub-dim-desc">积分效率</text>
  81. </view>
  82. </view>
  83. </view>
  84. <!-- 增值服务入口 -->
  85. <view class="section">
  86. <view class="section-header">
  87. <text class="section-title">🚀 增值服务</text>
  88. </view>
  89. <view class="service-grid">
  90. <view class="service-item" @click="goToCheckin">
  91. <text class="service-icon">📝</text>
  92. <text class="service-label">记账打卡</text>
  93. </view>
  94. <view class="service-item" @click="goToInsurance">
  95. <text class="service-icon">🛡️</text>
  96. <text class="service-label">保单管理</text>
  97. </view>
  98. <view class="service-item" @click="goToCreator">
  99. <text class="service-icon">🎨</text>
  100. <text class="service-label">创客中心</text>
  101. </view>
  102. <view class="service-item" @click="goToBadges">
  103. <text class="service-icon">🏅</text>
  104. <text class="service-label">成就系统</text>
  105. </view>
  106. <view class="service-item" @click="goToGrowthReport">
  107. <text class="service-icon">📈</text>
  108. <text class="service-label">成长报告</text>
  109. </view>
  110. </view>
  111. </view>
  112. <!-- 商品推荐 -->
  113. <DimensionProductList
  114. v-if="isLoggedIn"
  115. dimensionCode="wealth"
  116. :familyId="activeChildId"
  117. title="为你推荐" />
  118. <!-- 底部菜单(精简) -->
  119. <view class="menu-list">
  120. <view class="menu-item" v-if="role === 'parent'" @click="goToProfile">
  121. <text>⚙️ 个人设置</text>
  122. <text class="arrow">›</text>
  123. </view>
  124. <view class="menu-item" @click="goToPointsLogs">
  125. <text>📊 积分记录</text>
  126. <text class="arrow">›</text>
  127. </view>
  128. <view class="menu-item" @click="goToPromotion">
  129. <text>📣 推广中心</text>
  130. <text class="arrow">›</text>
  131. </view>
  132. </view>
  133. </template>
  134. </view>
  135. </template>
  136. <script>
  137. import PageBanner from '../../components/PageBanner.vue'
  138. import { getWealthDetail, verifyPassword, getChildren } from '../../utils/api.js'
  139. export default {
  140. components: { PageBanner },
  141. data() {
  142. return {
  143. role: 'parent',
  144. isSwitchedChild: false,
  145. // 身克富
  146. bodyScore: 0,
  147. wealthScore: 0,
  148. bodyWealthStatus: 'normal',
  149. bodyWealthMessage: '',
  150. // 子维度 - parent
  151. wealthIncome: null,
  152. wealthAchievement: null,
  153. wealthNetwork: null,
  154. // 子维度 - child
  155. wealthEducation: null,
  156. wealthSocial: null,
  157. wealthPoints: null,
  158. children: []
  159. }
  160. },
  161. computed: {
  162. isLoggedIn() {
  163. return !!uni.getStorageSync('token')
  164. }
  165. },
  166. onShow() {
  167. if (!uni.getStorageSync('token')) return
  168. var currentRole = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
  169. if (currentRole === 'teacher') {
  170. uni.redirectTo({ url: '/pages/teacher/teacher-profile' })
  171. return
  172. }
  173. this.role = currentRole
  174. this.isSwitchedChild = uni.getStorageSync('isSwitchedChild') || false
  175. this.loadChildren()
  176. this.loadWealthDetail()
  177. },
  178. methods: {
  179. goLogin() {
  180. uni.navigateTo({ url: '/pages/login/login' })
  181. },
  182. async loadChildren() {
  183. try {
  184. var res = await getChildren()
  185. this.children = res.data || []
  186. } catch (e) {
  187. console.error('获取孩子列表失败', e)
  188. }
  189. },
  190. async loadWealthDetail() {
  191. var memberId = null
  192. var memberType = this.role
  193. if (this.role === 'child') {
  194. memberId = uni.getStorageSync('currentChildId')
  195. if (!memberId && this.children.length > 0) {
  196. memberId = this.children[0].id
  197. }
  198. } else {
  199. memberId = uni.getStorageSync('userId')
  200. }
  201. if (!memberId) return
  202. try {
  203. var res = await getWealthDetail(memberId, memberType)
  204. if (res && res.data) {
  205. var d = res.data
  206. this.bodyScore = d.bodyScore || 0
  207. this.wealthScore = d.wealthScore || 0
  208. this.bodyWealthStatus = d.bodyWealthStatus || 'normal'
  209. this.bodyWealthMessage = d.bodyWealthMessage || ''
  210. if (memberType === 'parent') {
  211. this.wealthIncome = d.wealthIncome
  212. this.wealthAchievement = d.wealthAchievement
  213. this.wealthNetwork = d.wealthNetwork
  214. } else {
  215. this.wealthEducation = d.wealthEducation
  216. this.wealthSocial = d.wealthSocial
  217. this.wealthPoints = d.wealthPoints
  218. }
  219. }
  220. } catch (e) {
  221. console.error('获取富维度详情失败', e)
  222. }
  223. },
  224. exitSwitch() {
  225. if (!this.isSwitchedChild) return
  226. uni.showModal({
  227. title: '退出切换',
  228. content: '请输入家长密码以确认退出',
  229. editable: true,
  230. success: async (res) => {
  231. if (res.confirm && res.content) {
  232. try {
  233. var verifyResult = await verifyPassword(res.content)
  234. if (verifyResult.code === 200) {
  235. this.$store.commit('switchBackToParent')
  236. this.isSwitchedChild = false
  237. this.role = 'parent'
  238. uni.showToast({ title: '已退出切换', icon: 'success' })
  239. uni.reLaunch({ url: '/pages/index/index' })
  240. } else {
  241. uni.showToast({ title: '密码错误', icon: 'none' })
  242. }
  243. } catch (e) {
  244. uni.showToast({ title: '验证失败', icon: 'none' })
  245. }
  246. }
  247. }
  248. })
  249. },
  250. goToCheckin() {
  251. uni.navigateTo({ url: '/pages/wealth/checkin' })
  252. },
  253. goToInsurance() {
  254. uni.showToast({ title: '即将上线', icon: 'none' })
  255. },
  256. goToCreator() {
  257. uni.showToast({ title: '即将上线', icon: 'none' })
  258. },
  259. goToBadges() {
  260. uni.showToast({ title: '即将上线', icon: 'none' })
  261. },
  262. goToGrowthReport() {
  263. uni.showToast({ title: '即将上线', icon: 'none' })
  264. },
  265. goToPointsLogs() {
  266. uni.navigateTo({ url: '/pages/points/points' })
  267. },
  268. goToPromotion() {
  269. uni.navigateTo({ url: '/pages/promotion/index' })
  270. },
  271. goToProfile() {
  272. uni.navigateTo({ url: '/pages/profile/index' })
  273. },
  274. goToIncome() {
  275. uni.showToast({ title: '即将上线', icon: 'none' })
  276. },
  277. goToAchievements() {
  278. uni.showToast({ title: '即将上线', icon: 'none' })
  279. },
  280. goToNetwork() {
  281. uni.showToast({ title: '即将上线', icon: 'none' })
  282. }
  283. }
  284. }
  285. </script>
  286. <style scoped>
  287. .container {
  288. min-height: 100vh;
  289. background: #f5f7fa;
  290. padding-bottom: 120rpx;
  291. }
  292. .section {
  293. margin: 20rpx 30rpx;
  294. }
  295. .section-header {
  296. display: flex;
  297. justify-content: space-between;
  298. align-items: center;
  299. margin-bottom: 20rpx;
  300. }
  301. .section-title {
  302. font-size: 30rpx;
  303. font-weight: bold;
  304. color: #333;
  305. }
  306. /* 身克富状态条 */
  307. .body-wealth-bar {
  308. background: #fff;
  309. border-radius: 20rpx;
  310. padding: 30rpx;
  311. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  312. }
  313. .body-wealth-bar.status-overdraw {
  314. background: #FFFBEB;
  315. border: 1rpx solid #F59E0B;
  316. }
  317. .body-wealth-bar.status-penalty {
  318. background: #FEF2F2;
  319. border: 1rpx solid #EF4444;
  320. }
  321. .bar-row {
  322. display: flex;
  323. align-items: center;
  324. margin-bottom: 16rpx;
  325. }
  326. .bar-row:last-of-type {
  327. margin-bottom: 0;
  328. }
  329. .bar-label {
  330. font-size: 26rpx;
  331. color: #666;
  332. width: 140rpx;
  333. }
  334. .bar-track {
  335. flex: 1;
  336. height: 16rpx;
  337. background: #f0f0f0;
  338. border-radius: 8rpx;
  339. overflow: hidden;
  340. margin: 0 16rpx;
  341. }
  342. .bar-fill {
  343. height: 100%;
  344. border-radius: 8rpx;
  345. transition: width 0.3s;
  346. }
  347. .bar-fill.body-bar {
  348. background: linear-gradient(90deg, #FF8C42, #F97316);
  349. }
  350. .bar-fill.wealth-bar {
  351. background: linear-gradient(90deg, #F59E0B, #FBBF24);
  352. }
  353. .bar-value {
  354. font-size: 24rpx;
  355. color: #999;
  356. width: 80rpx;
  357. text-align: right;
  358. }
  359. .bw-message {
  360. margin-top: 16rpx;
  361. font-size: 24rpx;
  362. color: #666;
  363. padding: 12rpx 16rpx;
  364. background: rgba(0,0,0,0.03);
  365. border-radius: 8rpx;
  366. }
  367. .status-overdraw .bw-message {
  368. color: #92400E;
  369. background: rgba(245,158,11,0.1);
  370. }
  371. .status-penalty .bw-message {
  372. color: #991B1B;
  373. background: rgba(239,68,68,0.1);
  374. }
  375. /* 三子维度卡片 */
  376. .sub-dim-grid {
  377. display: flex;
  378. }
  379. .sub-dim-card {
  380. flex: 1;
  381. margin-right: 16rpx;
  382. background: #fff;
  383. border-radius: 16rpx;
  384. padding: 24rpx 16rpx;
  385. display: flex;
  386. flex-direction: column;
  387. align-items: center;
  388. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  389. }
  390. .sub-dim-card:last-child {
  391. margin-right: 0;
  392. }
  393. .sub-dim-score {
  394. font-size: 48rpx;
  395. font-weight: bold;
  396. color: #F59E0B;
  397. }
  398. .sub-dim-label {
  399. font-size: 24rpx;
  400. color: #333;
  401. margin-top: 8rpx;
  402. font-weight: 500;
  403. }
  404. .sub-dim-desc {
  405. font-size: 20rpx;
  406. color: #999;
  407. margin-top: 4rpx;
  408. }
  409. /* 增值服务 */
  410. .service-grid {
  411. display: flex;
  412. flex-wrap: wrap;
  413. background: #fff;
  414. border-radius: 20rpx;
  415. padding: 24rpx 16rpx;
  416. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  417. }
  418. .service-item {
  419. width: 20%;
  420. display: flex;
  421. flex-direction: column;
  422. align-items: center;
  423. padding: 16rpx 0;
  424. }
  425. .service-icon {
  426. font-size: 48rpx;
  427. margin-bottom: 8rpx;
  428. }
  429. .service-label {
  430. font-size: 22rpx;
  431. color: #666;
  432. }
  433. /* 底部菜单 */
  434. .menu-list {
  435. margin: 30rpx 30rpx 0;
  436. background: #fff;
  437. border-radius: 16rpx;
  438. }
  439. .menu-item {
  440. padding: 30rpx;
  441. border-bottom: 1rpx solid #f0f0f0;
  442. display: flex;
  443. justify-content: space-between;
  444. font-size: 28rpx;
  445. }
  446. .menu-item:last-child {
  447. border-bottom: none;
  448. }
  449. .arrow {
  450. color: #ccc;
  451. font-size: 32rpx;
  452. }
  453. /* 未登录 */
  454. .login-prompt {
  455. display: flex;
  456. flex-direction: column;
  457. align-items: center;
  458. justify-content: center;
  459. min-height: 80vh;
  460. padding: 60rpx;
  461. }
  462. .prompt-icon {
  463. font-size: 120rpx;
  464. margin-bottom: 30rpx;
  465. width: 160rpx;
  466. height: 160rpx;
  467. line-height: 160rpx;
  468. text-align: center;
  469. background: #f5f5f5;
  470. border-radius: 50%;
  471. }
  472. .prompt-title {
  473. font-size: 36rpx;
  474. font-weight: bold;
  475. color: #333;
  476. margin-bottom: 16rpx;
  477. }
  478. .prompt-desc {
  479. font-size: 26rpx;
  480. color: #999;
  481. text-align: center;
  482. margin-bottom: 40rpx;
  483. }
  484. .login-prompt .login-btn {
  485. width: 60%;
  486. height: 80rpx;
  487. line-height: 80rpx;
  488. background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
  489. color: #fff;
  490. font-size: 30rpx;
  491. font-weight: bold;
  492. border-radius: 40rpx;
  493. text-align: center;
  494. border: none;
  495. }
  496. .login-prompt .login-btn::after {
  497. border: none;
  498. }
  499. /* 退出切换 */
  500. .exit-switch {
  501. margin: 20rpx 30rpx 0;
  502. padding: 16rpx 24rpx;
  503. background: #FEF3C7;
  504. border-radius: 12rpx;
  505. text-align: center;
  506. font-size: 26rpx;
  507. color: #92400E;
  508. }
  509. </style>