NsHeaderTop.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div>
  3. <div class="header-top">
  4. <div class="top-content">
  5. <div class="top-left">
  6. <div class="left-item collect" @click="addFavorite">
  7. <span class="iconfont icon-shouzang"></span>
  8. <span>收藏本站</span>
  9. </div>
  10. </div>
  11. <div class="top-right">
  12. <div class="member-info" v-if="logined">
  13. <router-link to="/member">{{ member.nickname || member.username }}</router-link>
  14. <a @click="logout">退出</a>
  15. </div>
  16. <div class="member-info" v-if="!logined">
  17. <router-link to="/auth/login">登录</router-link>
  18. <router-link to="/auth/register">注册</router-link>
  19. </div>
  20. <router-link to="/cms/notice/list"><span class="announcement iconfont icon-xiaoxi"></span></router-link>
  21. <router-link to="/member/order_list">我的订单</router-link>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import {
  29. mapGetters
  30. } from "vuex"
  31. import {
  32. getToken
  33. } from "@/utils/auth"
  34. export default {
  35. props: {},
  36. data() {
  37. return {}
  38. },
  39. created() {
  40. this.$store.dispatch("member/member_detail")
  41. this.$store.dispatch("site/defaultFiles")
  42. this.$store.dispatch("site/addons")
  43. },
  44. mounted() {},
  45. watch: {},
  46. methods: {
  47. logout() {
  48. this.$store.dispatch("member/logout")
  49. this.$router.push('/');
  50. },
  51. //收藏本站
  52. addFavorite() {
  53. let title = "Niushop PC端",
  54. url = window.location.href;
  55. try {
  56. window.external.addFavorite(url, title);
  57. }
  58. catch (e) {
  59. try {
  60. window.sidebar.addPanel(title, url, "");
  61. }
  62. catch (e) {
  63. alert("抱歉,您所使用的浏览器无法完成此操作。\n\n加入收藏失败,请使用Ctrl+D进行添加");
  64. }
  65. }
  66. }
  67. },
  68. components: {},
  69. computed: {
  70. ...mapGetters(["wapQrcode", "member", "addonIsExit"]),
  71. logined: function() {
  72. return this.member !== undefined && this.member !== "" && this.member !== {}
  73. }
  74. }
  75. }
  76. </script>
  77. <style scoped lang="scss">
  78. // 公共部分
  79. %line{
  80. content: "";
  81. position: absolute;
  82. left: -2px;
  83. top: 50%;
  84. transform: translateY(-50%);
  85. width: 1px;
  86. height: 12px;
  87. }
  88. .header-top {
  89. width: 100%;
  90. height: 44px;
  91. font-size: 12px;
  92. background-color: #242424;
  93. .el-dropdown {
  94. font-size: $ns-font-size-sm;
  95. }
  96. .top-content {
  97. display: flex;
  98. align-items: center;
  99. width: $width;
  100. height: 100%;
  101. margin: 0 auto;
  102. .left-item{
  103. &.collect{
  104. display: flex;
  105. align-items: center;
  106. cursor: pointer;
  107. color: #b4b4b4;
  108. span:nth-child(1){
  109. font-weight: bold;
  110. line-height: 1;
  111. }
  112. span:nth-child(2){
  113. margin-left: 5px;
  114. font-size: 14px;
  115. line-height: 1;
  116. }
  117. &:hover{
  118. color: $base-color;
  119. }
  120. }
  121. }
  122. .top-right {
  123. display: flex;
  124. align-items: center;
  125. margin-left: auto;
  126. a {
  127. position: relative;
  128. padding: 20px 18px;
  129. color: #b4b4b4;
  130. font-size: 14px;
  131. &:hover {
  132. color: $base-color;
  133. }
  134. .iconfont{
  135. font-size: 18px;
  136. font-weight: bold;
  137. color: #fff;
  138. }
  139. .announcement{
  140. position: absolute;
  141. animation:mymove 3s infinite;
  142. position: absolute;
  143. top: 12px;
  144. left: 9px;
  145. line-height: 1;
  146. }
  147. @keyframes mymove {
  148. 5%,25%,45% {
  149. transform:rotate(8deg)
  150. }
  151. 0%,10%,30%,50% {
  152. transform:rotate(-8deg)
  153. }
  154. 15%,35%,55% {
  155. transform:rotate(4deg)
  156. }
  157. 20%,40%,60% {
  158. transform:rotate(-4deg)
  159. }
  160. 65%,to {
  161. transform:rotate(0deg)
  162. }
  163. }
  164. }
  165. &>a:nth-last-child(1):after,
  166. &>a:nth-last-child(2):after {
  167. @extend %line;
  168. background-color: #404040;
  169. }
  170. &>a:nth-last-child(2):after {
  171. left: 1px;
  172. }
  173. .member-info {
  174. padding: 0 10px;
  175. > a{
  176. position: relative;
  177. padding: 0;
  178. &:last-of-type{
  179. padding-left: 8px;
  180. margin-left: 2px;
  181. &::after{
  182. @extend %line;
  183. left: 0;
  184. background-color: #b4b4b4;
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. }
  192. .mobile-qrcode {
  193. padding: 10px 0;
  194. }
  195. .router-link-active {
  196. color: $base-color;
  197. }
  198. </style>