Files
dvcp_v2_wxcp_app/src/components/AiOpenData.vue

38 lines
723 B
Vue
Raw Normal View History

2021-11-24 16:34:31 +08:00
<template>
2021-12-03 15:18:13 +08:00
<div :type="type" :openid="oid" v-text="oid"/>
2021-11-24 16:34:31 +08:00
</template>
<script>
import {mapActions} from "vuex";
export default {
name: "AiOpenData",
props: ['type', 'openid'],
2021-12-03 15:18:13 +08:00
computed: {
oid() {
/**
* 后端返回格式(cropId|userId)
*/
return this.openid?.split("|")?.[1] || this.openid || ""
}
},
2021-11-24 16:34:31 +08:00
methods: {
2021-12-08 09:24:04 +08:00
...mapActions(['injectJWeixin']),
bindWWOpenData() {
2021-12-08 18:01:40 +08:00
if (window.WWOpenData) {
WWOpenData.bind(this.$el)
} else this.injectJWeixin().then(() => {
2021-12-08 09:24:04 +08:00
this.$nextTick(() => {
WWOpenData.bind(this.$el)
})
})
}
2021-11-24 16:34:31 +08:00
},
mounted() {
2021-12-08 18:01:40 +08:00
this.$nextTick(() => {
this.bindWWOpenData()
})
2021-11-24 16:34:31 +08:00
}
}
</script>