index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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. <view class="menu-list">
  114. <view class="menu-item" v-if="role === 'parent'" @click="goToProfile">
  115. <text>⚙️ 个人设置</text>
  116. <text class="arrow">›</text>
  117. </view>
  118. <view class="menu-item" @click="goToPointsLogs">
  119. <text>📊 积分记录</text>
  120. <text class="arrow">›</text>
  121. </view>
  122. <view class="menu-item" @click="goToPromotion">
  123. <text>📣 推广中心</text>
  124. <text class="arrow">›</text>
  125. </view>
  126. </view>
  127. </template>
  128. </view>
  129. </template>
  130. <script>
  131. import PageBanner from '../../components/PageBanner.vue'
  132. import { getWealthDetail, verifyPassword, getChildren } from '../../utils/api.js'
  133. export default {
  134. components: { PageBanner },
  135. data() {
  136. return {
  137. role: 'parent',
  138. isSwitchedChild: false,
  139. // 身克富
  140. bodyScore: 0,
  141. wealthScore: 0,
  142. bodyWealthStatus: 'normal',
  143. bodyWealthMessage: '',
  144. // 子维度 - parent
  145. wealthIncome: null,
  146. wealthAchievement: null,
  147. wealthNetwork: null,
  148. // 子维度 - child
  149. wealthEducation: null,
  150. wealthSocial: null,
  151. wealthPoints: null,
  152. children: []
  153. }
  154. },
  155. computed: {
  156. isLoggedIn() {
  157. return !!uni.getStorageSync('token')
  158. }
  159. },
  160. onShow() {
  161. if (!uni.getStorageSync('token')) return
  162. var currentRole = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
  163. if (currentRole === 'teacher') {
  164. uni.redirectTo({ url: '/pages/teacher/teacher-profile' })
  165. return
  166. }
  167. this.role = currentRole
  168. this.isSwitchedChild = uni.getStorageSync('isSwitchedChild') || false
  169. this.loadChildren()
  170. this.loadWealthDetail()
  171. },
  172. methods: {
  173. goLogin() {
  174. uni.navigateTo({ url: '/pages/login/login' })
  175. },
  176. async loadChildren() {
  177. try {
  178. var res = await getChildren()
  179. this.children = res.data || []
  180. } catch (e) {
  181. console.error('获取孩子列表失败', e)
  182. }
  183. },
  184. async loadWealthDetail() {
  185. var memberId = null
  186. var memberType = this.role
  187. if (this.role === 'child') {
  188. memberId = uni.getStorageSync('currentChildId')
  189. if (!memberId && this.children.length > 0) {
  190. memberId = this.children[0].id
  191. }
  192. } else {
  193. memberId = uni.getStorageSync('userId')
  194. }
  195. if (!memberId) return
  196. try {
  197. var res = await getWealthDetail(memberId, memberType)
  198. if (res && res.data) {
  199. var d = res.data
  200. this.bodyScore = d.bodyScore || 0
  201. this.wealthScore = d.wealthScore || 0
  202. this.bodyWealthStatus = d.bodyWealthStatus || 'normal'
  203. this.bodyWealthMessage = d.bodyWealthMessage || ''
  204. if (memberType === 'parent') {
  205. this.wealthIncome = d.wealthIncome
  206. this.wealthAchievement = d.wealthAchievement
  207. this.wealthNetwork = d.wealthNetwork
  208. } else {
  209. this.wealthEducation = d.wealthEducation
  210. this.wealthSocial = d.wealthSocial
  211. this.wealthPoints = d.wealthPoints
  212. }
  213. }
  214. } catch (e) {
  215. console.error('获取富维度详情失败', e)
  216. }
  217. },
  218. exitSwitch() {
  219. if (!this.isSwitchedChild) return
  220. uni.showModal({
  221. title: '退出切换',
  222. content: '请输入家长密码以确认退出',
  223. editable: true,
  224. success: async (res) => {
  225. if (res.confirm && res.content) {
  226. try {
  227. var verifyResult = await verifyPassword(res.content)
  228. if (verifyResult.code === 200) {
  229. this.$store.commit('switchBackToParent')
  230. this.isSwitchedChild = false
  231. this.role = 'parent'
  232. uni.showToast({ title: '已退出切换', icon: 'success' })
  233. uni.reLaunch({ url: '/pages/index/index' })
  234. } else {
  235. uni.showToast({ title: '密码错误', icon: 'none' })
  236. }
  237. } catch (e) {
  238. uni.showToast({ title: '验证失败', icon: 'none' })
  239. }
  240. }
  241. }
  242. })
  243. },
  244. goToCheckin() {
  245. uni.navigateTo({ url: '/pages/wealth/checkin' })
  246. },
  247. goToInsurance() {
  248. uni.showToast({ title: '即将上线', icon: 'none' })
  249. },
  250. goToCreator() {
  251. uni.showToast({ title: '即将上线', icon: 'none' })
  252. },
  253. goToBadges() {
  254. uni.showToast({ title: '即将上线', icon: 'none' })
  255. },
  256. goToGrowthReport() {
  257. uni.showToast({ title: '即将上线', icon: 'none' })
  258. },
  259. goToPointsLogs() {
  260. uni.navigateTo({ url: '/pages/points/points' })
  261. },
  262. goToPromotion() {
  263. uni.navigateTo({ url: '/pages/promotion/index' })
  264. },
  265. goToProfile() {
  266. uni.navigateTo({ url: '/pages/profile/index' })
  267. },
  268. goToIncome() {
  269. uni.showToast({ title: '即将上线', icon: 'none' })
  270. },
  271. goToAchievements() {
  272. uni.showToast({ title: '即将上线', icon: 'none' })
  273. },
  274. goToNetwork() {
  275. uni.showToast({ title: '即将上线', icon: 'none' })
  276. }
  277. }
  278. }
  279. </script>
  280. <style scoped>
  281. .container {
  282. min-height: 100vh;
  283. background: #f5f7fa;
  284. padding-bottom: 120rpx;
  285. }
  286. .section {
  287. margin: 20rpx 30rpx;
  288. }
  289. .section-header {
  290. display: flex;
  291. justify-content: space-between;
  292. align-items: center;
  293. margin-bottom: 20rpx;
  294. }
  295. .section-title {
  296. font-size: 30rpx;
  297. font-weight: bold;
  298. color: #333;
  299. }
  300. /* 身克富状态条 */
  301. .body-wealth-bar {
  302. background: #fff;
  303. border-radius: 20rpx;
  304. padding: 30rpx;
  305. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  306. }
  307. .body-wealth-bar.status-overdraw {
  308. background: #FFFBEB;
  309. border: 1rpx solid #F59E0B;
  310. }
  311. .body-wealth-bar.status-penalty {
  312. background: #FEF2F2;
  313. border: 1rpx solid #EF4444;
  314. }
  315. .bar-row {
  316. display: flex;
  317. align-items: center;
  318. margin-bottom: 16rpx;
  319. }
  320. .bar-row:last-of-type {
  321. margin-bottom: 0;
  322. }
  323. .bar-label {
  324. font-size: 26rpx;
  325. color: #666;
  326. width: 140rpx;
  327. }
  328. .bar-track {
  329. flex: 1;
  330. height: 16rpx;
  331. background: #f0f0f0;
  332. border-radius: 8rpx;
  333. overflow: hidden;
  334. margin: 0 16rpx;
  335. }
  336. .bar-fill {
  337. height: 100%;
  338. border-radius: 8rpx;
  339. transition: width 0.3s;
  340. }
  341. .bar-fill.body-bar {
  342. background: linear-gradient(90deg, #FF8C42, #F97316);
  343. }
  344. .bar-fill.wealth-bar {
  345. background: linear-gradient(90deg, #F59E0B, #FBBF24);
  346. }
  347. .bar-value {
  348. font-size: 24rpx;
  349. color: #999;
  350. width: 80rpx;
  351. text-align: right;
  352. }
  353. .bw-message {
  354. margin-top: 16rpx;
  355. font-size: 24rpx;
  356. color: #666;
  357. padding: 12rpx 16rpx;
  358. background: rgba(0,0,0,0.03);
  359. border-radius: 8rpx;
  360. }
  361. .status-overdraw .bw-message {
  362. color: #92400E;
  363. background: rgba(245,158,11,0.1);
  364. }
  365. .status-penalty .bw-message {
  366. color: #991B1B;
  367. background: rgba(239,68,68,0.1);
  368. }
  369. /* 三子维度卡片 */
  370. .sub-dim-grid {
  371. display: flex;
  372. }
  373. .sub-dim-card {
  374. flex: 1;
  375. margin-right: 16rpx;
  376. background: #fff;
  377. border-radius: 16rpx;
  378. padding: 24rpx 16rpx;
  379. display: flex;
  380. flex-direction: column;
  381. align-items: center;
  382. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  383. }
  384. .sub-dim-card:last-child {
  385. margin-right: 0;
  386. }
  387. .sub-dim-score {
  388. font-size: 48rpx;
  389. font-weight: bold;
  390. color: #F59E0B;
  391. }
  392. .sub-dim-label {
  393. font-size: 24rpx;
  394. color: #333;
  395. margin-top: 8rpx;
  396. font-weight: 500;
  397. }
  398. .sub-dim-desc {
  399. font-size: 20rpx;
  400. color: #999;
  401. margin-top: 4rpx;
  402. }
  403. /* 增值服务 */
  404. .service-grid {
  405. display: flex;
  406. flex-wrap: wrap;
  407. background: #fff;
  408. border-radius: 20rpx;
  409. padding: 24rpx 16rpx;
  410. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  411. }
  412. .service-item {
  413. width: 20%;
  414. display: flex;
  415. flex-direction: column;
  416. align-items: center;
  417. padding: 16rpx 0;
  418. }
  419. .service-icon {
  420. font-size: 48rpx;
  421. margin-bottom: 8rpx;
  422. }
  423. .service-label {
  424. font-size: 22rpx;
  425. color: #666;
  426. }
  427. /* 底部菜单 */
  428. .menu-list {
  429. margin: 30rpx 30rpx 0;
  430. background: #fff;
  431. border-radius: 16rpx;
  432. }
  433. .menu-item {
  434. padding: 30rpx;
  435. border-bottom: 1rpx solid #f0f0f0;
  436. display: flex;
  437. justify-content: space-between;
  438. font-size: 28rpx;
  439. }
  440. .menu-item:last-child {
  441. border-bottom: none;
  442. }
  443. .arrow {
  444. color: #ccc;
  445. font-size: 32rpx;
  446. }
  447. /* 未登录 */
  448. .login-prompt {
  449. display: flex;
  450. flex-direction: column;
  451. align-items: center;
  452. justify-content: center;
  453. min-height: 80vh;
  454. padding: 60rpx;
  455. }
  456. .prompt-icon {
  457. font-size: 120rpx;
  458. margin-bottom: 30rpx;
  459. width: 160rpx;
  460. height: 160rpx;
  461. line-height: 160rpx;
  462. text-align: center;
  463. background: #f5f5f5;
  464. border-radius: 50%;
  465. }
  466. .prompt-title {
  467. font-size: 36rpx;
  468. font-weight: bold;
  469. color: #333;
  470. margin-bottom: 16rpx;
  471. }
  472. .prompt-desc {
  473. font-size: 26rpx;
  474. color: #999;
  475. text-align: center;
  476. margin-bottom: 40rpx;
  477. }
  478. .login-prompt .login-btn {
  479. width: 60%;
  480. height: 80rpx;
  481. line-height: 80rpx;
  482. background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
  483. color: #fff;
  484. font-size: 30rpx;
  485. font-weight: bold;
  486. border-radius: 40rpx;
  487. text-align: center;
  488. border: none;
  489. }
  490. .login-prompt .login-btn::after {
  491. border: none;
  492. }
  493. /* 退出切换 */
  494. .exit-switch {
  495. margin: 20rpx 30rpx 0;
  496. padding: 16rpx 24rpx;
  497. background: #FEF3C7;
  498. border-radius: 12rpx;
  499. text-align: center;
  500. font-size: 26rpx;
  501. color: #92400E;
  502. }
  503. </style>