<template>
	<view class="content">
		<image class="logo" :src="apiHost+'/miniapp/static/wsapp/authlogo.png'"></image>
		<view class="title">分质分流排口智控系统</view>
		<uni-easyinput class="forminput" prefixIcon="person" v-model="user" type="text" placeholder="请输入用户名"></uni-easyinput>
		<view style="padding:20rpx">&nbsp;&nbsp;&nbsp;&nbsp;</view>
		<uni-easyinput class="forminput" prefixIcon="locked" v-model="pass" type="password" placeholder="请输入用户密码"></uni-easyinput>
		<button class="authbtn"  @tap="auth">登录</button>
		<view style="margin-top:120rpx">
			<view style="font-weight:bold;font-size:25rpx">系统账号，需联系工程师开通！</view>
		</view>
	</view>
</template>

<script>
	import myapp from '@/common/js/myapp.js'
	export default {
		data() {
			return {
				apiHost: myapp.apiHost,
				user: '',
				pass:'',
				useLocal: ''
			}
		},
		onShow: function() {

		},
		methods: {
			auth:function() {
				let user = this.user.trim()
				let pass = this.pass.trim()
				if (user == '') {
					myapp.showHint('请输入用户名')
				} else if (pass == '') {
					myapp.showHint('请输入用户密码')
				} else {
					// 获取登录信息
					let that = this;
					// 获取场站基本信息
					myapp.request('/?c=login&a=postCheckLogin',function(res) {
						that.useLocal = res.data.data
						
						if (res.data.data) {
							uni.setStorageSync('user', res.data.data)
							
							uni.reLaunch({
								url:'/pages/index/index'
							})
						} else {
							
							myapp.showHint('用户名或密码错误')
							
						}
						
					},{account:user,password:pass},'POST')
					
				}
			},
			phoneCall: function() {
				uni.makePhoneCall({
					phoneNumber: '18730306171' 
				});				
			}
		}
	}
</script>

<style>
	page {
		background-color: #F5F6FA;
	}
	.content {
		text-align: center;
		margin-left: 40px;
		margin-right: 40px;
	}
	.logo {
		width:100rpx;
		height:100rpx;
		margin-top: 220rpx;
		margin-bottom: 40rpx;
	}
	.title {
		font-size: 46rpx;
		color: #333;
		font-weight: bold;
		padding-bottom: 30rpx;
	}
	.forminput {
		background-color: #FFF;
		color: #000;
	}
	.authbtn {
		background-color: #5767CF;
		color: #FFF;
		margin-top: 60rpx;
	}
</style>
