123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <template>
- <view class="top">
- <view class="left">
- <image src="../static/logo.png" mode="widthFix" class="img"></image>
- <view class="nav">
- <text class="text" @click="clickIndex" :class="type=='index'?'navactive':''">首页</text>
- <text class="text" @click="toProduct" :class="type=='product'?'navactive':''">产品介绍</text>
- <text class="text" @click="toAboutUs" :class="type=='aboutUs'?'navactive':''">关于我们</text>
- </view>
- </view>
- <view class="right-content" v-if='hasLogin'>
- <view class="phone" @click="phoneClick">
- <image :src="userInfo.avatarUrl" class="img"></image>
- <view class="">
- {{userInfo.phone}}
- </view>
- </view>
- <view class="out-view" v-if="isSHowUser">
- <view class="text" @click="userClick">
- 个人中心
- </view>
- <view class="text" @click="logOut">
- 退出
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- mapState
- } from 'vuex';
- export default {
- name: 'top',
- emits: ['click'],
- props: {
- type: {
- type: String,
- default: ''
- },
- },
- data() {
- return {
- isSHowPhone: true,
- isSHowUser: false,
- }
- },
- watch: {
- title(newVal) {
- if (uni.report && newVal !== '') {
- uni.report('title', newVal)
- }
- }
- },
- computed: {
- ...mapState(['hasLogin', 'userInfo']),
- },
- methods: {
- logOut() {
- uni.clearStorageSync();
- var that = this
- this.$store.commit('logout')
- uni.navigateTo({
- url: `/pages/index/index`
- })
- },
- phoneClick() {
- this.isSHowUser = !this.isSHowUser
- },
- onClick() {
- this.$emit('click')
- },
- clickIndex() {
- uni.navigateTo({
- url: "/pages/index/index"
- })
- },
- userClick() {
- uni.navigateTo({
- url: "/pages/index/user"
- })
- },
- toProduct() {
- uni.navigateTo({
- url: "/pages/index/product"
- })
- },
- toAboutUs() {
- uni.navigateTo({
- url: "/pages/index/aboutUs"
- })
- },
- }
- }
- </script>
- <style lang="scss">
- .navactive {
- color: #2F54EF !important;
- }
- .img {
- width: 200rpx;
- }
- .right-content {
- position: relative;
- .phone {
- display: flex;
- align-items: center;
- position: relative;
- cursor: pointer;
- }
- .img {
- width: 64rpx;
- height: 64rpx;
- border-radius: 50%;
- margin-right: 10px;
- }
- .out-view {
- position: absolute;
- bottom: -80px;
- left: 45px;
- z-index: 2;
- width: 182rpx;
- height: 148rpx;
- background: #FFFFFF;
- box-shadow: 0px 2px 20px 0px rgba(0, 0, 0, 0.1);
- border-radius: 12px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .text {
- font-size: 28rpx;
- font-weight: 400;
- color: #333333;
- line-height: 20px;
- cursor: pointer;
- }
- }
- }
- .top {
- display: flex;
- align-items: center;
- background: white;
- justify-content: space-between;
- padding: 66rpx 10%;
- min-width: 1200px;
- box-sizing: border-box;
- .left {
- display: flex;
- .nav {
- margin-left: 200rpx;
- }
- }
- // color: white;
- // background: black
- }
- .title {
- margin: 0 40rpx;
- }
- .nav {
- display: flex;
- align-items: center;
- .text {
- font-size: 16px;
- color: #65676B;
- margin-right: 200rpx;
- }
- }
- </style>
|