<template>
  <BaseSameLayer
    :hosSameLayerArgs="hosSameLayerArgs"
    embedType="native/midea-audio-wave-view"
    :defaultWidth="300"
    :defaultHeight="300"
    ref="audioWaveRef"
  ></BaseSameLayer>
</template>

<script>
import BaseSameLayer from "./baseSameLayer.vue";
const weexModule = weex.requireModule('weexModule');

export default {
  name: "mideaAudioWaveView",
  data() {
    return {
      width: 0,
      height: 0
    }
  },
  components: {
    BaseSameLayer,
  },
  props: {
    hosUniqueProps: {
      type: Object,
      default() {
        return {};
      },
    },
    data: {
      type: Object,
      default() {
        return {
          embedId:''
        };
      },
    },
  },
  computed: {
    hosSameLayerArgs() {
      return {
        ...this.hosUniqueProps, // 鸿蒙原生组件独有属性
        width: this.width,
        height: this.height,
        data: this.data,
        updateVolume: this.updateVolume,
      };
    },
  },
  mounted() {
    this.width = this.$el.clientWidth;
    this.height = this.$el.clientHeight;
    this.embedId = this.$refs.audioWaveRef.embedId;
  },

  methods: {
    updateVolume(volume) {
      weexModule.callNative(
        'audioWaveHandle',
        {
          method: 'updateVolume',
          name: this.embedId,
          volume
        },
      );
    },
  },
};
</script>
