nav-logo.vue 1.6 KB

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