register.vue 2.7 KB
Newer Older
芊里 已提交
1 2
<template>
	<view class="uni-container">
3
		<uni-forms ref="form" :value="formData" :rules="rules" validate-trigger="submit" err-show-type="undertext">
4 5
			<uni-forms-item name="username" required>
				<uni-easyinput :inputBorder="false" class="phone-input-box" placeholder="请输入用户名" v-model="formData.username" trim="both" />
芊里 已提交
6
			</uni-forms-item>
7 8
			<uni-forms-item name="nickname">
				<uni-easyinput :inputBorder="false" class="phone-input-box" placeholder="请输入用户昵称" v-model="formData.nickname" trim="both" />
芊里 已提交
9
			</uni-forms-item>
10 11
			<uni-forms-item name="password" v-model="formData.password" required>
				<uni-easyinput :inputBorder="false" class="phone-input-box" placeholder="请输入6-20位密码" type="password" v-model="formData.password" trim="both" />
芊里 已提交
12
			</uni-forms-item>
13 14 15
			<uni-forms-item name="pwd2" v-model="formData.pwd2" required>
				<uni-easyinput :inputBorder="false" class="phone-input-box" placeholder="再次输入密码" type="password" v-model="formData.pwd2" trim="both" />
			</uni-forms-item>
DCloud_JSON's avatar
DCloud_JSON 已提交
16 17
			<uni-agreements></uni-agreements>
			<button class="send-btn" type="primary" @click="submit">注册并登陆</button>
芊里 已提交
18 19 20 21
		</uni-forms>
	</view>
</template>

22 23
<script>
import rules from './validator.js';
DCloud_JSON's avatar
DCloud_JSON 已提交
24
import mixin from '../common/login-page.mixin.js';
25 26
	export default {
		mixins:[mixin],
芊里 已提交
27 28 29 30
		data() {
			return {
				formData: {
					"username": "",
芊里 已提交
31
					"nickname": "",
DCloud_JSON's avatar
DCloud_JSON 已提交
32 33
					'password':'',
					'pwd2':''
芊里 已提交
34
				},
35
				rules
芊里 已提交
36 37 38 39 40 41 42 43 44
			}
		},
		onReady() {
			this.$refs.form.setRules(this.rules)
		},
		methods: {
			/**
			 * 触发表单提交
			 */
芊里 已提交
45
			submit() {
芊里 已提交
46 47 48
				uni.showLoading({
					mask: true
				})
49
				this.$refs.form.submit().then((res) => {
芊里 已提交
50 51 52 53 54 55 56 57 58
						this.submitForm(res)
					}).catch((errors) => {
						console.log(errors);
					})
					.finally(() => {
						uni.hideLoading()
					})
			},
			submitForm(value) {
DCloud_JSON's avatar
DCloud_JSON 已提交
59
				this.request('user-center/register',value,result=>{
60 61 62 63 64
					console.log(result);
					if(result.code === 0){
						this.loginSuccess(result)
					}
				})
芊里 已提交
65 66 67 68 69
			}
		}
	}
</script>

70 71
<style>
	@import url("../common/loginPage.css");
芊里 已提交
72 73
	.uni-container {
		padding: 15px;
DCloud_JSON's avatar
DCloud_JSON 已提交
74 75 76
	}
	.send-btn{
		margin-top: 5px;
芊里 已提交
77
	}
DCloud_JSON's avatar
DCloud_JSON 已提交
78
/* 
芊里 已提交
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
	.uni-input-border,
	.uni-textarea-border {
		width: 100%;
		font-size: 14px;
		color: #666;
		border: 1px #e5e5e5 solid;
		border-radius: 5px;
		box-sizing: border-box;
	}

	.uni-input-border {
		padding: 0 10px;
		height: 35px;

	}

	.uni-textarea-border {
		padding: 10px;
		height: 80px;
	}

	.uni-button-group {
		margin-top: 50px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.uni-button {
		padding: 12px 20px;
		font-size: 14px;
		border-radius: 4px;
		line-height: 1;
		margin: 0;
DCloud_JSON's avatar
DCloud_JSON 已提交
113
	} */
芊里 已提交
114
</style>