top.vue 3.4 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.isSHowUser=false
  64. this.$store.commit('logout')
  65. uni.navigateTo({
  66. url: `/pages/index/index`
  67. })
  68. },
  69. phoneClick() {
  70. this.isSHowUser = !this.isSHowUser
  71. },
  72. onClick() {
  73. this.$emit('click')
  74. },
  75. clickIndex() {
  76. uni.navigateTo({
  77. url: "/pages/index/index"
  78. })
  79. },
  80. userClick() {
  81. uni.navigateTo({
  82. url: "/pages/index/user"
  83. })
  84. },
  85. toProduct() {
  86. uni.navigateTo({
  87. url: "/pages/index/product"
  88. })
  89. },
  90. toAboutUs() {
  91. uni.navigateTo({
  92. url: "/pages/index/aboutUs"
  93. })
  94. },
  95. toSupport() {
  96. uni.navigateTo({
  97. url: "/pages/index/support"
  98. })
  99. },
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. .navactive {
  105. color: #2F54EF !important;
  106. }
  107. .img {
  108. width: 200rpx;
  109. }
  110. .right-content {
  111. position: relative;
  112. .phone {
  113. display: flex;
  114. align-items: center;
  115. position: relative;
  116. cursor: pointer;
  117. }
  118. .img {
  119. width: 64rpx;
  120. height: 64rpx;
  121. border-radius: 50%;
  122. margin-right: 10px;
  123. }
  124. .out-view {
  125. position: absolute;
  126. bottom: -80px;
  127. left: 45px;
  128. z-index: 2;
  129. width: 182rpx;
  130. height: 148rpx;
  131. background: #FFFFFF;
  132. box-shadow: 0px 2px 20px 0px rgba(0, 0, 0, 0.1);
  133. border-radius: 12px;
  134. display: flex;
  135. flex-direction: column;
  136. justify-content: center;
  137. align-items: center;
  138. .text {
  139. font-size: 28rpx;
  140. font-weight: 400;
  141. color: #333333;
  142. line-height: 20px;
  143. cursor: pointer;
  144. }
  145. }
  146. }
  147. .top {
  148. display: flex;
  149. align-items: center;
  150. background: white;
  151. justify-content: space-between;
  152. padding: 66rpx 10%;
  153. min-width: 1200px;
  154. box-sizing: border-box;
  155. .left {
  156. display: flex;
  157. .nav {
  158. margin-left: 200rpx;
  159. }
  160. }
  161. // color: white;
  162. // background: black
  163. }
  164. .title {
  165. margin: 0 40rpx;
  166. }
  167. .nav {
  168. display: flex;
  169. align-items: center;
  170. .text {
  171. font-size: 16px;
  172. color: #65676B;
  173. margin-right: 200rpx;
  174. cursor: pointer;
  175. }
  176. }
  177. </style>