profile.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  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,
  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. // 商城
  265. cartCount: 0,
  266. orderPending: 0,
  267. orderUnpaid: 0,
  268. orderShipped: 0,
  269. orderAfterSale: 0,
  270. // 推广中心
  271. commissionBalance: 0,
  272. referralCount: 0,
  273. teamCount: 0
  274. }
  275. },
  276. computed: {
  277. isLoggedIn() {
  278. return !!uni.getStorageSync('token')
  279. },
  280. roleLabel() {
  281. var map = { parent: '家长', child: '孩子', teacher: '规划师' }
  282. return map[this.role] || '用户'
  283. },
  284. memberLevelText() {
  285. var map = { FREE: '免费用户', FAMILY: '家庭会员', PREMIUM: '高级会员', LIFETIME: '终身会员' }
  286. return map[this.memberLevel] || this.memberLevel || ''
  287. },
  288. isLifetime() {
  289. return this.memberLevel === 'LIFETIME'
  290. },
  291. // 有升级空间:FREE(开通) / FAMILY(升PREMIUM);PREMIUM已是最高可购买等级,LIFETIME永久有效
  292. hasUpgradeSpace() {
  293. return this.memberLevel === 'FREE' || this.memberLevel === 'FAMILY'
  294. },
  295. upgradeBtnText() {
  296. return this.memberLevel === 'FAMILY' ? '升级' : '立即开通'
  297. },
  298. hasReminders() {
  299. return this.pendingTasks > 0 || this.activeChallenges > 0 || this.profileProgress < 14
  300. }
  301. },
  302. onShow() {
  303. if (!this.isLoggedIn) {
  304. // 未登录:不调用任何需登录接口,仅显示登录引导
  305. return
  306. }
  307. var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
  308. if (role === 'teacher') {
  309. uni.redirectTo({ url: '/pages/teacher/teacher-profile' })
  310. return
  311. }
  312. this.role = role
  313. this.isSwitchedChild = uni.getStorageSync('isSwitchedChild') || false
  314. this.nickname = (uni.getStorageSync('userInfo') || {}).nickname || ''
  315. this.loadAllData()
  316. },
  317. methods: {
  318. loadAllData() {
  319. this.loadUserInfo()
  320. this.loadMembership()
  321. this.loadPoints()
  322. this.loadFamily()
  323. this.loadTasks()
  324. this.loadChallenges()
  325. this.loadOrderCounts()
  326. this.loadCartCount()
  327. this.loadPromotion()
  328. },
  329. loadUserInfo() {
  330. var self = this
  331. getUserInfo().then(function(res) {
  332. if (res && res.code === 200 && res.data) {
  333. self.userInfo = res.data
  334. if (!self.nickname) self.nickname = res.data.nickname || ''
  335. }
  336. }).catch(function() {})
  337. },
  338. loadMembership() {
  339. var self = this
  340. getMyMembership().then(function(res) {
  341. if (res && res.data) {
  342. self.memberLevel = res.data.memberLevel || res.data.levelCode || null
  343. self.membershipDays = res.data.membershipDays || res.data.daysRemaining || 0
  344. }
  345. }).catch(function() {})
  346. },
  347. loadPoints() {
  348. var self = this
  349. var memberId = uni.getStorageSync('currentChildId') || uni.getStorageSync('userId')
  350. if (!memberId) return
  351. getPointsBalance(memberId).then(function(res) {
  352. if (res && res.data) {
  353. self.totalPoints = res.data.totalPoints || res.data.points || 0
  354. }
  355. }).catch(function() {})
  356. },
  357. loadFamily() {
  358. var self = this
  359. var childrenRes = getChildren()
  360. var membersRes = getVisibleFamilyMembers()
  361. Promise.all([childrenRes, membersRes]).then(function(results) {
  362. var children = results[0].data || []
  363. var members = results[1].data || []
  364. self.familyCount = members.length || children.length
  365. self.streakDays = parseInt(uni.getStorageSync('streakDays') || 0)
  366. }).catch(function() {
  367. self.familyCount = 0
  368. })
  369. },
  370. loadTasks() {
  371. var self = this
  372. var memberId = uni.getStorageSync('currentChildId') || uni.getStorageSync('userId')
  373. if (!memberId) return
  374. if (self.role === 'child' && memberId) {
  375. getTodayTasksByCategory(memberId, 'action').then(function(res) {
  376. if (res && res.data) {
  377. self.pendingTasks = Array.isArray(res.data) ? res.data.length : 0
  378. }
  379. }).catch(function() {})
  380. }
  381. self.pendingTasks = parseInt(uni.getStorageSync('pendingTaskCount') || 0)
  382. },
  383. loadChallenges() {
  384. var self = this
  385. getChallengeList({}).then(function(res) {
  386. if (res && res.data) {
  387. self.activeChallenges = Array.isArray(res.data) ? res.data.length : 0
  388. }
  389. }).catch(function() {})
  390. },
  391. loadOrderCounts() {
  392. var self = this
  393. getOrderCounts().then(function(res) {
  394. if (res && res.data) {
  395. self.orderPending = res.data.pending || 0
  396. self.orderUnpaid = res.data.unpaid || res.data.paid || 0
  397. self.orderShipped = res.data.shipped || 0
  398. self.orderAfterSale = res.data.refunding || res.data.afterSale || 0
  399. }
  400. }).catch(function() {})
  401. },
  402. loadCartCount() {
  403. var self = this
  404. cartCount().then(function(res) {
  405. if (res && res.data != null) {
  406. self.cartCount = res.data || 0
  407. }
  408. }).catch(function() {})
  409. },
  410. loadPromotion() {
  411. var self = this
  412. getCommissionSummary().then(function(res) {
  413. if (res && res.data) {
  414. self.commissionBalance = res.data.availableAmount || res.data.balance || 0
  415. }
  416. }).catch(function() {})
  417. getReferralSummary().then(function(res) {
  418. if (res && res.data) {
  419. self.referralCount = res.data.totalCount || res.data.count || 0
  420. }
  421. }).catch(function() {})
  422. },
  423. getDimColor: function(code) {
  424. var map = {
  425. body: '#FF8C42', mind: '#FF6B9D', wisdom: '#6366F1',
  426. action: '#10B981', wealth: '#F59E0B'
  427. }
  428. return map[code] || '#999'
  429. },
  430. goLogin: function() {
  431. uni.navigateTo({ url: '/pages/login/login' })
  432. },
  433. goSkip: function() {
  434. uni.switchTab({ url: '/pages/index-home/index' })
  435. },
  436. goToEditInfo: function() {
  437. uni.navigateTo({ url: '/pages/user-edit/user-edit' })
  438. },
  439. goToPoints: function() {
  440. uni.navigateTo({ url: '/pages/points/points' })
  441. },
  442. goToTasks: function() {
  443. uni.navigateTo({ url: '/pages/tasks/tasks' })
  444. },
  445. goToCheckin: function() {
  446. uni.navigateTo({ url: '/pages/health/daily-checkin' })
  447. },
  448. goToFamily: function() {
  449. uni.navigateTo({ url: '/pages/profile-extra/family-members' })
  450. },
  451. goToChildren: function() {
  452. uni.navigateTo({ url: '/pages/profile-extra/children' })
  453. },
  454. goToAppointments: function() {
  455. uni.navigateTo({ url: '/pages/parent/appointments' })
  456. },
  457. goToChallenges: function() {
  458. uni.navigateTo({ url: '/pages/health/challenge-manage' })
  459. },
  460. goToGrowth: function() {
  461. uni.navigateTo({ url: '/pages/growth-main/index' })
  462. },
  463. goToReport: function() {
  464. uni.navigateTo({ url: '/pages/profile/report-management' })
  465. },
  466. goToMembership: function() {
  467. uni.navigateTo({ url: '/pages/membership/index' })
  468. },
  469. goUpgrade: function() {
  470. uni.navigateTo({ url: '/pages/membership/upgrade' })
  471. },
  472. goToPromotion: function() {
  473. uni.navigateTo({ url: '/pages/promotion/index' })
  474. },
  475. goToCart: function() {
  476. uni.navigateTo({ url: '/pages/shop/cart/cart' })
  477. },
  478. goToOrders: function() {
  479. uni.navigateTo({ url: '/pages/shop/order-list/order-list' })
  480. },
  481. goToCoupons: function() {
  482. uni.navigateTo({ url: '/pages/profile-extra/coupons' })
  483. },
  484. goToSettings: function() {
  485. uni.showActionSheet({
  486. itemList: ['设置密码', '隐私设置', '关于浠艾福'],
  487. success: function(res) {
  488. if (res.tapIndex === 0) {
  489. uni.navigateTo({ url: '/pages/profile/settings' })
  490. }
  491. }
  492. })
  493. },
  494. onSwitchMode: function() {
  495. var self = this
  496. if (self.role === 'child') {
  497. uni.showModal({
  498. title: '验证密码',
  499. content: '请输入家长密码',
  500. editable: true,
  501. success: function(res) {
  502. if (res.confirm && res.content) {
  503. verifyPassword(res.content).then(function(result) {
  504. if (result.code === 200) {
  505. self.doSwitchMode()
  506. } else {
  507. uni.showToast({ title: '密码错误', icon: 'none' })
  508. }
  509. }).catch(function() {
  510. uni.showToast({ title: '验证失败', icon: 'none' })
  511. })
  512. }
  513. }
  514. })
  515. } else {
  516. this.doSwitchMode()
  517. }
  518. },
  519. doSwitchMode: function() {
  520. var self = this
  521. getChildren().then(function(res) {
  522. var children = res.data || []
  523. if (children.length === 0) {
  524. uni.showModal({
  525. title: '提示',
  526. content: '您还没有添加孩子,请先在家庭成员中添加',
  527. success: function(r) { if (r.confirm) uni.navigateTo({ url: '/pages/profile-extra/family-members' }) }
  528. })
  529. return
  530. }
  531. if (children.length === 1) {
  532. self.$store.commit('switchToChild', children[0].id)
  533. self.role = 'child'
  534. self.isSwitchedChild = true
  535. uni.showToast({ title: '已切换为孩子模式', icon: 'success' })
  536. return
  537. }
  538. uni.showActionSheet({
  539. itemList: children.map(function(c) { return c.nickname }),
  540. success: function(res) {
  541. var sel = children[res.tapIndex]
  542. self.$store.commit('switchToChild', sel.id)
  543. self.role = 'child'
  544. self.isSwitchedChild = true
  545. uni.showToast({ title: '已切换为' + sel.nickname + '模式', icon: 'success' })
  546. }
  547. })
  548. }).catch(function() {})
  549. },
  550. onExitSwitch: function() {
  551. var self = this
  552. uni.showModal({
  553. title: '退出切换',
  554. content: '请输入家长密码以确认退出',
  555. editable: true,
  556. success: function(res) {
  557. if (res.confirm && res.content) {
  558. verifyPassword(res.content).then(function(result) {
  559. if (result.code === 200) {
  560. self.$store.commit('switchBackToParent')
  561. self.isSwitchedChild = false
  562. self.role = 'parent'
  563. uni.showToast({ title: '已退出切换', icon: 'success' })
  564. uni.reLaunch({ url: '/pages/index-home/index' })
  565. } else {
  566. uni.showToast({ title: '密码错误', icon: 'none' })
  567. }
  568. }).catch(function() {
  569. uni.showToast({ title: '验证失败', icon: 'none' })
  570. })
  571. }
  572. }
  573. })
  574. },
  575. showInviteActionSheet: function() {
  576. var self = this
  577. var ui = uni.getStorageSync('userInfo') || {}
  578. var items = ['👨‍👩‍👧‍👦 邀请家人', '👨‍🏫 邀请成长规划师']
  579. uni.showActionSheet({
  580. itemList: items,
  581. success: function(res) {
  582. var type = res.tapIndex === 0 ? 'family' : 'guide'
  583. var title = (ui.nickname || '家人') + ' 邀请你加入家庭'
  584. var path = type === 'guide'
  585. ? '/pages/login/login?invite_type=guide'
  586. : '/pages/login/login?invite_type=family'
  587. self.$emit('invite-generate', { title: title, path: path, imageUrl: '/static/invite-card.png' })
  588. uni.showToast({ title: '点击右上角转发', icon: 'none' })
  589. }
  590. })
  591. },
  592. logout: function() {
  593. uni.showModal({
  594. title: '确认退出',
  595. content: '确定要退出登录吗?',
  596. success: function(res) {
  597. if (res.confirm) {
  598. this.$store.commit('logout')
  599. uni.reLaunch({ url: '/pages/index-home/index' })
  600. }
  601. }.bind(this)
  602. })
  603. }
  604. }
  605. }
  606. </script>
  607. <style scoped>
  608. .container {
  609. min-height: 100vh;
  610. background: #f5f7fa;
  611. padding-bottom: 120rpx;
  612. }
  613. /* 登录 */
  614. .login-prompt {
  615. display: flex;
  616. flex-direction: column;
  617. align-items: center;
  618. padding: 200rpx 60rpx;
  619. }
  620. .prompt-icon { font-size: 100rpx; margin-bottom: 30rpx; }
  621. .prompt-title { font-size: 40rpx; font-weight: bold; color: #333; margin-bottom: 16rpx; }
  622. .prompt-desc { font-size: 26rpx; color: #999; margin-bottom: 20rpx; }
  623. .login-btn {
  624. background: linear-gradient(135deg, #667eea, #764ba2);
  625. color: #fff;
  626. border-radius: 50rpx;
  627. font-size: 30rpx;
  628. padding: 24rpx 80rpx;
  629. }
  630. .skip-link {
  631. font-size: 26rpx;
  632. color: #999;
  633. margin-top: 24rpx;
  634. text-decoration: underline;
  635. }
  636. /* 退出切换 */
  637. .exit-switch {
  638. margin: 0 30rpx 16rpx;
  639. background: linear-gradient(135deg, #667eea, #764ba2);
  640. color: #fff;
  641. padding: 16rpx;
  642. border-radius: 12rpx;
  643. text-align: center;
  644. font-size: 26rpx;
  645. }
  646. /* 用户卡片 */
  647. .user-card {
  648. margin: 30rpx;
  649. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  650. border-radius: 24rpx;
  651. padding: 36rpx 32rpx;
  652. display: flex;
  653. justify-content: space-between;
  654. align-items: center;
  655. box-shadow: 0 8rpx 32rpx rgba(102,126,234,0.3);
  656. }
  657. .user-card-left {
  658. display: flex;
  659. align-items: center;
  660. flex: 1;
  661. }
  662. .avatar-wrap {
  663. width: 110rpx;
  664. height: 110rpx;
  665. border-radius: 50%;
  666. background: rgba(255,255,255,0.2);
  667. display: flex;
  668. align-items: center;
  669. justify-content: center;
  670. margin-right: 24rpx;
  671. overflow: hidden;
  672. border: 4rpx solid rgba(255,255,255,0.3);
  673. }
  674. .avatar-img {
  675. width: 110rpx;
  676. height: 110rpx;
  677. border-radius: 50%;
  678. }
  679. .avatar-text {
  680. font-size: 48rpx;
  681. color: #fff;
  682. }
  683. .user-meta { flex: 1; }
  684. .user-name-row {
  685. display: flex;
  686. align-items: center;
  687. gap: 12rpx;
  688. margin-bottom: 8rpx;
  689. }
  690. .nickname {
  691. font-size: 36rpx;
  692. font-weight: bold;
  693. color: #fff;
  694. }
  695. .role-tag {
  696. font-size: 22rpx;
  697. background: rgba(255,255,255,0.2);
  698. color: #fff;
  699. padding: 4rpx 16rpx;
  700. border-radius: 20rpx;
  701. }
  702. .user-sub {
  703. display: flex;
  704. align-items: center;
  705. gap: 12rpx;
  706. }
  707. .level-badge {
  708. font-size: 24rpx;
  709. padding: 8rpx 22rpx;
  710. border-radius: 24rpx;
  711. font-weight: bold;
  712. box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.2);
  713. border: 2rpx solid rgba(255,255,255,0.35);
  714. display: flex;
  715. align-items: center;
  716. gap: 6rpx;
  717. box-sizing: border-box;
  718. height: 44rpx;
  719. }
  720. .level-badge::before {
  721. content: '👑';
  722. font-size: 20rpx;
  723. }
  724. .level-FREE { background: linear-gradient(135deg, #9CA3AF, #6B7280); color: #fff; }
  725. .level-FREE::before { content: ''; }
  726. .level-FAMILY { background: linear-gradient(135deg, #F59E0B, #D97706); color: #fff; }
  727. .level-PREMIUM { background: linear-gradient(135deg, #6366F1, #4F46E5); color: #fff; }
  728. .level-LIFETIME {
  729. background: linear-gradient(135deg, #EC4899, #DB2777);
  730. color: #fff;
  731. box-shadow: 0 4rpx 16rpx rgba(236,72,153,0.45);
  732. border-color: rgba(255,255,255,0.55);
  733. }
  734. .days-left {
  735. font-size: 22rpx;
  736. color: rgba(255,255,255,0.85);
  737. }
  738. .upgrade-btn {
  739. background: rgba(255,255,255,0.22);
  740. border: 2rpx solid rgba(255,255,255,0.6);
  741. border-radius: 22rpx;
  742. padding: 8rpx 24rpx;
  743. flex-shrink: 0;
  744. box-sizing: border-box;
  745. height: 44rpx;
  746. display: flex;
  747. align-items: center;
  748. }
  749. .upgrade-btn-text {
  750. font-size: 22rpx;
  751. font-weight: bold;
  752. color: #fff;
  753. line-height: 1;
  754. }
  755. .user-card-right {
  756. display: flex;
  757. flex-direction: column;
  758. align-items: center;
  759. gap: 16rpx;
  760. }
  761. .points-box {
  762. text-align: center;
  763. background: rgba(255,255,255,0.15);
  764. padding: 16rpx 24rpx;
  765. border-radius: 16rpx;
  766. }
  767. /* 数据概览 */
  768. .stats-bar {
  769. margin: 0 30rpx 20rpx;
  770. background: #fff;
  771. border-radius: 20rpx;
  772. display: flex;
  773. align-items: center;
  774. padding: 28rpx 0;
  775. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  776. }
  777. .stat-item {
  778. flex: 1;
  779. display: flex;
  780. flex-direction: column;
  781. align-items: center;
  782. gap: 8rpx;
  783. }
  784. .stat-num {
  785. font-size: 40rpx;
  786. font-weight: bold;
  787. color: #667eea;
  788. }
  789. .stat-label {
  790. font-size: 24rpx;
  791. color: #999;
  792. }
  793. .stat-divider {
  794. width: 1rpx;
  795. height: 60rpx;
  796. background: #f0f0f0;
  797. }
  798. /* 待办提醒 */
  799. .reminders-section {
  800. margin: 0 30rpx 20rpx;
  801. }
  802. .reminder-item {
  803. background: #fff;
  804. border-radius: 16rpx;
  805. padding: 24rpx 28rpx;
  806. margin-bottom: 12rpx;
  807. display: flex;
  808. align-items: center;
  809. gap: 16rpx;
  810. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  811. }
  812. .reminder-icon { font-size: 36rpx; }
  813. .reminder-text { flex: 1; font-size: 28rpx; color: #333; }
  814. .reminder-arrow { font-size: 32rpx; color: #ccc; }
  815. /* 菜单 */
  816. .menu-section {
  817. margin: 0 30rpx;
  818. }
  819. .menu-group {
  820. background: #fff;
  821. border-radius: 20rpx;
  822. margin-bottom: 20rpx;
  823. overflow: hidden;
  824. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  825. }
  826. .menu-group-title {
  827. padding: 16rpx 28rpx 8rpx;
  828. font-size: 22rpx;
  829. color: #999;
  830. }
  831. .menu-item {
  832. display: flex;
  833. align-items: center;
  834. padding: 26rpx 28rpx;
  835. border-bottom: 1rpx solid #f5f5f5;
  836. }
  837. .menu-item:last-child { border-bottom: none; }
  838. .menu-icon { font-size: 36rpx; margin-right: 16rpx; }
  839. .menu-text { flex: 1; font-size: 28rpx; color: #333; }
  840. .arrow { font-size: 32rpx; color: #ccc; }
  841. .badge {
  842. background: #FF4D4F;
  843. color: #fff;
  844. font-size: 22rpx;
  845. padding: 2rpx 12rpx;
  846. border-radius: 20rpx;
  847. margin-right: 12rpx;
  848. min-width: 36rpx;
  849. text-align: center;
  850. }
  851. .mall-section {
  852. margin: 0 30rpx 20rpx;
  853. background: #fff;
  854. border-radius: 20rpx;
  855. overflow: hidden;
  856. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  857. }
  858. .mall-header {
  859. display: flex;
  860. justify-content: space-between;
  861. align-items: center;
  862. padding: 24rpx 28rpx 16rpx;
  863. border-bottom: 1rpx solid #f5f5f5;
  864. }
  865. .mall-title { font-size: 30rpx; font-weight: bold; color: #333; }
  866. .mall-more { font-size: 24rpx; color: #999; }
  867. .mall-grid { display: flex; padding: 20rpx 16rpx; }
  868. .mall-item {
  869. flex: 1;
  870. display: flex;
  871. flex-direction: column;
  872. align-items: center;
  873. gap: 8rpx;
  874. padding: 16rpx 0;
  875. }
  876. .mall-item-num { font-size: 36rpx; font-weight: bold; color: #F97316; }
  877. .mall-item-label { font-size: 22rpx; color: #999; }
  878. </style>