profile.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  1. <template>
  2. <view class="container">
  3. <!-- 未登录 -->
  4. <view v-if="!isLoggedIn" class="login-prompt">
  5. <text class="prompt-icon">👤</text>
  6. <text class="prompt-title">登录浠艾福</text>
  7. <text class="prompt-desc">登录后查看个人资料、积分记录、能量数据与家庭管理</text>
  8. <button class="login-btn" @click="goLogin">登录 / 注册</button>
  9. <text class="skip-link" @click="goSkip">暂不登录,先逛逛 ›</text>
  10. </view>
  11. <!-- 已登录 -->
  12. <template v-else>
  13. <!-- 退出切换 -->
  14. <view class="exit-switch" v-if="isSwitchedChild" @click="onExitSwitch">
  15. <text>🔄 退出切换</text>
  16. </view>
  17. <!-- 用户身份卡片 -->
  18. <view class="user-card">
  19. <view class="user-card-left">
  20. <view class="avatar-wrap" @click="goToEditInfo">
  21. <image v-if="userInfo.avatar" class="avatar-img" :src="userInfo.avatar" mode="aspectFill" />
  22. <text v-else class="avatar-text">{{ nickname.charAt(0) || '👤' }}</text>
  23. </view>
  24. <view class="user-meta">
  25. <view class="user-name-row">
  26. <text class="nickname">{{ nickname || '未设置昵称' }}</text>
  27. <text class="role-tag">{{ roleLabel }}</text>
  28. </view>
  29. <view class="user-sub" v-if="memberLevel">
  30. <text class="level-badge" :class="'level-' + memberLevel">{{ memberLevelText }}</text>
  31. <text v-if="membershipDays > 0 && membershipDays <= 30" class="days-left">剩余 {{ membershipDays }} 天</text>
  32. </view>
  33. <view class="user-sub" v-else>
  34. <text class="days-left">开通会员解锁更多权益</text>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="user-card-right">
  39. <view class="points-box" @click="goToPoints">
  40. <text class="points-num">{{ totalPoints }}</text>
  41. <text class="points-label">积分</text>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 核心数据概览 -->
  46. <view class="stats-bar">
  47. <view class="stat-item" @click="goToTasks">
  48. <text class="stat-num">{{ pendingTasks }}</text>
  49. <text class="stat-label">待完成任务</text>
  50. </view>
  51. <view class="stat-divider"></view>
  52. <view class="stat-item" @click="goToCheckin">
  53. <text class="stat-num">{{ streakDays }}</text>
  54. <text class="stat-label">连续打卡</text>
  55. </view>
  56. <view class="stat-divider"></view>
  57. <view class="stat-item" @click="goToFamily">
  58. <text class="stat-num">{{ familyCount }}</text>
  59. <text class="stat-label">家庭成员</text>
  60. </view>
  61. <view class="stat-divider"></view>
  62. <view class="stat-item" @click="goToChallenges">
  63. <text class="stat-num">{{ activeChallenges }}</text>
  64. <text class="stat-label">进行中挑战</text>
  65. </view>
  66. </view>
  67. <!-- 商城订单快捷 -->
  68. <view class="mall-section" v-if="totalPoints > 0">
  69. <view class="mall-header" @click="goToOrders">
  70. <text class="mall-title">🛒 商城订单</text>
  71. <text class="mall-more">全部订单 ›</text>
  72. </view>
  73. <view class="mall-grid">
  74. <view class="mall-item" @click="goToOrders">
  75. <text class="mall-item-num" v-if="orderPending > 0">{{ orderPending }}</text>
  76. <text class="mall-item-num" v-else>0</text>
  77. <text class="mall-item-label">待审核</text>
  78. </view>
  79. <view class="mall-item" @click="goToOrders">
  80. <text class="mall-item-num" v-if="orderUnpaid > 0">{{ orderUnpaid }}</text>
  81. <text class="mall-item-num" v-else>0</text>
  82. <text class="mall-item-label">待付款</text>
  83. </view>
  84. <view class="mall-item" @click="goToOrders">
  85. <text class="mall-item-num" v-if="orderShipped > 0">{{ orderShipped }}</text>
  86. <text class="mall-item-num" v-else>0</text>
  87. <text class="mall-item-label">待发货</text>
  88. </view>
  89. <view class="mall-item" @click="goToOrders">
  90. <text class="mall-item-num" v-if="orderAfterSale > 0">{{ orderAfterSale }}</text>
  91. <text class="mall-item-num" v-else>0</text>
  92. <text class="mall-item-label">售后</text>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 推广中心快捷 -->
  97. <view class="mall-section" v-if="commissionBalance > 0 || referralCount > 0 || teamCount > 0">
  98. <view class="mall-header" @click="goToPromotion">
  99. <text class="mall-title">💰 推广中心</text>
  100. <text class="mall-more">进入 ›</text>
  101. </view>
  102. <view class="mall-grid">
  103. <view class="mall-item" @click="goToPromotion">
  104. <text class="mall-item-num">{{ commissionBalance }}</text>
  105. <text class="mall-item-label">可提现</text>
  106. </view>
  107. <view class="mall-item" @click="goToPromotion">
  108. <text class="mall-item-num">{{ referralCount }}</text>
  109. <text class="mall-item-label">邀请人数</text>
  110. </view>
  111. <view class="mall-item" @click="goToPromotion">
  112. <text class="mall-item-num">{{ teamCount }}</text>
  113. <text class="mall-item-label">团队人数</text>
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 五维能量 -->
  118. <view class="energy-section" v-if="sandboxData">
  119. <view class="section-header">
  120. <text class="section-title">🌟 五维能量</text>
  121. <text class="section-more" @click="goToEnergySandbox">详情 ›</text>
  122. </view>
  123. <view class="energy-row">
  124. <view class="energy-item" v-for="dim in energyDims" :key="dim.code">
  125. <view class="energy-circle" :style="{ background: dim.color }">
  126. <text class="energy-val">{{ dim.score || 0 }}</text>
  127. </view>
  128. <text class="energy-label">{{ dim.label }}</text>
  129. </view>
  130. </view>
  131. </view>
  132. <!-- 待办提醒 -->
  133. <view class="reminders-section" v-if="hasReminders">
  134. <view class="section-header">
  135. <text class="section-title">📌 待办提醒</text>
  136. </view>
  137. <view class="reminder-item" v-if="pendingTasks > 0" @click="goToTasks">
  138. <text class="reminder-icon">📋</text>
  139. <text class="reminder-text">有 {{ pendingTasks }} 个任务待完成</text>
  140. <text class="reminder-arrow">›</text>
  141. </view>
  142. <view class="reminder-item" v-if="activeChallenges > 0" @click="goToChallenges">
  143. <text class="reminder-icon">🔥</text>
  144. <text class="reminder-text">{{ activeChallenges }} 个挑战进行中</text>
  145. <text class="reminder-arrow">›</text>
  146. </view>
  147. <view class="reminder-item" v-if="profileProgress < 14" @click="goToEditInfo">
  148. <text class="reminder-icon">📝</text>
  149. <text class="reminder-text">个人信息待完善({{ profileProgress }}/14)</text>
  150. <text class="reminder-arrow">›</text>
  151. </view>
  152. </view>
  153. <!-- 功能菜单 -->
  154. <view class="menu-section">
  155. <!-- 家庭 -->
  156. <view class="menu-group">
  157. <view class="menu-group-title">家庭</view>
  158. <view class="menu-item" @click="goToFamily">
  159. <text class="menu-icon">👨‍👩‍👧‍👦</text>
  160. <text class="menu-text">家庭成员</text>
  161. <text class="arrow">›</text>
  162. </view>
  163. <view class="menu-item" @click="goToChildren">
  164. <text class="menu-icon">👶</text>
  165. <text class="menu-text">孩子管理</text>
  166. <text class="arrow">›</text>
  167. </view>
  168. <view class="menu-item" v-if="role === 'parent'" @click="goToAppointments">
  169. <text class="menu-icon">📅</text>
  170. <text class="menu-text">测评预约</text>
  171. <text class="arrow">›</text>
  172. </view>
  173. <view class="menu-item" @click="goToChallenges">
  174. <text class="menu-icon">🔥</text>
  175. <text class="menu-text">家庭挑战</text>
  176. <text class="arrow">›</text>
  177. </view>
  178. </view>
  179. <!-- 成长 -->
  180. <view class="menu-group">
  181. <view class="menu-group-title">成长</view>
  182. <view class="menu-item" @click="goToTasks">
  183. <text class="menu-icon">📋</text>
  184. <text class="menu-text">每日任务</text>
  185. <text class="arrow">›</text>
  186. </view>
  187. <view class="menu-item" @click="goToGrowth">
  188. <text class="menu-icon">📈</text>
  189. <text class="menu-text">成长档案</text>
  190. <text class="arrow">›</text>
  191. </view>
  192. <view class="menu-item" @click="goToReport">
  193. <text class="menu-icon">📊</text>
  194. <text class="menu-text">健康报告</text>
  195. <text class="arrow">›</text>
  196. </view>
  197. </view>
  198. <!-- 商城 -->
  199. <view class="menu-group" v-if="showServices">
  200. <view class="menu-group-title">商城</view>
  201. <view class="menu-item" @click="goToPromotion">
  202. <text class="menu-icon">💰</text>
  203. <text class="menu-text">推广中心</text>
  204. <text class="arrow">›</text>
  205. </view>
  206. <view class="menu-item" @click="goToOrders">
  207. <text class="menu-icon">🛒</text>
  208. <text class="menu-text">我的订单</text>
  209. <text class="badge" v-if="orderPending + orderUnpaid + orderShipped + orderAfterSale > 0">{{ orderPending + orderUnpaid + orderShipped + orderAfterSale }}</text>
  210. <text class="arrow">›</text>
  211. </view>
  212. <view class="menu-item" @click="goToCart">
  213. <text class="menu-icon">🛍️</text>
  214. <text class="menu-text">购物车</text>
  215. <text class="badge" v-if="cartCount > 0">{{ cartCount }}</text>
  216. <text class="arrow">›</text>
  217. </view>
  218. <view class="menu-item" @click="goToCoupons">
  219. <text class="menu-icon">🎫</text>
  220. <text class="menu-text">优惠券</text>
  221. <text class="arrow">›</text>
  222. </view>
  223. </view>
  224. <!-- 更多 -->
  225. <view class="menu-group">
  226. <view class="menu-group-title">更多</view>
  227. <view class="menu-item" v-if="role === 'parent'" @click="showInviteActionSheet">
  228. <text class="menu-icon">📨</text>
  229. <text class="menu-text">邀请加入</text>
  230. <text class="arrow">›</text>
  231. </view>
  232. <view class="menu-item" @click="goToSettings">
  233. <text class="menu-icon">⚙️</text>
  234. <text class="menu-text">设置</text>
  235. <text class="arrow">›</text>
  236. </view>
  237. <view class="menu-item" @click="logout">
  238. <text class="menu-icon">🚪</text>
  239. <text class="menu-text">退出登录</text>
  240. <text class="arrow">›</text>
  241. </view>
  242. </view>
  243. </view>
  244. </template>
  245. <AIFloatingAvatar />
  246. </view>
  247. </template>
  248. <script>
  249. import AIFloatingAvatar from '../../components/AIFloatingAvatar.vue'
  250. import {
  251. getChildren, getVisibleFamilyMembers, getFamilyEnergySandbox,
  252. getTodayTasksByCategory, getChallengeList, getMyMembership,
  253. verifyPassword, getPointsBalance, getUserInfo,
  254. cartCount, getOrderCounts, getCommissionSummary, getReferralSummary
  255. } from '../../utils/api.js'
  256. export default {
  257. components: { AIFloatingAvatar },
  258. data() {
  259. return {
  260. nickname: '',
  261. role: 'parent',
  262. isSwitchedChild: false,
  263. userInfo: {},
  264. memberLevel: null,
  265. membershipDays: 0,
  266. totalPoints: 0,
  267. pendingTasks: 0,
  268. streakDays: 0,
  269. familyCount: 0,
  270. activeChallenges: 0,
  271. profileProgress: 0,
  272. sandboxData: null,
  273. energyDims: [],
  274. // 商城
  275. cartCount: 0,
  276. orderPending: 0,
  277. orderUnpaid: 0,
  278. orderShipped: 0,
  279. orderAfterSale: 0,
  280. // 推广中心
  281. commissionBalance: 0,
  282. referralCount: 0,
  283. teamCount: 0
  284. }
  285. },
  286. computed: {
  287. isLoggedIn() {
  288. return !!uni.getStorageSync('token')
  289. },
  290. roleLabel() {
  291. var map = { parent: '家长', child: '孩子', teacher: '规划师' }
  292. return map[this.role] || '用户'
  293. },
  294. memberLevelText() {
  295. var map = { GOLD: '金卡', PLATINUM: '白金', DIAMOND: '钻石' }
  296. return map[this.memberLevel] || this.memberLevel || ''
  297. },
  298. hasReminders() {
  299. return this.pendingTasks > 0 || this.activeChallenges > 0 || this.profileProgress < 14
  300. }
  301. },
  302. onShow() {
  303. if (!this.isLoggedIn) {
  304. this.loadAllData()
  305. return
  306. }
  307. var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
  308. if (role === 'teacher') {
  309. uni.redirectTo({ url: '/pages/teacher/teacher-profile' })
  310. return
  311. }
  312. this.role = role
  313. this.isSwitchedChild = uni.getStorageSync('isSwitchedChild') || false
  314. this.nickname = (uni.getStorageSync('userInfo') || {}).nickname || ''
  315. this.loadAllData()
  316. },
  317. methods: {
  318. loadAllData() {
  319. this.loadUserInfo()
  320. this.loadMembership()
  321. this.loadPoints()
  322. this.loadFamily()
  323. this.loadSandbox()
  324. this.loadTasks()
  325. this.loadChallenges()
  326. this.loadOrderCounts()
  327. this.loadCartCount()
  328. this.loadPromotion()
  329. },
  330. loadUserInfo() {
  331. var self = this
  332. getUserInfo().then(function(res) {
  333. if (res && res.code === 200 && res.data) {
  334. self.userInfo = res.data
  335. if (!self.nickname) self.nickname = res.data.nickname || ''
  336. }
  337. }).catch(function() {})
  338. },
  339. loadMembership() {
  340. var self = this
  341. getMyMembership().then(function(res) {
  342. if (res && res.data) {
  343. self.memberLevel = res.data.memberLevel || res.data.levelCode || null
  344. self.membershipDays = res.data.membershipDays || res.data.daysRemaining || 0
  345. }
  346. }).catch(function() {})
  347. },
  348. loadPoints() {
  349. var self = this
  350. var memberId = uni.getStorageSync('currentChildId') || uni.getStorageSync('userId')
  351. if (!memberId) return
  352. getPointsBalance(memberId).then(function(res) {
  353. if (res && res.data) {
  354. self.totalPoints = res.data.totalPoints || res.data.points || 0
  355. }
  356. }).catch(function() {})
  357. },
  358. loadFamily() {
  359. var self = this
  360. var childrenRes = getChildren()
  361. var membersRes = getVisibleFamilyMembers()
  362. Promise.all([childrenRes, membersRes]).then(function(results) {
  363. var children = results[0].data || []
  364. var members = results[1].data || []
  365. self.familyCount = members.length || children.length
  366. self.streakDays = parseInt(uni.getStorageSync('streakDays') || 0)
  367. }).catch(function() {
  368. self.familyCount = 0
  369. })
  370. },
  371. loadSandbox() {
  372. var self = this
  373. getFamilyEnergySandbox().then(function(res) {
  374. if (res && res.data) {
  375. self.sandboxData = res.data
  376. var dims = res.data.dimensions || []
  377. self.energyDims = dims.map(function(d) {
  378. return {
  379. code: d.code,
  380. label: d.label || d.code,
  381. score: d.score || 0,
  382. color: self.getDimColor(d.code)
  383. }
  384. })
  385. }
  386. }).catch(function() {})
  387. },
  388. loadTasks() {
  389. var self = this
  390. var memberId = uni.getStorageSync('currentChildId') || uni.getStorageSync('userId')
  391. if (!memberId) return
  392. if (self.role === 'child' && memberId) {
  393. getTodayTasksByCategory(memberId, 'action').then(function(res) {
  394. if (res && res.data) {
  395. self.pendingTasks = Array.isArray(res.data) ? res.data.length : 0
  396. }
  397. }).catch(function() {})
  398. }
  399. self.pendingTasks = parseInt(uni.getStorageSync('pendingTaskCount') || 0)
  400. },
  401. loadChallenges() {
  402. var self = this
  403. getChallengeList({}).then(function(res) {
  404. if (res && res.data) {
  405. self.activeChallenges = Array.isArray(res.data) ? res.data.length : 0
  406. }
  407. }).catch(function() {})
  408. },
  409. loadOrderCounts() {
  410. var self = this
  411. getOrderCounts().then(function(res) {
  412. if (res && res.data) {
  413. self.orderPending = res.data.pending || 0
  414. self.orderUnpaid = res.data.unpaid || res.data.paid || 0
  415. self.orderShipped = res.data.shipped || 0
  416. self.orderAfterSale = res.data.refunding || res.data.afterSale || 0
  417. }
  418. }).catch(function() {})
  419. },
  420. loadCartCount() {
  421. var self = this
  422. cartCount().then(function(res) {
  423. if (res && res.data != null) {
  424. self.cartCount = res.data || 0
  425. }
  426. }).catch(function() {})
  427. },
  428. loadPromotion() {
  429. var self = this
  430. getCommissionSummary().then(function(res) {
  431. if (res && res.data) {
  432. self.commissionBalance = res.data.availableAmount || res.data.balance || 0
  433. }
  434. }).catch(function() {})
  435. getReferralSummary().then(function(res) {
  436. if (res && res.data) {
  437. self.referralCount = res.data.totalCount || res.data.count || 0
  438. }
  439. }).catch(function() {})
  440. },
  441. getDimColor: function(code) {
  442. var map = {
  443. body: '#FF8C42', mind: '#FF6B9D', wisdom: '#6366F1',
  444. action: '#10B981', wealth: '#F59E0B'
  445. }
  446. return map[code] || '#999'
  447. },
  448. goLogin: function() {
  449. uni.navigateTo({ url: '/pages/login/login' })
  450. },
  451. goSkip: function() {
  452. uni.switchTab({ url: '/pages/index-home/index' })
  453. },
  454. goToEditInfo: function() {
  455. uni.navigateTo({ url: '/pages/user-edit/user-edit' })
  456. },
  457. goToPoints: function() {
  458. uni.navigateTo({ url: '/pages/points/points' })
  459. },
  460. goToTasks: function() {
  461. uni.navigateTo({ url: '/pages/tasks/tasks' })
  462. },
  463. goToCheckin: function() {
  464. uni.navigateTo({ url: '/pages/health/daily-checkin' })
  465. },
  466. goToFamily: function() {
  467. uni.navigateTo({ url: '/pages/profile-extra/family-members' })
  468. },
  469. goToChildren: function() {
  470. uni.navigateTo({ url: '/pages/profile-extra/children' })
  471. },
  472. goToAppointments: function() {
  473. uni.navigateTo({ url: '/pages/parent/appointments' })
  474. },
  475. goToChallenges: function() {
  476. uni.navigateTo({ url: '/pages/health/challenge-manage' })
  477. },
  478. goToGrowth: function() {
  479. uni.navigateTo({ url: '/pages/growth-main/index' })
  480. },
  481. goToReport: function() {
  482. uni.navigateTo({ url: '/pages/profile/report-management' })
  483. },
  484. goToMembership: function() {
  485. uni.navigateTo({ url: '/pages/membership/index' })
  486. },
  487. goToPromotion: function() {
  488. uni.navigateTo({ url: '/pages/promotion/index' })
  489. },
  490. goToCart: function() {
  491. uni.navigateTo({ url: '/pages/shop/cart/cart' })
  492. },
  493. goToOrders: function() {
  494. uni.navigateTo({ url: '/pages/shop/order-list/order-list' })
  495. },
  496. goToCoupons: function() {
  497. uni.navigateTo({ url: '/pages/profile-extra/coupons' })
  498. },
  499. goToEnergySandbox: function() {
  500. uni.switchTab({ url: '/pages/index-home/index' })
  501. },
  502. goToSettings: function() {
  503. uni.showActionSheet({
  504. itemList: ['设置密码', '隐私设置', '关于浠艾福'],
  505. success: function(res) {
  506. if (res.tapIndex === 0) {
  507. uni.navigateTo({ url: '/pages/profile/settings' })
  508. }
  509. }
  510. })
  511. },
  512. onSwitchMode: function() {
  513. var self = this
  514. if (self.role === 'child') {
  515. uni.showModal({
  516. title: '验证密码',
  517. content: '请输入家长密码',
  518. editable: true,
  519. success: function(res) {
  520. if (res.confirm && res.content) {
  521. verifyPassword(res.content).then(function(result) {
  522. if (result.code === 200) {
  523. self.doSwitchMode()
  524. } else {
  525. uni.showToast({ title: '密码错误', icon: 'none' })
  526. }
  527. }).catch(function() {
  528. uni.showToast({ title: '验证失败', icon: 'none' })
  529. })
  530. }
  531. }
  532. })
  533. } else {
  534. this.doSwitchMode()
  535. }
  536. },
  537. doSwitchMode: function() {
  538. var self = this
  539. getChildren().then(function(res) {
  540. var children = res.data || []
  541. if (children.length === 0) {
  542. uni.showModal({
  543. title: '提示',
  544. content: '您还没有添加孩子,请先在家庭成员中添加',
  545. success: function(r) { if (r.confirm) uni.navigateTo({ url: '/pages/profile-extra/family-members' }) }
  546. })
  547. return
  548. }
  549. if (children.length === 1) {
  550. self.$store.commit('switchToChild', children[0].id)
  551. self.role = 'child'
  552. self.isSwitchedChild = true
  553. uni.showToast({ title: '已切换为孩子模式', icon: 'success' })
  554. return
  555. }
  556. uni.showActionSheet({
  557. itemList: children.map(function(c) { return c.nickname }),
  558. success: function(res) {
  559. var sel = children[res.tapIndex]
  560. self.$store.commit('switchToChild', sel.id)
  561. self.role = 'child'
  562. self.isSwitchedChild = true
  563. uni.showToast({ title: '已切换为' + sel.nickname + '模式', icon: 'success' })
  564. }
  565. })
  566. }).catch(function() {})
  567. },
  568. onExitSwitch: function() {
  569. var self = this
  570. uni.showModal({
  571. title: '退出切换',
  572. content: '请输入家长密码以确认退出',
  573. editable: true,
  574. success: function(res) {
  575. if (res.confirm && res.content) {
  576. verifyPassword(res.content).then(function(result) {
  577. if (result.code === 200) {
  578. self.$store.commit('switchBackToParent')
  579. self.isSwitchedChild = false
  580. self.role = 'parent'
  581. uni.showToast({ title: '已退出切换', icon: 'success' })
  582. uni.reLaunch({ url: '/pages/index-home/index' })
  583. } else {
  584. uni.showToast({ title: '密码错误', icon: 'none' })
  585. }
  586. }).catch(function() {
  587. uni.showToast({ title: '验证失败', icon: 'none' })
  588. })
  589. }
  590. }
  591. })
  592. },
  593. showInviteActionSheet: function() {
  594. var self = this
  595. var ui = uni.getStorageSync('userInfo') || {}
  596. var items = ['👨‍👩‍👧‍👦 邀请家人', '👨‍🏫 邀请成长规划师']
  597. uni.showActionSheet({
  598. itemList: items,
  599. success: function(res) {
  600. var type = res.tapIndex === 0 ? 'family' : 'guide'
  601. var title = (ui.nickname || '家人') + ' 邀请你加入家庭'
  602. var path = type === 'guide'
  603. ? '/pages/login/login?invite_type=guide'
  604. : '/pages/login/login?invite_type=family'
  605. self.$emit('invite-generate', { title: title, path: path, imageUrl: '/static/invite-card.png' })
  606. uni.showToast({ title: '点击右上角转发', icon: 'none' })
  607. }
  608. })
  609. },
  610. logout: function() {
  611. uni.showModal({
  612. title: '确认退出',
  613. content: '确定要退出登录吗?',
  614. success: function(res) {
  615. if (res.confirm) {
  616. this.$store.commit('logout')
  617. uni.reLaunch({ url: '/pages/index-home/index' })
  618. }
  619. }.bind(this)
  620. })
  621. }
  622. }
  623. }
  624. </script>
  625. <style scoped>
  626. .container {
  627. min-height: 100vh;
  628. background: #f5f7fa;
  629. padding-bottom: 120rpx;
  630. }
  631. /* 登录 */
  632. .login-prompt {
  633. display: flex;
  634. flex-direction: column;
  635. align-items: center;
  636. padding: 200rpx 60rpx;
  637. }
  638. .prompt-icon { font-size: 100rpx; margin-bottom: 30rpx; }
  639. .prompt-title { font-size: 40rpx; font-weight: bold; color: #333; margin-bottom: 16rpx; }
  640. .prompt-desc { font-size: 26rpx; color: #999; margin-bottom: 60rpx; }
  641. .login-btn {
  642. background: linear-gradient(135deg, #667eea, #764ba2);
  643. color: #fff;
  644. border-radius: 50rpx;
  645. font-size: 30rpx;
  646. padding: 24rpx 80rpx;
  647. }
  648. /* 退出切换 */
  649. .exit-switch {
  650. margin: 0 30rpx 16rpx;
  651. background: linear-gradient(135deg, #667eea, #764ba2);
  652. color: #fff;
  653. padding: 16rpx;
  654. border-radius: 12rpx;
  655. text-align: center;
  656. font-size: 26rpx;
  657. }
  658. /* 用户卡片 */
  659. .user-card {
  660. margin: 30rpx;
  661. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  662. border-radius: 24rpx;
  663. padding: 36rpx 32rpx;
  664. display: flex;
  665. justify-content: space-between;
  666. align-items: center;
  667. box-shadow: 0 8rpx 32rpx rgba(102,126,234,0.3);
  668. }
  669. .user-card-left {
  670. display: flex;
  671. align-items: center;
  672. flex: 1;
  673. }
  674. .avatar-wrap {
  675. width: 110rpx;
  676. height: 110rpx;
  677. border-radius: 50%;
  678. background: rgba(255,255,255,0.2);
  679. display: flex;
  680. align-items: center;
  681. justify-content: center;
  682. margin-right: 24rpx;
  683. overflow: hidden;
  684. border: 4rpx solid rgba(255,255,255,0.3);
  685. }
  686. .avatar-img {
  687. width: 110rpx;
  688. height: 110rpx;
  689. border-radius: 50%;
  690. }
  691. .avatar-text {
  692. font-size: 48rpx;
  693. color: #fff;
  694. }
  695. .user-meta { flex: 1; }
  696. .user-name-row {
  697. display: flex;
  698. align-items: center;
  699. gap: 12rpx;
  700. margin-bottom: 8rpx;
  701. }
  702. .nickname {
  703. font-size: 36rpx;
  704. font-weight: bold;
  705. color: #fff;
  706. }
  707. .role-tag {
  708. font-size: 22rpx;
  709. background: rgba(255,255,255,0.2);
  710. color: #fff;
  711. padding: 4rpx 16rpx;
  712. border-radius: 20rpx;
  713. }
  714. .user-sub {
  715. display: flex;
  716. align-items: center;
  717. gap: 12rpx;
  718. }
  719. .level-badge {
  720. font-size: 26rpx;
  721. padding: 6rpx 20rpx;
  722. border-radius: 20rpx;
  723. font-weight: bold;
  724. box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.15);
  725. border: 2rpx solid rgba(255,255,255,0.3);
  726. }
  727. .level-GOLD { background: linear-gradient(135deg, #F59E0B, #D97706); color: #fff; }
  728. .level-PLATINUM { background: linear-gradient(135deg, #6366F1, #4F46E5); color: #fff; }
  729. .level-DIAMOND { background: linear-gradient(135deg, #EC4899, #DB2777); color: #fff; }
  730. .days-left {
  731. font-size: 24rpx;
  732. color: rgba(255,255,255,0.8);
  733. }
  734. .user-card-right {
  735. display: flex;
  736. flex-direction: column;
  737. align-items: center;
  738. gap: 16rpx;
  739. }
  740. .points-box {
  741. text-align: center;
  742. background: rgba(255,255,255,0.15);
  743. padding: 16rpx 24rpx;
  744. border-radius: 16rpx;
  745. }
  746. /* 数据概览 */
  747. .stats-bar {
  748. margin: 0 30rpx 20rpx;
  749. background: #fff;
  750. border-radius: 20rpx;
  751. display: flex;
  752. align-items: center;
  753. padding: 28rpx 0;
  754. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  755. }
  756. .stat-item {
  757. flex: 1;
  758. display: flex;
  759. flex-direction: column;
  760. align-items: center;
  761. gap: 8rpx;
  762. }
  763. .stat-num {
  764. font-size: 40rpx;
  765. font-weight: bold;
  766. color: #667eea;
  767. }
  768. .stat-label {
  769. font-size: 24rpx;
  770. color: #999;
  771. }
  772. .stat-divider {
  773. width: 1rpx;
  774. height: 60rpx;
  775. background: #f0f0f0;
  776. }
  777. /* 五维能量 */
  778. .energy-section {
  779. margin: 0 30rpx 20rpx;
  780. background: #fff;
  781. border-radius: 20rpx;
  782. padding: 28rpx;
  783. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  784. }
  785. .section-header {
  786. display: flex;
  787. justify-content: space-between;
  788. align-items: center;
  789. margin-bottom: 20rpx;
  790. }
  791. .section-title {
  792. font-size: 30rpx;
  793. font-weight: bold;
  794. color: #333;
  795. }
  796. .section-more {
  797. font-size: 24rpx;
  798. color: #999;
  799. }
  800. .energy-row {
  801. display: flex;
  802. justify-content: space-around;
  803. }
  804. .energy-item {
  805. display: flex;
  806. flex-direction: column;
  807. align-items: center;
  808. gap: 10rpx;
  809. }
  810. .energy-circle {
  811. width: 88rpx;
  812. height: 88rpx;
  813. border-radius: 50%;
  814. display: flex;
  815. align-items: center;
  816. justify-content: center;
  817. box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.15);
  818. }
  819. .energy-val {
  820. font-size: 28rpx;
  821. font-weight: bold;
  822. color: #fff;
  823. }
  824. .energy-label {
  825. font-size: 24rpx;
  826. color: #666;
  827. }
  828. /* 待办提醒 */
  829. .reminders-section {
  830. margin: 0 30rpx 20rpx;
  831. }
  832. .reminder-item {
  833. background: #fff;
  834. border-radius: 16rpx;
  835. padding: 24rpx 28rpx;
  836. margin-bottom: 12rpx;
  837. display: flex;
  838. align-items: center;
  839. gap: 16rpx;
  840. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  841. }
  842. .reminder-icon { font-size: 36rpx; }
  843. .reminder-text { flex: 1; font-size: 28rpx; color: #333; }
  844. .reminder-arrow { font-size: 32rpx; color: #ccc; }
  845. /* 菜单 */
  846. .menu-section {
  847. margin: 0 30rpx;
  848. }
  849. .menu-group {
  850. background: #fff;
  851. border-radius: 20rpx;
  852. margin-bottom: 20rpx;
  853. overflow: hidden;
  854. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  855. }
  856. .menu-group-title {
  857. padding: 16rpx 28rpx 8rpx;
  858. font-size: 22rpx;
  859. color: #999;
  860. }
  861. .menu-item {
  862. display: flex;
  863. align-items: center;
  864. padding: 26rpx 28rpx;
  865. border-bottom: 1rpx solid #f5f5f5;
  866. }
  867. .menu-item:last-child { border-bottom: none; }
  868. .menu-icon { font-size: 36rpx; margin-right: 16rpx; }
  869. .menu-text { flex: 1; font-size: 28rpx; color: #333; }
  870. .arrow { font-size: 32rpx; color: #ccc; }
  871. .badge {
  872. background: #FF4D4F;
  873. color: #fff;
  874. font-size: 22rpx;
  875. padding: 2rpx 12rpx;
  876. border-radius: 20rpx;
  877. margin-right: 12rpx;
  878. min-width: 36rpx;
  879. text-align: center;
  880. }
  881. .mall-section {
  882. margin: 0 30rpx 20rpx;
  883. background: #fff;
  884. border-radius: 20rpx;
  885. overflow: hidden;
  886. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  887. }
  888. .mall-header {
  889. display: flex;
  890. justify-content: space-between;
  891. align-items: center;
  892. padding: 24rpx 28rpx 16rpx;
  893. border-bottom: 1rpx solid #f5f5f5;
  894. }
  895. .mall-title { font-size: 30rpx; font-weight: bold; color: #333; }
  896. .mall-more { font-size: 24rpx; color: #999; }
  897. .mall-grid { display: flex; padding: 20rpx 16rpx; }
  898. .mall-item {
  899. flex: 1;
  900. display: flex;
  901. flex-direction: column;
  902. align-items: center;
  903. gap: 8rpx;
  904. padding: 16rpx 0;
  905. }
  906. .mall-item-num { font-size: 36rpx; font-weight: bold; color: #F97316; }
  907. .mall-item-label { font-size: 22rpx; color: #999; }
  908. </style>