login.vue 2.6 KB
Newer Older
Y
..  
yyt 已提交
1 2 3 4
<template>
	<view class="content">
		<image class="logo" src="/static/login/login.png"></image>
		<view class="text-area">
Y
yyt 已提交
5 6 7 8 9 10 11 12 13 14 15 16
			<uni-forms :modelValue="formData" :rules="loginRules" ref="form"  validate-trigger="bind" err-show-type="undertext">
				<uni-forms-item name="phone" required label="手机号">
					<uni-easyinput type="text" :inputBorder="true" v-model="formData.phone"
						placeholder="请输入手机号"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item name="password" required label="密码">
					<uni-easyinput type="password" :inputBorder="true" v-model="formData.password" placeholder="请输入密码"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item>
					<button @click="login(form)">登录</button>
				</uni-forms-item>
			</uni-forms>
Y
..  
yyt 已提交
17
		</view>
赵十四's avatar
赵十四 已提交
18
	
Y
..  
yyt 已提交
19 20 21 22
	</view>
</template>

<script>
Y
yyt 已提交
23 24 25 26 27 28 29
	// uni.getLocation({
	// 	type: 'wgs84',
	// 	success: function(res) {
	// 		console.log('当前位置的经度:' + res.longitude);
	// 		console.log('当前位置的纬度:' + res.latitude);
	// 	}
	// });
Y
..  
yyt 已提交
30 31 32 33

	export default {
		name: 'login',
		components: {},
赵十四's avatar
赵十四 已提交
34 35 36
		onLoad() {
			uni.hideTabBar();
		},
Y
..  
yyt 已提交
37 38
		data() {
			return {
Y
yyt 已提交
39
				formData: {
Y
..  
yyt 已提交
40 41 42
					phone: '',
					password: ''
				},
Y
yyt 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
				loginRules: {
					phone: {
						rules: [{
							required: true,
							errorMessage: '请输入手机号'
						}, {
							validateFunction: function(rule, value, data, callback) {
								if (value === '') {
									callback(new Error('手机号不能为空'))
								} else {
									const reg = /^1[3|4|5|7|8][0-9]\d{8}$/
									const reg2 = /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/
									if ((reg.test(value) || reg2.test(value))) {
										this.yzmshow = true
										callback()
									} else {
										callback(new Error('请输入正确的手机号'))
									}
								}
							}
						}]
					},
					password: {
						rules: [{
							required: true,
							errorMessage: '请输入密码'
						}, {
							validateFunction: function(rule, value, data, callback) {
								if (value.length > 20 || value.length < 8) {
									callback('密码长度在8-20位!')
								} else {
									callback();
								}
							}
						}]
					},
Y
..  
yyt 已提交
79 80 81 82
				}
			}
		},
		methods: {
Y
yyt 已提交
83 84 85 86 87 88
			login(validateForm) {
				// this.$refs[validateForm].validate(valid => {
				// 	if (valid) {
				// 		//
				// 	}
				// })
Y
..  
yyt 已提交
89
			}
Y
yyt 已提交
90
		},
Y
..  
yyt 已提交
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 480rpx;
		width: 500rpx;
		margin-top: 100rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}
</style>