Files
BlockChainH5/pages/wxAuth/wxAuth.vue

47 lines
796 B
Vue

<template>
<view class="content vertical">
<u-loading mode="flower"></u-loading>
</view>
</template>
<script>
import { wxCode, wxOpenid } from '@/apis/interfaces/wx'
export default {
data() {
return {
};
},
created() {
// 微信鉴权
if(!this.$Route.query.code){
wxCode({
pages: 'wechat-auth'
}).then(res => {
window.location.href = res
})
}else{
wxOpenid({
code: this.$Route.query.code
}).then(res => {
this.$store.commit('setCode', res.openid)
this.$Router.replaceAll({name: 'Index'})
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
}
}
}
</script>
<style lang="scss">
.content{
background: white;
height: 100vh;
text-align: center;
}
</style>