Files
dvcp_v2_wxcp_app/src/components/AiOpenData.vue

61 lines
1.0 KiB
Vue
Raw Normal View History

2021-11-24 16:34:31 +08:00
<template>
2021-12-08 11:18:24 +08:00
<div :type="type" :openid="oid">
<div class="loading" v-text="`读取中...`"/>
</div>
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 11:18:24 +08:00
if (window?.WWOpenData) {
WWOpenData.bind(this.$el)
} else {
this.injectJWeixin().then(() => {
this.$nextTick(() => {
2021-12-08 09:24:04 +08:00
WWOpenData.bind(this.$el)
})
})
2021-12-08 11:18:24 +08:00
}
}
},
watch: {
openid(v) {
v && this.bindWWOpenData()
2021-12-08 09:24:04 +08:00
}
2021-11-24 16:34:31 +08:00
},
mounted() {
2021-12-08 09:24:04 +08:00
this.bindWWOpenData()
2021-11-24 16:34:31 +08:00
}
}
</script>
2021-12-08 11:18:24 +08:00
<style lang="scss" scoped>
.loading {
color: transparent;
height: 100%;
animation: loading 1s infinite alternate;
}
@keyframes loading {
from {
background: rgba(#eee,.6);
}
to {
background: rgba(#eee,.2);
}
}
</style>