nav-logo.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <view>
  3. <u-navbar :class="title ? 'navbarL' : 'navbarC'" :is-back="false" :title="title" :border-bottom="false"
  4. :height="height" title-color="#ffffff" back-icon-color="#ffffff" :background="background">
  5. <view class="slot-wrap" v-if="isShowLogo">
  6. <image :src="$method.splitImgHost(config.h5Logo)" @load="load"
  7. :style="{ width: imgwidth + 'rpx', height: imgheight + 'rpx' }" />
  8. </view>
  9. </u-navbar>
  10. </view>
  11. </template>
  12. <script>
  13. import {
  14. mapGetters
  15. } from "vuex";
  16. export default {
  17. name: "NavLogo",
  18. props: {
  19. title: {
  20. type: String,
  21. default: "",
  22. },
  23. isShowLogo: {
  24. type: Boolean,
  25. default: false,
  26. },
  27. },
  28. data() {
  29. return {
  30. height: 50,
  31. imgwidth: 0,
  32. imgheight: 0,
  33. background: {
  34. backgroundColor: 'rgb(0, 122, 255)',
  35. }
  36. };
  37. },
  38. mounted() {},
  39. computed: {
  40. ...mapGetters(["userInfo", "config"]),
  41. },
  42. methods: {
  43. load(e) {
  44. console.log(e, 'e')
  45. this.imgwidth = e.detail.width;
  46. this.imgheight = e.detail.height;
  47. },
  48. },
  49. };
  50. </script>
  51. <style lang="scss" scoped>
  52. .navbarL {
  53. image {
  54. margin-left: 20rpx;
  55. }
  56. img {
  57. margin-left: 20rpx;
  58. }
  59. }
  60. .navbarC {
  61. /deep/ .u-navbar-inner {
  62. margin-right: 0 !important;
  63. }
  64. .slot-wrap {
  65. width: 100vw;
  66. display: flex;
  67. align-items: center;
  68. image {
  69. margin-left: 20rpx;
  70. width: 178rpx;
  71. height: 31rpx;
  72. }
  73. }
  74. }
  75. </style>