<template>
  <div>
    <div class="btn_content">
      <b-button size="lg" variant="primary" @click="handleClick">{{
        state ? "停止扫描" : "开始扫描"
      }}</b-button>
    </div>
    <b-modal
      v-model="is_show"
      centered
      scrollable
      no-close-on-backdrop
      no-close-on-esc
      hide-header
    >
      <p>
        {{ list.toString() }}
      </p>
      <div slot="modal-footer">
        <b-button @click="handleCancel">取消</b-button>
      </div>
    </b-modal>
  </div>
</template>
<script>
export default {
  data() {
    return {
      state: false,
      is_show: false,
      list: []
    }
  },
  mounted() {
    console.log(111);
    window.uploadEPC = this.uploadEPC;
  },
  methods: {
    uploadEPC(e) {

      this.list.push(JSON.stringify(e + ''));
    },
    handleClick() {
      this.state = !this.state
      if (this.state) {
        androidJs.startInventory();
      } else {
        androidJs.stopInventory();
        this.is_show = true;
      }
    },
    handleCancel() {
      this.is_show = false
    }
  }
}
</script>
<style lang="scss" scoped>
.btn_content {
  text-align: center;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  transform: translate(-50%, -100%);
}
</style>