Files
dvcp_v2_wxcp_app/src/components/AiOpenData.vue
aixianling 8f7d0c3a84 BUG 25277
2021-12-08 09:24:04 +08:00

38 lines
769 B
Vue

<template>
<div :type="type" :openid="oid" v-text="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(['injectJWeixin']),
bindWWOpenData() {
if (window?.WWOpenData) WWOpenData.bind(this.$el)
else this.injectJWeixin().then(() => {
this.$nextTick(() => {
WWOpenData.bind(this.$el)
WWOpenData.on('update', () => {
WWOpenData.bind(this.$el)
})
})
})
}
},
mounted() {
this.bindWWOpenData()
}
}
</script>