<template>
	<view style="display: flex;align-items: center;justify-content: center;height: 100vh;">
		<!-- <image src="../../static/logo.png" style="width: 90px;height:80px"></image> -->
		 <!-- <tn-loading mode="circle" size="60"></tn-loading> -->

	</view>
	
</template>

<script>
	import request from '../../utils/request'
	
	export default {
		name: 'Auth',
		data() {
			return {
				
			}
		},
		created() {		
			uni.reLaunch({
				url:'/pages/index/index'
			})
		},
		methods: {
			loginByCode(frontId) {
				const that = this;
				uni.setStorageSync('loginStatus', 'false');
				wx.getUserInfo({
				  success: function(res) {
					console.error(res);
					request.post("/slbMpAutoLogin", {
					 		code:frontId, 
					 	    appType:'ma',
							encryptedData:res.encryptedData,
							iv: res.iv
					 	}, {
						login: false,
						warn:false,
						loading:false
					}).then(res2=>{
						console.error(res2);
						if(res2.success){
							//登录成功
							uni.setStorageSync('loginStatus', 'true');
							uni.setStorageSync('userMap', JSON.stringify(res2.resultMap));
							uni.setStorageSync('userNo', res2.resultMap.accountName);
							that.getUserInfo();
						}else{
							console.error(12345);
							uni.setStorageSync('loginStatus', 'false');
							uni.removeStorageSync('userMap');
							uni.removeStorageSync('userNo');
							uni.removeStorageSync('userInfo');
							uni.reLaunch({
								url:'/pages/index/index'
							})
							//登录失败,
							// uni.login({
							// 	success(res) {
							// 		 console.error(res);
							// 		 that.getOpenId(res.code);
							// 	},
							// 	fail(res) {
							// 		 console.error(res);
							// 		uni.hideLoading();
							// 	}
							// });
							 
						}
						console.error(res2);
					});
					 
					 
				  }
				})
				 
				
			},
			getUserInfo() {
					  let that = this;
					  request.post('/slbWxma/getPersonlInfo', {
					  	 
					  }).then(res => {
							  console.warn(res);
							  if(res&&res.success){
								  that.personInfo = res.resultMap.userInfo||{};
								  uni.setStorageSync('userInfo', JSON.stringify(res.resultMap.userInfo));
								  uni.reLaunch({
								  	url:'/pages/index/index'
								  })
							  }else{
								  uni.reLaunch({
								  	url:'/pages/index/index'
								  })
							  }
					  	console.warn(res);
					  })
			   
			},
		}
	}
</script>

<style>

</style>
