<template>
	<view class="logo flex_column flex_items">
		<image :src="logoimg" style="width: 226rpx;height: 226rpx;margin-top:100rpx;"></image>
		<text class="f44" style="color: #333;">欢迎来到分发平台</text>
		<view class="mt60 plr30">
			<van-field v-model="form.name" label="" placeholder="账号"
				style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx;" />
			<van-field class="mt30" type="password" v-model="form.password" label="" placeholder="密码"
				style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx" />
		</view>
		<van-button :loading="loading" loading-text="登录中..." @click="gologin" class="f32 f-center mt60"
			style="margin-top: 60rpx;width: 696rpx;height: 108rpx;line-height: 108rpx;color: #fff;background: linear-gradient(90deg, #B72027 0%, #0D0E5C 100%);border-radius: 12rpx;">立即登录</van-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				logoimg: require('@/static/logo.png'),
				form: {
					name: "",
					password: ""
				},
				loading:false
			}
		},
		onLoad() {},
		methods: {
			gologin() {
				this.loading = true
				this.api.login(this.form).then((res) => {
					console.log(res)
					if (res.data.code == 200) {
						uni.setStorageSync("token", res.data.data.token);
						uni.setStorageSync("site_id", res.data.data.site_id);
						uni.setStorageSync("user_id", res.data.data.id);
						uni.setStorageSync("adminname", res.data.data.name);
						uni.switchTab({
							url:'/pages/index/index'
						})
					} else {
						this.loading = false
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-image: url('~@/static/lbg.png') !important;
		background-size: 100% 100%;
	}
</style>
