<template>
	<view class="content">
		<image class="logo" :src="apiHost+'/miniapp/static/authlogo.png'"></image>
		<view class="title">医疗废弃物追溯系统</view>
		<uni-easyinput class="forminput" prefixIcon="person" v-model="account" type="text" placeholder="请输入用户名"></uni-easyinput>
		<view style="padding:20rpx">&nbsp;&nbsp;&nbsp;&nbsp;</view>
		<uni-easyinput class="forminput" prefixIcon="locked" v-model="password" 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 @tap="phoneCall" style="font-size:25rpx;margin-top:20rpx;color:#5767CF">联系工程师</view>
		</view>
	</view>
</template>

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

		},
		methods: {
			auth:function() {
				let account = this.account.trim()
				let password = this.password.trim()
				
				// console.info(account,password)
				if (account == '') {
					myapp.showHint('请输入用户名')
				} else if (password == '') {
					myapp.showHint('请输入用户密码')
				} else {
					// console.log(666)
					myapp.request('/?c=user&a=postCheckLogin', function(res) {
						let data = res.data
						if (data.code == 1) {
							
						} else if(data.code == 0){
							try {
								uni.setStorageSync('user', data.data)
								uni.reLaunch({
									url:'/pages/index/index'
								})
							} catch (e) {
								// error
							}
						}
					}, {account:account,password:password}, 'POST')
				}
			},
			phoneCall: function() {
				uni.makePhoneCall({
					phoneNumber: '18888886666' 
				});				
			}
		}
	}
</script>

<style>
	page {
		background-color: #F5F6FA;
	}
	.content {
		text-align: center;
		margin-left: 40px;
		margin-right: 40px;
	}
	.logo {
		width:300rpx;
		height:100rpx;
		margin-top: 220rpx;
	}
	.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>
