profile.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. <template>
  2. <view class="container">
  3. <!-- ===== 未登录状态 ===== -->
  4. <view v-if="!isLoggedIn" class="login-prompt">
  5. <view class="prompt-icon">👤</view>
  6. <text class="prompt-title">登录浠艾福</text>
  7. <text class="prompt-desc">登录后可查看个人资料、积分记录等</text>
  8. <button class="login-btn" @click="goLogin">登录 / 注册</button>
  9. </view>
  10. <!-- ===== 已登录状态 ===== -->
  11. <template v-else>
  12. <!-- 品牌头部 -->
  13. <PageBanner theme="wealth"
  14. tagline="财富管理 · 价值创造"
  15. quote="富足源于利他与坚持" />
  16. <!-- 退出切换按钮(仅家长切换到孩子状态时显示) -->
  17. <view class="exit-switch" v-if="isSwitchedChild" @click="exitSwitch">
  18. <text>🔄 退出切换</text>
  19. </view>
  20. <view class="user-card">
  21. <view class="avatar">👤</view>
  22. <view class="user-info">
  23. <view class="nickname">{{ nickname || '未设置昵称' }}</view>
  24. <view class="role">{{ role === 'parent' ? '家长模式' : (role === 'child' ? '孩子模式' : '成长规划师模式') }}</view>
  25. <view class="system-points" v-if="role === 'parent' && children.length > 0">🏅 系统积分: {{ children[0].systemPoints || 0 }}</view>
  26. </view>
  27. <!-- 切换按钮仅在非切换状态下显示 -->
  28. <button class="btn-switch" v-if="!isSwitchedChild" @click="switchMode">切换</button>
  29. </view>
  30. <!-- 行动数据 -->
  31. <view class="section">
  32. <view class="section-header">
  33. <text class="section-title">🎯 行动数据</text>
  34. </view>
  35. <view class="wealth-card">
  36. <view class="wealth-item">
  37. <text class="wealth-value">{{ actionData.taskCount }}</text>
  38. <text class="wealth-label">完成任务</text>
  39. </view>
  40. <view class="wealth-divider"></view>
  41. <view class="wealth-item">
  42. <text class="wealth-value">{{ actionData.purchaseCount }}</text>
  43. <text class="wealth-label">购买商品</text>
  44. </view>
  45. <view class="wealth-divider"></view>
  46. <view class="wealth-item">
  47. <text class="wealth-value">{{ actionData.activityCount }}</text>
  48. <text class="wealth-label">参加活动</text>
  49. </view>
  50. <view class="wealth-divider"></view>
  51. <view class="wealth-item">
  52. <text class="wealth-value">{{ actionData.courseCount }}</text>
  53. <text class="wealth-label">学习课程</text>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 财富数据(推广收益) -->
  58. <view class="section">
  59. <view class="section-header">
  60. <text class="section-title">💰 财富数据</text>
  61. <text class="section-more" @click="goToPromotion">全部 ›</text>
  62. </view>
  63. <view class="wealth-card">
  64. <view class="wealth-item">
  65. <text class="wealth-value">¥{{ wealthData.totalEarnings }}</text>
  66. <text class="wealth-label">累计收益</text>
  67. </view>
  68. <view class="wealth-divider"></view>
  69. <view class="wealth-item">
  70. <text class="wealth-value">¥{{ wealthData.availableAmount }}</text>
  71. <text class="wealth-label">可提现</text>
  72. </view>
  73. <view class="wealth-divider"></view>
  74. <view class="wealth-item">
  75. <text class="wealth-value">{{ wealthData.referralCount }}</text>
  76. <text class="wealth-label">邀请人数</text>
  77. </view>
  78. </view>
  79. <view class="referral-code-bar" @click="copyReferralCode" v-if="wealthData.referralCode">
  80. <text class="referral-code-label">邀请码</text>
  81. <text class="referral-code-value">{{ wealthData.referralCode }}</text>
  82. <text class="referral-code-copy">复制</text>
  83. </view>
  84. </view>
  85. <!-- 成就徽章 -->
  86. <view class="section">
  87. <view class="section-header">
  88. <text class="section-title">🏅 成就徽章</text>
  89. <text class="section-more" @click="goAllBadges">全部 ›</text>
  90. </view>
  91. <view class="badge-grid">
  92. <view class="badge-item" v-for="badge in badges" :key="badge.id">
  93. <view :class="['badge-icon-wrap', badge.unlocked ? 'unlocked' : 'locked']">
  94. <text class="badge-icon">{{ badge.icon }}</text>
  95. </view>
  96. <text class="badge-name">{{ badge.name }}</text>
  97. </view>
  98. </view>
  99. </view>
  100. <!-- 成长报告 -->
  101. <view class="section">
  102. <view class="section-header">
  103. <text class="section-title">📈 成长报告</text>
  104. <text class="section-more" @click="goGrowthReport">查看 ›</text>
  105. </view>
  106. <view class="report-card" @click="goGrowthReport">
  107. <view class="report-stat-item">
  108. <text class="report-stat">{{ growthReport.monthActiveDays || 0 }}天</text>
  109. <text class="report-label">本月活跃</text>
  110. </view>
  111. <view class="report-divider"></view>
  112. <view class="report-stat-item">
  113. <text class="report-stat">{{ growthReport.totalTasks || 0 }}</text>
  114. <text class="report-label">累计任务</text>
  115. </view>
  116. <view class="report-divider"></view>
  117. <view class="report-stat-item">
  118. <text class="report-stat">{{ growthReport.completionRate || 0 }}%</text>
  119. <text class="report-label">完成率</text>
  120. </view>
  121. </view>
  122. </view>
  123. <view class="menu-list">
  124. <!-- 修改个人资料:所有角色可见 -->
  125. <view class="menu-item" @click="goToEditInfo">
  126. <text>📝 修改个人资料</text>
  127. <text class="arrow">›</text>
  128. </view>
  129. <!-- 我的孩子:仅家长可见 -->
  130. <view class="menu-item" v-if="role === 'parent'" @click="goToChildren">
  131. <text>👶 我的孩子</text>
  132. <text class="arrow">›</text>
  133. </view>
  134. <!-- 家庭成员 -->
  135. <view class="menu-item" v-if="role === 'parent'" @click="goToFamilyMembers">
  136. <text>👨‍👩‍👧‍👦 家庭成员</text>
  137. <text class="arrow">›</text>
  138. </view>
  139. <view class="menu-item" @click="goToPointsLogs">
  140. <text>📊 积分记录</text>
  141. <text class="arrow">›</text>
  142. </view>
  143. <!-- 设置/重置密码:仅家长和成长规划师可见,孩子不可见 -->
  144. <view class="menu-item" v-if="role === 'parent'" @click="showPasswordModal = true">
  145. <text>🔐 {{ hasPassword ? '重置密码' : '设置密码' }}</text>
  146. <text class="arrow">›</text>
  147. </view>
  148. <button class="menu-item menu-item-btn" open-type="share" @click="inviteFamily" v-if="role === 'parent'">
  149. <text>👨‍👩‍👧‍👦 邀请家人</text>
  150. <text class="arrow">›</text>
  151. </button>
  152. <button class="menu-item menu-item-btn" open-type="share" @click="inviteTeacher" v-if="role === 'parent'">
  153. <text>👨‍🏫 邀请规划师</text>
  154. <text class="arrow">›</text>
  155. </button>
  156. <!-- 会员中心(浠艾福俱乐部) -->
  157. <view class="menu-item" @click="goToMembership">
  158. <text>👑 会员中心</text>
  159. <text class="arrow">›</text>
  160. </view>
  161. <!-- 服务商中心(仅已通过服务商可见) -->
  162. <view class="menu-item" v-if="isVendor" @click="goToVendorCenter">
  163. <text>🏪 服务商中心</text>
  164. <text class="arrow">›</text>
  165. </view>
  166. <view class="menu-item" @click="logout">
  167. <text>🚪 退出登录</text>
  168. <text class="arrow">›</text>
  169. </view>
  170. </view>
  171. <!-- 设置/重置密码弹窗 -->
  172. <view class="modal-mask" v-if="showPasswordModal" @click="showPasswordModal = false">
  173. <view class="modal" @click.stop>
  174. <view class="modal-title">{{ hasPassword ? '重置密码' : '设置密码' }}</view>
  175. <view class="form-item" v-if="hasPassword">
  176. <input v-model="oldPassword" type="number" password placeholder="输入旧密码" maxlength="6" />
  177. </view>
  178. <view class="form-item">
  179. <input v-model="newPassword" type="number" password placeholder="输入新密码" maxlength="6" />
  180. </view>
  181. <view class="form-item">
  182. <input v-model="confirmPassword" type="number" password placeholder="确认新密码" maxlength="6" />
  183. </view>
  184. <view class="modal-btns">
  185. <button @click="showPasswordModal = false">取消</button>
  186. <button class="btn-primary" @click="savePassword">确定</button>
  187. </view>
  188. </view>
  189. </view>
  190. </template>
  191. </view>
  192. </template>
  193. <script>
  194. import PageBanner from '../../components/PageBanner.vue'
  195. import { setPassword, verifyPassword, getChildren, vendorStatus, getEnergyOverview, getUserActionStats, getReferralCode, getReferralSummary, getCommissionSummary } from '../../utils/api.js'
  196. export default {
  197. components: { PageBanner },
  198. data() {
  199. return {
  200. nickname: '',
  201. role: 'parent',
  202. hasPassword: false,
  203. showPasswordModal: false,
  204. oldPassword: '',
  205. newPassword: '',
  206. confirmPassword: '',
  207. children: [],
  208. isSwitchedChild: false,
  209. shareData: null,
  210. isVendor: false,
  211. totalEnergy: null,
  212. badges: [
  213. { id: 1, icon: '\u{1F3C6}', name: '连续7天', unlocked: false },
  214. { id: 2, icon: '\u{2B50}', name: '积分达人', unlocked: false },
  215. { id: 3, icon: '\u{1F525}', name: '执行之星', unlocked: false },
  216. { id: 4, icon: '\u{1F31F}', name: '学习先锋', unlocked: false }
  217. ],
  218. actionData: {
  219. purchaseCount: 0,
  220. activityCount: 0,
  221. taskCount: 0,
  222. courseCount: 0
  223. },
  224. wealthData: {
  225. totalEarnings: '0.00',
  226. availableAmount: '0.00',
  227. referralCount: 0,
  228. referralCode: ''
  229. },
  230. growthReport: {
  231. monthActiveDays: 0,
  232. totalTasks: 0,
  233. completionRate: 0
  234. }
  235. }
  236. },
  237. computed: {
  238. isLoggedIn() {
  239. return !!uni.getStorageSync('token')
  240. }
  241. },
  242. onShareAppMessage() {
  243. if (this.shareData) {
  244. return {
  245. title: this.shareData.title,
  246. path: this.shareData.path,
  247. imageUrl: '/static/invite-card.png'
  248. }
  249. }
  250. },
  251. onShow() {
  252. if (!uni.getStorageSync('token')) return
  253. const currentRole = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
  254. if (currentRole === 'teacher') {
  255. uni.redirectTo({ url: '/pages/teacher/teacher-profile' })
  256. return
  257. }
  258. var userInfo = uni.getStorageSync('userInfo')
  259. this.nickname = this.$store.state.nickname || (userInfo && userInfo.nickname) || ''
  260. // 使用 currentRole(视图角色),而非 role(实际角色)
  261. this.role = currentRole
  262. this.hasPassword = !!uni.getStorageSync('passwordSet')
  263. // 获取切换标记
  264. this.isSwitchedChild = uni.getStorageSync('isSwitchedChild') || false
  265. this.loadChildren()
  266. this.checkVendorStatus()
  267. this.loadEnergyData()
  268. this.loadBadges()
  269. this.loadActionData()
  270. this.loadWealthData()
  271. },
  272. methods: {
  273. goLogin() {
  274. uni.navigateTo({ url: '/pages/login/login' })
  275. },
  276. async loadChildren() {
  277. try {
  278. const res = await getChildren()
  279. this.children = res.data || []
  280. } catch (e) {
  281. console.error('获取孩子列表失败', e)
  282. }
  283. },
  284. goToEditInfo() {
  285. uni.navigateTo({ url: '/pages/user-edit/user-edit' })
  286. },
  287. goToChildren() {
  288. uni.navigateTo({ url: '/pages/profile/children' })
  289. },
  290. goToFamilyMembers() {
  291. uni.navigateTo({ url: '/pages/profile/family-members' })
  292. },
  293. goToPointsLogs() {
  294. uni.navigateTo({ url: '/pages/points/points' })
  295. },
  296. switchMode() {
  297. if (this.role === 'child') {
  298. this.verifyPasswordForSwitch(() => {
  299. this.doSwitchMode()
  300. })
  301. } else {
  302. this.doSwitchMode()
  303. }
  304. },
  305. doSwitchMode() {
  306. const newRole = this.role === 'parent' ? 'child' : 'parent'
  307. if (newRole === 'child') {
  308. if (this.children.length === 0) {
  309. this.loadChildren()
  310. }
  311. if (this.children.length === 0) {
  312. uni.showModal({
  313. title: '提示',
  314. content: '您还没有添加孩子,是否现在去添加?',
  315. success: (res) => {
  316. if (res.confirm) {
  317. uni.navigateTo({ url: '/pages/profile/create-child' })
  318. }
  319. }
  320. })
  321. return
  322. }
  323. if (this.children.length === 1) {
  324. this.$store.commit('switchToChild', this.children[0].id)
  325. this.role = newRole
  326. uni.showToast({ title: '已切换为孩子模式', icon: 'success' })
  327. return
  328. }
  329. uni.showActionSheet({
  330. itemList: this.children.map(c => c.nickname),
  331. success: (res) => {
  332. const selectedChild = this.children[res.tapIndex]
  333. this.$store.commit('switchToChild', selectedChild.id)
  334. this.role = newRole
  335. uni.showToast({ title: `已切换为${selectedChild.nickname}模式`, icon: 'success' })
  336. }
  337. })
  338. return
  339. }
  340. this.$store.commit('switchBackToParent')
  341. this.role = newRole
  342. uni.showToast({ title: `已切换为${newRole === 'parent' ? '家长' : '孩子'}模式`, icon: 'success' })
  343. },
  344. verifyPasswordForSwitch(callback) {
  345. uni.showModal({
  346. title: '验证密码',
  347. content: '请输入家长密码',
  348. editable: true,
  349. success: async (res) => {
  350. if (res.confirm && res.content) {
  351. try {
  352. const result = await verifyPassword(res.content)
  353. if (result.code === 200) {
  354. callback && callback()
  355. } else {
  356. uni.showToast({ title: '密码错误', icon: 'none' })
  357. }
  358. } catch (e) {
  359. uni.showToast({ title: '验证失败', icon: 'none' })
  360. }
  361. }
  362. }
  363. })
  364. },
  365. async savePassword() {
  366. if (this.newPassword.length !== 6) {
  367. uni.showToast({ title: '请输入6位密码', icon: 'none' })
  368. return
  369. }
  370. if (this.newPassword !== this.confirmPassword) {
  371. uni.showToast({ title: '两次密码不一致', icon: 'none' })
  372. return
  373. }
  374. if (this.hasPassword && this.oldPassword.length !== 6) {
  375. uni.showToast({ title: '请输入旧密码', icon: 'none' })
  376. return
  377. }
  378. try {
  379. if (this.hasPassword) {
  380. const verifyRes = await verifyPassword(this.oldPassword)
  381. if (verifyRes.code !== 200) {
  382. uni.showToast({ title: '旧密码错误', icon: 'none' })
  383. return
  384. }
  385. }
  386. await setPassword(this.newPassword)
  387. uni.setStorageSync('passwordSet', true)
  388. this.hasPassword = true
  389. uni.showToast({ title: '密码设置成功', icon: 'success' })
  390. this.showPasswordModal = false
  391. this.oldPassword = ''
  392. this.newPassword = ''
  393. this.confirmPassword = ''
  394. } catch (e) {
  395. console.error('设置密码失败', e)
  396. }
  397. },
  398. logout() {
  399. uni.showModal({
  400. title: '确认退出',
  401. content: '确定要退出登录吗?',
  402. success: (res) => {
  403. if (res.confirm) {
  404. this.$store.commit('logout')
  405. // 退出后返回首页 Tab(预登录状态,5 个底签可见)
  406. uni.reLaunch({ url: '/pages/index/index' })
  407. }
  408. }
  409. })
  410. },
  411. inviteFamily() {
  412. const userInfo = uni.getStorageSync('userInfo')
  413. const familyId = uni.getStorageSync('familyId')
  414. if (!familyId) {
  415. uni.showToast({ title: '您暂未加入家庭', icon: 'none' })
  416. return
  417. }
  418. this.inviteFamilyGenerate(familyId, userInfo)
  419. },
  420. async inviteFamilyGenerate(familyId, userInfo) {
  421. try {
  422. const { generateInviteCard } = require('../../utils/api.js')
  423. const res = await generateInviteCard('family', familyId)
  424. const code = res.data.code
  425. this.shareData = {
  426. title: (userInfo && userInfo.nickname ? userInfo.nickname : '家人') + ' 邀请你加入家庭',
  427. path: '/pages/login/login?invite_code=' + code
  428. }
  429. uni.showToast({ title: '点击右上角转发给TA', icon: 'none' })
  430. } catch (e) {
  431. uni.showToast({ title: e.message || '生成邀请失败', icon: 'none' })
  432. }
  433. },
  434. inviteTeacher() {
  435. const userInfo = uni.getStorageSync('userInfo')
  436. const familyId = uni.getStorageSync('familyId')
  437. if (!familyId) {
  438. uni.showToast({ title: '您暂未加入家庭', icon: 'none' })
  439. return
  440. }
  441. this.inviteTeacherGenerate(familyId, userInfo)
  442. },
  443. async inviteTeacherGenerate(familyId, userInfo) {
  444. try {
  445. const { generateInviteCard } = require('../../utils/api.js')
  446. const res = await generateInviteCard('guide', familyId)
  447. const code = res.data.code
  448. this.shareData = {
  449. title: (userInfo && userInfo.nickname ? userInfo.nickname : '家长') + ' 邀请你成为家庭成长规划师',
  450. path: '/pages/login/login?invite_code=' + code
  451. }
  452. uni.showToast({ title: '点击右上角转发给规划师', icon: 'none' })
  453. } catch (e) {
  454. uni.showToast({ title: e.message || '生成邀请失败', icon: 'none' })
  455. }
  456. },
  457. goToMembership() {
  458. uni.showToast({ title: '即将上线', icon: 'none' })
  459. },
  460. goToVendorCenter() {
  461. uni.navigateTo({ url: '/pages/vendor/center' })
  462. },
  463. goToPromotion() {
  464. uni.navigateTo({ url: '/pages/promotion/index' })
  465. },
  466. async loadEnergyData() {
  467. var childId = uni.getStorageSync('currentChildId') || null
  468. if (!childId) {
  469. // Try to get first child
  470. if (this.children.length > 0) {
  471. childId = this.children[0].id
  472. }
  473. }
  474. if (!childId) return
  475. try {
  476. var res = await getEnergyOverview(childId)
  477. if (res && res.data) {
  478. this.totalEnergy = res.data.totalEnergy || 0
  479. }
  480. } catch (e) { console.log('获取能量概览失败', e) }
  481. },
  482. loadBadges() {
  483. // Unlock based on stored stats
  484. var streakDays = parseInt(uni.getStorageSync('streakDays') || 0)
  485. var totalPoints = parseInt(uni.getStorageSync('totalPoints') || 0)
  486. if (streakDays >= 7) this.badges[0].unlocked = true
  487. if (totalPoints >= 1000) this.badges[1].unlocked = true
  488. // Growth report mock
  489. this.growthReport.monthActiveDays = streakDays > 0 ? Math.min(streakDays, 30) : 0
  490. this.growthReport.totalTasks = parseInt(uni.getStorageSync('completedTasks') || 0)
  491. this.growthReport.completionRate = 85
  492. },
  493. async loadActionData() {
  494. try {
  495. const res = await getUserActionStats()
  496. if (res.code === 200 && res.data) {
  497. this.actionData.purchaseCount = res.data.purchaseCount || 0
  498. this.actionData.activityCount = res.data.activityCount || 0
  499. this.actionData.taskCount = res.data.taskCount || 0
  500. this.actionData.courseCount = res.data.courseCount || 0
  501. }
  502. } catch (e) {
  503. // Fallback to local computed stats
  504. this.actionData.taskCount = parseInt(uni.getStorageSync('completedTasks') || 0)
  505. console.log('获取行动统计失败,使用本地数据', e)
  506. }
  507. },
  508. async loadWealthData() {
  509. try {
  510. const codeRes = await getReferralCode()
  511. if (codeRes.data) {
  512. this.wealthData.referralCode = codeRes.data.referralCode || codeRes.data.code || ''
  513. }
  514. } catch (e) { console.log('获取邀请码失败', e) }
  515. try {
  516. const summaryRes = await getReferralSummary()
  517. if (summaryRes.data) {
  518. this.wealthData.totalEarnings = summaryRes.data.totalEarnings || '0.00'
  519. this.wealthData.referralCount = summaryRes.data.referredCount || summaryRes.data.totalCount || 0
  520. }
  521. } catch (e) { console.log('获取邀请统计失败', e) }
  522. try {
  523. const comRes = await getCommissionSummary()
  524. if (comRes.data) {
  525. this.wealthData.availableAmount = comRes.data.availableAmount || '0.00'
  526. }
  527. } catch (e) { console.log('获取佣金总览失败', e) }
  528. },
  529. copyReferralCode() {
  530. if (!this.wealthData.referralCode) return
  531. uni.setClipboardData({
  532. data: this.wealthData.referralCode,
  533. success: () => { uni.showToast({ title: '邀请码已复制', icon: 'success' }) }
  534. })
  535. },
  536. goAllBadges() {
  537. uni.showToast({ title: '即将上线', icon: 'none' })
  538. },
  539. goGrowthReport() {
  540. uni.showToast({ title: '即将上线', icon: 'none' })
  541. },
  542. async checkVendorStatus() {
  543. try {
  544. const res = await vendorStatus()
  545. this.isVendor = res.data && res.data.vendorStatus === 'approved'
  546. } catch (e) {
  547. this.isVendor = false
  548. }
  549. },
  550. exitSwitch() {
  551. if (!this.isSwitchedChild) return
  552. uni.showModal({
  553. title: '退出切换',
  554. content: '请输入家长密码以确认退出',
  555. editable: true,
  556. success: async (res) => {
  557. if (res.confirm && res.content) {
  558. try {
  559. const verifyResult = await verifyPassword(res.content)
  560. if (verifyResult.code === 200) {
  561. this.$store.commit('switchBackToParent')
  562. this.isSwitchedChild = false
  563. this.role = 'parent'
  564. uni.showToast({ title: '已退出切换', icon: 'success' })
  565. // 刷新首页
  566. uni.reLaunch({ url: '/pages/index/index' })
  567. } else {
  568. uni.showToast({ title: '密码错误', icon: 'none' })
  569. }
  570. } catch (e) {
  571. uni.showToast({ title: '验证失败', icon: 'none' })
  572. }
  573. }
  574. }
  575. })
  576. }
  577. }
  578. }
  579. </script>
  580. <style scoped>
  581. .container {
  582. min-height: 100vh;
  583. background: #f5f7fa;
  584. padding-bottom: 120rpx;
  585. }
  586. /* ===== 通用区块 ===== */
  587. .section {
  588. margin: 20rpx 30rpx;
  589. }
  590. .section-header {
  591. display: flex;
  592. justify-content: space-between;
  593. align-items: center;
  594. margin-bottom: 20rpx;
  595. }
  596. .section-title {
  597. font-size: 30rpx;
  598. font-weight: bold;
  599. color: #333;
  600. }
  601. .section-more {
  602. font-size: 24rpx;
  603. color: #999;
  604. }
  605. /* ===== 推广邀请码 ===== */
  606. .referral-code-bar {
  607. display: flex;
  608. align-items: center;
  609. background: #fff;
  610. border-radius: 16rpx;
  611. padding: 20rpx 24rpx;
  612. margin-top: 16rpx;
  613. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  614. }
  615. .referral-code-label {
  616. font-size: 26rpx;
  617. color: #999;
  618. margin-right: 16rpx;
  619. }
  620. .referral-code-value {
  621. flex: 1;
  622. font-size: 28rpx;
  623. font-weight: bold;
  624. color: #F97316;
  625. letter-spacing: 4rpx;
  626. }
  627. .referral-code-copy {
  628. font-size: 24rpx;
  629. color: #5B9BD5;
  630. padding: 4rpx 16rpx;
  631. border: 1rpx solid #5B9BD5;
  632. border-radius: 8rpx;
  633. }
  634. /* ===== 行动数据(推广收益) ===== */
  635. .wealth-card {
  636. background: #fff;
  637. border-radius: 20rpx;
  638. padding: 30rpx 20rpx;
  639. display: flex;
  640. align-items: center;
  641. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  642. }
  643. .wealth-item {
  644. flex: 1;
  645. display: flex;
  646. flex-direction: column;
  647. align-items: center;
  648. }
  649. .wealth-value {
  650. font-size: 40rpx;
  651. font-weight: bold;
  652. color: #F97316;
  653. }
  654. .wealth-label {
  655. font-size: 24rpx;
  656. color: #999;
  657. margin-top: 8rpx;
  658. }
  659. .wealth-divider {
  660. width: 1rpx;
  661. height: 60rpx;
  662. background: #f0f0f0;
  663. }
  664. /* ===== 成就徽章 ===== */
  665. .badge-grid {
  666. display: flex;
  667. background: #fff;
  668. border-radius: 20rpx;
  669. padding: 24rpx 16rpx;
  670. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  671. }
  672. .badge-item {
  673. flex: 1;
  674. display: flex;
  675. flex-direction: column;
  676. align-items: center;
  677. }
  678. .badge-icon-wrap {
  679. width: 72rpx;
  680. height: 72rpx;
  681. border-radius: 50%;
  682. display: flex;
  683. align-items: center;
  684. justify-content: center;
  685. margin-bottom: 8rpx;
  686. }
  687. .badge-icon-wrap.unlocked {
  688. background: linear-gradient(135deg, #FBBF24, #F97316);
  689. }
  690. .badge-icon-wrap.locked {
  691. background: #f0f0f0;
  692. opacity: 0.5;
  693. }
  694. .badge-icon {
  695. font-size: 36rpx;
  696. }
  697. .badge-name {
  698. font-size: 22rpx;
  699. color: #666;
  700. }
  701. /* ===== 成长报告 ===== */
  702. .report-card {
  703. background: #fff;
  704. border-radius: 20rpx;
  705. padding: 30rpx 20rpx;
  706. display: flex;
  707. align-items: center;
  708. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  709. }
  710. .report-stat-item {
  711. flex: 1;
  712. display: flex;
  713. flex-direction: column;
  714. align-items: center;
  715. }
  716. .report-stat {
  717. font-size: 36rpx;
  718. font-weight: bold;
  719. color: #5B9BD5;
  720. }
  721. .report-label {
  722. font-size: 22rpx;
  723. color: #999;
  724. margin-top: 6rpx;
  725. }
  726. .report-divider {
  727. width: 1rpx;
  728. height: 50rpx;
  729. background: #f0f0f0;
  730. }
  731. .user-card {
  732. background: linear-gradient(135deg, #5B9BD5 0%, #3A7CC4 100%);
  733. border-radius: 20rpx;
  734. padding: 40rpx;
  735. display: flex;
  736. align-items: center;
  737. color: #fff;
  738. }
  739. .avatar {
  740. font-size: 80rpx;
  741. margin-right: 30rpx;
  742. }
  743. .user-info {
  744. flex: 1;
  745. }
  746. .nickname {
  747. font-size: 36rpx;
  748. font-weight: bold;
  749. }
  750. .role {
  751. font-size: 24rpx;
  752. opacity: 0.8;
  753. }
  754. .system-points {
  755. font-size: 22rpx;
  756. color: #D6EAF8;
  757. margin-top: 8rpx;
  758. font-weight: 500;
  759. }
  760. .btn-switch {
  761. background: rgba(255, 255, 255, 0.2);
  762. color: #fff;
  763. font-size: 24rpx;
  764. padding: 10rpx 20rpx;
  765. border-radius: 20rpx;
  766. }
  767. .menu-list {
  768. margin-top: 30rpx;
  769. background: #fff;
  770. border-radius: 16rpx;
  771. }
  772. .menu-item {
  773. padding: 30rpx;
  774. border-bottom: 1rpx solid #f0f0f0;
  775. display: flex;
  776. justify-content: space-between;
  777. font-size: 28rpx;
  778. }
  779. .menu-item:last-child {
  780. border-bottom: none;
  781. }
  782. .arrow {
  783. color: #ccc;
  784. font-size: 32rpx;
  785. }
  786. .menu-item-btn {
  787. display: flex;
  788. justify-content: space-between;
  789. align-items: center;
  790. width: 100%;
  791. padding: 28rpx 24rpx;
  792. border: none;
  793. background: transparent;
  794. font-size: 28rpx;
  795. color: #333;
  796. }
  797. .menu-item-btn::after { border: none; }
  798. .modal-mask {
  799. position: fixed;
  800. top: 0;
  801. left: 0;
  802. right: 0;
  803. bottom: 0;
  804. background: rgba(0, 0, 0, 0.5);
  805. display: flex;
  806. align-items: center;
  807. justify-content: center;
  808. }
  809. .modal {
  810. background: #fff;
  811. border-radius: 20rpx;
  812. padding: 40rpx;
  813. width: 80%;
  814. }
  815. .modal-title {
  816. font-size: 32rpx;
  817. font-weight: bold;
  818. margin-bottom: 30rpx;
  819. text-align: center;
  820. }
  821. .form-item {
  822. margin-bottom: 20rpx;
  823. }
  824. .form-item input {
  825. border: 1rpx solid #ddd;
  826. border-radius: 10rpx;
  827. padding: 20rpx;
  828. font-size: 28rpx;
  829. }
  830. .modal-btns {
  831. display: flex;
  832. gap: 20rpx;
  833. margin-top: 30rpx;
  834. }
  835. .modal-btns button {
  836. flex: 1;
  837. }
  838. /* ===== 未登录提示 ===== */
  839. .login-prompt {
  840. display: flex;
  841. flex-direction: column;
  842. align-items: center;
  843. justify-content: center;
  844. min-height: 80vh;
  845. padding: 60rpx;
  846. }
  847. .prompt-icon {
  848. font-size: 120rpx;
  849. margin-bottom: 30rpx;
  850. width: 160rpx;
  851. height: 160rpx;
  852. line-height: 160rpx;
  853. text-align: center;
  854. background: #f5f5f5;
  855. border-radius: 50%;
  856. }
  857. .prompt-title {
  858. font-size: 36rpx;
  859. font-weight: bold;
  860. color: #333;
  861. margin-bottom: 16rpx;
  862. }
  863. .prompt-desc {
  864. font-size: 26rpx;
  865. color: #999;
  866. text-align: center;
  867. margin-bottom: 40rpx;
  868. }
  869. .login-prompt .login-btn {
  870. width: 60%;
  871. height: 80rpx;
  872. line-height: 80rpx;
  873. background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
  874. color: #fff;
  875. font-size: 30rpx;
  876. font-weight: bold;
  877. border-radius: 40rpx;
  878. text-align: center;
  879. border: none;
  880. }
  881. .login-prompt .login-btn::after {
  882. border: none;
  883. }
  884. </style>