<template>
	<view class="container">

		<view class="input_box">
			<text class="input_title">{{$t('pages.user.auth.login.mobile')}}</text>
			<view class="input_content">
				<u--input
					:placeholder="$t('pages.user.auth.login.input_mobile')"
					prefixIcon="phone"
					prefixIconStyle="font-size: 24rpx;color: #909399"
					v-model="form.mobile"
					@change="mobileChange"
				></u--input>
			</view>
		</view>
		
		
		
		<view class="input_box">
			<text class="input_title">{{$t('pages.user.auth.login.password')}}</text>
			<view class="input_content">
				<u--input
					:placeholder="$t('pages.user.auth.login.input_password')"
					prefixIcon="lock"
					prefixIconStyle="font-size: 24rpx;color: #909399"
					border="surround"
					password
					clearable
					v-model="form.password"
					@change="pwdChange"
				></u--input>
			</view>
		</view>
		
	
		
		<view class="button_box">
			<view class="submit">
						<u-button type="primary" :plain="true" :hairline="true" :text="$t('locale.login')" size="normal" @click="login"></u-button>
			</view>
		</view>
		<view class="footer">
			<!-- <text class="footer-text">找回密码</text> -->
			<text class="footer-text" @click="regist">{{$t('locale.regist')}}</text>
			<!-- <text class="footer-text">投诉建议</text> -->
		</view>
	</view>
</template>
<script>
	export default {
		components: {
			
		},
		data() {
			return {
				
				form:{
					mobile:'',
					password:'',
				},
			};
		},
		onShow() {
			var _this =this;
		
		},
		methods:{
			//跳转到注册
			regist(){
						uni.$u.route({
								type:'redirectTo',
								url: 'pages/user/auth/regist',
								params: {}
							});
			},
			//手机号
			mobileChange(e)
			{
				var _this = this;
				_this.form['mobile'] = e;
				
			},
			//密码
			pwdChange(e)
			{
				var _this = this;
				_this.form['password'] = e;
			},
			login(){
				var _this =this;
				var form = _this.form;
				if(!_this.$com.check(form.mobile,'mobile'))
				{
					uni.$u.toast(_this.$t('pages.user.auth.login.mobile_must'));
					return false;
				}
				if(form.password.length < 6)
				{
					uni.$u.toast(_this.$t('pages.user.auth.login.password_must'));
					return false;
				}
			
				var post = form;
				_this.$api.post('user/log',post,function(rs){
					console.log(rs);
					_this.$user.session('userInfo',rs.userinfo);
					_this.$user.session('token',rs.token);
					uni.$u.route({
							type:'navigateBack',
							delta:2,
							params: {}
						});
				},function(err){
					console.log(err);
				});
			},
			
		},
	};
</script>

<style scoped lang="scss">
	/*输入框*/
	.input_box{
		width: 90%;
		margin: 40rpx auto 40rpx auto;
		height: auto;
	}
	.input_title{
		font-size: 30rpx;
		color: #ABABAB;
		height: 50rpx;
		line-height: 50rpx;
		margin: 10rpx auto;
		display: block;
		
	}

	.button_box {
		width: 90%;
		margin: 40rpx auto 20rpx auto;

	}

	.submit {
		width: 100%;
		background-color: #4CAF50;
		justify-content: center;
		align-items: center;
		border-radius: 10rpx;
	}

	.submit-text {
		color: white;
		padding: 30rpx;
	}

	.submit:active {
		background-color: green;
		opacity: 0.5;
	}

	.footer {
		flex-direction: row;
		justify-content: center;
		text-align: center;
		align-items: center;
		margin-top: 100rpx;
	}

	.footer-text {
		font-size: 28rpx;
		color: #296db5;
		padding: 30rpx;
	}
</style>
