<template>
	<view class="container">
		<view class="wjmm" style="text-align: right;padding-right: 30rpx;font-size: 36rpx;" @click="zc()">
			注冊
		</view>
		<view class="tit" style="padding-top:120rpx;">
			郵箱
		</view>
		<input type="text" class="shuru" placeholder="請翰入郵箱" v-model="email">
		<view class="tit">
			密碼
		</view>
		<input type="password" class="shuru" placeholder="請翰入密碼" v-model="lpwd" >
		<view class="" style="padding:20rpx 48rpx;">
			<view class="wjmm" @click="wjmm()">
				忘記密碼?
			</view>
		</view>
		<view class="flex" style="justify-content: flex-end;padding: 0 48rpx;">
			<view class="gologin" @click="gologin">
				登錄
			</view>
		</view>
		
		<!-- <view class="login_text">
			<view class="login_input flex">
				<view class="login_img">
					<image src="/static/icon/img03.png"></image>
				</view>
				<view class="login_name"><input class="uni-input" v-model="username" focus placeholder="请输入手机号" />
				</view>
			</view>
			<view class="login_input flex">
				<view class="login_img">
					<image src="/static/icon/img04.png"></image>
				</view>
				<view class="login_name"><input class="uni-input" type="password" v-model="passward" focus
						placeholder="请输入密码" /></view>
			</view>
			<view><button type="green" class="uni-button uni-button-green" @click="toLogin">登录</button></view>
			<view><button type="green" class="uni-button uni-button-green uni-button-green-plain" plain="true"
					hover-class="none" @click="register">注册</button></view>
			<navigator url="./forget">
				<view class="forget">忘记密码</view>
			</navigator>
			<view class="flex other">
				<view class="fenge"></view>
				<view class="qita">其他方式登录</view>
				<view class="fenge"></view>
			</view>
		</view> -->
	</view>
</template>

<script>
	import {
		loginWx,
		gologin
	} from '@/api/login.js';
	export default {
		data() {
			return {
				email: '',
				lpwd: ''
			};
		},
		onLoad() {
			
		},
		methods: {
			zc() {
				uni.navigateTo({
					url: '/pages/public/register',
				})
			},
			wjmm() {
				uni.navigateTo({
					url: '/pages/public/forget',
				})
			},
			gologin() {
				let obj = this
				if(obj.loadingType == 'loading') {
					return
				}
				if(!obj.isEmailAvailable(obj.email)) {
					return obj.$api.msg('請輸入正確的郵箱！')
				}
				obj.loadingType = 'loading'
				gologin({
					email: obj.email,
					lpwd: obj.lpwd
				}).then(res => {
					console.log(res)
					obj.loadingType = 'no'
				}).catch(err => {
					console.log(res)
					obj.loadingType = 'no'
				})
			},
			
			isEmailAvailable(obj) {
				let email = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
				if (!email.test(obj)) {
					return false;
				}
			 return true;
			},

		}
	};
</script>

<style lang="scss">

	page {
		height: 100%;
		background-color: #fff;
		font-size: 32rpx;
	}

	.container {
		width: 100%;
		height: 100%;
		background-size: 100%;
	}

	.shuru {
		display: block;
		background-color: #f5f5f5;
		width: 673rpx;
		height: 95rpx;
		margin: auto;
		padding-left: 30rpx;
		text-align: 95rpx;
	}
	.tit {
		padding:60rpx 48rpx 20rpx;
	}
	.gologin {
		width: 204rpx;
		height: 98rpx;
		line-height: 98rpx;
		background-color: #fcd535;
		text-align: center;
		border-radius: 20rpx;
	}
	.wjmm {
		color: #fcd535;
	}
</style>
