profile.vue 30 KB

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