<template>
  <view>
    <u-navbar
      :class="title ? 'navbarL' : 'navbarC'"
      :is-back="false"
      :title="title"
      :border-bottom="false"
      title-color="#333333"
      back-icon-color="#ffffff"
    >
      <view class="slot-wrap">
        <!-- #ifdef H5 -->
        <img :src="$method.splitImgHost(config.h5Logo)" alt="" srcset="" />
        <!-- #endif -->
        <!-- #ifdef MP-WEIXIN -->
        <image
          :src="$method.splitImgHost(config.h5Logo)"
          @load="load"
          :style="{ width: imgwidth + 'rpx', height: imgheight + 'rpx' }"
        />
        <!-- #endif -->
      </view>
    </u-navbar>
  </view>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  name: "NavLogo",
  props: {
    title: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      imgwidth: 0,
      imgheight: 0,
    };
  },

  mounted() {},
  computed: {
    ...mapGetters(["userInfo", "config"]),
  },
  methods: {
    load(e) {
      this.imgwidth = e.detail.width * 2;
      this.imgheight = e.detail.height * 2;
    },
  },
};
</script>

<style lang="scss" scoped>
.navbarL {
  image {
    margin-left: 30rpx;
  }
  img {
    margin-left: 30rpx;
  }
}
.navbarC {
  /deep/ .u-navbar-inner {
    margin-right: 0 !important;
  }

  .slot-wrap {
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;

    image {
      width: 178rpx;
      height: 31rpx;
    }
  }
}
</style>
