profile.vue 30 KB

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