退出页面强制清除登录状态和token

This commit is contained in:
aixianling
2023-01-03 10:39:43 +08:00
parent 57c2ddf631
commit 9e490d3e4d

View File

@@ -14,7 +14,7 @@
</template> </template>
<script> <script>
import {mapState, mapActions} from "vuex" import {mapState, mapActions, mapMutations} from "vuex"
export default { export default {
name: "voteDetail", name: "voteDetail",
@@ -22,7 +22,7 @@ export default {
computed: { computed: {
...mapState(['user']), ...mapState(['user']),
wxCode: v => v.$route.query.code, wxCode: v => v.$route.query.code,
canotVote: v => v.detail.isVote == '0' && v.user.token canotVote: v => !!v.user.token && v.detail.isVote == '0'
}, },
data() { data() {
return { return {
@@ -31,9 +31,10 @@ export default {
}, },
methods: { methods: {
...mapActions(['getWechatToken', 'getCode']), ...mapActions(['getWechatToken', 'getCode']),
...mapMutations(['setToken']),
getDetail() { getDetail() {
const {id} = this.$route.query const {id} = this.$route.query
this.$http.post("/app/appvideoinfo/queryDetailById", null, {params: {id}, withoutToken: true}).then(res => { this.$http.post("/app/appvideoinfo/queryDetailById", null, {params: {id}, withoutToken: !this.user.token}).then(res => {
if (res?.data) { if (res?.data) {
this.detail = res.data this.detail = res.data
document.title = this.detail.videoName document.title = this.detail.videoName
@@ -67,6 +68,9 @@ export default {
if (!!this.wxCode) { if (!!this.wxCode) {
this.getWechatToken({module: "AppVote", code: this.wxCode}).then(this.handleVote) this.getWechatToken({module: "AppVote", code: this.wxCode}).then(this.handleVote)
} }
},
destroyed() {
this.setToken(null)
} }
} }
</script> </script>