user.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view class="container">
  3. <u-cell-group><u-cell title="用户名" :value="userName"></u-cell></u-cell-group>
  4. <view class="btn-box" @click="loginOut"><u-button type="primary">退出</u-button></view>
  5. <tabbar :currentTab="3"></tabbar>
  6. </view>
  7. </template>
  8. <script>
  9. import api from "@/common/api.js";
  10. import { log } from "@/utils/base.js";
  11. import tabbar from "@/components/tabbar";
  12. export default {
  13. components: {
  14. tabbar,
  15. },
  16. data() {
  17. return {
  18. userName: "",
  19. };
  20. },
  21. mounted() {
  22. this.userName = this.$store.state.userInfo.name;
  23. },
  24. methods: {
  25. loginOut() {
  26. uni.showModal({
  27. title: "确定要退出吗?",
  28. content: " ",
  29. success: res => {
  30. if (res.confirm) {
  31. this.confirmLoginOut();
  32. }
  33. },
  34. });
  35. },
  36. confirmLoginOut() {
  37. this.$store.commit("logout");
  38. uni.reLaunch({
  39. url: "/pages/login/login",
  40. });
  41. },
  42. },
  43. };
  44. </script>
  45. <style lang="scss">
  46. .container {
  47. padding: 20px;
  48. font-size: 14px;
  49. line-height: 24px;
  50. }
  51. .btn-box {
  52. padding: 50px 30px 10px;
  53. }
  54. /deep/ .u-cell {
  55. &__title {
  56. font-weight: 600;
  57. }
  58. &__value {
  59. color: $uni-color-primary;
  60. }
  61. }
  62. </style>