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-15 14:12:56 +08:00
|
|
|
window?.WWOpenData?.checkSession({
|
|
|
|
|
success: () => {
|
2021-12-08 09:24:04 +08:00
|
|
|
WWOpenData.bind(this.$el)
|
2021-12-15 14:12:56 +08:00
|
|
|
},
|
|
|
|
|
fail: () => {
|
2021-12-16 15:20:14 +08:00
|
|
|
this.injectJWeixin().then(() => {
|
2021-12-15 14:12:56 +08:00
|
|
|
WWOpenData.bind(this.$el)
|
|
|
|
|
})
|
|
|
|
|
}
|
2021-12-16 15:20:14 +08:00
|
|
|
}) || this.injectJWeixin().then(() => {
|
|
|
|
|
WWOpenData.bind(this.$el)
|
2021-12-08 09:24:04 +08:00
|
|
|
})
|
|
|
|
|
}
|
2021-11-24 16:34:31 +08:00
|
|
|
},
|
2021-12-15 14:12:56 +08:00
|
|
|
watch: {
|
|
|
|
|
openid(v) {
|
|
|
|
|
v && this.bindWWOpenData()
|
|
|
|
|
}
|
|
|
|
|
},
|
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>
|