<template>
	<form class="login-form">
		<view class="form-item">
			<view class="form-lable" @click.stop="selectAreaCode()"><text>+86</text><text class="form-lable-icon iconfont">&#xe601;</text></view>
			<input class="form-input" v-model="formData.user_string" name="user_string"
				placeholder-class="form-input-place" placeholder="请输入您的手机号" />
		</view>
		<view class="form-item">
			<input type="password" class="form-input" v-model="formData.password" name="password"
				placeholder-class="form-input-place" placeholder="邀请码 (选填)" />
		</view>
		<!-- <view class="form-agreement">
			<view class="agreement-confirm">
				<text class="confirm-icon iconfont">&#xe6c5;</text>
			</view>
			<text>我已阅读并同意</text>
			<text class="agreement-name">《用户协议》</text>
		</view> -->
		<view class="form-btn" style="margin-top: 28rpx;" @click.stop="formSubmit">
			登录
		</view>
		<view class="form-hint">
			已有账号？<text class="hint-btn"> 立即登录</text>
		</view>

		<slider-verify ref="sliderVerifyRef" />
	</form>
</template>

<script>
	import {
		reverseBack
	} from "@/utils/common.js"
	import {
		Api_userLogin
	} from "@/api/index.js"

	export default {
		data() {
			return {
				formData: {
					user_string: '14100000001',
					password: '123456'
				}
			};
		},
		methods: {
			selectAreaCode(){
				uni.navigateTo({
					url:'/pages/login/area-code'
				})
			},
			formSubmit() {
				Api_userLogin(this.formData).then(res => {
					if (res) {
						this.$store.dispatch("app/setToken", res)
						uni.showToast({
							title: '登录成功',
							icon: 'none'
						});
						setTimeout(() => {
							reverseBack()
						}, 1500)
					}

				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "~./../common.scss"
</style>