index.vue 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. <template>
  2. <view class="container">
  3. <!-- TabTransition overlay -->
  4. <tab-transition v-if="showTabTransition" dimCode="wealth" ref="tabTransition" @close="showTabTransition = false" />
  5. <!-- 未登录时显示精简内容 -->
  6. <template v-if="!isLoggedIn">
  7. <!-- 品牌定位语 -->
  8. <view class="brand-strap">
  9. <text class="brand-strap-text">分享价值,收获财富</text>
  10. </view>
  11. <!-- 月度引导语 -->
  12. <view class="monthly-guidance" v-if="!isLoggedIn">
  13. <text class="guidance-icon">💧</text>
  14. <text class="guidance-text">{{ monthlyGuidance }}</text>
  15. </view>
  16. <!-- 登录引导 -->
  17. <view class="login-guide-section">
  18. <LoginGuideCard
  19. title="解锁财富能量与推广收益"
  20. :items="[
  21. '查看家庭财富能量仪表盘与推广收益',
  22. '管理邀请返利,开通会员享专属折扣',
  23. '浏览商城精选商品,一键加入购物车'
  24. ]" />
  25. </view>
  26. <!-- 商城精选预览(无需登录) -->
  27. <view class="section">
  28. <view class="section-header">
  29. <text class="section-title">🛍️ 商城精选</text>
  30. <text class="section-more" @click="goToShop">查看全部 ›</text>
  31. </view>
  32. <scroll-view scroll-x class="product-scroll" show-scrollbar="false">
  33. <view class="product-list">
  34. <view class="product-card" v-for="(item, idx) in guestProducts" :key="idx" @click="goProductDetail(item.id)">
  35. <image class="product-img" :src="getImageUrl(item.coverImage || item.image) || '/static/default-product.png'" mode="aspectFill" />
  36. <text class="product-name">{{ item.name }}</text>
  37. <text class="product-price">¥{{ item.price || 0 }}</text>
  38. </view>
  39. </view>
  40. </scroll-view>
  41. </view>
  42. </template>
  43. <template v-else>
  44. <!-- 家庭成员选择条 -->
  45. <FamilyMemberStrip
  46. v-if="currentView === 'self' && isLoggedIn"
  47. :members="familyMembersVisible"
  48. :selectedMemberId="selectedMemberId"
  49. @select="onFamilyMemberSelect"
  50. @removed="loadFamilyMembersVisible" />
  51. <!-- 五维能量条 -->
  52. <FamilyEnergyBar
  53. v-if="isLoggedIn && sandboxData"
  54. dimensionCode="wealth"
  55. :sandboxData="sandboxData"
  56. :dualDimension="dualDimension" />
  57. <!-- 身克富杠杆警告 -->
  58. <body-wealth-alert
  59. :status="bodyWealthStatus"
  60. :message="bodyWealthMessage"
  61. :showTip="true" />
  62. <!-- 财富能量环 -->
  63. <WealthEnergyRing
  64. :score="wealthScore"
  65. :delta="deltaPercent" />
  66. <!-- 财富成长 -->
  67. <view class="section stream-section">
  68. <view class="section-header">
  69. <text class="section-title">💰 财富成长</text>
  70. <text class="section-sub">记录家庭财富积累过程,看到每月的成长变化</text>
  71. </view>
  72. <view class="stream-stages">
  73. <view
  74. class="stage-card"
  75. :class="{ active: stage.key === currentStage }"
  76. v-for="stage in streamStages"
  77. :key="stage.key">
  78. <text class="stage-icon">{{ stage.icon }}</text>
  79. <text class="stage-name">{{ stage.name }}</text>
  80. <text class="stage-desc">{{ stage.desc }}</text>
  81. <text class="stage-range">{{ stage.range }}</text>
  82. </view>
  83. </view>
  84. <view class="stream-water">
  85. <view class="stream-water-fill" :style="{ width: wealthScore + '%' }"></view>
  86. </view>
  87. <text class="stream-percent">水位 {{ wealthScore }}%</text>
  88. <text class="stream-tip">{{ streamTip }}</text>
  89. </view>
  90. <!-- 子维度水滴 -->
  91. <wealth-sub-scores
  92. :role="role"
  93. :skill="wealthSkill"
  94. :altruism="wealthAltruism"
  95. :income="wealthIncome"
  96. :fx="wealthFx" />
  97. <!-- 子维度评分表 -->
  98. <dimension-sub-dims
  99. v-if="isLoggedIn && wealthSubDims.length > 0"
  100. title="💧 财富维度构成"
  101. subtitle="家庭财富能量的各个方面"
  102. accent-color="#F59E0B"
  103. :dims="wealthSubDims" />
  104. <!-- 财富强项与提升 -->
  105. <view class="section wealth-insight" v-if="isLoggedIn && wealthSubDims.length > 0 && (wealthStrengths.length > 0 || wealthImproves.length > 0)">
  106. <view class="section-header">
  107. <text class="section-title">📈 财富强项与提升</text>
  108. </view>
  109. <view class="insight-group" v-if="wealthStrengths.length > 0">
  110. <text class="insight-group-title">💪 财富强项</text>
  111. <view class="insight-item" v-for="(item, idx) in wealthStrengths" :key="getInsightKey('s', idx)">
  112. <text class="insight-item-name">{{ item.label }}</text>
  113. <text class="insight-item-score">{{ item.score }}分</text>
  114. <text class="insight-item-tag tag-strong">强项</text>
  115. </view>
  116. </view>
  117. <view class="insight-group" v-if="wealthImproves.length > 0">
  118. <text class="insight-group-title">🌱 提升空间</text>
  119. <view class="insight-item" v-for="(item, idx) in wealthImproves" :key="getInsightKey('i', idx)">
  120. <text class="insight-item-name">{{ item.label }}</text>
  121. <text class="insight-item-score">{{ item.score }}分</text>
  122. <text class="insight-item-tag tag-improve">待提升</text>
  123. </view>
  124. </view>
  125. <view class="insight-tip" v-if="wealthStrengths.length > 0 && wealthImproves.length > 0">
  126. <text class="insight-tip-text">保持优势项,薄弱项可通过参与活动与任务逐步积累</text>
  127. </view>
  128. </view>
  129. <!-- 财富数据卡(家长) -->
  130. <view class="section" v-if="role === 'parent'">
  131. <view class="disc-card">
  132. <text class="disc-label">💰 累计收益</text>
  133. <text class="disc-value">¥{{ wealthData.totalEarnings || 0 }}</text>
  134. <text class="disc-sub" v-if="deltaPercent > 0">较上月 ↑ {{ deltaPercent }}%</text>
  135. </view>
  136. <view class="disc-sub-row">
  137. <view class="disc-sub-card" @click="goToIncome">
  138. <text class="disc-sub-label">可提现</text>
  139. <text class="disc-sub-value">¥{{ wealthData.availableAmount || 0 }}</text>
  140. <text class="disc-sub-action">提现 →</text>
  141. </view>
  142. <view class="disc-sub-card" @click="goToAchievements">
  143. <text class="disc-sub-label">邀请人数</text>
  144. <text class="disc-sub-value">{{ wealthData.referralCount || 0 }}人</text>
  145. <text class="disc-sub-action">邀请 →</text>
  146. </view>
  147. </view>
  148. </view>
  149. <!-- 财富数据卡(孩子) -->
  150. <view class="section" v-else>
  151. <view class="child-wealth-card">
  152. <view class="child-wealth-item">
  153. <text class="child-wealth-icon">⭐</text>
  154. <text class="child-wealth-value">{{ wealthIncome || 0 }}</text>
  155. <text class="child-wealth-label">累计积分</text>
  156. </view>
  157. <view class="child-wealth-item">
  158. <text class="child-wealth-icon">📝</text>
  159. <text class="child-wealth-value">{{ taskPercent }}%</text>
  160. <text class="child-wealth-label">任务完成</text>
  161. </view>
  162. <view class="child-wealth-item">
  163. <text class="child-wealth-icon">🏆</text>
  164. <text class="child-wealth-value">{{ badgeCount }}</text>
  165. <text class="child-wealth-label">已获徽章</text>
  166. </view>
  167. </view>
  168. <view class="child-trend">
  169. <text class="child-trend-title">📊 本周成长趋势</text>
  170. <view class="child-trend-bars">
  171. <view class="trend-bar" v-for="(h, i) in weekTrend" :key="i" :style="{ height: h + '%' }"></view>
  172. </view>
  173. <view class="child-trend-days">
  174. <text class="trend-day" v-for="(d, i) in weekDays" :key="i">{{ d }}</text>
  175. </view>
  176. </view>
  177. </view>
  178. <!-- 保单管理 -->
  179. <view class="section" v-if="insuranceLoaded">
  180. <view class="section-header">
  181. <text class="section-title">🛡️ 保单管理</text>
  182. <text class="section-more" @click="goToInsuranceList">查看更多 ›</text>
  183. </view>
  184. <view class="insurance-card" v-if="insuranceList.length === 0">
  185. <view class="insurance-empty">
  186. <text class="insurance-empty-icon">📋</text>
  187. <text class="insurance-empty-text">暂无保单</text>
  188. </view>
  189. </view>
  190. <view class="insurance-card" v-else>
  191. <view class="insurance-item" v-for="(item, idx) in insuranceList" :key="idx" @click="goToInsuranceList">
  192. <view class="insurance-item-header">
  193. <text class="insurance-item-name">{{ item.policyName }}</text>
  194. <text class="insurance-item-status" :class="'status-' + item.status">{{ getPolicyStatusLabel(item.status) }}</text>
  195. </view>
  196. <view class="insurance-item-row">
  197. <text class="insurance-item-label">保险公司</text>
  198. <text class="insurance-item-value">{{ item.insuranceCompany || '未知' }}</text>
  199. </view>
  200. <view class="insurance-item-row">
  201. <text class="insurance-item-label">被保人</text>
  202. <text class="insurance-item-value">{{ item.insuredPerson }}</text>
  203. </view>
  204. </view>
  205. </view>
  206. </view>
  207. <!-- 富维度介绍卡片 -->
  208. <DimensionIntroCard dimCode="wealth" v-if="isLoggedIn" learn-more-url="/pages/wealth/dimension-intro" />
  209. </template>
  210. </view>
  211. </template>
  212. <script>
  213. import TabTransition from '../../components/tab-transition.vue'
  214. import WealthEnergyRing from '../../components/WealthEnergyRing.vue'
  215. import WealthSubScores from '../../components/WealthSubScores.vue'
  216. import BodyWealthAlert from '../../components/BodyWealthAlert.vue'
  217. import FamilyMemberStrip from '../../components/FamilyMemberStrip.vue'
  218. import FamilyEnergyBar from '../../components/FamilyEnergyBar.vue'
  219. import DimensionIntroCard from '../../components/DimensionIntroCard.vue'
  220. import DimensionSubDims from '../../components/DimensionSubDims.vue'
  221. import {
  222. getChildren,
  223. getWealthDetail,
  224. getReferralCode,
  225. getReferralSummary,
  226. getCommissionSummary,
  227. getFamilyMemberList,
  228. getInsuranceList,
  229. getFamilyEnergySandbox,
  230. getEnergyOverview,
  231. productList,
  232. extractReferralCode,
  233. getChildBadgeStats,
  234. getDailyTaskOverview
  235. } from '../../utils/api.js'
  236. import nav from '../../utils/nav.js'
  237. import config from '../../config.js'
  238. export default {
  239. components: { TabTransition, WealthEnergyRing, WealthSubScores, BodyWealthAlert, FamilyMemberStrip, FamilyEnergyBar, DimensionIntroCard, DimensionSubDims },
  240. data() {
  241. return {
  242. showTabTransition: true,
  243. isLoggedIn: false,
  244. role: 'parent',
  245. // 五维评分
  246. wealthScore: 0,
  247. // 子维度 - 利他创富四维(家长/孩子共用字段)
  248. wealthSkill: null,
  249. wealthAltruism: null,
  250. wealthIncome: null,
  251. wealthFx: null,
  252. // 子维度汇总(DimensionSubDims 用)
  253. wealthSubDims: [],
  254. // 身克富杠杆
  255. bodyWealthStatus: 'normal',
  256. bodyWealthMessage: '',
  257. // 财富数据
  258. wealthData: {
  259. totalEarnings: 0,
  260. availableAmount: 0,
  261. referralCount: 0,
  262. referralCode: ''
  263. },
  264. // 财富成长
  265. deltaPercent: 0,
  266. streamStages: [
  267. { key: 'start', icon: '💧', name: '起步', desc: '新人阶段', range: '0-30%' },
  268. { key: 'mid', icon: '🌊', name: '汇流', desc: '成长阶段', range: '30-70%' },
  269. { key: 'surge', icon: '🌊🌊', name: '奔涌', desc: '达人阶段', range: '70-100%' }
  270. ],
  271. // 孩子数据
  272. taskPercent: 0,
  273. badgeCount: 0,
  274. weekTrend: [30, 40, 35, 50, 60, 55, 70],
  275. weekDays: ['一', '二', '三', '四', '五', '六', '日'],
  276. // 服务列表
  277. serviceList: [
  278. { icon: '📝', label: '记账', action: 'goToCheckin' },
  279. { icon: '🛡️', label: '保单管理', action: 'goToInsurance' },
  280. { icon: '🎨', label: '创客中心', action: 'goToCreator' },
  281. { icon: '🏪', label: '商城首页', action: 'goToShop' },
  282. { icon: '🛒', label: '购物车', action: 'goToCart' },
  283. { icon: '📋', label: '我的订单', action: 'goToOrders' },
  284. { icon: '🔄', label: '售后服务', action: 'goToAfterSales' },
  285. { icon: '📊', label: '收益中心', action: 'goToIncome' },
  286. { icon: '💎', label: '家庭CF值', action: 'goToFamilyCf' }
  287. ],
  288. children: [],
  289. familyMembersVisible: [],
  290. selectedMemberId: null,
  291. guestProducts: [],
  292. // 五维能量条数据
  293. sandboxData: null,
  294. dualDimension: null,
  295. // 保单列表
  296. insuranceList: [],
  297. insuranceLoaded: false,
  298. }
  299. },
  300. computed: {
  301. activeChildId() {
  302. if (this.role === 'child') {
  303. return uni.getStorageSync('currentChildId')
  304. }
  305. return ''
  306. },
  307. currentStage() {
  308. var s = this.wealthScore
  309. if (s >= 70) return 'surge'
  310. if (s >= 30) return 'mid'
  311. return 'start'
  312. },
  313. streamTip() {
  314. var s = this.wealthScore
  315. if (s >= 70) return '🎉 已是富足达人,继续引领全家成长!'
  316. if (s >= 30) return '💡 坚持分享,下一阶段"奔涌"在望'
  317. return '🌱 从今天开始,迈出创富第一步'
  318. },
  319. /** 财富强项:wealthSubDims 中得分 ≥75 的维度 */
  320. wealthStrengths() {
  321. var result = []
  322. for (var i = 0; i < this.wealthSubDims.length; i++) {
  323. var d = this.wealthSubDims[i]
  324. var s = Number(d.score)
  325. if (s >= 75) result.push({ label: d.label, score: s })
  326. }
  327. return result
  328. },
  329. /** 财富提升空间:wealthSubDims 中 0<得分<60 的维度 */
  330. wealthImproves() {
  331. var result = []
  332. for (var i = 0; i < this.wealthSubDims.length; i++) {
  333. var d = this.wealthSubDims[i]
  334. var s = Number(d.score)
  335. if (s > 0 && s < 60) result.push({ label: d.label, score: s })
  336. }
  337. return result
  338. }
  339. },
  340. onShow() {
  341. this.showTabTransition = true
  342. var token = uni.getStorageSync('token')
  343. if (!token) {
  344. this.isLoggedIn = false
  345. this.loadGuestProducts()
  346. this._watchPageReady()
  347. return
  348. }
  349. this.isLoggedIn = true
  350. var currentRole = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
  351. if (currentRole === 'teacher') {
  352. uni.redirectTo({ url: '/pages/teacher/teacher-profile' })
  353. return
  354. }
  355. this.role = currentRole
  356. this.loadChildren()
  357. this.loadWealthDetail()
  358. this.loadWealthData()
  359. this.loadChildData()
  360. this.loadFamilyMembersVisible()
  361. this.loadInsuranceList()
  362. this.loadSandboxData()
  363. this.loadEnergyData()
  364. this._watchPageReady()
  365. },
  366. /** 每月引导语 */
  367. monthlyGuidance: function() {
  368. var month = new Date().getMonth()
  369. var messages = [
  370. '一月:理财从记账开始,养习惯',
  371. '二月:新年规划,梳理家庭收支',
  372. '三月:春耕时节,播种财富种子',
  373. '四月:清明踏青,规划家庭支出',
  374. '五月:劳动节后,复盘收支状况',
  375. '六月:年中复盘,调整财富目标',
  376. '七月:暑期规划,优化家庭消费',
  377. '八月:开学季,教育专项规划',
  378. '九月:金秋收获,检视推广收益',
  379. '十月:国庆消费,理性理财',
  380. '十一月:年终冲刺,盘点年度收益',
  381. '十二月:年度总结,规划来年财富'
  382. ]
  383. return messages[month] || messages[0]
  384. },
  385. methods: {
  386. getInsightKey(prefix, idx) { return prefix + idx },
  387. onFamilyMemberSelect(member) {
  388. this.selectedMemberId = member.id
  389. },
  390. loadFamilyMembersVisible() {
  391. var self = this
  392. getFamilyMemberList({ visibleOnly: true }).then(function(res) {
  393. self.familyMembersVisible = res.data || []
  394. }).catch(function(e) {
  395. console.log('获取可见家庭成员失败', e)
  396. self.familyMembersVisible = []
  397. })
  398. },
  399. loadInsuranceList() {
  400. var self = this
  401. this.insuranceLoaded = false
  402. getInsuranceList({}).then(function(res) {
  403. if (res && res.code === 200) {
  404. self.insuranceList = (res.data || []).slice(0, 3)
  405. }
  406. self.insuranceLoaded = true
  407. }).catch(function() {
  408. self.insuranceLoaded = true
  409. })
  410. },
  411. getPolicyStatusLabel: function(status) {
  412. var map = { active: '有效', expired: '已过期', cancelled: '已取消' }
  413. return map[status] || status || '未知'
  414. },
  415. goLogin() {
  416. uni.navigateTo({ url: '/pages/login/login' })
  417. },
  418. _watchPageReady() {
  419. var self = this
  420. this.$nextTick(function() {
  421. if (self.$refs.tabTransition) self.$refs.tabTransition.markReady()
  422. })
  423. },
  424. async loadChildren() {
  425. try {
  426. var res = await getChildren()
  427. this.children = res.data || []
  428. } catch (e) {
  429. console.error('获取孩子列表失败', e)
  430. }
  431. },
  432. async loadWealthDetail() {
  433. var memberId = null
  434. var memberType = this.role
  435. if (this.role === 'child') {
  436. memberId = uni.getStorageSync('currentChildId')
  437. if (!memberId && this.children.length > 0) {
  438. memberId = this.children[0].id
  439. }
  440. } else {
  441. memberId = uni.getStorageSync('userId')
  442. }
  443. if (!memberId) return
  444. try {
  445. var res = await getWealthDetail(memberId, memberType)
  446. if (res && res.data) {
  447. var d = res.data
  448. this.wealthScore = d.wealthScore || 0
  449. // 利他创富四子维度(家长/孩子共用字段)
  450. this.wealthSkill = d.wealthSkill
  451. this.wealthAltruism = d.wealthAltruism
  452. this.wealthIncome = d.wealthIncome
  453. this.wealthFx = d.wealthFx
  454. // 身克富杠杆状态
  455. this.bodyWealthStatus = d.bodyWealthStatus || 'normal'
  456. this.bodyWealthMessage = d.bodyWealthMessage || ''
  457. // 子维度汇总(供 DimensionSubDims 使用)
  458. if (memberType === 'parent') {
  459. this.wealthSubDims = [
  460. { label: '个人能力', score: this.wealthSkill || 0, desc: '服务商资质与成长学习' },
  461. { label: '利他贡献', score: this.wealthAltruism || 0, desc: '邀请分享帮助他人' },
  462. { label: 'CF值积累', score: this.wealthIncome || 0, desc: '家庭第二收入曲线' },
  463. { label: '财务素养', score: this.wealthFx || 0, desc: '记账理财储蓄习惯' }
  464. ]
  465. } else {
  466. this.wealthSubDims = [
  467. { label: '学业能力', score: this.wealthSkill || 0, desc: '测评成绩与进步趋势' },
  468. { label: '利他贡献', score: this.wealthAltruism || 0, desc: '帮助他人与分享' },
  469. { label: '积分积累', score: this.wealthIncome || 0, desc: '完成任务获取积分' },
  470. { label: '财务素养', score: this.wealthFx || 0, desc: '财商学习与储蓄习惯' }
  471. ]
  472. }
  473. }
  474. } catch (e) {
  475. console.error('获取富维度详情失败', e)
  476. }
  477. },
  478. loadSandboxData: function() {
  479. var self = this
  480. getFamilyEnergySandbox().then(function(res) {
  481. if (res && res.data) self.sandboxData = res.data
  482. }).catch(function() {})
  483. },
  484. loadEnergyData: function() {
  485. var self = this
  486. var memberId = uni.getStorageSync('userId') || null
  487. if (!memberId) return
  488. getEnergyOverview(memberId).then(function(res) {
  489. if (res && res.data) {
  490. var dims = res.data.dimensions
  491. if (dims && dims.length > 0) {
  492. for (var i = 0; i < dims.length; i++) {
  493. if (dims[i].code === 'wealth') {
  494. self.dualDimension = dims[i]
  495. break
  496. }
  497. }
  498. }
  499. }
  500. }).catch(function() {})
  501. },
  502. goToMemberDetail: function(memberId) {
  503. uni.navigateTo({ url: '/pages/wealth-detail/member-wealth-detail?memberId=' + memberId })
  504. },
  505. async loadWealthData() {
  506. if (this.role !== 'parent') return
  507. try {
  508. var codeRes = await getReferralCode()
  509. this.wealthData.referralCode = extractReferralCode(codeRes)
  510. } catch (e) {
  511. console.error('获取邀请码失败', e)
  512. }
  513. try {
  514. var summaryRes = await getReferralSummary()
  515. if (summaryRes && summaryRes.code === 200 && summaryRes.data) {
  516. this.wealthData.referralCount = summaryRes.data.invitedCount || 0
  517. }
  518. } catch (e) {
  519. console.error('获取邀请统计失败', e)
  520. }
  521. try {
  522. var commissionRes = await getCommissionSummary()
  523. if (commissionRes && commissionRes.code === 200 && commissionRes.data) {
  524. this.wealthData.totalEarnings = commissionRes.data.totalEarnings || 0
  525. this.wealthData.availableAmount = commissionRes.data.availableAmount || 0
  526. }
  527. } catch (e) {
  528. console.error('获取佣金统计失败', e)
  529. }
  530. },
  531. async loadChildData() {
  532. if (this.role !== 'child') return
  533. var memberId = uni.getStorageSync('currentChildId')
  534. if (!memberId && this.children.length > 0) {
  535. memberId = this.children[0].id
  536. }
  537. if (!memberId) return
  538. try {
  539. var badgeRes = await getChildBadgeStats(memberId)
  540. if (badgeRes && badgeRes.code === 200 && badgeRes.data) {
  541. this.badgeCount = badgeRes.data.active || 0
  542. }
  543. } catch (e) {
  544. console.error('获取徽章统计失败', e)
  545. }
  546. try {
  547. var taskRes = await getDailyTaskOverview({ memberId: memberId })
  548. if (taskRes && taskRes.code === 200 && taskRes.data && taskRes.data.tasks) {
  549. var done = taskRes.data.tasks.doneToday || 0
  550. var todo = taskRes.data.tasks.todoToday || 0
  551. var total = done + todo
  552. this.taskPercent = total > 0 ? Math.round(done / total * 100) : 0
  553. }
  554. } catch (e) {
  555. console.error('获取任务概览失败', e)
  556. }
  557. },
  558. logout() {
  559. uni.showModal({
  560. title: '退出登录',
  561. content: '确定要退出登录吗?',
  562. success: function(res) {
  563. if (res.confirm) {
  564. uni.clearStorageSync()
  565. uni.reLaunch({ url: '/pages/login/login' })
  566. }
  567. }
  568. })
  569. },
  570. goToCheckin() {
  571. uni.navigateTo({ url: '/pages/wealth-sub/checkin' })
  572. },
  573. goToInsurance() {
  574. uni.navigateTo({ url: '/pages/wealth-sub/insurance-list' })
  575. },
  576. goToInsuranceList: function() {
  577. uni.navigateTo({ url: '/pages/wealth-sub/insurance-list' })
  578. },
  579. goToCreator() {
  580. uni.navigateTo({ url: '/pages/promotion/index' })
  581. },
  582. goToShop() {
  583. uni.navigateTo({ url: '/pages/shop/index/index' })
  584. },
  585. goToOrders() {
  586. uni.navigateTo({ url: '/pages/shop/order-list/order-list' })
  587. },
  588. goToAfterSales() {
  589. uni.navigateTo({ url: '/pages/shop/after-sales/after-sales' })
  590. },
  591. goToIncome() {
  592. uni.navigateTo({ url: '/pages/promotion/commission' })
  593. },
  594. goToFamilyCf() {
  595. uni.navigateTo({ url: '/pages/wealth-cf/index' })
  596. },
  597. goToAchievements() {
  598. uni.navigateTo({ url: '/pages/rewards/badge' })
  599. },
  600. goToNetwork() {
  601. uni.navigateTo({ url: '/pages/promotion/team' })
  602. },
  603. goToCart() {
  604. uni.navigateTo({ url: '/pages/shop/cart/cart' })
  605. },
  606. loadGuestProducts() {
  607. var self = this
  608. productList({ page: 1, size: 4, sort: 'sales' }).then(function(res) {
  609. if (res.code === 200 && res.data && res.data.records) {
  610. self.guestProducts = res.data.records.slice(0, 4)
  611. }
  612. }).catch(function() {})
  613. },
  614. goProductDetail(id) {
  615. uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + id })
  616. },
  617. getImageUrl: function(path) {
  618. return config.API_BASE_URL + path
  619. },
  620. onServiceClick(action) {
  621. if (this[action]) {
  622. this[action]()
  623. }
  624. }
  625. }
  626. }
  627. </script>
  628. .view-toggle {
  629. display: flex;
  630. margin: 20rpx 30rpx;
  631. background: rgba(255,255,255,0.12);
  632. border-radius: 12rpx;
  633. padding: 6rpx;
  634. }
  635. .toggle-btn {
  636. flex: 1;
  637. text-align: center;
  638. padding: 12rpx 0;
  639. border-radius: 8rpx;
  640. font-size: 26rpx;
  641. color: rgba(255,255,255,0.65);
  642. }
  643. .toggle-btn.active {
  644. background: rgba(255,255,255,0.22);
  645. color: #fff;
  646. font-weight: 600;
  647. }
  648. /* 页面说明 */
  649. .section-sub {
  650. font-size: 22rpx;
  651. color: rgba(255,255,255,0.55);
  652. margin-top: 6rpx;
  653. display: block;
  654. }
  655. /* 得分解读卡片 */
  656. .score-explain-card {
  657. margin: 20rpx 30rpx;
  658. padding: 28rpx 24rpx;
  659. background: rgba(255,255,255,0.1);
  660. border-radius: 20rpx;
  661. border: 1rpx solid rgba(255,255,255,0.15);
  662. }
  663. .explain-header {
  664. display: flex;
  665. align-items: center;
  666. margin-bottom: 14rpx;
  667. }
  668. .explain-icon {
  669. font-size: 36rpx;
  670. margin-right: 10rpx;
  671. }
  672. .explain-title {
  673. font-size: 28rpx;
  674. font-weight: 600;
  675. color: #fff;
  676. }
  677. .explain-text {
  678. font-size: 26rpx;
  679. color: rgba(255,255,255,0.8);
  680. line-height: 1.6;
  681. }
  682. <style scoped>
  683. .container {
  684. min-height: 100vh;
  685. background: #f5f7fa;
  686. padding-bottom: 120rpx;
  687. }
  688. .section {
  689. margin: 20rpx 30rpx;
  690. }
  691. .section-header {
  692. display: flex;
  693. justify-content: space-between;
  694. align-items: center;
  695. margin-bottom: 20rpx;
  696. }
  697. .section-title {
  698. font-size: 30rpx;
  699. font-weight: bold;
  700. color: #333;
  701. }
  702. .section-more {
  703. font-size: 24rpx;
  704. color: #999;
  705. }
  706. /* 财富成长 */
  707. .stream-section {
  708. background: #fff;
  709. border-radius: 20rpx;
  710. padding: 24rpx;
  711. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  712. }
  713. .stream-stages {
  714. display: flex;
  715. justify-content: space-between;
  716. margin-bottom: 20rpx;
  717. }
  718. .stage-card {
  719. flex: 1;
  720. margin: 0 8rpx;
  721. padding: 20rpx;
  722. border-radius: 16rpx;
  723. background: #F5F9FC;
  724. display: flex;
  725. flex-direction: column;
  726. align-items: center;
  727. }
  728. .stage-card.active {
  729. background: #FFF7ED;
  730. border: 2rpx solid #FBBF24;
  731. }
  732. .stage-icon {
  733. font-size: 44rpx;
  734. }
  735. .stage-name {
  736. font-size: 26rpx;
  737. font-weight: bold;
  738. color: #333;
  739. margin-top: 8rpx;
  740. }
  741. .stage-desc {
  742. font-size: 20rpx;
  743. color: #999;
  744. margin-top: 4rpx;
  745. }
  746. .stage-range {
  747. font-size: 20rpx;
  748. color: #F59E0B;
  749. margin-top: 4rpx;
  750. }
  751. .stream-water {
  752. height: 20rpx;
  753. border-radius: 10rpx;
  754. background: #FEF3C7;
  755. overflow: hidden;
  756. }
  757. .stream-water-fill {
  758. height: 100%;
  759. border-radius: 10rpx;
  760. background: linear-gradient(90deg, #F59E0B, #FBBF24);
  761. transition: width 0.8s ease;
  762. }
  763. .stream-percent {
  764. display: block;
  765. text-align: right;
  766. font-size: 22rpx;
  767. color: #F59E0B;
  768. margin-top: 8rpx;
  769. }
  770. .stream-tip {
  771. display: block;
  772. text-align: center;
  773. font-size: 24rpx;
  774. color: #92400E;
  775. margin-top: 12rpx;
  776. }
  777. /* 财富数据主卡 */
  778. .disc-card {
  779. background: linear-gradient(135deg, #FFF7ED, #FEF3C7);
  780. border-radius: 20rpx;
  781. padding: 30rpx;
  782. margin-bottom: 16rpx;
  783. display: flex;
  784. flex-direction: column;
  785. }
  786. .disc-label {
  787. font-size: 26rpx;
  788. color: #92400E;
  789. }
  790. .disc-value {
  791. font-size: 56rpx;
  792. font-weight: bold;
  793. color: #F59E0B;
  794. margin-top: 8rpx;
  795. }
  796. .disc-sub {
  797. font-size: 24rpx;
  798. color: #B45309;
  799. margin-top: 8rpx;
  800. }
  801. .disc-sub-row {
  802. display: flex;
  803. margin-bottom: 16rpx;
  804. }
  805. .disc-sub-card {
  806. flex: 1;
  807. background: #fff;
  808. border-radius: 16rpx;
  809. padding: 24rpx;
  810. display: flex;
  811. flex-direction: column;
  812. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  813. }
  814. .disc-sub-card:first-child {
  815. margin-right: 8rpx;
  816. }
  817. .disc-sub-card:last-child {
  818. margin-left: 8rpx;
  819. }
  820. .disc-sub-label {
  821. font-size: 24rpx;
  822. color: #999;
  823. }
  824. .disc-sub-value {
  825. font-size: 36rpx;
  826. font-weight: bold;
  827. color: #333;
  828. margin-top: 8rpx;
  829. }
  830. .disc-sub-action {
  831. font-size: 22rpx;
  832. color: #F59E0B;
  833. margin-top: 8rpx;
  834. }
  835. /* 孩子财富卡 */
  836. .child-wealth-card {
  837. display: flex;
  838. background: #fff;
  839. border-radius: 20rpx;
  840. padding: 24rpx 0;
  841. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  842. }
  843. .child-wealth-item {
  844. flex: 1;
  845. display: flex;
  846. flex-direction: column;
  847. align-items: center;
  848. }
  849. .child-wealth-icon {
  850. font-size: 44rpx;
  851. }
  852. .child-wealth-value {
  853. font-size: 36rpx;
  854. font-weight: bold;
  855. color: #F59E0B;
  856. margin-top: 8rpx;
  857. }
  858. .child-wealth-label {
  859. font-size: 22rpx;
  860. color: #999;
  861. margin-top: 4rpx;
  862. }
  863. .child-trend {
  864. margin-top: 16rpx;
  865. background: #fff;
  866. border-radius: 20rpx;
  867. padding: 24rpx;
  868. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  869. }
  870. .child-trend-title {
  871. font-size: 26rpx;
  872. color: #333;
  873. font-weight: bold;
  874. }
  875. .child-trend-bars {
  876. display: flex;
  877. align-items: flex-end;
  878. height: 120rpx;
  879. margin-top: 16rpx;
  880. }
  881. .trend-bar {
  882. flex: 1;
  883. margin: 0 6rpx;
  884. background: linear-gradient(180deg, #FBBF24, #F59E0B);
  885. border-radius: 6rpx 6rpx 0 0;
  886. }
  887. .child-trend-days {
  888. display: flex;
  889. margin-top: 8rpx;
  890. }
  891. .trend-day {
  892. flex: 1;
  893. text-align: center;
  894. font-size: 20rpx;
  895. color: #999;
  896. }
  897. /* 服务入口 */
  898. .service-grid {
  899. display: flex;
  900. flex-wrap: wrap;
  901. background: #fff;
  902. border-radius: 20rpx;
  903. padding: 24rpx 16rpx;
  904. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  905. }
  906. .service-item {
  907. width: 25%;
  908. display: flex;
  909. flex-direction: column;
  910. align-items: center;
  911. padding: 16rpx 0;
  912. }
  913. .service-icon-wrap {
  914. width: 88rpx;
  915. height: 88rpx;
  916. border-radius: 24rpx;
  917. background: #FFF7ED;
  918. display: flex;
  919. align-items: center;
  920. justify-content: center;
  921. margin-bottom: 8rpx;
  922. }
  923. .service-icon {
  924. font-size: 40rpx;
  925. }
  926. .service-label {
  927. font-size: 22rpx;
  928. color: #666;
  929. }
  930. .logout-item {
  931. color: #EF4444;
  932. }
  933. /* 未登录 */
  934. .login-guide-section {
  935. display: flex;
  936. flex-direction: column;
  937. align-items: center;
  938. padding: 60rpx 40rpx;
  939. margin: 30rpx;
  940. background: #fff;
  941. border-radius: 20rpx;
  942. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  943. }
  944. .login-guide-text {
  945. font-size: 26rpx;
  946. color: #999;
  947. text-align: center;
  948. margin-bottom: 30rpx;
  949. line-height: 1.6;
  950. }
  951. .login-guide-section .login-btn {
  952. width: 60%;
  953. height: 80rpx;
  954. line-height: 80rpx;
  955. background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
  956. color: #fff;
  957. font-size: 30rpx;
  958. font-weight: bold;
  959. border-radius: 40rpx;
  960. text-align: center;
  961. border: none;
  962. }
  963. .login-prompt .login-btn::after {
  964. border: none;
  965. }
  966. /* 品牌定位语 */
  967. .brand-strap {
  968. margin: 16rpx 30rpx 0;
  969. padding: 20rpx 28rpx;
  970. background: linear-gradient(135deg, #FFFBEB, rgba(245,158,11,0.12));
  971. border-radius: 16rpx;
  972. border-left: 4rpx solid #F59E0B;
  973. }
  974. .brand-strap-text {
  975. font-size: 26rpx;
  976. color: #92400E;
  977. font-weight: 500;
  978. }
  979. /* 商城精选预览 */
  980. .product-scroll {
  981. white-space: nowrap;
  982. padding: 0 30rpx;
  983. }
  984. .product-list {
  985. display: inline-flex;
  986. gap: 20rpx;
  987. }
  988. .product-card {
  989. width: 220rpx;
  990. flex-shrink: 0;
  991. background: #fff;
  992. border-radius: 16rpx;
  993. overflow: hidden;
  994. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  995. }
  996. .product-img {
  997. width: 220rpx;
  998. height: 220rpx;
  999. background: #f5f5f5;
  1000. }
  1001. .product-name {
  1002. display: block;
  1003. padding: 12rpx 12rpx 4rpx;
  1004. font-size: 24rpx;
  1005. color: #333;
  1006. overflow: hidden;
  1007. text-overflow: ellipsis;
  1008. white-space: nowrap;
  1009. }
  1010. .product-price {
  1011. display: block;
  1012. padding: 4rpx 12rpx 12rpx;
  1013. font-size: 26rpx;
  1014. font-weight: bold;
  1015. color: #F59E0B;
  1016. }
  1017. /* 保单管理 */
  1018. .insurance-card {
  1019. background: #fff;
  1020. border-radius: 20rpx;
  1021. padding: 24rpx;
  1022. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  1023. }
  1024. .insurance-empty {
  1025. display: flex;
  1026. flex-direction: column;
  1027. align-items: center;
  1028. padding: 40rpx 0;
  1029. }
  1030. .insurance-empty-icon { font-size: 60rpx; }
  1031. .insurance-empty-text { font-size: 24rpx; color: #999; margin-top: 12rpx; }
  1032. .insurance-item {
  1033. padding: 16rpx 0;
  1034. border-bottom: 1rpx solid #f5f5f5;
  1035. }
  1036. .insurance-item:last-child { border-bottom: none; }
  1037. .insurance-item-header {
  1038. display: flex;
  1039. justify-content: space-between;
  1040. align-items: center;
  1041. margin-bottom: 8rpx;
  1042. }
  1043. .insurance-item-name {
  1044. font-size: 26rpx;
  1045. font-weight: 600;
  1046. color: #333;
  1047. }
  1048. .insurance-item-status {
  1049. font-size: 20rpx;
  1050. padding: 4rpx 12rpx;
  1051. border-radius: 8rpx;
  1052. }
  1053. .insurance-item-status.status-active { background: #DCFCE7; color: #16A34A; }
  1054. .insurance-item-status.status-expired { background: #FEF2F2; color: #DC2626; }
  1055. .insurance-item-status.status-cancelled { background: #F5F5F5; color: #999; }
  1056. .insurance-item-row {
  1057. display: flex;
  1058. justify-content: space-between;
  1059. padding: 4rpx 0;
  1060. }
  1061. .insurance-item-label { font-size: 22rpx; color: #999; }
  1062. .insurance-item-value { font-size: 22rpx; color: #666; }
  1063. /* ===== 财富强项与提升卡片 ===== */
  1064. .wealth-insight {
  1065. background: #fff;
  1066. border-radius: 20rpx;
  1067. padding: 24rpx;
  1068. }
  1069. .insight-group {
  1070. margin-bottom: 16rpx;
  1071. }
  1072. .insight-group-title {
  1073. font-size: 26rpx;
  1074. font-weight: 600;
  1075. color: #333;
  1076. margin-bottom: 10rpx;
  1077. display: block;
  1078. }
  1079. .insight-item {
  1080. display: flex;
  1081. align-items: center;
  1082. padding: 12rpx 16rpx;
  1083. background: #FFFBEB;
  1084. border-radius: 12rpx;
  1085. margin-bottom: 8rpx;
  1086. }
  1087. .insight-item-name {
  1088. flex: 1;
  1089. font-size: 26rpx;
  1090. color: #333;
  1091. }
  1092. .insight-item-score {
  1093. font-size: 24rpx;
  1094. color: #666;
  1095. margin-right: 12rpx;
  1096. }
  1097. .insight-item-tag {
  1098. font-size: 20rpx;
  1099. padding: 4rpx 16rpx;
  1100. border-radius: 8rpx;
  1101. font-weight: 500;
  1102. }
  1103. .insight-item-tag.tag-strong {
  1104. background: #D1FAE5;
  1105. color: #059669;
  1106. }
  1107. .insight-item-tag.tag-improve {
  1108. background: #FEF3C7;
  1109. color: #D97706;
  1110. }
  1111. .insight-tip {
  1112. padding: 12rpx 16rpx;
  1113. background: #FFFBEB;
  1114. border-radius: 12rpx;
  1115. }
  1116. .insight-tip-text {
  1117. font-size: 22rpx;
  1118. color: #F59E0B;
  1119. }
  1120. </style>
  1121. /* 月度引导语 */
  1122. .monthly-guidance {
  1123. margin: 0 30rpx 20rpx;
  1124. background: linear-gradient(135deg, #FFFBEB, rgba(245,158,11,0.1));
  1125. border-radius: 16rpx;
  1126. padding: 20rpx 24rpx;
  1127. display: flex;
  1128. align-items: center;
  1129. gap: 12rpx;
  1130. }
  1131. .guidance-icon { font-size: 32rpx; flex-shrink: 0; }
  1132. .guidance-text { font-size: 26rpx; color: #F59E0B; font-weight: 500; }