Profile.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. <template>
  2. <div class="usremei-container">
  3. <!-- 第一个白色背景板块 -->
  4. <div class="profile-card">
  5. <div class="avatar-section">
  6. <img src="@/assets/logo.png" class="avatar" alt="用户头像" />
  7. </div>
  8. <div class="info-row">
  9. <span class="name">{{ userInfo.nickname }}</span>
  10. <img src="@/assets/sign.png" class="sign-icon" alt="签到" @click="goToSignin" />
  11. </div>
  12. <div class="info-row">
  13. <span class="label">手机号码</span>
  14. <span class="value">{{ userInfo.mobile }}</span>
  15. </div>
  16. <div class="info-row">
  17. <span class="label">邀请码</span>
  18. <span class="value">{{ userInfo.salt }}</span>
  19. </div>
  20. </div>
  21. <!-- 第二个银行卡板块 -->
  22. <div class="bank-card">
  23. <div class="bank-content">
  24. <img src="@/assets/bank.png" class="bank-logo" alt="银行logo" />
  25. <div class="bank-text">
  26. <div class="bank-name">中国农业银行农泉联名账户</div>
  27. <div><span style="font-size:13px;">余额:</span><span class="balance">{{ userInfo.ukaedu }}</span></div>
  28. </div>
  29. <div class="button-group">
  30. <button class="action-btn button-click-effect" @click="goToCharges">缴纳税费</button>
  31. <button class="action-btn button-click-effect" @click="goToFinancial">提升到账额度</button>
  32. </div>
  33. </div>
  34. </div>
  35. <!-- 收益板块组 -->
  36. <div class="profit-section">
  37. <!-- 第一行 -->
  38. <div class="profit-block">
  39. <div class="profit-left">
  40. <div class="profit-header">
  41. <span>每日分红</span>
  42. <button class="profit-btn button-click-effect" @click="$router.push('/mention?type=3')">提现</button>
  43. </div>
  44. <div class="profit-amount">¥{{ userInfo.dayred }}</div>
  45. </div>
  46. <div class="profit-right">
  47. <div class="profit-header">
  48. <span>万泰股权</span>
  49. <button class="profit-btn button-click-effect" @click="handleCashOut">套现</button>
  50. </div>
  51. <div class="profit-amount">¥{{ userInfo.guquan }}</div>
  52. </div>
  53. </div>
  54. <!-- 第二行 -->
  55. <div class="profit-block">
  56. <div class="profit-left">
  57. <div class="profit-header">
  58. <span>财政补贴</span>
  59. <button class="profit-btn button-click-effect" @click="$router.push('/mention?type=1')">提现</button>
  60. </div>
  61. <div class="profit-amount">¥{{ userInfo.coins }}</div>
  62. </div>
  63. <div class="profit-right">
  64. <div class="profit-header">
  65. <span>养老金</span>
  66. <button class="profit-btn button-click-effect" @click="handlePensionWithdraw">提现</button>
  67. </div>
  68. <div class="profit-amount">¥{{ userInfo.xianjin }}</div>
  69. </div>
  70. </div>
  71. <!-- 第三行 -->
  72. <div class="profit-block">
  73. <div class="profit-left">
  74. <div class="profit-header">
  75. <span>万泰红利</span>
  76. <button class="profit-btn button-click-effect" @click="$router.push('/mention?type=2')">提现</button>
  77. </div>
  78. <div class="profit-amount">¥{{ userInfo.money }}</div>
  79. </div>
  80. <div class="profit-right">
  81. <div class="profit-header">
  82. <span>养生币</span>
  83. <button class="profit-btn button-click-effect">抢福</button>
  84. </div>
  85. <div class="profit-amount">¥{{ userInfo.score }}</div>
  86. </div>
  87. </div>
  88. </div>
  89. <!-- 应用中心板块 -->
  90. <div class="app-center">
  91. <div class="section-title">
  92. <div class="title-line"></div>
  93. <span>应用中心</span>
  94. </div>
  95. <div class="function-grid">
  96. <div class="function-item button-click-effect" @click="$router.push('/user-center')">
  97. <img src="@/assets/221.png" alt="实名认证" />
  98. <span>实名认证</span>
  99. </div>
  100. <div class="function-item button-click-effect" @click="$router.push('/bank-card')">
  101. <img src="@/assets/222.png" alt="银行卡绑定" />
  102. <span>银行卡绑定</span>
  103. </div>
  104. <div class="function-item button-click-effect" @click="$router.push('/member')">
  105. <img src="@/assets/223.png" alt="我的团队" />
  106. <span>我的团队</span>
  107. </div>
  108. <div class="function-item button-click-effect" @click="$router.push('/asset-center')">
  109. <img src="@/assets/224.png" alt="资金明细" />
  110. <span>资金明细</span>
  111. </div>
  112. <div class="function-item button-click-effect" @click="$router.push('/order-list')">
  113. <img src="@/assets/225.png" alt="提现记录" />
  114. <span>提现记录</span>
  115. </div>
  116. <div class="function-item button-click-effect" @click="$router.push('/lever-list')">
  117. <img src="@/assets/226.png" alt="礼品福利" />
  118. <span>礼品福利</span>
  119. </div>
  120. <div class="function-item button-click-effect" @click="toAppDownload">
  121. <img src="@/assets/227.png" alt="APP下载" />
  122. <span>APP下载</span>
  123. </div>
  124. </div>
  125. </div>
  126. <!-- 退出登录按钮 -->
  127. <div class="logout-wrapper">
  128. <button class="logout-btn button-click-effect" @click="handleLogout">退出登录</button>
  129. </div>
  130. <!-- 自定义确认框 -->
  131. <div class="confirm-dialog" v-if="showConfirm">
  132. <div class="confirm-mask"></div>
  133. <div class="confirm-content">
  134. <div class="confirm-title">提示</div>
  135. <div class="confirm-message">确认退出登录吗?</div>
  136. <div class="confirm-btns">
  137. <button class="confirm-btn cancel" @click="cancelLogout">取消</button>
  138. <button class="confirm-btn confirm" @click="confirmLogout">确认</button>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </template>
  144. <script>
  145. import { getUserInfo } from '@/api/home';
  146. import { logout, cashOut, withdrawPension } from '@/api/profile';
  147. export default {
  148. name: 'UsreMei',
  149. data() {
  150. return {
  151. userInfo: {},
  152. showConfirm: false
  153. }
  154. },
  155. mounted() {
  156. this.getUserInfo();
  157. },
  158. methods: {
  159. async getUserInfo() {
  160. const res = await getUserInfo();
  161. this.userInfo = res.data;
  162. },
  163. goToCharges() {
  164. this.$router.push('/charges');
  165. },
  166. goToFinancial() {
  167. this.$router.push('/financial');
  168. },
  169. goToSignin() {
  170. this.$router.push('/signin');
  171. },
  172. async handleCashOut() {
  173. try {
  174. await cashOut();
  175. alert('套现成功');
  176. // 刷新用户信息
  177. await this.getUserInfo();
  178. } catch (error) {
  179. console.error('套现失败:', error);
  180. alert('套现失败,请重试');
  181. }
  182. },
  183. async handlePensionWithdraw() {
  184. try {
  185. await withdrawPension();
  186. alert('提现成功');
  187. // 刷新用户信息
  188. await this.getUserInfo();
  189. } catch (error) {
  190. console.error('提现失败:', error);
  191. alert('提现失败,请重试');
  192. }
  193. },
  194. handleLogout() {
  195. this.showConfirm = true;
  196. },
  197. cancelLogout() {
  198. this.showConfirm = false;
  199. },
  200. toAppDownload() {
  201. window.open(this.userInfo.link[1].value, '_blank');
  202. },
  203. async confirmLogout() {
  204. try {
  205. await logout();
  206. alert('退出成功');
  207. // 清除本地存储的token等信息
  208. localStorage.removeItem('token');
  209. // 跳转到登录页
  210. this.$router.replace('/login');
  211. } catch (error) {
  212. alert('退出失败,请重试');
  213. } finally {
  214. this.showConfirm = false;
  215. }
  216. }
  217. }
  218. }
  219. </script>
  220. <style scoped>
  221. .usremei-container {
  222. min-height: 100vh;
  223. background-image: url('../assets/dabag.png');
  224. background-size: cover;
  225. background-position: center;
  226. padding: 20px;
  227. padding-top: 60px;
  228. padding-bottom: 80px; /* 为底部tab预留空间 */
  229. box-sizing: border-box; /* 确保padding不会增加容器高度 */
  230. overflow-y: auto; /* 允许内容滚动 */
  231. position: relative; /* 为fixed定位提供参考 */
  232. }
  233. .profile-card {
  234. background: #fff;
  235. border-radius: 12px;
  236. padding: 20px;
  237. margin-bottom: 20px;
  238. position: relative;
  239. padding-top: 60px;
  240. }
  241. .avatar-section {
  242. position: absolute;
  243. top: -40px; /* 让头像向上偏移,实现半超出效果 */
  244. left: 20px; /* 左侧距离 */
  245. }
  246. .avatar {
  247. width: 80px;
  248. height: 80px;
  249. border-radius: 50%;
  250. object-fit: cover;
  251. border: 2px solid #fff; /* 添加白色边框使头像更突出 */
  252. box-shadow: 0 2px 8px rgba(0,0,0,0.1); /* 添加阴影效果 */
  253. }
  254. .info-row {
  255. display: flex;
  256. justify-content: space-between;
  257. align-items: center;
  258. margin-bottom: 15px;
  259. font-size: 16px;
  260. }
  261. .name {
  262. font-size: 18px;
  263. font-weight: bold;
  264. }
  265. .sign-icon {
  266. width: 50px;
  267. height: 40px;
  268. }
  269. .label {
  270. color: #666;
  271. }
  272. .value {
  273. color: #333;
  274. }
  275. .bank-card {
  276. background: url('../assets/gebg.png');
  277. background-size: cover;
  278. border-radius: 12px;
  279. padding: 20px;
  280. }
  281. .bank-content {
  282. display: flex;
  283. align-items: center;
  284. justify-content: space-between;
  285. gap: 15px;
  286. }
  287. .bank-logo {
  288. width: 50px; /* 稍微缩小logo */
  289. height: 50px;
  290. flex-shrink: 0;
  291. }
  292. .bank-text {
  293. flex: 2; /* 给文字更多空间 */
  294. min-width: 0;
  295. }
  296. .bank-name {
  297. font-weight: bold;
  298. font-size: 10px; /* 稍微减小字号 */
  299. color: #333;
  300. margin-bottom: 10px;
  301. line-height: 1.2;
  302. white-space: normal; /* 允许换行 */
  303. }
  304. .balance {
  305. font-size: 18px;
  306. color: #85370d;
  307. font-weight: bold;
  308. }
  309. .button-group {
  310. display: flex;
  311. flex-direction: column;
  312. gap: 6px; /* 减小按钮间距 */
  313. flex-shrink: 0;
  314. width: 90px; /* 固定按钮组宽度 */
  315. }
  316. .action-btn, .profit-btn, .logout-btn {
  317. position: relative;
  318. overflow: hidden;
  319. transition: all 0.2s;
  320. }
  321. .action-btn {
  322. background-color: #fb3f6c;
  323. color: #fff;
  324. border: none;
  325. border-radius: 4px;
  326. padding: 6px 8px;
  327. font-size: 12px;
  328. cursor: pointer;
  329. white-space: nowrap;
  330. width: 100%;
  331. }
  332. .action-btn:active {
  333. transform: scale(0.98);
  334. opacity: 0.9;
  335. }
  336. .profit-btn {
  337. background-color: #fb3f6c;
  338. color: #fff;
  339. border: none;
  340. border-radius: 4px;
  341. padding: 6px 12px;
  342. font-size: 12px;
  343. cursor: pointer;
  344. position: relative;
  345. overflow: hidden;
  346. }
  347. .profit-btn:active {
  348. transform: scale(0.98);
  349. opacity: 0.9;
  350. }
  351. .function-item {
  352. display: flex;
  353. flex-direction: column;
  354. align-items: center;
  355. gap: 8px;
  356. cursor: pointer;
  357. transition: all 0.2s;
  358. }
  359. .function-item:active {
  360. transform: scale(0.95);
  361. opacity: 0.8;
  362. }
  363. @keyframes ripple {
  364. 0% {
  365. transform: scale(0, 0);
  366. opacity: 0.5;
  367. }
  368. 20% {
  369. transform: scale(25, 25);
  370. opacity: 0.3;
  371. }
  372. 100% {
  373. opacity: 0;
  374. transform: scale(40, 40);
  375. }
  376. }
  377. .action-btn::after,
  378. .profit-btn::after,
  379. .logout-btn::after {
  380. content: '';
  381. position: absolute;
  382. top: 50%;
  383. left: 50%;
  384. width: 5px;
  385. height: 5px;
  386. background: rgba(255, 255, 255, 0.5);
  387. opacity: 0;
  388. border-radius: 100%;
  389. transform: scale(1, 1) translate(-50%);
  390. transform-origin: 50% 50%;
  391. }
  392. .action-btn:active::after,
  393. .profit-btn:active::after,
  394. .logout-btn:active::after {
  395. animation: ripple 0.4s ease-out;
  396. }
  397. /* 调整信息行的位置,让它不会被头像遮挡 */
  398. .info-row:first-of-type {
  399. margin-top: 10px;
  400. }
  401. /* 移动端适配 */
  402. @media screen and (max-width: 375px) {
  403. .usremei-container {
  404. padding: 15px;
  405. padding-top: 50px;
  406. padding-bottom: 70px;
  407. }
  408. .profile-card,
  409. .bank-card {
  410. padding: 15px;
  411. }
  412. .bank-content {
  413. flex-direction: column;
  414. align-items: flex-start;
  415. }
  416. .bank-text {
  417. width: 100%;
  418. margin: 10px 0;
  419. }
  420. .button-group {
  421. width: 100%;
  422. }
  423. .action-btn {
  424. width: 100%;
  425. }
  426. }
  427. .profit-section {
  428. display: flex;
  429. flex-direction: column;
  430. gap: 15px;
  431. margin-top: 15px;
  432. margin-bottom: 15px; /* 底部添加间距 */
  433. }
  434. .profit-block {
  435. display: flex;
  436. gap: 15px;
  437. background: url('../assets/neibg.png');
  438. background-size: cover;
  439. border-radius: 12px;
  440. padding: 6px;
  441. }
  442. .profit-left, .profit-right {
  443. flex: 1;
  444. padding: 10px;
  445. position: relative; /* 为分隔线定位做准备 */
  446. }
  447. /* 添加分隔线 */
  448. .profit-block:not(:first-child) .profit-left::after {
  449. content: '';
  450. position: absolute;
  451. right: -7.5px; /* 居中放置,gap的一半 */
  452. top: 50%;
  453. transform: translateY(-50%);
  454. width: 1px;
  455. height: 70%;
  456. background-color: #85370d;
  457. }
  458. .profit-header {
  459. display: flex;
  460. justify-content: space-between;
  461. align-items: center;
  462. /* margin-bottom: 10px; */
  463. }
  464. .profit-header span {
  465. color: #85370d;
  466. font-size: 14px;
  467. }
  468. .profit-amount {
  469. font-size: 20px;
  470. font-weight: bold;
  471. color: #85370d;
  472. }
  473. /* 移动端适配 */
  474. @media screen and (max-width: 375px) {
  475. .profit-block {
  476. flex-direction: column;
  477. gap: 10px;
  478. padding: 6px;
  479. }
  480. .profit-left, .profit-right {
  481. padding: 8px;
  482. }
  483. .profit-amount {
  484. font-size: 18px;
  485. }
  486. }
  487. .app-center {
  488. background: #fff;
  489. border-radius: 12px;
  490. padding: 20px;
  491. margin-top: 15px;
  492. }
  493. .section-title {
  494. display: flex;
  495. align-items: center;
  496. gap: 10px;
  497. margin-bottom: 20px;
  498. }
  499. .title-line {
  500. width: 2px;
  501. height: 16px;
  502. background-color: #ff6b00;
  503. }
  504. .section-title span {
  505. font-size: 16px;
  506. font-weight: bold;
  507. color: #333;
  508. }
  509. .function-grid {
  510. display: grid;
  511. grid-template-columns: repeat(4, 1fr);
  512. gap: 20px 10px;
  513. }
  514. .function-item img {
  515. width: 50px;
  516. height: 50px;
  517. object-fit: contain;
  518. }
  519. .function-item span {
  520. font-size: 12px;
  521. color: #333;
  522. text-align: center;
  523. }
  524. /* 移动端适配补充 */
  525. @media screen and (max-width: 375px) {
  526. .app-center {
  527. padding: 15px;
  528. }
  529. .function-grid {
  530. gap: 15px 8px;
  531. }
  532. .function-item img {
  533. width: 24px;
  534. height: 24px;
  535. }
  536. .function-item span {
  537. font-size: 11px;
  538. }
  539. }
  540. .logout-wrapper {
  541. margin-top: 30px;
  542. margin-bottom: 20px;
  543. padding: 0 20px;
  544. }
  545. .logout-btn {
  546. width: 100%;
  547. background-color: #fb3f6c;
  548. color: #fff;
  549. border: none;
  550. border-radius: 6px;
  551. padding: 12px 0;
  552. font-size: 16px;
  553. cursor: pointer;
  554. position: relative;
  555. overflow: hidden;
  556. }
  557. .logout-btn:active {
  558. transform: scale(0.98);
  559. opacity: 0.9;
  560. }
  561. /* 移动端适配补充 */
  562. @media screen and (max-width: 375px) {
  563. .logout-btn {
  564. padding: 10px 0;
  565. font-size: 14px;
  566. }
  567. }
  568. .button-click-effect {
  569. position: relative !important;
  570. overflow: hidden !important;
  571. transition: all 0.2s !important;
  572. }
  573. .button-click-effect:active {
  574. transform: scale(0.98) !important;
  575. opacity: 0.9 !important;
  576. }
  577. /* 确认框样式 */
  578. .confirm-dialog {
  579. position: fixed;
  580. top: 0;
  581. left: 0;
  582. width: 100%;
  583. height: 100%;
  584. z-index: 9999;
  585. }
  586. .confirm-mask {
  587. position: absolute;
  588. top: 0;
  589. left: 0;
  590. width: 100%;
  591. height: 100%;
  592. background: rgba(0, 0, 0, 0.5);
  593. }
  594. .confirm-content {
  595. position: absolute;
  596. top: 50%;
  597. left: 50%;
  598. transform: translate(-50%, -50%);
  599. width: 80%;
  600. max-width: 300px;
  601. background: #fff;
  602. border-radius: 12px;
  603. overflow: hidden;
  604. }
  605. .confirm-title {
  606. padding: 15px;
  607. text-align: center;
  608. font-size: 16px;
  609. font-weight: bold;
  610. color: #333;
  611. border-bottom: 1px solid #eee;
  612. }
  613. .confirm-message {
  614. padding: 20px 15px;
  615. text-align: center;
  616. font-size: 14px;
  617. color: #666;
  618. line-height: 1.5;
  619. }
  620. .confirm-btns {
  621. display: flex;
  622. border-top: 1px solid #eee;
  623. }
  624. .confirm-btn {
  625. flex: 1;
  626. padding: 12px;
  627. text-align: center;
  628. font-size: 14px;
  629. background: #fff;
  630. border: none;
  631. cursor: pointer;
  632. transition: all 0.2s;
  633. }
  634. .confirm-btn.cancel {
  635. color: #666;
  636. border-right: 1px solid #eee;
  637. }
  638. .confirm-btn.confirm {
  639. color: #fb3f6c;
  640. font-weight: bold;
  641. }
  642. .confirm-btn:active {
  643. opacity: 0.8;
  644. background: #f5f5f5;
  645. }
  646. </style>