<template>
	<view class="main">
		<view class="one">
			<image class="logo" :src="logoUrl"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				logoUrl: ""
			};
		},
		onLoad: async function() {
			const that = this;
			await that.searchConfig();
		},
		methods: {
			// 查询基本设置
			async searchConfig() {
				const that = this;
				let res = await that.$api(`/Config`, 'GET', {});
				if (res.errcode == '0') {
					that.$set(that, `logoUrl`, res.data.logo_url[0].url || '../../static/login.jpeg');
					uni.setStorage({
						key: 'config',
						data: res.data,
						success: function(res) {
							uni.getStorage({
								key: 'token',
								success: function(res) {
									let url = `/pages/home/index`;
									uni.reLaunch({
										url
									})
								},
								fail: async function(err) {
									let url = `/pages/login/index`;
									uni.reLaunch({
										url
									})
								},
							})
						},
						fail: function(err) {
							console.log(err);
						}
					})
				}
			}
		},
	}
</script>

<style lang="scss">
	.main {
		display: flex;
		flex-direction: column;
		width: 100vw;
		height: 100vh;

		.one {
			text-align: center;
			margin: 40vw 0 0 0;

			.logo {
				width: 50vw;
				height: 50vw;
				border-radius: 90px;
				box-shadow: 0 0 5px var(--f1Color);
			}
		}
	}
</style>
