Home.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <div>
  3. <BaseHeader></BaseHeader>
  4. <div class="container width_1200">
  5. <Layout class="layoutAll">
  6. <Sider class="side-bar" ref="side" :collapsed-width="78">
  7. <Menu
  8. class="side-menu"
  9. theme="light"
  10. width="auto"
  11. :active-name="$route.name"
  12. :open-names="['订单中心', '会员中心', '账户中心']"
  13. @on-select="onSelect"
  14. >
  15. <div class="user-icon">
  16. <div class="user-img">
  17. <img :src="userInfo.face" />
  18. </div>
  19. <p>{{userInfo.username | secrecyMobile}}</p>
  20. </div>
  21. <!-- 循环导航栏 -->
  22. <Submenu
  23. v-for="(menu, index) in menuList"
  24. :key="index"
  25. :name="menu.title"
  26. >
  27. <template slot="title" v-if="menu.display">
  28. <Icon type="location"></Icon>
  29. <span>{{ menu.title }}</span>
  30. </template>
  31. <MenuItem
  32. v-for="(chlidren, i) in menu.menus"
  33. :key="i"
  34. :name="chlidren.path"
  35. >{{ chlidren.title }}</MenuItem
  36. >
  37. </Submenu>
  38. </Menu>
  39. </Sider>
  40. <Layout class="layout ml_10">
  41. <Content class="content">
  42. <transition mode="out-in">
  43. <router-view></router-view>
  44. </transition>
  45. </Content>
  46. </Layout>
  47. </Layout>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import menuList from './menu';
  53. import Storage from '@/plugins/storage.js';
  54. export default {
  55. name: 'Home',
  56. data () {
  57. return {
  58. menuList // 会员中心左侧列表
  59. };
  60. },
  61. computed: {
  62. userInfo () {
  63. return JSON.parse(Storage.getItem('userInfo'));
  64. }
  65. },
  66. methods: {
  67. // 每次点击左侧bar的callback
  68. onSelect (name) {
  69. this.$router.push({name: name});
  70. },
  71. // 跳转到个人中心的首页
  72. toUserMain () {
  73. this.$router.push(`/home`);
  74. }
  75. }
  76. };
  77. </script>
  78. <style scoped lang="scss">
  79. .content {
  80. padding: 15px 50px;
  81. }
  82. .header {
  83. @include background_color($light_background_color);
  84. }
  85. .side-menu,
  86. .side-bar,
  87. .content {
  88. @include white_background_color();
  89. @include title_color($light_title_color);
  90. }
  91. .side-bar {
  92. min-height: 600px;
  93. height: auto;
  94. }
  95. .layoutAll {
  96. min-height: 1200px;
  97. @include background_color($light_background_color);
  98. }
  99. .container {
  100. margin: 0 auto;
  101. padding: 20px 0;
  102. }
  103. .side-bar a {
  104. @include title_color($light_title_color);
  105. }
  106. .user-icon {
  107. height: 200px;
  108. display: flex;
  109. flex-direction: column;
  110. justify-content: center;
  111. align-items: center;
  112. }
  113. .user-icon span {
  114. font-size: 96px;
  115. }
  116. .user-img {
  117. margin-bottom: 15px;
  118. width: 96px;
  119. height: 96px;
  120. border-radius: 48px;
  121. overflow: hidden;
  122. }
  123. .user-img img {
  124. width: 100%;
  125. }
  126. .layout-footer-center {
  127. padding: 0px 15px;
  128. padding-bottom: 15px;
  129. text-align: center;
  130. }
  131. </style>