<template>
	<u-loading-page loading-color="#000000" :loading="true" loadingText="正在请求微信授权"></u-loading-page>
</template>

<script>
	import qs from 'qs';
	export default {
		data() {
			return {
			}
		},
		onLoad(option){
			let { shiYuWxLogin , username : userName } = option;
			if(shiYuWxLogin){
				uni.redirectTo({
					url : "/pages/login/index?shiYuWxLogin=" + shiYuWxLogin,
				})
			}else if(userName){
				uni.$u.api.shiYuWxLoginGetInfo({userName}).then((res)=>{
					const { access_token } = res.data;
					this.$store.commit("user/SET_TOKEN", access_token);
					this.$store.dispatch("user/getUserInfo").then(()=>{
						uni.reLaunch({
							url:"/pages/bindSuccess/index",
						});
						// uni.switchTab({
						// 	url: `/pages/person/index`,
						// 	success: () => {
						// 		this.$store.dispatch("app/register");
						// 		uni.$u.toast("登录成功");
						// 	}
						// })
					})
				})
			}else{
				window.location.href = "https://crm.nanjingshiyu.com/prod-api/auth/shiYuWxLogin";
			}
		},
	}
</script>

<style lang="scss" scoped>
</style>