main-navbar.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <nav class="site-navbar">
  3. <div class="site-navbar clearfix">
  4. <ul class="TT-nav">
  5. <li>
  6. <router-link :to="{name: 'home'}">首页</router-link>
  7. </li>
  8. <li>
  9. <el-dropdown class="TT-login" :show-timeout="0" placement="bottom" style="cursor: pointer;">
  10. <span class="el-dropdown-link">淘宝工具</span>
  11. <el-dropdown-menu slot="dropdown">
  12. <el-dropdown-item>
  13. <router-link :to="{name: 'toolsAnalyze'}">竞品透析</router-link>
  14. </el-dropdown-item>
  15. <el-dropdown-item>
  16. <router-link :to="{name: 'toolsCredit'}">旺旺透视</router-link>
  17. </el-dropdown-item>
  18. <el-dropdown-item>
  19. <router-link :to="{name: 'toolsOnline'}">指数转换</router-link>
  20. </el-dropdown-item>
  21. <el-dropdown-item>
  22. <router-link :to="{name: 'toolsPricetrend'}">价格走势</router-link>
  23. </el-dropdown-item>
  24. <el-dropdown-item>
  25. <router-link :to="{name: 'toolsOrdersearch'}">淘客订单查询</router-link>
  26. </el-dropdown-item>
  27. <el-dropdown-item>
  28. <router-link :to="{name: 'toolsStarkeysearch'}">淘宝下拉框选词</router-link>
  29. </el-dropdown-item>
  30. <el-dropdown-item>
  31. <router-link :to="{name: 'toolsShopinfo'}">店铺信息查询</router-link>
  32. </el-dropdown-item>
  33. </el-dropdown-menu>
  34. </el-dropdown>
  35. </li>
  36. </ul>
  37. <template v-if="token">
  38. <el-dropdown class="TT-login" :show-timeout="0" placement="bottom" style="cursor: pointer;">
  39. <span class="el-dropdown-link">个人中心</span>
  40. <el-dropdown-menu slot="dropdown">
  41. <el-dropdown-item>
  42. <router-link :to="{name: 'minePaycheck'}">充值</router-link>
  43. </el-dropdown-item>
  44. <el-dropdown-item>
  45. <router-link :to="{name: 'mineWallet'}">我的钱包</router-link>
  46. </el-dropdown-item>
  47. <el-dropdown-item @click.native="updatePasswordHandle()">修改密码</el-dropdown-item>
  48. <el-dropdown-item @click.native="logoutHandle()">退出</el-dropdown-item>
  49. </el-dropdown-menu>
  50. </el-dropdown>
  51. </template>
  52. <template v-else>
  53. <router-link :to="{name: 'login'}" replace>登录</router-link>
  54. <router-link :to="{name: 'register'}" replace>/注册</router-link>
  55. </template>
  56. </div>
  57. <!-- 弹窗, 修改密码 -->
  58. <update-password v-if="updatePassowrdVisible" ref="updatePassowrd"/>
  59. </nav>
  60. </template>
  61. <script>
  62. import UpdatePassword from './main-navbar-update-password'
  63. import { clearLoginInfo } from '@/utils'
  64. import Vue from 'vue'
  65. export default {
  66. components: {
  67. UpdatePassword
  68. },
  69. data () {
  70. return {
  71. updatePassowrdVisible: false
  72. }
  73. },
  74. computed: {
  75. token () {
  76. return this.$store.state.user.token || Vue.cookie.get('token')
  77. }
  78. },
  79. methods: {
  80. // 修改密码
  81. updatePasswordHandle () {
  82. this.updatePassowrdVisible = true
  83. this.$nextTick(() => {
  84. this.$refs.updatePassowrd.init()
  85. })
  86. },
  87. // 退出
  88. logoutHandle () {
  89. this.$confirm(`确定进行[退出]操作?`, '提示', {
  90. confirmButtonText: '确定',
  91. cancelButtonText: '取消',
  92. type: 'warning'
  93. }).then(() => {
  94. this.$http({
  95. url: this.$http.adornUrl('/user/loginout'),
  96. method: 'post',
  97. data: this.$http.adornData()
  98. }).then(({ data }) => {
  99. if (data.status) {
  100. clearLoginInfo()
  101. this.$router.push({ name: 'login' })
  102. }
  103. })
  104. }).catch(() => {})
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .site-navbar {
  111. display: flex;
  112. justify-content: space-between;
  113. align-items: center;
  114. padding: 0 10%;
  115. background: #fff;
  116. .TT-nav {
  117. flex: 1;
  118. display: flex;
  119. align-items: center;
  120. list-style: none;
  121. li {
  122. display: flex;
  123. justify-content: center;
  124. width: 12.5%;
  125. padding: 0 20px;
  126. }
  127. }
  128. }
  129. a {
  130. display: block;
  131. font-size: 16px;
  132. color: #666;
  133. text-decoration: none;
  134. }
  135. </style>