<template>
	<view class="normal-login-container">
		<view class="logo-content">
			<!-- <image src="../../static/jnImage/loginPage/logo.png">
			</image> -->
			<view class="logoTit">
				<view class="titleZN">晋能控股电力集团</view>
				<view class="titleZN">清洁能源有限公司</view>
				<view class="titleEN">发电场站生产实时运营管理平台</view>
			</view>
		</view>
		<view class="login-form-content">
			<view class="input-item flex align-center">
				<image src="../../static/jnImage/loginPage/userName.png">
					<input v-model="loginForm.username" class="input" type="text" placeholder="用户名" maxlength="30" />
			</view>
			<view class="input-item flex align-center">
				<image src="../../static/jnImage/loginPage/locked.png">
					<input v-model="loginForm.password" type="password" class="input" placeholder="密码" maxlength="20" />
			</view>
			<view class="action-btn">
				<button @click="handleLogin" class="login-btn">登录</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		setToken
	} from '@/utils/auth'
	import {
		login
	} from '../../api/login.js'
	export default {
		name: 'Login',
		data() {
			return {
				captchaEnabled: false, // 验证码开关 TODO 芋艿：需要抽到配置里
				globalConfig: getApp().globalData.config,
				loginForm: {
					username: "admin",
					password: "123456"
				}
			}
		},
		methods: {
			// 登录方法
			handleLogin(params) {
				let that = this
				if (this.loginForm.username === "") {
					this.$modal.msgError("请输入您的账号")
				} else if (this.loginForm.password === "") {
					this.$modal.msgError("请输入您的密码")
				} else {
					this.pwdLogin({})
				}

				// that.$tab.switchTab('/pages/home/index')
			},
			// 密码登录
			pwdLogin() {
				this.$modal.loading("登录中，请耐心等待...")
				let params = {
					username: this.loginForm.username,
					password: this.loginForm.password
				}
				login(params).then(res => {
					if (res && res.data) {
						this.$modal.closeLoading()
						setToken(res.data)
						this.$tab.switchTab('/pages/home/index')
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #202246;
	}

	.normal-login-container {
		background: url('../../static/jnImage/loginPage/loginBac.png');
		background-size: cover;
		width: 100%;
		hieght: 100vh;

		.logo-content {
			width: 100%;
			font-size: 21px;
			text-align: center;
			padding-top: 45%;

			// image {
			// 	border-radius: 4px;
			// 	margin-top: 40px;
			// 	width: 80px;
			// 	height: 60px;
			// }

			.logoTit {
				color: #fff;

				.titleZN {
					font-size: 60upx;
					font-family: FZZhengHeiS-M-GB;
					font-weight: 500;
					color: #FFFFFF;
					letter-spacing: 3px;
				}

				.titleEN {
					margin-top: 5px;
					font-size: 26upx;
					color: #E5E9F2;
					letter-spacing: 5px;
				}
			}
		}

		.login-form-content {
			text-align: center;
			margin: 20px auto;
			margin-top: 50%;
			width: 80%;

			.input-item {
				margin: 20px auto;
				// background-color: #f5f6f7;
				height: 45px;

				border-bottom: 1px solid #f5f6f7;

				image {
					width: 20px;
					height: 23px;
				}

				.input {
					color: #fff;
					width: 100%;
					font-size: 14px;
					line-height: 20px;
					text-align: left;
					padding-left: 15px;

					.uni-input-wrapper {
						.input-placeholder {
							color: #fff;
							font-size: 16px;
						}
					}
				}


			}

			.login-btn {
				margin-top: 30px;
				height: 40px;
				color: #fff;
				background: #4287FF;
				border-radius: 10px;
				letter-spacing: 10px;
				line-height: 40px;
			}
		}

		.easyinput {
			width: 100%;
		}
	}

	.login-code-img {
		height: 45px;
	}
</style>