<template>
	<view class="page">
		<view class="logTitle">
			<view class="flex-row justify-center">
				<image src="../../static/logo.png" class="log"></image>
			</view>

			<view class="flex-row justify-center title">
				<text>欢迎登录娇骄儿造型员工端</text>
			</view>

		</view>

		<view class="form">
			<u--form labelPosition="left" :model="form" :rules="rules" ref="uForm">
				<view class="formItem">
					<u-form-item label="账号" prop="username" borderBottom ref="item1">
						<u--input v-model="form.username" border="none"></u--input>
					</u-form-item>
				</view>

				<view class="formItem">
					<u-form-item label="密码" prop="password" borderBottom ref="item1">
						<u--input v-model="form.password" border="none" type="password"></u--input>
					</u-form-item>
				</view>

				<view class="formItem">
					<button class="button" @click="login">提交</button>
				</view>

			</u--form>

		</view>
	</view>
</template>

<script>
	import login from "../../common/js/login";

	export default {
		data() {
			return {
				form: {
					username: '',
					password: ''
				},
				rules: {
					'username': {
						type: 'string',
						required: true,
						min: 11,
						max: 11,
						message: '请输入11位手机号',
						trigger: ['blur', 'change']
					},
					'password': {
						type: 'string',
						required: true,
						min: 6,
						max: 18,
						message: '请输入6-18位密码',
						trigger: ['blur', 'change']
					}
				}

			}
		},
		methods: {

			login() {
				this.$refs.uForm.validate().then(res => {
					this.$api.login.techLogin(this.form).then(res => {
						uni.setStorageSync('accessToken', res.data.data.access_token)
						uni.switchTab({
							url: "/pages/index/index"
						})
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '../../common/css/common.css';
	@import './index.rpx.css';
</style>