微信登录问题修复

This commit is contained in:
aixianling
2021-11-29 11:56:32 +08:00
parent f0f3ebf7b7
commit 21cb522b73
2 changed files with 52 additions and 46 deletions

View File

@@ -8,22 +8,53 @@
</template>
<script>
import {mapState} from "vuex";
import {mapActions, mapState} from "vuex";
import FormDetail from "./formDetail";
import AiResult from "../../components/AiResult";
export default {
name: "AppForm",
appName: "问卷表单",
inject: {root: {}},
components: {AiResult, FormDetail},
data() {
return {
access: false
}
},
computed: {
...mapState(['openUser', 'user']),
...mapState(['user', 'token']),
showDetail() {
return !!this.$route.query?.id
return !!this.$route.query?.id && this.access
},
errMsg() {
return this.showDetail ? "加载表单中..." : "表单不存在"
return this.access ? "表单不存在" : "无法获取用户信息"
},
isPreview() {
return !!this.$route.query?.preview
}
},
methods: {
...mapActions(['getCode', 'getToken']),
checkAccess() {
let {corpId, code, suiteId} = this.$route.query
if (this.isPreview) {
this.access = true
} else if (!!this.token) {
this.access = true
} else if (code) {
this.getToken({code, corpId, suiteId, isAppForm: true}).then(() => {
let {query, path, hash} = this.$route
delete query.code
this.root.goto({query, path, hash})
})
} else {
this.getCode({corpId, url: location.href})
}
},
},
created() {
this.checkAccess()
}
}
</script>