register.vue 3.1 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 16 17
			<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>
			<login-ikonw class="login-iknow" :link="link" text="登录即表示同意用户协议和隐私政策"></login-ikonw>
			<button class="send-btn-box" type="primary" @click="submit">注册并登陆</button>
芊里 已提交
18 19 20 21
		</uni-forms>
	</view>
</template>

22 23
<script>
import rules from './validator.js';
24
import mixin from '../common/loginPage.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) {
59 60 61 62 63 64
				this.request('user-center/register',value,(data,result)=>{
					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 74 75 76 77 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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
	.uni-container {
		padding: 15px;
	}

	.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;
	}

	.avatar-box {
		width: 700rpx;
		height: 200rpx;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: center;
		align-items: center;
	}

	.avatar-img {
		width: 150rpx;
		height: 150rpx;
		border-radius: 75rpx;
		border: #F8F8F8 solid 3px;
	}
</style>