| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <template>
- <view class="ss-header" :class="{ spread: spread }" :style="{ paddingTop: navBarHeight + 'px' }">
- <view class="header-left" :class="{ show: showLogo }">
- <view class="menus" :class="{ open: switchMenu }" @tap="toggleMenus">
- <view class="menus-line left"></view>
- <image class="menus-arrow" mode="aspectFill" :src="getStaticImageUrl('/images/header-menu-arrow.png')"></image>
- <view class="menus-line right"></view>
- </view>
- <image class="logo" mode="aspectFill" src="/static/images/logo-round.png" @tap="goHome"></image>
- <view class="title">商小川</view>
- </view>
- </view>
- </template>
- <script>
- import { useGlobalStore } from '@/stores/global';
- import { MessageApi } from '@/api/message';
- export default {
- name: 'SsHeader',
- data() {
- return {
- globalStore: useGlobalStore(),
- navBarHeight: 0,
- showLogo: false
- };
- },
- computed: {
- spread() {
- return this.globalStore.spread;
- },
- switchMenu() {
- return this.globalStore.menuSwitch;
- }
- },
- mounted() {
- this.calculateNavBarHeight();
- },
- methods: {
- calculateNavBarHeight() {
- const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
- this.navBarHeight = menuButtonInfo.top + 1;
- setTimeout(() => {
- this.showLogo = true;
- this.globalStore.setPaddingTop(this.navBarHeight + menuButtonInfo.height);
- }, 100);
- },
- toggleMenus() {
- this.globalStore.toggleMenuSwitch();
- },
- goHome() {
- this.globalStore.setMenuSwitch(false);
- this.globalStore.setSpread(false);
- this.globalStore.setChatLoading(false);
- MessageApi.stop();
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .ss-header {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- z-index: 1000;
- padding: 0 32rpx 0 32rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .header-left {
- display: none;
- align-items: center;
- transition: padding-left 0.3s linear;
- .menus {
- display: none;
- align-items: center;
- justify-content: space-between;
- width: 46rpx;
- height: 42rpx;
- margin-right: 32rpx;
- border-top: 4rpx solid #101333;
- border-bottom: 4rpx solid #101333;
- .menus-line {
- height: 12rpx;
- border-top: 4rpx solid #101333;
- border-bottom: 4rpx solid #101333;
- transition: width 0.3s linear;
- &.left {
- width: 0;
- margin-left: 2rpx;
- }
- &.right {
- margin-right: 2rpx;
- width: calc(100% - 22rpx);
- }
- }
- .menus-arrow {
- width: 16rpx;
- height: 14rpx;
- margin-left: 0;
- margin-right: 4rpx;
- transition: transform 0.3s linear;
- }
- &.open {
- .menus-line {
- &.left {
- width: calc(100% - 20rpx);
- }
- &.right {
- width: 0;
- }
- }
- .menus-arrow {
- margin-left: 4rpx;
- margin-right: 0;
- transform: rotateY(180deg);
- }
- }
- }
- .logo {
- width: 60rpx;
- height: 60rpx;
- border-radius: 12rpx;
- margin-right: 16rpx;
- }
- .title {
- color: #101333;
- font-size: 32rpx;
- line-height: 32rpx;
- font-weight: bold;
- }
- &.show {
- display: flex;
- }
- }
- &.spread {
- .header-left {
- .menus {
- display: flex;
- }
- }
- }
- }
- </style>
|