profile.vue 30 KB

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