vue判断微信登录公众号退出登录
微信公众号退出问题
1、判断是否是微信端登录
main.js
Vue.prototype.isWx = () => {
let ua = navigator.userAgent.toLowerCase()
return (/micromessenger/.test(ua))
}
2、退出按钮
logout () {
let vm = this
this.$http.get(this.base + 'logout?token=' + this.$store.getters.get_token).then(res => {
if (res.data.code === 200) {
if (vm.isWx()) {
this.$store.commit('set_token', '')
location.assign('https://') // 微信登录地址
this.showOut = false
} else {
this.$store.commit('set_token', '')
this.$router.push('/')
this.showOut = false
}
} else {
}
}).catch(err => {
console.log(err)
})
}