<template>
	<view class="yc_main bg_ff">
		<view class="pt80 tc fs40">用户注册</view>
		<!-- 登录窗口 -->
		<view class="p40">
			<view class="p20">
				<u-input v-model="form.login_name" maxlength="20" prefixIcon="account" placeholder="请输入账号" border="surround" clearable></u-input>
			</view>
			<view class="p20">
				<u-input v-model="form.password" maxlength="25" prefixIcon="lock" placeholder="请输入密码" border="surround" password clearable></u-input>
			</view>
			<view class="p20">
				<u-input v-model="form.repassword" maxlength="25" prefixIcon="lock" placeholder="请再次输入密码" border="surround" password clearable></u-input>
			</view>
			<view class="p20">
				<u-button type="primary" text="注册" @click="reg"></u-button>
			</view>
			<view class="p20 fs24 tc"> <text class="font_color_content">已有账号，</text><text class="font_color_primary" @click="navigateTo('index')">立即登录 </text> </view>
		</view>

		<view class="fiexd_bottom_box p20">
			<version></version>
		</view>
	</view>
</template>

<script>
let tagInfo = "[/pages/index/index.vue]";
import basePage from "@/libs/base-page.js";
import Index from ".../../libs/model/index";
export default {
	//name: "index-me",
	mixins: [basePage],

	data() {
		return {
			form: {
				login_name: "",
				password: "",
				repassword: ""
			}
		};
	},
	onLoad() {
		this.loadData();
	},
	methods: {
		async loadData() {
			//this.initSaveData();
		},
		async reg() {
			if (!this.form.login_name || !this.form.password || !this.form.repassword) {
				this._util.message.alert("请填写用户名、密码或确认密码！");
				return;
			}
			if (this.form.password != this.form.repassword) {
				this._util.message.alert("两次输入的密码不一致！");
				return;
			}
			let res = await Index.reg(this.form.login_name, this.form.password, this.form.repassword);
			if (res.code != 0) {
				this._util.message.alert(res.msg);
				return;
			}
			this.setToken(res.data.token);
			this.navigateTo("../manager/index");
		}
	}
};
</script>

<style lang="scss" scoped>
</style>
