<template>
  <div class="AiOpenData" :type="type" :openid="oid"/>
</template>

<script>
import {mapActions} from "vuex";

export default {
  name: "AiOpenData",
  props: ['type', 'openid'],
  computed: {
    oid() {
      /**
       * 后端返回格式(cropId|userId)
       */
      return this.openid?.split("|")?.[1] || this.openid || ""
    }
  },
  methods: {
    ...mapActions(['initOpenData']),
  },
  watch: {
    openid: {
      handler(v) {
        v && this.initOpenData()
      },
      immediate: true
    }
  }
}
</script>
