33 lines
1.0 KiB
Vue
33 lines
1.0 KiB
Vue
<template>
|
|
<web-view :src="webSrc" @load="bindLoad" @message="receptMessage"></web-view>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
import { ref } from 'vue';
|
|
import {postRegister} from "@/api/user";
|
|
const webSrc=ref('')
|
|
onLoad((option)=>{
|
|
webSrc.value =`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${option.appId}&redirect_uri=${encodeURI(option.url)}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`
|
|
})
|
|
const bindLoad=(e)=>{
|
|
let code =e.detail.src.split('=')[1].split('&')[0]
|
|
let XcxId = uni.getStorageSync('XCXID')
|
|
postRegister({
|
|
XcxId,
|
|
Code: code
|
|
}).then((res :any)=> {
|
|
console.log('注册', res);
|
|
if (res.Code == 200) {
|
|
uni.setStorageSync('TokenType', res.Data.TokenType)
|
|
uni.setStorageSync('HAS_STUDENT', res.Data.user.HasStudent)
|
|
uni.setStorageSync('token', res.Data.AccessToken)
|
|
}
|
|
})
|
|
}
|
|
const receptMessage=(e :any)=>{
|
|
console.log('接受消息',e);
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
</style> |