<template>
	<view class="page">
		<view class="logTitle">
			<view class="welcome">
				<text>HI，您好！</text>
			</view>
			<view class="welcome">
				<text>欢迎登录技师端</text>
			</view>
			<view class="flex-row justify-center">
				<image src="../../static/logo.png" class="log"></image>
			</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="forgetPassword"><text>忘记密码?</text></view>

				<view class="loginButton" @click="login">
					<text>登录</text>
				</view>

			</u--form>

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

<script>

	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 './index.rpx.css';
</style>
