top.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="top">
  3. <view class="left">
  4. <image src="../static/logo.png" mode="widthFix" class="img"></image>
  5. <view class="nav">
  6. <text class="text" @click="clickIndex" :class="type=='index'?'navactive':''">首页</text>
  7. <text class="text" @click="toProduct" :class="type=='product'?'navactive':''">产品介绍</text>
  8. <text class="text" @click="toAboutUs" :class="type=='aboutUs'?'navactive':''">关于我们</text>
  9. <text class="text" @click="toSupport" :class="type=='support'?'navactive':''">技术支持</text>
  10. </view>
  11. </view>
  12. <view class="right-content" v-if='hasLogin'>
  13. <view class="phone" @click="phoneClick">
  14. <image :src="userInfo.avatarUrl" class="img"></image>
  15. <view class="">
  16. {{userInfo.phone}}
  17. </view>
  18. </view>
  19. <view class="out-view" v-if="isSHowUser">
  20. <view class="text" @click="userClick">
  21. 个人中心
  22. </view>
  23. <view class="text" @click="logOut">
  24. 退出
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. mapState
  33. } from 'vuex';
  34. export default {
  35. name: 'top',
  36. emits: ['click'],
  37. props: {
  38. type: {
  39. type: String,
  40. default: ''
  41. },
  42. },
  43. data() {
  44. return {
  45. isSHowPhone: true,
  46. isSHowUser: false,
  47. }
  48. },
  49. watch: {
  50. title(newVal) {
  51. if (uni.report && newVal !== '') {
  52. uni.report('title', newVal)
  53. }
  54. }
  55. },
  56. computed: {
  57. ...mapState(['hasLogin', 'userInfo']),
  58. },
  59. methods: {
  60. logOut() {
  61. uni.clearStorageSync();
  62. var that = this
  63. this.$store.commit('logout')
  64. uni.navigateTo({
  65. url: `/pages/index/index`
  66. })
  67. },
  68. phoneClick() {
  69. this.isSHowUser = !this.isSHowUser
  70. },
  71. onClick() {
  72. this.$emit('click')
  73. },
  74. clickIndex() {
  75. uni.navigateTo({
  76. url: "/pages/index/index"
  77. })
  78. },
  79. userClick() {
  80. uni.navigateTo({
  81. url: "/pages/index/user"
  82. })
  83. },
  84. toProduct() {
  85. uni.navigateTo({
  86. url: "/pages/index/product"
  87. })
  88. },
  89. toAboutUs() {
  90. uni.navigateTo({
  91. url: "/pages/index/aboutUs"
  92. })
  93. },
  94. toSupport() {
  95. uni.navigateTo({
  96. url: "/pages/index/support"
  97. })
  98. },
  99. }
  100. }
  101. </script>
  102. <style lang="scss">
  103. .navactive {
  104. color: #2F54EF !important;
  105. }
  106. .img {
  107. width: 200rpx;
  108. }
  109. .right-content {
  110. position: relative;
  111. .phone {
  112. display: flex;
  113. align-items: center;
  114. position: relative;
  115. cursor: pointer;
  116. }
  117. .img {
  118. width: 64rpx;
  119. height: 64rpx;
  120. border-radius: 50%;
  121. margin-right: 10px;
  122. }
  123. .out-view {
  124. position: absolute;
  125. bottom: -80px;
  126. left: 45px;
  127. z-index: 2;
  128. width: 182rpx;
  129. height: 148rpx;
  130. background: #FFFFFF;
  131. box-shadow: 0px 2px 20px 0px rgba(0, 0, 0, 0.1);
  132. border-radius: 12px;
  133. display: flex;
  134. flex-direction: column;
  135. justify-content: center;
  136. align-items: center;
  137. .text {
  138. font-size: 28rpx;
  139. font-weight: 400;
  140. color: #333333;
  141. line-height: 20px;
  142. cursor: pointer;
  143. }
  144. }
  145. }
  146. .top {
  147. display: flex;
  148. align-items: center;
  149. background: white;
  150. justify-content: space-between;
  151. padding: 66rpx 10%;
  152. min-width: 1200px;
  153. box-sizing: border-box;
  154. .left {
  155. display: flex;
  156. .nav {
  157. margin-left: 200rpx;
  158. }
  159. }
  160. // color: white;
  161. // background: black
  162. }
  163. .title {
  164. margin: 0 40rpx;
  165. }
  166. .nav {
  167. display: flex;
  168. align-items: center;
  169. .text {
  170. font-size: 16px;
  171. color: #65676B;
  172. margin-right: 200rpx;
  173. cursor: pointer;
  174. }
  175. }
  176. </style>